Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: File::Path and mode with sgid

by Eliya (Vicar)
on Apr 27, 2012 at 09:44 UTC ( #967569=note: print w/replies, xml ) Need Help??

in reply to Re^2: File::Path and mode with sgid
in thread File::Path and mode with sgid

Well, it seems File::Path::make_path uses plain mkdir calls under the hood, which don't honor special bits.1  I.e., the following wouldn't work either

$ perl -e 'mkdir "foo", 02750' $ ls -ld foo drwxr-x--- 2 eliya eliya 4096 Apr 27 11:40 foo/

while chmod does

$ perl -e 'mkdir "foo", 0750; chmod 02750, "foo"' $ ls -ld foo drwxr-s--- 2 eliya eliya 4096 Apr 27 11:41 foo/


1 This is OS specific; it has nothing to do with Perl.  Perl just passes through the mode value to the mkdir system call (see man 2 mkdir).

The command mkdir -pm2750 foo also has to apply a chmod after having used mkdir:

$ strace mkdir -pm2750 foo ... mkdir("foo", 02750) = 0 open("foo", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = 3 fstat(3, {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0 fchmod(3, 02750) = 0 <--- ...

Replies are listed 'Best First'.
Re^4: File::Path and mode with sgid
by Hena (Friar) on Apr 27, 2012 at 11:31 UTC
    You are right. Using mkdir -pm2750 foo/faa creates faa with correct permissions and foo with wrong permissions. How annoying. Essentially:
    mkdir -pm2750 foo/bar $ ls -lh total 4.0K drwxrwxr-x 3 hena hena 4.0K 2012-04-27 14:30 foo $ ls -lh foo/ total 4.0K drwxr-s--- 2 hena hena 4.0K 2012-04-27 14:30 bar

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2016-09-30 05:04 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (562 votes). Check out past polls.