Why don't you do the thing id does by yourself? It will be quite a lot simpler and cleaner. getuid(2) and geteuid(2).
Why don't you do the thing id does by yourself? It will be quite a lot simpler and cleaner. getuid(2) and geteuid(2).
Thanks fronty for your suggestion. Its working with the function getuid(). Is root's uid (0) same in all linux flavours?
Also can some one let's know, why length of ch is 5? why not 4?
There from man fgets.fgets() reads in at most one less than size characters from stream and
stores them into the buffer pointed to by s. Reading stops after an
EOF or a newline. If a newline is read, it is stored into the buffer.
A '\0' is stored after the last character in the buffer.