NetBSD-Bugs archive

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

Re: kern/56398 (`mkdir -p -m` fails to assign the correct mode with trailing slashes)



The following reply was made to PR kern/56398; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/56398 (`mkdir -p -m` fails to assign the correct mode with trailing slashes)
Date: Mon, 13 Sep 2021 07:40:44 -0000 (UTC)

 martin%NetBSD.org@localhost writes:
 
 >Synopsis: `mkdir -p -m` fails to assign the correct mode with trailing slashes
 
 >Responsible-Changed-From-To: bin-bug-people->kern-bug-people
 >Responsible-Changed-By: martin%NetBSD.org@localhost
 >Responsible-Changed-When: Mon, 13 Sep 2021 05:54:31 +0000
 >Responsible-Changed-Why:
 >This is a kernel bug
 
 I don't think so.
 
 mkdir -p creates upper directories with 'dir_mode' and the last
 element with 'mode'.
 
 When parsing a path like a/b/c you get:
 
 mkdir a        with 'dir_mode'
 mkdir a/b      with 'dir_mode'
 mkdir a/b/c    <- last element with 'mode'
 
 The mode of each element is set by the mkdir() call (unless, for
 the last element stick,setuid or setgid bits are included).
 
 When parsing a path like a/b/c/ you get:
 
 mkdir a        with 'dir_mode'
 mkdir a/b      with 'dir_mode'
 mkdir a/b/c    with 'dir_mode'
 mkdir a/b/c/   <- last element with 'mode'
 
 The last path already exists, mkdir checks if the path exists
 and is a directory and ignores it then.
 
 There is a 'notdef' part that strips trailing slashes which would
 avoid this issue. Not sure why it is commented out, probably some
 unwanted side effect. It's probably better to improve the mkpath
 parser.
 


Home | Main Index | Thread Index | Old Index