gpt4 book ai didi

c - setuid 与 seteuid 函数

转载 作者:IT王子 更新时间:2023-10-29 00:32:02 26 4
gpt4 key购买 nike

setuid 和seteuid 函数有什么区别。在手册页中,这两个函数都有相似的描述。

设置标识符:

DESCRIPTION

setuid() sets the effective user ID of the calling process. If the effective UID of the caller is root, the real UID and saved
set-user-ID are also set.

seteuid:

DESCRIPTION

seteuid() sets the effective user ID of the calling process. Unprivileged user processes may only set the effective user ID to
the real user ID, the effective user ID or the saved set-user-ID.

在这两个描述中都包含设置调用进程的有效用户ID。那么有什么区别这两个以及这些函数之间的功能差异。

还有一个疑问是,使用 chmod(chmod u+s ) 只有我们可以给文件设置set user id权限。然后只有在程序运行期间,进程才有权限设置谁用户身份。除了这些功能之外,这些功能如何将有效用户标识设置为进程。

最佳答案

来自man page :

   Thus, a set-user-ID-root program wishing to temporarily drop root
privileges, assume the identity of an unprivileged user, and then
regain root privileges afterward cannot use setuid(). You can
accomplish this with seteuid(2).

关于c - setuid 与 seteuid 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33076543/

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