Hi. I have a small app that needs to run as root, but nothing I’ve found on the net seems to relate to that, other than using sudo in rather puzzling ways. I’d really like to avoid sudo anyway. su would be my preference if there’s nothing I can set in the IDE to do the job. Any help would be most appreciated.
There is nothing in the IDE that can do this automatically. That would be a severe security issue if any app could raise its permissions.
You use normal linux means to achieve this:
- using sudo (probably the “best” option as sudo can be restricted)
- using su
- setting the uid or gid bits (not likely desirable)
You could run a shell to check if you are root with whoami, then if not root, relaunch with gksu. It will present the “Administrative tasks” password dialog. Check for an error code to see if the user cancelled without entering an admin password.
We have a LinuxSuMBS class available for this.
Thanks, man. That works perfectly.