如何实现在Gnome 3中用户不再被允许关闭计算机?

如何实现在Gnome 3中用户不再被允许关闭计算机?

我正在使用 Gnome 3 和 Debian Wheezy。我正在寻找一种方法,让用户在使用菜单中的关机按钮时至少询问 root 密码。

答案1

polkit/consolekit可以满足您的需要。编写一条新的 polkit 规则:

/etc/polkit-1/localauthority/50-local.d/org.freedesktop.SysPower.pkla

添加以下内容(假设关机和重启都需要 root 密码):

[Disable shutdown/restart]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop;org.freedesktop.consolekit.system.restart
ResultAny=no
ResultInactive=no
ResultActive=auth_admin

答案2

更改 /sbin 中关机命令的权限,以便只有 root(或具有同等权限的组成员)可以执行该命令。您可以通过 chmod 或发行版中选择的文件管理器进行更改。如果您这样做了,在理论您必须“sudo shutdown -h now”,系统会提示您输入 root 密码。这应该在理论

其他更复杂更好的回答:

Step1:
Open /etc/X11/gdm/gdm.conf in a text editor and find the [greeter] section. Make sure that there is a line which says SystemMenu = false. This line will ensure that the gdm login screen will not have the option for shutting down the system etc.

Step 2:
If you have a laptop, or an acpi system on your computer, then go to /etc/acpi and disable the power button, so that, when someone presses the power button, the system does not shutdown. You can disable this easily by doing chmod 000 /etc/acpi/powerbtn.sh

Step 3:
Now edit /etc/inittab

and find the lines that say:

#Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

And change it to read:

#Disallow CTRL-ALT-DELETE
ca::ctrlaltdel:/bin/echo “ctrl-alt-delete has been disabled” .

This will effectively prevent users from changing to a console screen and using ctrl+alt+delete to shutdown the system.

Step 4:
Execute the following commands:
sudo chgrp admin /sbin/halt /sbin/shutdown
sudo chmod 550 /sbin/halt /sbin/shutdown

Step 5:
Use the Configuration Editor (Applications -> System Tools -> Configuration Editor) to edit the preference apps->gnome-session->options->logout_opt… to “logout” instead of “shutdown”.

Now only a superuser (Admin) can shutdown the system, using the command:
$sudo shutdown -t3 -r now

从这里获得帮助:http://answers.yahoo.com/question/index?qid=20080606143849AAONUy9

相关内容