I'm building a Gnome shell extension, and I want to be able to do some things with escalated privileges. So, I'm thinking I need to use "policy kit", but I don't know how to do go about doing this.
So, say I wanted to do something like ifconfig eth0 down
or ifconfig eth0 up
I can run from the terminal: pkexec ifconfig eth0 down
and it will prompt for a password and then do it.
But, how am I supposed to do it from inside an extension?
I'm pretty sure it has something to do with making a file in /usr/share/polkit-1/actions, but I can't find anything on the internet or otherwise.
I want to be able to set it up so that there is no need for a password to be typed in, and the extension can just run the certain command whenever.
I know that it is a really bad idea to allow any command to be run. That is not what I am asking for, I want to be able to just run a single program/command.
EDIT: I'm not sure, but I think it might be impossible for there to be no need to type in a password. I just know that sudo doesn't ask for the password for a while after the first time, so I kind of want similar functionality. Not sure what possible.
pkexec
or otherwise isolate the “unsafe” bit of privileged code in a separate process… PS: The re-prompting for a password bysudo
et al is a system-wide security setting; the default is usually to re-prompt after a (long) while – Sartopkexec
is what I want to do. How would I do that from within the extension? – Bowens