bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "mkdir -p" new child dirs don't inherit default POSIX ACLs properl


From: C. J. Meidlinger
Subject: Re: "mkdir -p" new child dirs don't inherit default POSIX ACLs properly
Date: Sat, 16 Feb 2008 16:55:57 -0500 (EST)
User-agent: SquirrelMail/1.4.9a

Paul,

I modified the C program slightly (just to better understand what's going
on) and ran it like this:

-----mkdir-test.c------------------------------
#include <sys/stat.h>

int
main (void)
{
        umask (022);
        mkdir ("acl-test/dir-022-777", 0777);
        mkdir ("acl-test/dir-022-755", 0755);
        umask (0);
        mkdir ("acl-test/dir-0-777", 0777);
        mkdir ("acl-test/dir-0-755", 0755);
        return 0;
}
-----mkdir-test.c------------------------------

What I learned was that the umask() lines had no affect on the effective
rights mask of the inherited ACLs, but the mode did.  The 0777 mkdir lines
all inherited the default mask (rwx) properly and the 0755 lines inherited
the mask as (r-x).

To eliminate kernel and filesystem differences I brought the
coreutils-5.97 package up to the same distro level (Slackware-current) and
also tested on both ReiserFS (my original filesystem) and ext3.  There
were no differences in behaviors between ReiserFS and ext3 in any of my
tests, so I won't mention them anymore.

There was a difference in the coreutils versions however... Not in the
behavior of the C program calls, but in the way that "mkdir -p" constructs
those calls from the shell.  So, if I understand your last note correctly,
the following should be equivalent:

     umask (022);
     mkdir ("acl-test/dir-777", 0777);

...and...

     umask (0);
     mkdir ("acl-test/dir-755", 0755);

With "mkdir -p", the 5.97 coreutils constructs the calls with the umask
022 + mkdir 0777 method and 6.10 uses the umask 0 + mkdir 0755 method.

In 6.10, with my shell environment umask at 022, mkdir -p gives:

umask(0)                                = 022
mkdir("acl-test", 0755)                 = -1 EEXIST (File exists)
chdir("acl-test")                       = 0
mkdir("mkdir-p", 0755)                  = 0

...and the inherited ACL mask is wrong.

In 5.97, with my shell environment umask at 022, mkdir -p gives:

umask(0)                                = 022
umask(022)                              = 0
stat64("acl-test/mkdir-p", 0xbfca8134)  = -1 ENOENT (No such file or
directory)
umask(0)                                = 022
open(".", O_RDONLY|O_LARGEFILE)         = 3
mkdir("acl-test", 0755)                 = -1 EEXIST (File exists)
chdir("acl-test")                       = 0
umask(022)                              = 0
mkdir("mkdir-p", 0777)                  = 0

...and the inherited ACL mask is correct.

So if the shell command "mkdir" under version 6.10 uses 0777 in its system
call, maybe "mkdir -p" should as well?  At least for newly created dirs?

I've attached traces for "mkdir -p" and the C code that I called
"mkdir-test.c" for both 5.97 and 6.10 versions of coreutils.

Thanks,

CJM

Attachment: mkdir-5.97-vs-6.10-traces.tgz
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]