How to run specific program with root privileges (Ubuntu OS) when no sudo user log into system? Program need root privileges to function correctly. Normal user shouldn't be able to shutdown this process. For example, I have to users. Admin and Client. Program should start only when Client log into system. It needs root privileges and Client shouldn't be able to shut this process down.
|
feedback
|
|
There are a few ways to do this. Ubuntu's graphical login is provided by GDM (or KDM if you're using Kubuntu). GDM is started by the Upstart subsystem. The startup process follows these steps:
Where to run your script Everything prior to XSession runs as root. /etc/gdm/Xsession and everything after runs as the user. This leaves you with three real options for where to run your script.
How to avoid the Admin user Your script will need to examine the user/username in the environment variables it gets from one of these methods and use that to determine whether to abort or continue. Standard shell-scripting methods will work. Depending on which starting location you chose from the above list, the username may be available in the USER, USERNAME, or PAM_USER environment variables. | |||
|
feedback
|
|
You could use setuid, to always run the program as root. From a security point of view, this is probably a very, very bad idea. If one of your users managed to exploit the setuid program it will give them root access to the whole server | |||
feedback
|