質問

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). 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?

役に立ちましたか?

解決

You can compare result of getuid() and geteuid() library calls.

If geteuid() returns 0 (root), but getuid() returns not 0, you can say that suid is active.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top