10

I have a server where users are connecting using the RDP protocol, and accessing a Gnome desktop environment.

Even if they do not have permissions, I want to avoid any temptation/mistake/confusion given by the button "Shutdown". Just a "Log out" button provided by this extension

I could not find extensions that allows me to hide or disable the button.

https://askubuntu.com/a/93956/197910 as suggested below did not work to solve this.

Is there a way to achieve it?

K7AAY
  • 17,202
Manuel
  • 938
  • 11
  • 20

3 Answers3

12

You may use this gnome-shell-extension Remove PowerOff

Ubuntu 18.04.3 enter image description here

Ubuntu 19.10 enter image description here

PRATAP
  • 22,460
  • 2
    Not sure why someone downvoted you. This seems to be exactly what OP is looking for - removal of the button, not permissions. – user31389 Dec 15 '19 at 13:52
  • 1
    This is exactly what I need. Thank you. Do you think you can make it available on the Gnome Extensions website? (I can also make it, but I think that you should take credit for it) – Manuel Dec 16 '19 at 10:26
  • 1
    In my use case, I do not mind if the users disable the extension. They already know that they cannot (and should not) shutdown the system, this extension makes the interface more coherent and avoids misunderstanding. If they disable it, they just introduce noise to their own environment. But I understand what you are proposing. – Manuel Dec 16 '19 at 10:33
  • Looks great. It's amazing how very few lines of code is required to accomplish the goals. – WinEunuuchs2Unix Dec 16 '19 at 15:29
1

You can use this extension to hide the shutdown button.

hide shutdown button.png


This article describes how to disable shutdown and reboot:

Certain Linux distros such as Ubuntu, Linux Mint, Mandriva just to mention but a few, make it possible to reboot/halt/shutdown the system as a normal user, by default. This is not ideal setting especially on servers, it must be something to worry about especially for a system administrator.

Here are a summary of steps in article:

  • Edit /etc/sudoers to disable shutdown.
  • Use chmod o-x /sbin/shutdown and chmod o-x /sbin/reboot to deny permissions.
  • For systemd based systems (probably most today) use: chmod o-x /bin/systemctl which /sbin/shutdown and the rest have symbolic links to.

I don't know how to change the GUI to remove the "Shutdown" button but you can tell the users not to press it and if they do nothing will happen.

  • Even if this is a correct answer for not allowing users to reboot/shutdown the system, it is not an answer to my question. I want to remove the button from the pannel (and avoid any misunderstanding about what they can do) since they already cannot reboot the system. My goal is to be more coherent between what they can actually do, and what they see that they can do. – Manuel Dec 16 '19 at 10:28
  • @Manuel Fair enough, I've added a link to hide the shut down button with an extension. – WinEunuuchs2Unix Dec 16 '19 at 15:10
  • Thanks, I already checked that extension. It hides it from the bar, but the button is still present on the menu. – Manuel Dec 16 '19 at 15:20
  • It appears the one PRATAP wrote just for you will be the perfect fit! – WinEunuuchs2Unix Dec 16 '19 at 15:22
0

Adding the following lines into a file
/etc/polkit-1/localauthority/50-local.d/restrict-login-powermgmt.pkla
will prevent shutdown from working. Other options will still work, and the server can still be shut down from the command line.

[Disable lightdm PowerMgmt]
Identity=unix-user:*
Action= org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions
ResultAny=no
ResultInactive=no
ResultActive=no

K7AAY
  • 17,202
  • I've tried this on Ubuntu 18.04. It does not work and the system can still be rebooted from Gnome. After creating the file with the indicated content, I've rebooted the system to make sure the policy is updated. Do I need to make any other change? – Manuel Dec 11 '19 at 15:04
  • 1
    Well, GNOME evidently changed where that could be locked down. I will donate some points to see if we can't get a better answer. – K7AAY Dec 12 '19 at 21:51