![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PERL: Searching for a string in a text file problem | meevagh | Shell Programming and Scripting | 15 | 05-01-2008 11:57 AM |
| about setuid setgid permissions | saravananpalani | SUN Solaris | 1 | 03-12-2008 05:11 AM |
| Perl: searching for a string in a file... | pondlife | Shell Programming and Scripting | 4 | 09-17-2007 08:35 AM |
| Using setuid and setgid | crispy | UNIX for Dummies Questions & Answers | 1 | 04-16-2005 08:58 AM |
| perl: why the return valure of stat and lstat are the same? | gusla | Shell Programming and Scripting | 1 | 05-30-2002 02:58 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Searching for SETUID and SETGID using PERL file find with lstat
About System and Perl: Sun Solaris 5.9 sparc, Perl 5.6.1
I've decided to use the perl file::find module to look for all the SETUID and SETGID files on my unix boxes. I wrote something like this: (I've shorted it a little to make it simple) #!/opt/perl/bin/perl use File::Find; find \&wanted, "/"; sub wanted { (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = lstat("$_")); if ($mode eq "34280") { print "Mode = $mode\n"; system "ls -dl $_\n"; } As you can see I am making an lstat call on each file. I'm reading the mode variable on each file to determine if it's a SETUID/SETGID or both. However, each mode seems to differ. A file that is -rwsrwsrwx might have a mode of 36351 but a file with -rwsrwsrw- might have a file mode of 37987. Maybe this isn't the best way to do this. Can someone show me a better way to do this or explain how I get a list of mode numbers in Solaris. I don't want to use the unix find because it's to damn slow. Perl file find is fast and I prefer to us it. Thanks, x |
|
||||
|
The answer is in this page:
http://perldoc.perl.org/functions/stat.html Some hints: - use Fcntl ':mode'; - use the S_I* named constants; - Bitmasking with the '&' operator. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|