(翻译)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的可变化状态.



目录
相关文章
|
算法 Linux 数据安全/隐私保护
Linux权限管理:深入理解setuid、setgid、seteuid和setegid
Linux权限管理:深入理解setuid、setgid、seteuid和setegid
1885 0
|
文字识别 安全 程序员
PowerToys微软官方效率工具实操教程!Windows系统增强神器!
PowerToys是微软官方推出的免费开源工具集,集成20余款高效插件,如窗口管理、快速启动、批量重命名、OCR文字提取等,显著提升Windows使用体验,支持多屏协作、快捷操作,安全稳定,持续更新,适合各类用户优化工作效率。
1661 6
|
编译器 测试技术 C++
【Python 基础教程 01 全面介绍】 Python编程基础全攻略:一文掌握Python语法精髓,从C/C++ 角度学习Python的差异
【Python 基础教程 01 全面介绍】 Python编程基础全攻略:一文掌握Python语法精髓,从C/C++ 角度学习Python的差异
974 0
|
关系型数据库 MySQL 数据库
【MySQL】手把手教你MySQL数据同步
【MySQL】手把手教你MySQL数据同步
|
存储 编解码 Android开发
58. 【Android教程】音频录制:MediaRecord
58. 【Android教程】音频录制:MediaRecord
625 2
|
Linux API 芯片
Linux GPIO 和 Pinctrl 子系统的使用(十四)
Linux GPIO 和 Pinctrl 子系统的使用(十四)
1123 1
|
存储 监控 安全
深度剖析Linux进程的内部机制:一探/proc/pid的奥秘
深度剖析Linux进程的内部机制:一探/proc/pid的奥秘
4215 0
|
算法 程序员 C++
【Python 基础教程 05】超详细解析Python3注释:全面入门教程,初学者必读,了解Python如何 进行注释
【Python 基础教程 05】超详细解析Python3注释:全面入门教程,初学者必读,了解Python如何 进行注释
1261 1
|
存储 Java API
一篇文章讲明白luauserdata
一篇文章讲明白luauserdata
803 0