Privilege elevation on Linux

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
Durandal
Bile-Driven Hate Machine
Posts: 17927
Joined: 2002-07-03 06:26pm
Location: Silicon Valley, CA
Contact:

Privilege elevation on Linux

Post by Durandal »

So I'm curious about something, and I haven't been able to find any documentation on it with a round of Googling. What's the generally-recommended method for elevating privileges on Linux?

I'm sure it varies from distro to distro, but say the user is working in a GUI app (launched as a normal user), and that GUI app needs to write to a location that only root can write to. What should the developer do? Spawn a setuid-root helper process? Is there API for this sort of thing in most distros? I haven't found any documentation on this specific problem.
Damien Sorresso

"Ever see what them computa bitchez do to numbas? It ain't natural. Numbas ain't supposed to be code, they supposed to quantify shit."
- The Onion
User avatar
phongn
Rebel Leader
Posts: 18487
Joined: 2002-07-03 11:11pm

Post by phongn »

I read about PolicyKit on Ars a short while ago, and that may end up being the standardized method for fine-grained, secure privilege escalation. Other than that, though, I think you may well be limited to a helper process and then using IPC. HAL and NetworkManager do that, IIRC.
User avatar
Pu-239
Sith Marauder
Posts: 4727
Joined: 2002-10-21 08:44am
Location: Fake Virginia

Post by Pu-239 »

Admin tools on GNOME generallyuse gksudo to either launch a helper or relaunch themselves, asking for the root password and run w/ root privileges. Another option would be to add the user to a group and make the file restricted to that group if it's not important write access be restricted.

ah.....the path to happiness is revision of dreams and not fulfillment... -SWPIGWANG
Sufficient Googling is indistinguishable from knowledge -somebody
Anything worth the cost of a missile, which can be located on the battlefield, will be shot at with missiles. If the US military is involved, then things, which are not worth the cost if a missile will also be shot at with missiles. -Sea Skimmer


George Bush makes freedom sound like a giant robot that breaks down a lot. -Darth Raptor
RThurmont
Jedi Master
Posts: 1243
Joined: 2005-07-09 01:58pm
Location: Desperately trying to find a local restaurant that serves foie gras.

Post by RThurmont »

Kdesu is the KDE equivalent of gksudo. Neither is Linux-specific; they'll run on any system that KDE and GNOME run on (with Sudo, of course).
"Here's a nickel, kid. Get yourself a better computer."
User avatar
Pu-239
Sith Marauder
Posts: 4727
Joined: 2002-10-21 08:44am
Location: Fake Virginia

Post by Pu-239 »

It's probably best to use the GUI implementations of su/sudo like gksudo or gksu, since then you don't have to bother asking the password yourself (which is liable to introduce security holes).

ah.....the path to happiness is revision of dreams and not fulfillment... -SWPIGWANG
Sufficient Googling is indistinguishable from knowledge -somebody
Anything worth the cost of a missile, which can be located on the battlefield, will be shot at with missiles. If the US military is involved, then things, which are not worth the cost if a missile will also be shot at with missiles. -Sea Skimmer


George Bush makes freedom sound like a giant robot that breaks down a lot. -Darth Raptor
User avatar
Chris OFarrell
Durandal's Bitch
Posts: 5724
Joined: 2002-08-02 07:57pm
Contact:

Post by Chris OFarrell »

A big question is going to be how often this program is going to be needing to do its operations it needs to be root. If its one or two times, and it only is doing minor stuff as root, that it just has to be root because of the security model, then by all means have something like the GUI sudo stuff, or a spawning a child that can do it.

But if its going to be doing a LOT of work as the super user, then you might consider making the program only something a high level user can run...
Image
Post Reply