[uw.unix] groups, directories, and file creation

dgcasperson@violet.waterloo.edu (david Casperson) (09/22/89)

Could someone explain to me how UNIX chooses the group of a newly
created file?  I am also curious what the setgid and setuid bits mean
on a directory.  I have tried to find the above information in the man
pages, but perhaps i have been looking in the wrong place.

                          --david

jmsellens@watdragon.waterloo.edu (John M. Sellens) (09/22/89)

In article <16580@watdragon.waterloo.edu> dgcasperson@violet.waterloo.edu (david Casperson) writes:
>Could someone explain to me how UNIX chooses the group of a newly
>created file?  I am also curious what the setgid and setuid bits mean
>on a directory.  I have tried to find the above information in the man
>pages, but perhaps i have been looking in the wrong place.

You're posting from violet, but that's probably not how the question came up.

On BSD machines:
  When a file is created, it is created with the same group as the directory
  that contains it.  I don't think the setuid and setgid bits on a directory
  mean anything (though I may be wrong).
On Sys V (boo, hiss) machines:
  When a file is created, it is created with the group of the process that
  creates it - you can only be a member of one group at a time.  I don't
  know anything about the bits.
On SunOS (barf, retch) machines:
  A file gets a group according to the SysV rules unless:
  - the setgid bit is set on the containing directory, in which case it
    follows the BSD rules.
  - or unless the file system that it is on was mounted with the "grpid"
    option, in which case it follows the BSD rules, regardless of the mode
    of the directory.  The Sun installation notes say to use the grpid
    option.
  I don't think the setuid bit on a directory has a special meaning, though
  knowing Sun, it's probably something really weird.