Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: getcwd() as different user

by 0xbeef (Hermit)
on Nov 19, 2005 at 12:53 UTC ( #510082=note: print w/replies, xml ) Need Help??


in reply to Re^2: getcwd() as different user
in thread getcwd() as different user

If anyone's interested, here's a snippet with the basic working logic. Although the "id -G" portion is not the safest way of doing this, I just don't know how:

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, +$blksize,$blocks) = stat($targetdir); $newuser = getpwuid($uid); $groups = `/usr/bin/id -G $newuser`; $) = "$groups"; $> = $uid; if ( not chdir("$targetdir")) { print "$targetdir is inaccessible to its owner\n"; next; } else { $currentdir = Cwd::getcwd(); my $lasterr = $!; if (not defined $currentdir) { # incorrect underlying mount-point permissions print "getcwd() failed for $targetdir:$lasterr\n"; } else { print "getcwd() for $over is OK."); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://510082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2022-07-01 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (98 votes). Check out past polls.

    Notices?