The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-31-2006
x96riley3 x96riley3 is offline
Registered User
  
 

Join Date: Mar 2006
Location: Nashville
Posts: 79
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
  #2 (permalink)  
Old 03-31-2006
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0