setuid, setgid - set user / group ID
#include <unistd.h>
int setuid(uid_t);
int setgid(gid_t);
Sets all of real, effective, and saved user or group ID to the given ID.
For non-superusers, the given ID has to be equal to the current real or effective ID for the call to succeed.
If the call was set successful, returns 0.
Otherwise, returns -1 and sets errno
to describe the error.
EPERM
: The new ID is not equal to the real ID or effective ID, and the user is not superuser.EINVAL
: The new ID is set to invalid value (-1).setuid_overview
(7)geteuid
(2) / getegid
(2)getuid
(2) / getgid
(2)getresuid
(2) / getresgid
(2)seteuid
(2) / setegid
(2)setresuid
(2) / setresgid
(2)