Subject: bug#45886: mkdir -m argument does not work correctly, applies incorrect permissions

From: Davin McCall <[email-masked]>
Date: Fri, 15 Jan 2021 17:45:29 +1000

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.