What's the purpose of each of the different UIDs a process can have?

前端 未结 5 537
暖寄归人
暖寄归人 2020-12-04 12:39

Real UID, effective UID, and some systems even have a \"saved UID\". What\'s the purpose of all these, especially the last one?

5条回答
  •  忘掉有多难
    2020-12-04 13:01

    Each UNIX process has 3 UIDs associated to it. Superuser privilege is UID=0.

    Real UID

    This is the UID of the user/process that created THIS process. It can be changed only if the running process has EUID=0.

    Effective UID

    This UID is used to evaluate privileges of the process to perform a particular action. EUID can be changed either to RUID, or SUID if EUID!=0. If EUID=0, it can be changed to anything.

    Saved UID

    If you run an executable with the set-UID bit set, then the resulting running process will start off with a real UID of the real user running it, and an effective and saved UID of the owner of the executable file. If the process then calls setuid() or seteuid() to change their effective UID, they can still get back their original privileges again thanks to the saved UID. If the set-UID bit is not set, SUID will be the RUID.

提交回复
热议问题