Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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 <--- ...


Comment on Re^3: File::Path and mode with sgid
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (15)
As of 2015-07-31 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls