2

So I get that running a GUI application as root in a Linux environment is a Bad Idea, and the prevailing wisdom seems to be that it's better to run such a service by having separate processes: a GUI interface process and a background, root-privileged daemon which does the actual work.

I'm creating a program targeted at not tech-savy, desktop users of Linux environments. I don't want to require them to open the command-line and run a command in order to start my program. They should be able to click the menu item (or a .desktop file) and simply have this program work. Therefore the GUI program needs to start the root-process or vice-versa. They will of course need to enter the admin password, but I'm not sure how to even allow that in a secure, distribution agnostic manner.

This is a backup program so it needs to partition the target drive to duplicate the partitions on the source drive, which requires root permissions. After that step, it simply needs to mount and unmount the partitions in order to copy the files from the source drive to the target. The program would be installed via a package manager, presumably with administrative permissions for at least the initial install.

How can I securely allow a GUI program to run a root-privileged daemon?

Note: If it matters, the language I'm using is Python 3.

1

Simple - you totally separate the program into 2 pieces.

First is your server/service and its daemon. This should be installable stand-alone, and integrate into whatever process manager the host uses - systemd, upstart, initd, etc

Then you have your GUI program. Set it up to connect via network on local machine (using loopbacks) or a remote host running the daemon.

For an example of this, look at the mysql server and mysql-workbench. Two totally separate apps, one GUI and no root needed, one service and root possibly needed.

  • What do I do if I don't need the background program running all the time (unlike most MySQL setups)? It's a backup program that only needs to work when the backup is running (which could be as little as once a month). Are daemons low-enough resources to basically just ignore? Sorry if some of these questions are dumb, I have next to no experience in these areas. – DonyorM Aug 10 '18 at 17:56
0

If you need to launch a root privileged job you could use "sudo". It can be configured to say "a specific userid running the GUI process can run a certain root command, with these parameters".

  • How would I do that configuration? – DonyorM Aug 11 '18 at 12:45

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.