Originally posted by Octo:
<STRONG>I'm writing a small command line program for OSX in C. I want the program to behave slightly differently if I'm running it as the super user. Is there any sort of isroot() function?
Thanks for any help</STRONG>
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
if (getuid() == <font color = blue>0</font>)
{
if(geteuid() == <font color = blue>0</font>)
{
<font color = brown>//Root</font>
} else {
<font color = brown>//Root with droped priviledges (seteuid())</font>
}
} else {
if(geteuid() == <font color = blue>0</font>)
{
<font color = brown>//Normal user running a setuid root program</font>
} else {
<font color = brown>//Not root</font>
}
}
</font>[/code]
Louis