The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SUID not working Pankaj Mishra UNIX for Advanced & Expert Users 3 10-20-2006 12:48 AM
SUID and SGID searching... B14speedfreak SUN Solaris 2 05-23-2006 09:13 AM
is SUID disabled for shell shriashishpatil UNIX for Advanced & Expert Users 3 03-22-2006 08:44 PM
what is suid ? simon2000 UNIX for Dummies Questions & Answers 2 07-18-2002 06:43 AM
suid files??? solvman Security 1 10-12-2001 10:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 09-27-2001
solvman's Avatar
Registered User
 

Join Date: Sep 2001
Posts: 67
Question SUID bit???

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
Reply With Quote
Forum Sponsor
  #2  
Old 09-28-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Use the symbolic name rather than the octal constant. And use a bitwise "and":

Code:
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)
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0