setuid, setgid

setuid

int setuid(uid_t uid);
  • If effective uid == superuser
    • set ruid, euid, saved-suid to uid
  • otherwise
    • change euid to uid if uid==euid or uid==saved-suid

setgid

int setgid(gid_t gid);
  • setuid 一樣

這兩個 system call 我們現在都很少用了


setreuid, setregid

Function Prototype

int setreuid(uid_t ruid, uid_t euid);
int setregid(uid_t rgid, uid_t egid);

Function

Superuser

隨意更改 process 的 real/effective uid/gid

Others

可以將 real/effective UID 在原本的 real/effective UID 間隨意更改


seteuid, setegid

Function Prototype

int seteuid(uid_t uid);
int setegid(uid_t gid);

Function

Superuser

可以隨便改

Others

可以讓 effective UID 在 real UID 及 saved set-UID 間切換