Hi all
I'm getting file info through stat( char *filename, struct stat *buf)
Taking all the file attributes to buf->st_mode,
How can i check the suid bit in there, if suid bit mask is 0004000??
Thank you all
Hi all
I'm getting file info through stat( char *filename, struct stat *buf)
Taking all the file attributes to buf->st_mode,
How can i check the suid bit in there, if suid bit mask is 0004000??
Thank you all
Use the symbolic name rather than the octal constant. And use a bitwise "and":
if (buf->stmode & S_ISUID) {
printf{"suid bit set\n");
} else {
printf("suid bit clear\n");
}
Some people don't like that form and think this is more clear:
if ((buf->stmode & S_ISUID) == S_ISUID)