I am creating a graphical installer that should run on Linux. Installing should consist of copying files to some places in /usr
. Currently the installer is written in Python.
How can I escalate the privileges of my installer when I need to copy files? I looked at PolicyKit but
- a) there doesn t seem to be a generic "install files" action-id for PolicyKit
- b) of the action ids I can use, I don t think they are standard across distros
I also looked at PAM and I have code that uses libpam but I can t seem to do anything with it. After authenticating my user (by providing username and password) I don t have write access to /usr
. I tried changing my user with os.setuid(0)
after authentication but I get an error from the OS.
Also, strangely, it doesn t seem to matter what service I provide to pam_start
. As long as the username and password are correct I can pass anything I want. I see I have /etc/pam.d/sudo
. The below code is simplified, the password is correctly stored in a pam_conversation
object and I do pass a handle object.
pam_start("my_user", "my_pass", "sudo_garbage_12345");
works just as well as
pam_start("my_user", "my_pass", "sudo");
That is, they both succeed.
As a last resort I can probably execute gksudo
or kdesudo
but I don t want to be tied to those programs. Requiring users to invoke my installer with sudo
is a (very) last resort.