Mac OS X 中的权限如何传播?
因此,如果我在我的 mac 上创建一个 suid root 程序,并且该程序在 /bin/sh 上运行 exec,则 shell 不是 root,而如果我在 Linux 上执行相同的操作,则 shell 是 root。 Mac 是否不像 Linux 那样传播权限?还是 suid 位发生了一些不同的事情?我的理解是具有suid root的程序以root权限运行。由于调用 /bin/sh 的 root shell 将创建另一个 root shell,因此在 /bin/sh 上调用 exec 的 suid root 程序不应该创建一个 root shell 吗?
So if I make a program suid root on my mac, and that program runs exec on /bin/sh, the shell is not root whereas if I do the same thing on Linux, the shell is root. Does Mac not propagate permissions the same way Linux does? Or is there just something different going on with the suid bits? My understanding is that programs with suid root run with root privileges. And since a root shell that calls /bin/sh will create another root shell, shouldn't an suid root program that calls exec on /bin/sh create a root shell?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所有进程都有多个UID(至少是真实的、有效的、保存的UID)。执行 setuid 二进制文件仅影响有效和保存的 UID,而不影响“真实”UID——因此,setuid 二进制文件将“知道”它是从哪个 UID 执行的,并且可以返回到该 UID。在这种情况下,
/bin/sh
的 bash 实现在执行时会自动返回其真实的 UID。All processes have multiple UIDs (the real, effective, and saved UID, at a minimum). Executing a setuid binary only affects the effective and saved UIDs, not the "real" UID -- as a result, a setuid binary will "know" what UID it was executed from, and can return to that UID. In this case, the bash implementation of
/bin/sh
automatically returns to its real UID when it's executed.