Penguin
Note: You are viewing an old revision of this page. View the current version.

A SUID program (short for Set UID) is when a program has the u+s permission bit set. This means that the program runs with the EffectiveUid? of the person that owns the file, not the person that runs the program. For instance, a SUID program owned by root would run as root, instead of a normal user when executed.

To run a progam completely as a new user, it needs to be SUID to that user, and you need to execute

setregid( getegid(), getegid() );
setreuid( geteuid(), getegid() );

Many progams need this, as they will drop any EUID permissions on startup. You can do so using:

setregid( getgid(), getgid() );
setreuid( getuid(), getuid() );