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?