0

On my system (Ubuntu 20.04) I have installed this Gnome Shell Extension that modifies the style of the power-off options and also adds an option to hibernate, which I occasionally use on my system in place of suspend. While the extension works as expected, every time I want to hibernate, I am prompted for a superuser password in order to proceed, which is annoying. To get rid of the password dialog, I followed this answer and added

my_username ALL=(ALL:ALL) NOPASSWD:/bin/systemctl hibernate

to my sudoers. After this change, I am able to hibernate from command line without password, as expected. However, the corresponding option from said Gnome Shell Extension still prompts me for a password. The code behind the scenes of the extension can be found here. I was unable to find any implementation of the function Util.trySpawnCommandLine, but it appears that it would just call the supplemented command in a shell. Hence, it's not clear to me, why I am still asked for a password. I have checked that which systemctl returns /bin/systemctl. Could it be that commands from the Gnome Shell are executed in a different user context than the logged in user?

PS: Is it considered safe from a security standpoint, anyway, to add above line to the sudoers file?

8
  • There is a extension extensions.gnome.org/extension/755/hibernate-status-button this does not require root password. If you want to stick with the extension you mentioned.. tweaking that extension can do the job. I suggest you to try that extension, if that works, I can help to integrate the same to your installed extension.
    – UnKNOWn
    Aug 20 at 16:32
  • For me the extension, which you suggest, does not work. In Ubuntu 20.04, at least for me, there are no longer those circular buttons to power off. When installing the extension, nothing happens in the menu.
    – ranguwud
    Aug 20 at 18:40
  • For me the extension does not work, too. And hitting ALT+F2 and giving the systemctl hibernate command does not require any password by default. Did you install the extension system wide, or for user only?
    – starkus
    Aug 21 at 9:18
  • Oh, that was way too fast I guess. The extension does its trick for me without giving a password prompt.
    – starkus
    Aug 21 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.