Requesting Superuser
BCS
ao at pathlink.com
Mon Oct 1 21:09:32 PDT 2007
Reply to Nathan,
> 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
almost
A program with the SUID bit can use the setuid system call (and a few related
functions) to move around several different UIDs (IIRC there are three, the
owner of the file, the original from the process that exec'ed and another
that I forget where it comes from). Run a man on setuid and you will get
more than you want to wade through. If you are interested I did a term paper
on the Linux system calls a while ago and it has a little better description
in it.
More information about the Digitalmars-d-learn
mailing list