分页: 1 / 1

关于setuid的一点疑问

发表于 : 2014-10-25 10:24
jiandan23
按照道理,如果某个可执行程序设置了setuid的话,那么任何用户在执行它的时候,都自动的变成文件拥有者的身份。
但是大家请看下面的这个例子:
捕获.JPG
为什么普通用户在执行ping命令时,所产生的进程的real user和effective user还是它自己?不知道是不是我的理解有误

Re: 关于setuid的一点疑问

发表于 : 2014-10-25 14:21
poloshiao
为什么普通用户在执行ping命令时,所产生的进程的real user和effective user还是它自己?
參閱
http://manpages.ubuntu.com/manpages/uto ... uid.2.html
If the effective UID of the caller is root, the real UID and saved set-user-ID are also set.

Re: 关于setuid的一点疑问

发表于 : 2014-10-25 17:51
astolia
这有什么想不明白的,程序自己用setuid重置了呗,用ltrace或strace看就知道了
或者直接看代码也行 http://sourceforge.net/p/iputils/code/c ... g_common.c 第114行
MacOS上的ping的源代码注释更明白 http://www.opensource.apple.com/source/ ... roj/ping.c
/*
* Do the stuff that we need root priv's for *first*, and
* then drop our setuid bit. Save error reporting for
* after arg parsing.
*/