Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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

by 0xbeef (Hermit)
on Dec 07, 2005 at 00:21 UTC ( #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.


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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2022-07-07 06:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found