Subject: Group IDs of directories (was Re: Sticky bit?)
To: Benjamin Lorenz <benni@ps.uni-sb.de>
From: Todd Vierling <tv@pobox.com>
List: netbsd-users
Date: 09/10/1997 08:49:54
On Tue, 9 Sep 1997, Benjamin Lorenz wrote:

: Another strange thing:
: 
: drwxrwxrwt   3 root   wheel      1024 Sep  9 23:25 /tmp
: 
: When I copy a file to /tmp, it is owned by group wheel, even if I am not
: in that group! This is funny because I can't move such a file back to
: my home directory without an error of `mv' about not being able to set
: the group... ?!

To answer your question, the sticky bit keeps you from messing with the file
because you aren't both owner and group-user of the file.  That's how the
sticky bit protects the directory from malicious users.

I've changed the subject line to re-question this:

This is a weirdness that's partly 4.4BSD's fault.  New files in directories
are created with the group-id of that directory, which is IMHO a bad idea.
It should always start out with the user and primary group ID of the
creator.  Or at least, the primary group ID of the creator if the creator is
not in the group ID of the directory. 

Now, I've seen systems where directories utilised the set-gid bit to "cause" 
the 4.4BSD behaviour of setting the group-id.  Can we implement something
like this to keep it from being default?  It seems to me that changing the
group ID, if the file's creator is not in that group, is a security problem
(Think if the user's umask is 002), though that may be the intent(?).

=====
== Todd Vierling (Personal tv@pobox.com; Business tv@lucent.com)
== I know you like the Internet, Bobby.  Now go eat your Frosted Flakes.