RUID EUID SUID的一些解释和例子

RUID EUID SUID的一些解释和例子

[root@host ~]# id
uid=0(root) gid=0(root) euid=502(oracle) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@host ~]# cat /etc/passwd | head -n 1
root:x:0:0:root:/root:/bin/bash
[root@host ~]#
以不带参数的id的输出为例:
RUID(Real UID)等于uid,等于用户在/etc/passwd里面的第3列,可用命令id -ru查看.
EUID(Effective UID)表示用户当前的有效身份.如果root的euid为502(oracle),就表示现在root正以oracle的身份在运行,可用命令id -u查看.
SUID(Saved UID)表示保存的euid,当用户在运行suid程序时(如passwd),保存运行前的euid,并在程序结束前,将保存的euid再设置回来.


一个如果改变euid的例子:
(http://superuser.com/questions/56884/change-euid-of-running-process)
[root@user-desktop ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=user_u:system_r:unconfined_t

[root@user-desktop ~]# gdb /bin/bash $$
GNU gdb Fedora (6.8-27.el5)
# cut copyright & license statements
This GDB was configured as "x86_64-redhat-linux-gnu"...
# cut some initialization output    
0x00000036b0a99335 in waitpid () from /lib64/libc.so.6
(gdb) call seteuid(500)
$1 = 0
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /bin/bash, process 29017

[root@user-desktop ~]# id
uid=0(root) gid=0(root) euid=500(user) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=user_u:system_r:unconfined_t


RUID EUID SUID的解释
(http://www.cyberciti.biz/tips/linux-more-on-user-id-password-and-group-management.html)
RUID : Identify the real user, normal user cannot change it.
EUID : Decides access level, normal user can change it.
SUID : Saves the EUID, normal user cannot change it.


SUID与passwd命令的例子
(http://blog.csdn.net/guosha/article/details/2679334)


man setuid

你可能感兴趣的:(U/Linux)