Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Testing the current directory with Cwd and File::Spec

by 0xbeef (Hermit)
on Dec 07, 2005 at 00:21 UTC ( [id://514687]=note: print w/replies, xml ) Need Help??


in reply to Testing the current directory with Cwd and File::Spec

Here is another Cwd consideration. If the directory is a mounted filesystem, getcwd() (as the owner of the mounted filesystem) may return undefined if the owner has insufficient access to the underlying mount-point even if he has full access to the mounted filesystem.

For example:

#get group $groups = `/usr/bin/id -G $username`; chomp $groups; # drop privileges to owner of filesystem $) = "$groups"; #setegid $> = $uid; #seteuid $currentdir = Cwd::getcwd(); my $lasterr = $!; if (not defined $currentdir) { print "getcwd() failed : @_\n"; } else { print "getcwd() for $over is OK."; }

A command like tar will usually give an error like "tar: The getwd subroutine failed. Cannot open parent directory."

This is useful to know in cases where the underlying stub directory's permissions affect programs relying on getcwd() e.g. /bin/pwd, tar etc.

0xbeef

Replies are listed 'Best First'.
Re^2: Testing the current directory with Cwd and File::Spec
by Celada (Monk) on Dec 07, 2005 at 00:57 UTC
    That's an interesting little quirk! I guess that's why it's considered unwise to give less than 0555 permission to mountpoints. By the way I can't reproduce the behaviour under Linux but I can under Solaris.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-26 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found