20181126文件权限管理之:高级权限suid

文件权限管理之:高级权限suid

[root@dong ~]# touch /root/file1.txt
[root@dong ~]# ll /root/file1.txt
-rw-r--r--. 1 root root 0 11月 9 09:02 /root/file1.txt

[dong1@dong ~]$ cat /root/file1.txt
cat: /root/file1.txt: 权限不够
问题:为什么会失败?
[dong1@dong ~]$ ll -d /root
dr-xr-x---. 28 root root 4096 11月 9 09:04 /root 因为无法进入到root目录
分析:
[dong1@dong ~]$ which cat
/bin/cat 这个进程的所有者是dong1,/root,无法访问
普通用户可以修改密码:
[dong1@dong ~]$ passwd
更改用户 dong1 的密码 。
为 dong1 更改 STRESS 密码。
(当前)UNIX 密码:

[root@dong ~]# ps aux |grep passwd
root 2130 0.3 0.1 168188 2140 pts/1 S+ 09:17 0:00 passwd 实际上进程的执行者是root

[root@dong ~]# which passwd
/usr/bin/passwd
[root@dong ~]# ll /usr/bin/passwd
-rwsr-xr-x. 1 root root 30768 2月 22 2012 /usr/bin/passwd
20181126文件权限管理之:高级权限suid

示例:普通用户勇过suid授权(针对文件)
在进程文件(二进制、可执行)上增加suid权限
1.[root@dong ~]# which cat
/bin/cat
[root@dong ~]# chmod u+s /bin/cat
[root@dong ~]# which rm

[dong1@dong ~]$ cat /root/file1.txt 现在可以正常显示文件
1233345664646464789797979sflsjflsjfl

2.[dong1@dong ~]$ rm -rf /root/file1.txt
rm: 无法删除"/root/file1.txt": 权限不够
[root@dong ~]# which rm
alias rm='rm -i'
/bin/rm
[root@dong ~]# chmod u+s /bin/rm

[dong1@dong ~]$ rm -rf /root/file1.txt 已经删除

猜你喜欢

转载自blog.51cto.com/8450442/2322282