[英]setuid and seteuid function
I tried to find the difference between setuid and seteuid function. 我试图找到setuid和seteuid函数之间的区别。 At that time, many of them says the following is the difference. 当时,许多人说以下是区别。 It is showed in the man page of setuid. 它显示在setuid的手册页中。
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()
. 因此,希望暂时放弃root特权,假定未特权用户的身份,然后再获取root特权的set-user-ID-root程序不能使用setuid()
。 You can accomplish this withseteuid(2)
. 您可以使用seteuid(2)
完成此seteuid(2)
。
I have a doubt in the above man page reference. 我对上面的手册页参考有疑问。 Using setuid we can set the effective user id of the process. 使用setuid,我们可以设置进程的有效用户ID。 For Ex: 例如:
setuid(getuid());
After this statement is executed, the effective userid of the process is changed to current user. 执行此语句后,该进程的有效用户标识将更改为当前用户。 So, to regain the root permission, I simply use, 因此,为了获得root权限,我只需使用,
setuid(0);
But why the man page reference shows 但是为什么手册页参考显示
afterward cannot use setuid(). You can accomplish this with seteuid(2)
请注意手册页的措辞:它用于set-user-id-root程序(因此,可执行文件由用户root拥有,并且suid位置1)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.