作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有这个:
$ ls -l test1.sh
-rwxr-sr-x 1 root root 24 2011-05-31 13:27 test1.sh # sgid root
$ id
uid=1001(abc) gid=1001(abc) groups=4(adm),6(disk),20(dialout),21(fax),24(cdrom),26(tape),29(audio),30(dip),44(video),46(plugdev),104( fuse),106(lpadmin),112(netdev),121(admin),122(sambashare),1001(abc),1002(sbox)
但是,当我运行 test1.sh 时,我在 ps o/p 中看不到 Effective Group Owner 是 root。为什么?
$ ps -o pid,ppid,cmd,euid,euser,ruid,ruser,egid,egroup,rgid,rgroup,nice,tty,user
PID PPID CMD EUID EUSER RUID RUSER EGID EGROUP RGID RGROUP NI TT USER
8793 2349 bash 1001 abc 1001 abc 1001 abc 1001 abc 0 pts/2 abc
8865 8793 /bin/bash ./test1.sh 1001 abc 1001 abc 1001 abc 1001 abc 0 pts/2 abc
8866 8865 sleep 60 1001 abc 1001 abc 1001 abc 1001 abc 0 pts/2 abc
8868 8793 ps -o pid,ppid,cmd,euid,eus 1001 abc 1001 abc 1001 abc 1001 abc 0 pts/2 abc
最佳答案
编写安全的 shell 脚本真的很难。想想 $PATH
、$IFS
,... 所以,Linux 不支持 shell 脚本的 setuid/setgid 位。
关于linux - EGID 和 RGID 在 ps o/p 中显示不正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6193457/
我有这个: $ ls -l test1.sh -rwxr-sr-x 1 root root 24 2011-05-31 13:27 test1.sh # sgid root $ id uid=1001
我是一名优秀的程序员,十分优秀!