GNU bug report logs - #45886
mkdir -m argument does not work correctly, applies incorrect permissions

Previous Next

Package: coreutils;

Reported by: Davin McCall <davmac <at> davmac.org>

Date: Fri, 15 Jan 2021 07:46:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Davin McCall <davmac <at> davmac.org>
To: 45886 <at> debbugs.gnu.org
Subject: bug#45886: mkdir -m argument does not work correctly, applies incorrect permissions
Date: Fri, 15 Jan 2021 17:45:29 +1000
[Message part 1 (text/plain, inline)]
Coreutils 8.32 (and possibly earlier) "mkdir -m <mode> ..." appears to
ignore parts of the mode specification. POSIX suggests that with -m
specified, the mode is "relative" to a=rwx. That implies a mode of "o-w"
should yield a mode of "rwxrwxr-x", and a mode of "o+w" should yield
"rwxrwxrwx". Instead:

$ mkdir -m o-w t1
$ mkdir -m o+w t2
$ ls -l
total 8
drwxr-xr-x 2 davmac users 4096 Jan 15 17:27 t1
drwxrwxrwx 2 davmac users 4096 Jan 15 17:27 t2
$

So, the "o+w" or "o-w" selects the "other" permissions but also the
"group" permissions. This also happens with "g+w" and "g-w" (i.e. both
"group" and "other" permissions get set or cleared). This implies it's
not just a case of the initial mode not matching POSIX, but somehow "o"
and "g" are being applied incorrectly.

Setting POSIXLY_CORRECT makes no difference.


[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.