Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top