bug-hurd
[Top][All Lists]
Advanced

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

mkdir() and group id


From: Marcus Brinkmann
Subject: mkdir() and group id
Date: Fri, 26 Apr 2002 02:00:44 +0200
User-agent: Mutt/1.3.28i

Hi,

I have found a part of the gid problem.  In quite some cases, the gid in the
packages was not random but the id of my user marcus.  This is because the
packages assume the Linux behaviour of mkdir() and open(..., O_CREAT):

ulysses:/tmp# mkdir foo
ulysses:/tmp# chgrp marcus foo
ulysses:/tmp# ls -l
insgesamt 4
drwxr-xr-x    2 root     marcus       4096 26. Apr 01:44 foo/
ulysses:/tmp# cd foo
ulysses:/tmp/foo# mkdir bar
ulysses:/tmp/foo# touch baz
ulysses:/tmp/foo# ls -l
insgesamt 4
drwxr-xr-x    2 root     root         4096 26. Apr 01:44 bar/
-rw-r--r--    1 root     root            0 26. Apr 01:44 baz
ulysses:/tmp/foo# ls -l ..
insgesamt 4
drwxr-xr-x    3 root     marcus       4096 26. Apr 01:44 foo/

While they will fail on the Hurd behaviour:

ulysses:/tmp# mkdir foo
ulysses:/tmp# chgrp marcus foo
ulysses:/tmp# ls -l
insgesamt 4
drwxr-xr-x    2 root     marcus       4096 26. Apr 01:44 foo/
ulysses:/tmp# cd foo
ulysses:/tmp/foo# mkdir bar
ulysses:/tmp/foo# touch baz
ulysses:/tmp/foo# ls -l
insgesamt 4
drwxr-xr-x    2 root     marcus       4096 26. Apr 01:44 bar/
-rw-r--r--    1 root     marcus          0 26. Apr 01:44 baz
ulysses:/tmp/foo# ls -l ..
insgesamt 4
drwxr-xr-x    3 root     marcus       4096 26. Apr 01:44 foo/

The POSIX standard says (in mkdir and O_CREAT):

 The directory's user ID shall be set to the process' effective user ID. The
 directory's group ID shall be set to the group ID of the parent directory
 or to the effective group ID of the process.
 Implementations shall provide a way to initialize the directory's group ID
 to the group ID of the parent directory. Implementations may, but need not,
 provide an implementation-defined way to initialize the directory's group
 ID to the effective group ID of the calling process.

So, both behaviours are correct according to the standard, and this is
clearly a bug in the software that it assumes that the group ID of a node
created by a root owned process is root.  The packages which make this
assumption need to be fixed to at least create the top level directory in
which they install the final files with a proper group ID.

The requirement in the second paragraph seems just to be the sgid flag.
The optional feature is not provided by us, or is it?

Although our behaviour is standard conform, I want to verify with you that
it is really what we want.  One remark is that defaulting to giving it the
group id of the parent directory makes the sgid flag a bit pointless.  So it
seems to be more featureful to default to giving the gid the gid of the
process.  This also will be in line with the popular Linux kernel, so is les
surprising for many users coming from there, and relieves us from fixing the
broken package build scripts (I am not sure how many there are.  Potentially
many, but as long as you build as root in root owned directories we won't
easily notice most of them).  I guess we are imitating some BSD behaviour here?
What do modern BSDs do?

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]