Michael Stone <[EMAIL PROTECTED]> writes:

> On Sat, Apr 23, 2005 at 07:12:03PM -0700, Paul Eggert wrote:
>>   $ umask 077
>>   $ mkdir -m =+rwx d
>>   $ ls -ld d
>>   drwxrwxrwx  2 eggert eggert 4096 Apr 23 18:51 d
>
> I don't get it -- where is the bug? The documentation specifically says
> that it ignores the umask

The coreutils documentation may not be sufficiently clear here, but
the intent was always to be compatible with Unix and with POSIX, and
I've read POSIX and tested Unix (Solaris 9) and it's quite clear that
coreutils mkdir is buggy here.

It's true that mkdir ignores the umask when setting the permissions.
But mkdir is supposed to obey the umask when interpreting -m's operand.
This can be seen in the POSIX specification for mkdir here:

http://www.opengroup.org/onlinepubs/009695399/utilities/mkdir.html

where the description for -m is as follows:

  -m  mode
    Set the file permission bits of the newly-created directory to the
    specified mode value.

(I.e., -m ignores the umask, as you said.  But when we want to find
out what "mode" means, the text goes on to say this:)

    The 'mode' option-argument shall be the same as the mode operand
    defined for the chmod utility.

Now, the mode in the example above is "=+rwx".  The "=" clears all the
mode bits, so the implied mode is now 000, and now we have to see how
"+rwx" is interpreted.  This is described in
<http://www.opengroup.org/onlinepubs/009695399/utilities/chmod.html>,
under "+":

  If 'who' is not specified,

(which is the case here)

  the file mode bits represented by 'perm' for the owner, group, and
  other permissions, except for those with corresponding bits in the
  file mode creation mask of the invoking process, shall be set.

so the umask _is_ significant when interpreting the "+rwx".


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to