简体   繁体   English

是否设置了set-user-id位?

[英]Is set-user-id bit set?

I'm going to write a code which will extensively execute other programs. 我将编写一个代码,它将广泛执行其他程序。 I don't want it to have root privileges if someone set a set-user-id bit(and root is an owner). 如果有人设置了set-user-id位(并且root是所有者),我不希望它具有root权限。 So I'm going to drop privileges at startup. 所以我要在启动时放弃权限。

My question is: How can I understand from within the program whether it run in set-user-id mode? 我的问题是:如何在程序中理解它是否以set-user-id模式运行?

You can compare result of getuid() and geteuid() library calls . 您可以比较getuid()geteuid() 库调用的结果

If geteuid() returns 0 (root), but getuid() returns not 0, you can say that suid is active. 如果geteuid()返回0(root),但getuid()返回的不是0,则可以说suid处于活动状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM