On Wed, Dec 01, 2010 at 10:09:30AM -0500, Wietse Venema wrote:

> Apparently, FreeBSD copies the GID of a new directory from its
> parent, even when the parent does not have sticky/setwhatever
> bits set.

It seems this applies not just to sub-directories, but also to new
files:

  http://www.manpages.info/freebsd/open.2.html

    When a new file is created it is given the group of the directory which
    contains it.

  http://www.manpages.info/freebsd/mkdir.2.html

    The directory's owner ID is set to the process's effective user ID.  The
    directory's group ID is set to that of the parent directory in which it
    is created.

And in http://www.manpages.info/freebsd/mount.2.html, we see:

    MNT_SUIDDIR      Directories with the SUID bit set chown new files to
                     their own owner.

without any corresponding mechanism to adjust group ownership inheritance.

The OpenGroup POSIX spec says:

http://www.opengroup.org/onlinepubs/009695399/functions/mkdir.html

    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.

http://www.opengroup.org/onlinepubs/009695399/functions/open.html

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

-- 
        Viktor.

Reply via email to