gpt4 book ai didi

linux - 可执行文件是否与运行它的用户具有相同的文件权限?

转载 作者:太空狗 更新时间:2023-10-29 12:09:32 25 4
gpt4 key购买 nike

在 Unix 中,如果我运行一个包含文件的二进制文件,该二进制文件是否具有与我(运行该二进制文件的用户)相同的文件权限?

最佳答案

在大多数情况下,答案是肯定的!

但是,如果您在该二进制文件上启用了 setuidsetgid 位,则情况并非如此。

启用 setuid 的二进制文件的经典示例。

ls -ltra `which passwd`

如果在执行期间不能授予您(执行该命令的用户)与 root 相同的权限来修改 /etc/password/etc/shadow

看看:

https://docs.oracle.com/cd/E19683-01/816-4883/secfile-69/index.html

setuid 权限

When set-user identification (setuid) permission is set on an executable file, a process that runs this file is granted access based on the owner of the file (usually root), rather than the user who is running the executable file. This special permission allows a user to access files and directories that are normally only available to the owner.

setgid 权限

The set-group identification (setgid) permission is similar to setuid, except that the process's effective group ID (GID) is changed to the group owner of the file, and a user is granted access based on permissions granted to that group. The /usr/bin/mail command has setgid permissions

如果您想更深入地了解 Linux 如何管理进程和子进程,您可能还想看看 forkexec

关于linux - 可执行文件是否与运行它的用户具有相同的文件权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50575515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com