(翻译)Real-UID,Effective-UID,Saved-UID区别

简介: (翻译)Real-UID,Effective-UID,Saved-UID区别

Content


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


每一个Unix进程拥有3个用户ID与之关联.超级权限的用户ID为0.


Real UID


真实用户ID


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


这是创建这个进程的用户/进程的用户ID.只有有效用户ID是0才能修改这项信息.


Effective UID


有效用户ID


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


这项用户ID是用来扩充进程的权力以用来开展一项特定的操作.有效用户ID在有效用户ID不为0时,能被切换为真实用户ID或者保存用户ID.如果有效用户ID为0,它能被切换成任何用户ID.


Saved UID


保存用户ID


If the binary image file, that was launched has a Set-UID bit on, SUID will be the UID of the owner of the file. Otherwise, SUID will be the RUID.


如果一项二进制图像文件,含有Set-UID的二进制标记,那么保存用户ID将会成为这个文件拥有者的用户ID.否则,保存用户ID将会变成真实用户ID.


What is the idea behind this?


这之后的意义是什么?


Normal programs, like “ls”, “cat”, “echo” will be run by a normal user, under that users UID. Special programs that allow user to have controlled access to protected data, can have Set-UID bit to allow the program to be run under privileged UID.


常见的程序,像"ls",“cat”,"echo"一般用户所运行时,是基于这个一般用户的用户ID进行的.特定的程序当用户在访问限制数据的时候会受到限制,能通过设置Set-UID位来允许该程序通过特权用户ID来运行该程序.


An example of such program is “passwd”. If you list it in full, you will see that it has Set-UID bit and the owner is “root”. When a normal user, say “ananta”, runs “passwd”, passwd starts with:


一个这样的例子就是"passwd".如果你采取命令显示文件的所有信息,就能看到它标记了set-uid位并且该文件的拥有者是超级权限"root".当一个一般用户"ananta",运行"passwd"程序,passwd的用户ID设置如下:


Real-UID = ananta

Effective-UID = ananta

Saved-UID = root

The the program calls a system call “seteuid( 0 )” and since SUID=0, the call will succede and the UIDs will be:


这个程序会执行一个系统调用"seteiud(0)"而且,如果SUID=0,这次调用将会成功并且用户ID配置将会变成:


Real-UID = ananta

Effective-UID = root

Saved-UID = root

After that, “passwd” process will be able to access /etc/passwd and change password for user “ananta”. Note that user “ananta” cannot write to /etc/passwd on it’s own. Note one other thing, setting a Set-UID on a executable file is not enough to make it run as privileged process. The program itself must make a system call.


在此之后,"passwd"进程就将能够使用/etc/passwd 然后为"ananta"修改密码.注意,ananta用户本身并不能对/etc/passwd文件进行写入操作.另外,还需要注意,为一个可执行文件设置set-uid位并不足以让该程序在运行的时候获得相应的特殊权限,该程序本身必须要执行一个系统调用才能达成相应的目的


Conclusion


总而言之,按照这里的描述,


RealUID是根据当前的操作用户/进程而定的.


SavedUID则是充当一个暂存的容器,如果设置了set-uid位,则其设置为和当前文件拥有者相同,不然,则设置为和RealUID相同.


EffectiveUID的作用是作为实际起作用的,发挥效果的UID信息,这个UID是随着运行状态不断变化的,当前的EUID的实际设置将直接决定这个EUID的可变化状态.



目录
相关文章
|
网络安全 开发工具 git
Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解决的两种方式)
Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解决的两种方式)
3526 0
Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解决的两种方式)
|
23天前
|
Linux
解决:“userdel: user xxxx is currently used by process xxx” 的问题
解决:“userdel: user xxxx is currently used by process xxx” 的问题
78 3
|
网络虚拟化
使用ChatGPT Access denied,Error reference number: 1020问题解决
使用ChatGPT Access denied,Error reference number: 1020问题解决
使用ChatGPT Access denied,Error reference number: 1020问题解决
|
开发者
返回 account_number|学习笔记
快速学习返回 account_number。
122 0
返回 account_number|学习笔记
|
数据库
LeetCode(数据库)- Users That Actively Request Confirmation Messages
LeetCode(数据库)- Users That Actively Request Confirmation Messages
74 0
在S4 key user tool里创建Custom Logic的后台实现
在S4 key user tool里创建Custom Logic的后台实现
105 0
在S4 key user tool里创建Custom Logic的后台实现
|
Python
如何查看某个ABAP user针对某个authorization object的assignment status
如何查看某个ABAP user针对某个authorization object的assignment status
143 0