Como evitar poweroff / shutdown / reboot / suspend / hibernate por usuários não-root no Ubuntu Xenial 16.04?

1
Perguntas similares foram feitas sobre isso aqui, mas eu tentei sem sucesso. Eu suspeito que o que costumava trabalhar no passado não tem funcionado nas últimas versões do Ubuntu. Estou usando o Ubuntu Xenial 16.04.

Eu tentei o seguinte:

1.

pico /etc/polkit-1/50-local.d/disable-shutdown.pkla

Em seguida, preencha o arquivo com:

[Disable shutdown/restart etc. for users]
Identity=unix-user:a;unix-group:b;
Action=org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions;org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions;org.freedesktop.consolekit.system.stop;org.freedesktop.consolekit.system.restart;org.freedesktop.upower.suspend;org.freedesktop.upower.hibernate;org.freedesktop.login1.suspend;org.freedesktop.login1.suspend-multiple-sessions;org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultAny=no
ResultInactive=no
ResultActive=no

2.

chmod o-x /sbin/shutdown
chmod o-x /sbin/reboot

Esses métodos não funcionaram para mim. Eu ainda poderia reiniciar o servidor com uma conta não-root depois de digitar a senha:

 sudo reboot

EDITAR: Com a conta de xxx:

sudo -l

Matching Defaults entries for xxx on scw-415fa7:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:
                /usr/bin\:/sbin\:/bin\:/snap/bin

User xxx may run the following commands on scw-415fa7:
    (ALL : ALL) ALL

.

sudo grep xxx /etc/sudoers* -R

/etc/sudoers:xxx ALL=(ALL:ALL) ALL
    
por Chong Lip Phang 26.12.2017 / 06:45

1 resposta

0

Acho que resolvi meu problema com isso na conta raiz:

visudo

Em seguida, comente esta linha:

#xxx ALL=(ALL:ALL) ALL
    
por Chong Lip Phang 26.12.2017 / 07:26