From unknown Sun Aug 10 16:51:12 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14371 <14371@debbugs.gnu.org> To: bug#14371 <14371@debbugs.gnu.org> Subject: Status: Argument --parents ignores default ACLs Reply-To: bug#14371 <14371@debbugs.gnu.org> Date: Sun, 10 Aug 2025 23:51:12 +0000 retitle 14371 Argument --parents ignores default ACLs reassign 14371 coreutils submitter 14371 Killer Bassist severity 14371 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed May 08 14:19:16 2013 Received: (at submit) by debbugs.gnu.org; 8 May 2013 18:19:16 +0000 Received: from localhost ([127.0.0.1]:34116 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua8xO-0005By-70 for submit@debbugs.gnu.org; Wed, 08 May 2013 14:19:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50149) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ua8N8-0003NW-ML for submit@debbugs.gnu.org; Wed, 08 May 2013 13:41:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua8N1-0005q3-Me for submit@debbugs.gnu.org; Wed, 08 May 2013 13:41:46 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:50789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua8N1-0005py-IA for submit@debbugs.gnu.org; Wed, 08 May 2013 13:41:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua8Mv-0005Wf-5Z for bug-coreutils@gnu.org; Wed, 08 May 2013 13:41:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ua8Ms-0005o0-6k for bug-coreutils@gnu.org; Wed, 08 May 2013 13:41:33 -0400 Received: from mail-ie0-x235.google.com ([2607:f8b0:4001:c03::235]:40401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ua8Ms-0005nm-1L for bug-coreutils@gnu.org; Wed, 08 May 2013 13:41:30 -0400 Received: by mail-ie0-f181.google.com with SMTP id x12so3773838ief.12 for ; Wed, 08 May 2013 10:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=zewMjpChxyW4ReMl3iVzgyxT1MiLgnTb4h3JtVqhiOA=; b=Fo9j/B4kEp12J7ZIeDq7bfmMWeoZ6CxgOc18YhtXmMkzB6A7o4Zbz7vzVZNIblz9oH GAQVnc2OfmuXHXlzaRIga/REnR5GDI1mgCKLW8At9xRFyo0rTmDrwl1/ufwCCU2kSEVE VQMDc+ka/z3YG+u3Tnl71va9egqiN9zbdtSSxFrdtcEmRaAxx6pgpWyYRxJNGl1cFYFn xId30b87Lh1swk68Vg8sJrQ0yCfYnl4Jmn+S6Lt0SIb2LRYqiEmLHVo6X3GMTanMk4SS OMxPIG7i4nComK8d3tRGA2yymjXl0p9G+Kk3inrc/EWxFlylJRki4pGBpBKtzfeM1STV g+bQ== MIME-Version: 1.0 X-Received: by 10.50.3.38 with SMTP id 6mr2936298igz.44.1368034889138; Wed, 08 May 2013 10:41:29 -0700 (PDT) Received: by 10.50.147.36 with HTTP; Wed, 8 May 2013 10:41:29 -0700 (PDT) Date: Wed, 8 May 2013 10:41:29 -0700 Message-ID: Subject: Argument --parents ignores default ACLs From: Killer Bassist To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary=089e013c684e9b943404dc387105 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 08 May 2013 14:19:12 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --089e013c684e9b943404dc387105 Content-Type: text/plain; charset=ISO-8859-1 Hello there, Stumbled on to this when I discovered permissions issues on directories created from a script. The -p option ignores default ACLs set on the parent directory. Note that the mkdir -p command does not seem to give the g+w attribute to new directories. Even the bar directory is missing it. [root@server mirror_crop]# mkdir -p foo/bar [root@server mirror_crop]# mkdir foobar [root@server mirror_crop]# ll -d foobar drwxrws---+ 2 root apache 4096 May 8 09:37 foobar [root@server mirror_crop]# ll -d foo drwxr-s---+ 3 root apache 4096 May 8 09:36 foo [root@server mirror_crop]# getfacl foo # file: foo # owner: root # group: apache # flags: -s- user::rwx group::r-x other::--- default:user::rwx default:group::rwx default:other::--- [root@server mirror_crop]# getfacl foobar # file: foobar # owner: root # group: apache # flags: -s- user::rwx group::rwx other::--- default:user::rwx default:group::rwx default:other::--- And to show the default... [root@server virtualmirror]# getfacl mirror_crop/ # file: mirror_crop/ # owner: root # group: apache # flags: -s- user::rwx group::rwx other::--- default:user::rwx default:group::rwx default:other::--- It appears that -p is actually using the umask where without -p it uses the defaults =) -- Thank you for your time, Dylan -With all due respect, please do not enter this email address into any mass CC mailings, web forms, eCards, friends networks (facebook/myspace), joke pages or the like. --089e013c684e9b943404dc387105 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello there,
Stumbled on to this when I discovered per= missions issues on directories created from a script. =A0The -p option igno= res default ACLs set on the parent directory.

Note that the mkdir -p command does not seem to give the g+w attribute to n= ew directories. Even the bar directory is missing it.=A0

[root@server mirror_crop]# mkdir -p foo/bar
[root@server mirror_crop]# mkdir foobar

[root@serv= er=A0mirror_crop]# ll -d foobar
drwxrws---+ 2 root apache 4096 Ma= y =A08 09:37 foobar
[root@server=A0mirror_crop]# ll -d foo
<= div> drwxr-s---+ 3 root apache 4096 May =A08 09:36 foo

= [root@server=A0mirror_crop]# getfacl foo
# file: foo
# = owner: root
# group: apache
# flags: -s-
user= ::rwx
group::r-x
other::---
default:user::rwx
= default:group::rwx
default:other::---

[r= oot@server=A0mirror_crop]# getfacl foobar
# file: foobar
# owner: root
# group: apache
# flags: -s-
us= er::rwx
group::rwx
other::---
default:user::r= wx
default:group::rwx
default:other::---

And to show the default...
[root@= server virtualmirror]# getfacl mirror_crop/
# file: mirror_crop/<= /div>
# owner: root
# group: apache
# flags: -s= -
user::rwx
group::rwx
other::---
default:= user::rwx
default:group::rwx
default:other::---

It appears that -p is actually using the umask wher= e without -p it uses the defaults =3D)



--
T= hank you for your time,=A0
Dylan=A0

-With all due respect, please do not enter this email address into any mass= CC mailings, web forms, eCards, friends networks (facebook/myspace), joke = pages or the like.
--089e013c684e9b943404dc387105-- From debbugs-submit-bounces@debbugs.gnu.org Thu May 09 15:37:05 2013 Received: (at 14371-done) by debbugs.gnu.org; 9 May 2013 19:37:05 +0000 Received: from localhost ([127.0.0.1]:35005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UaWeG-0006jA-Ec for submit@debbugs.gnu.org; Thu, 09 May 2013 15:37:05 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:53799) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UaWeD-0006ii-Dy for 14371-done@debbugs.gnu.org; Thu, 09 May 2013 15:37:02 -0400 Received: from [192.168.1.11] (p5091E09C.dip0.t-ipconnect.de [80.145.224.156]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0LdPLa-1U9P2V33NS-00ikfw; Thu, 09 May 2013 21:36:53 +0200 Message-ID: <518BFAD5.5060209@bernhard-voelker.de> Date: Thu, 09 May 2013 21:36:53 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Killer Bassist Subject: Re: bug#14371: Argument --parents ignores default ACLs References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:MnRfF/9N0XvyI7jv98tvBCSZ6prpB/PrRIBqNfdWqFA C6H/7MeiH3et8HiOEdpYvRJMV0KQtO3jVW8xOr8ZG++6sueCAK QkImxpsh8OVLha4T3MIHbqPWnEEyBCvQOmN6xF0Qqe7qDp7jhX +1NjFItDGrvCXxmk4i81Pb6lxEAtoiYwwMuJ8T4KX25LYpuO/a KBQUD2wL2amr+h5SuO8TvxDrFa7Sx61IpOkdnIFjlTuuz7Tywh D+Q9qpvAl06Su/6dMOiVkQmNo/Cz7mepcOlgT0JD8yRVAm/eJV 5fgrYIE3oegNaOjksKqo1e9wGFF8l0Bq2ObXXkmmxFL0aAfl46 CbXqLMZhXbvDYrGmyaSXohaBas2MeqlEtZyAs2ztb X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 14371-done Cc: 14371-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) tag 14371 notabug thanks On 05/08/2013 07:41 PM, Killer Bassist wrote: > It appears that -p is actually using the umask where without -p it uses the > defaults =) Thanks for the bug report. However we've seen a very similar one just a few days ago (http://bugs.gnu.org/14249). This is the behavior required by POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/mkdir.html You can read more in the above mentioned bug report. Meanwhile, I'm closing this bug, but you're free to continue discussion if you have further questions. Have a nice day, Berny From unknown Sun Aug 10 16:51:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: Did not alter fixed versions and reopened. Date: Thu, 09 May 2013 19:45:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # Did not alter fixed versions and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Thu May 09 15:56:30 2013 Received: (at 14371) by debbugs.gnu.org; 9 May 2013 19:56:30 +0000 Received: from localhost ([127.0.0.1]:35021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UaWx4-0007UY-8R for submit@debbugs.gnu.org; Thu, 09 May 2013 15:56:30 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49556) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UaWx0-0007UE-Db for 14371@debbugs.gnu.org; Thu, 09 May 2013 15:56:28 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id C1EA239E8109; Thu, 9 May 2013 12:56:19 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KQv+-8A-tly8; Thu, 9 May 2013 12:56:19 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 2B68C39E8108; Thu, 9 May 2013 12:56:19 -0700 (PDT) Message-ID: <518BFF62.80406@cs.ucla.edu> Date: Thu, 09 May 2013 12:56:18 -0700 From: Paul Eggert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: 14371@debbugs.gnu.org, mail@bernhard-voelker.de, killer.bassist@gmail.com Subject: Re: bug#14371: Argument --parents ignores default ACLs References: <518BFAD5.5060209@bernhard-voelker.de> In-Reply-To: <518BFAD5.5060209@bernhard-voelker.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 14371 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.4 (-----) On 05/09/13 12:36, Bernhard Voelker wrote: > we've seen a very similar one > just a few days ago (http://bugs.gnu.org/14249). That was a similar bug report, but it's not the same thing. I think this one is a new one. The problem here is that the operating system ignores the umask when creating files in a directory that has a default mask, whereas coreutils is assuming that the umask is respected. For now I'm reopening the bug. From debbugs-submit-bounces@debbugs.gnu.org Sat May 11 22:26:24 2013 Received: (at 14371-done) by debbugs.gnu.org; 12 May 2013 02:26:24 +0000 Received: from localhost ([127.0.0.1]:37002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbLzS-0004Sv-Lh for submit@debbugs.gnu.org; Sat, 11 May 2013 22:26:23 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:48806) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbLzL-0004SM-NO for 14371-done@debbugs.gnu.org; Sat, 11 May 2013 22:26:18 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 9260BA60005; Sat, 11 May 2013 19:25:55 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KPICvE9rMes1; Sat, 11 May 2013 19:25:53 -0700 (PDT) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 8E49FA60001; Sat, 11 May 2013 19:25:53 -0700 (PDT) Message-ID: <518EFDB1.10908@cs.ucla.edu> Date: Sat, 11 May 2013 19:25:53 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130404 Thunderbird/17.0.5 MIME-Version: 1.0 To: Killer Bassist Subject: Re: bug#14371: Argument --parents ignores default ACLs References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: 14371-done Cc: 14371-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.7 (-----) Thanks for reporting the bug. I installed the following patches into the coreutils master branch and am marking this as done. >From 10287448997642ea04d27372f9283e477a070a70 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 11 May 2013 18:29:47 -0700 Subject: [PATCH 1/3] build: update gnulib submodule to latest --- gl/lib/regex_internal.h.diff | 6 +++--- gl/modules/tempname.diff | 7 ++++--- gnulib | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gl/lib/regex_internal.h.diff b/gl/lib/regex_internal.h.diff index fe0f2b7..f410882 100644 --- a/gl/lib/regex_internal.h.diff +++ b/gl/lib/regex_internal.h.diff @@ -1,11 +1,11 @@ diff --git a/lib/regex_internal.h b/lib/regex_internal.h -index 2b9f697..7f4e349 100644 +index 439444c..7242084 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h -@@ -823,7 +823,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx) +@@ -827,7 +827,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx) # ifndef NOT_IN_libc static int - internal_function __attribute ((pure)) + internal_function __attribute__ ((pure, unused)) -re_string_elem_size_at (const re_string_t *pstr, Idx idx) +re_string_elem_size_at (const re_string_t *pstr _UNUSED_PARAMETER_, + Idx idx _UNUSED_PARAMETER_) diff --git a/gl/modules/tempname.diff b/gl/modules/tempname.diff index 3603a59..219deed 100644 --- a/gl/modules/tempname.diff +++ b/gl/modules/tempname.diff @@ -1,19 +1,20 @@ diff --git a/modules/tempname b/modules/tempname -index b4708d9..e003c41 100644 +index 7fafd72..4703517 100644 --- a/modules/tempname +++ b/modules/tempname -@@ -1,5 +1,5 @@ +@@ -1,2 +1,2 @@ Description: -gen_tempname() function: create a private temporary file or directory. +gen_tempname, gen_tempname_len: create a private temporary file or directory. Files: lib/tempname.c -@@ -11,6 +11,8 @@ extensions +@@ -11,7 +11,9 @@ extensions fcntl-h gettimeofday lstat +randint + secure_getenv +stdbool stdint sys_stat diff --git a/gnulib b/gnulib index 4a82904..cda5c90 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 4a82904680e6974db7b9eed6a3ed4c6eb24ecbe4 +Subproject commit cda5c90820d55b4b1f52d6a6f5329a10668bd720 -- 1.7.11.7 >From 26927c7266c1194c77a50abc49bc9cbd3854db14 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 11 May 2013 19:17:10 -0700 Subject: [PATCH 2/3] mkdir: don't assume umask equals POSIX default ACL mask This fixes Bug#14371, reported by Killer Bassist. * NEWS: Document this. * src/mkdir.c (struct mkdir_options): Remove member ancestor_mode. New member umask_value. All uses changed. * src/mkdir.c (make_ancestor): Fix umask assumption. * src/mkdir.c, src/mkfifo.c, src/mknod.c (main): Leave umask alone. This requires invoking lchmod after creating the file, which introduces a race condition, but this can't be avoided on hosts with "POSIX" default ACLs, and there's no easy way with network file systems to tell what kind of host the directory is on. * tests/local.mk (all_tests): Add tests/mkdir/p-acl.sh. * tests/mkdir/p-acl.sh: New file. --- NEWS | 5 +++++ src/mkdir.c | 25 ++++++++++++++++++------- src/mkfifo.c | 11 ++++++++++- src/mknod.c | 9 ++++++++- tests/local.mk | 1 + tests/mkdir/p-acl.sh | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 9 deletions(-) create mode 100755 tests/mkdir/p-acl.sh diff --git a/NEWS b/NEWS index ae6251d..eec93df 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,11 @@ GNU coreutils NEWS -*- outline -*- the relative link on the dereferenced path of an existing link. [This bug was introduced when --relative was added in coreutils-8.16.] + mkdir, mkfifo, and mknod now work better when creating a file in a directory + with a default ACL whose umask disagrees with the process's umask, on a + system such as GNU/Linux where directory ACL umasks override process umasks. + [bug introduced in coreutils-6.0] + tail --retry -f now waits for the files specified to appear. Before, tail would immediately exit when such a file is inaccessible during the initial open. diff --git a/src/mkdir.c b/src/mkdir.c index a94f96e..b36237a 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -81,8 +81,8 @@ struct mkdir_options made. */ int (*make_ancestor_function) (char const *, char const *, void *); - /* Mode for ancestor directory. */ - mode_t ancestor_mode; + /* Umask value in effect. */ + mode_t umask_value; /* Mode for directory itself. */ mode_t mode; @@ -112,10 +112,21 @@ static int make_ancestor (char const *dir, char const *component, void *options) { struct mkdir_options const *o = options; - int r = mkdir (component, o->ancestor_mode); + int r; + mode_t user_wx = S_IWUSR | S_IXUSR; + bool self_denying_umask = (o->umask_value & user_wx) != 0; + if (self_denying_umask) + umask (o->umask_value & ~user_wx); + r = mkdir (component, S_IRWXUGO); + if (self_denying_umask) + { + int mkdir_errno = errno; + umask (o->umask_value); + errno = mkdir_errno; + } if (r == 0) { - r = ! (o->ancestor_mode & S_IRUSR); + r = (o->umask_value & S_IRUSR) != 0; announce_mkdir (dir, options); } return r; @@ -191,8 +202,8 @@ main (int argc, char **argv) if (options.make_ancestor_function || specified_mode) { mode_t umask_value = umask (0); - - options.ancestor_mode = (S_IRWXUGO & ~umask_value) | (S_IWUSR | S_IXUSR); + umask (umask_value); + options.umask_value = umask_value; if (specified_mode) { @@ -205,7 +216,7 @@ main (int argc, char **argv) free (change); } else - options.mode = S_IRWXUGO & ~umask_value; + options.mode = S_IRWXUGO; } exit (savewd_process_files (argc - optind, argv + optind, diff --git a/src/mkfifo.c b/src/mkfifo.c index 76291e5..78ff909 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -116,10 +116,13 @@ main (int argc, char **argv) newmode = MODE_RW_UGO; if (specified_mode) { + mode_t umask_value; struct mode_change *change = mode_compile (specified_mode); if (!change) error (EXIT_FAILURE, 0, _("invalid mode")); - newmode = mode_adjust (newmode, false, umask (0), change, NULL); + umask_value = umask (0); + umask (umask_value); + newmode = mode_adjust (newmode, false, umask_value, change, NULL); free (change); if (newmode & ~S_IRWXUGO) error (EXIT_FAILURE, 0, @@ -132,6 +135,12 @@ main (int argc, char **argv) error (0, errno, _("cannot create fifo %s"), quote (argv[optind])); exit_status = EXIT_FAILURE; } + else if (specified_mode && lchmod (argv[optind], newmode) != 0) + { + error (0, errno, _("cannot set permissions of `%s'"), + quote (argv[optind])); + exit_status = EXIT_FAILURE; + } exit (exit_status); } diff --git a/src/mknod.c b/src/mknod.c index 7cfc708..a384ad3 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -122,10 +122,13 @@ main (int argc, char **argv) newmode = MODE_RW_UGO; if (specified_mode) { + mode_t umask_value; struct mode_change *change = mode_compile (specified_mode); if (!change) error (EXIT_FAILURE, 0, _("invalid mode")); - newmode = mode_adjust (newmode, false, umask (0), change, NULL); + umask_value = umask (0); + umask (umask_value); + newmode = mode_adjust (newmode, false, umask_value, change, NULL); free (change); if (newmode & ~S_IRWXUGO) error (EXIT_FAILURE, 0, @@ -226,5 +229,9 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } + if (specified_mode && lchmod (argv[optind], newmode) != 0) + error (EXIT_FAILURE, errno, _("cannot set permissions of `%s'"), + quote (argv[optind])); + exit (EXIT_SUCCESS); } diff --git a/tests/local.mk b/tests/local.mk index fb5cc63..5ec7d98 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -555,6 +555,7 @@ all_tests = \ tests/mkdir/p-1.sh \ tests/mkdir/p-2.sh \ tests/mkdir/p-3.sh \ + tests/mkdir/p-acl.sh \ tests/mkdir/p-slashdot.sh \ tests/mkdir/p-thru-slink.sh \ tests/mkdir/p-v.sh \ diff --git a/tests/mkdir/p-acl.sh b/tests/mkdir/p-acl.sh new file mode 100755 index 0000000..f1be628 --- /dev/null +++ b/tests/mkdir/p-acl.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Test "mkdir -p" with default ACLs. + +# Copyright (C) 1997-2013 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ mkdir + +require_setfacl_ + +mkdir d || framework_failure_ +setfacl -d -m group::rwx d || framework_failure_ +umask 077 + +mkdir --parents d/e || fail=1 +ls_l=$(ls -ld d/e) || fail=1 +case $ls_l in + d???rw[sx]*) ;; + *) fail=1 ;; +esac + +Exit $fail -- 1.7.11.7 >From 7a4d509292c62704c265254eb702321f7e533277 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 11 May 2013 19:21:06 -0700 Subject: [PATCH 3/3] maint: add FIXME comment --- src/copy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/copy.c b/src/copy.c index 5c0ee1e..c1c8273 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2747,8 +2747,12 @@ owner_failure_ok (struct cp_options const *x) return ((errno == EPERM || errno == EINVAL) && !x->owner_privileges); } -/* Return the user's umask, caching the result. */ +/* Return the user's umask, caching the result. + FIXME: If the destination's parent directory has has a default ACL, + some operating systems (e.g., GNU/Linux's "POSIX" ACLs) use that + ACL's mask rather than the process umask. Currently, the callers + of cached_umask incorrectly assume that this situation cannot occur. */ extern mode_t cached_umask (void) { -- 1.7.11.7 From debbugs-submit-bounces@debbugs.gnu.org Sat May 11 22:43:58 2013 Received: (at 14371) by debbugs.gnu.org; 12 May 2013 02:43:58 +0000 Received: from localhost ([127.0.0.1]:37017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbMGT-0005eU-KJ for submit@debbugs.gnu.org; Sat, 11 May 2013 22:43:58 -0400 Received: from mx.meyering.net ([88.168.87.75]:46526) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UbMGQ-0005eB-0I for 14371@debbugs.gnu.org; Sat, 11 May 2013 22:43:55 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 2423760146; Sun, 12 May 2013 04:43:34 +0200 (CEST) From: Jim Meyering To: 14371@debbugs.gnu.org Subject: Re: bug#14371: Argument --parents ignores default ACLs In-Reply-To: <518EFDB1.10908@cs.ucla.edu> (Paul Eggert's message of "Sat, 11 May 2013 19:25:53 -0700") References: <518EFDB1.10908@cs.ucla.edu> Date: Sun, 12 May 2013 04:43:34 +0200 Message-ID: <8761yohq95.fsf@rho.meyering.net> Lines: 48 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: 14371 Cc: eggert@cs.ucla.edu, killer.bassist@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.7 (-----) Paul Eggert wrote: > Thanks for reporting the bug. > > I installed the following patches into the coreutils master branch > and am marking this as done. > >>>From 10287448997642ea04d27372f9283e477a070a70 Mon Sep 17 00:00:00 2001 > From: Paul Eggert > Date: Sat, 11 May 2013 18:29:47 -0700 > Subject: [PATCH 1/3] build: update gnulib submodule to latest > > --- > gl/lib/regex_internal.h.diff | 6 +++--- > gl/modules/tempname.diff | 7 ++++--- > gnulib | 2 +- > 3 files changed, 8 insertions(+), 7 deletions(-) Hi Paul, Thanks for fixing that and for adapting to newer gnulib. I've pushed this additional change so that "make syntax-check" continues to pass: >From 7c0191e1456d38e7d5b64f21a06711de728cee54 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 11 May 2013 18:28:32 +0200 Subject: [PATCH] build: avoid new syntax-check failure * po/POTFILES.in: Reflect renaming. --- po/POTFILES.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 21617cc..39de91b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -18,7 +18,7 @@ lib/randread.c lib/regcomp.c lib/root-dev-ino.h lib/rpmatch.c -lib/set-mode-acl.c +lib/set-acl.c lib/siglist.h lib/spawn-pipe.c lib/strsignal.c -- 1.8.3.rc1.44.gb387c77 From unknown Sun Aug 10 16:51:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 09 Jun 2013 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 05:57:51 2021 Received: (at control) by debbugs.gnu.org; 15 Jan 2021 10:57:52 +0000 Received: from localhost ([127.0.0.1]:39961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0Mnf-0001ti-LF for submit@debbugs.gnu.org; Fri, 15 Jan 2021 05:57:51 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:58654) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0Mnc-0001tT-Dm for control@debbugs.gnu.org; Fri, 15 Jan 2021 05:57:50 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id CC25316012F for ; Fri, 15 Jan 2021 02:57:41 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id v39K5NGTVx07 for ; Fri, 15 Jan 2021 02:57:41 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 39CDF160132 for ; Fri, 15 Jan 2021 02:57:41 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QsABovmipSoL for ; Fri, 15 Jan 2021 02:57:41 -0800 (PST) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1B15116012F for ; Fri, 15 Jan 2021 02:57:41 -0800 (PST) To: control@debbugs.gnu.org From: Paul Eggert Subject: unarchive 14371 Organization: UCLA Computer Science Department Message-ID: <069d7702-d6fb-fef1-62f2-e5f0a5073841@cs.ucla.edu> Date: Fri, 15 Jan 2021 02:57:40 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) unarchive 14371 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 06:03:15 2021 Received: (at 14371) by debbugs.gnu.org; 15 Jan 2021 11:03:15 +0000 Received: from localhost ([127.0.0.1]:39977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0Mst-000485-8S for submit@debbugs.gnu.org; Fri, 15 Jan 2021 06:03:15 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59284) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0Msr-00047o-Fz; Fri, 15 Jan 2021 06:03:14 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E646A160132; Fri, 15 Jan 2021 03:03:06 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1kKLZdDoHCWL; Fri, 15 Jan 2021 03:03:04 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3114D160138; Fri, 15 Jan 2021 03:03:04 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ev2V-MrVOMXR; Fri, 15 Jan 2021 03:03:04 -0800 (PST) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 00819160132; Fri, 15 Jan 2021 03:03:03 -0800 (PST) Subject: Re: bug#45886: mkdir -m argument does not work correctly, applies incorrect permissions To: Davin McCall References: <4ea6d6a5-dbae-a6f0-e702-1ee1695985da@davmac.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Fri, 15 Jan 2021 03:03:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <4ea6d6a5-dbae-a6f0-e702-1ee1695985da@davmac.org> Content-Type: multipart/mixed; boundary="------------DE8E9032DA0B4892713B7F9E" Content-Language: en-US X-Spam-Score: -2.5 (--) X-Debbugs-Envelope-To: 14371 Cc: 14371@debbugs.gnu.org, 45886-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.5 (---) This is a multi-part message in MIME format. --------------DE8E9032DA0B4892713B7F9E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for the bug report. I reproduced the problem and installed the attached patch to fix it. --------------DE8E9032DA0B4892713B7F9E Content-Type: text/x-patch; charset=UTF-8; name="0001-mkdir-fix-bug-when-m-s-more-generous-than-umask.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-mkdir-fix-bug-when-m-s-more-generous-than-umask.patch" >From b8375c422ffe0e018cbb4cad187d1e909195d263 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 15 Jan 2021 02:57:59 -0800 Subject: [PATCH] mkdir: fix bug when -m's more generous than umask Problem reported by David McCall (Bug#45886). I introduced this problem when fixing Bug#14371. * NEWS: Mention the fix. * src/mkdir.c (struct mkdir_options): New members umask_ancestor, umask_self, replacing umask_value. (make_ancestor): Use them when temporarily adjusting umask. (main): Set them, and set the umask to umask_self instead of leaving it alone. * tests/mkdir/perm.sh (tests): Add test case for bug. --- NEWS | 3 +++ src/mkdir.c | 30 ++++++++++++++++++------------ tests/mkdir/perm.sh | 1 + 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index c2474fee3..a6ba96450 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,9 @@ GNU coreutils NEWS -*- outline -*- ls no longer crashes when printing the SELinux context for unstatable files. [bug introduced in coreutils-6.9.91] + mkdir -m no longer mishandles modes more generous than the umask. + [bug introduced in coreutils-8.22] + nl now handles single character --section-delimiter arguments, by assuming a second ':' character has been specified, as specified by POSIX. [This bug was present in "the beginning".] diff --git a/src/mkdir.c b/src/mkdir.c index eccc9d382..b266cee8c 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -89,8 +89,11 @@ struct mkdir_options made. */ int (*make_ancestor_function) (char const *, char const *, void *); - /* Umask value in effect. */ - mode_t umask_value; + /* Umask value for when making an ancestor. */ + mode_t umask_ancestor; + + /* Umask value for when making the directory itself. */ + mode_t umask_self; /* Mode for directory itself. */ mode_t mode; @@ -130,20 +133,18 @@ make_ancestor (char const *dir, char const *component, void *options) error (0, errno, _("failed to set default creation context for %s"), quoteaf (dir)); - mode_t user_wx = S_IWUSR | S_IXUSR; - bool self_denying_umask = (o->umask_value & user_wx) != 0; - if (self_denying_umask) - umask (o->umask_value & ~user_wx); + if (o->umask_ancestor != o->umask_self) + umask (o->umask_ancestor); int r = mkdir (component, S_IRWXUGO); - if (self_denying_umask) + if (o->umask_ancestor != o->umask_self) { int mkdir_errno = errno; - umask (o->umask_value); + umask (o->umask_self); errno = mkdir_errno; } if (r == 0) { - r = (o->umask_value & S_IRUSR) != 0; + r = (o->umask_ancestor & S_IRUSR) != 0; announce_mkdir (dir, options); } return r; @@ -282,8 +283,7 @@ main (int argc, char **argv) if (options.make_ancestor_function || specified_mode) { mode_t umask_value = umask (0); - umask (umask_value); - options.umask_value = umask_value; + options.umask_ancestor = umask_value & ~(S_IWUSR | S_IXUSR); if (specified_mode) { @@ -293,10 +293,16 @@ main (int argc, char **argv) quote (specified_mode)); options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change, &options.mode_bits); + options.umask_self = umask_value & ~options.mode; free (change); } else - options.mode = S_IRWXUGO; + { + options.mode = S_IRWXUGO; + options.umask_self = umask_value; + } + + umask (options.umask_self); } return savewd_process_files (argc - optind, argv + optind, diff --git a/tests/mkdir/perm.sh b/tests/mkdir/perm.sh index 4d36f19b5..083a47733 100755 --- a/tests/mkdir/perm.sh +++ b/tests/mkdir/perm.sh @@ -35,6 +35,7 @@ tests=' 050 : -m 312 : drwx-w-rwx : d-wx--x-w- : 160 : empty : drwx--xrwx : drw---xrwx : 160 : -m 743 : drwx--xrwx : drwxr---wx : + 022 : -m o-w : drwxr-xr-x : drwxrwxr-x : 027 : -m =+x : drwxr-x--- : d--x--x--- : 027 : -m =+X : drwxr-x--- : d--x--x--- : - : - : last : last : -- 2.27.0 --------------DE8E9032DA0B4892713B7F9E-- From unknown Sun Aug 10 16:51:12 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 12 Feb 2021 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator