Requesting Superuser

Nathan Reed nathaniel.reed at gmail.com
Mon Oct 1 19:07:18 PDT 2007


Jesse Phillips wrote:
> As a Linux programmer it can be important to have a program run with 
> superuser privileges. I am trying to figure out the best way to either 
> become a super user by asking for a password, or simply checking if it is 
> run as a superuser.

I'm not a Linux expert, but it's my understanding that there is no way 
to "become" a superuser.  The program cannot be run as an ordinary user 
and then elevate itself to superuser status (that would make the whole 
superuser concept pointless).

Programs like 'sudo' and 'passwd', which always execute as root but can 
be called by any user, are made by first ensuring that the executable is 
owned by root and then setting the SUID bit in the permissions bitmask 
on the executable.  This does not affect how the programs are written at 
all; it is solely a file-system/OS feature.

Thanks,
Nathan Reed


More information about the Digitalmars-d-learn mailing list