From: plarkin@iphase.com (Patrick Larkin)
Subject: Re: Sticky-Bits and Group IDs in DIRECTORIES?
Originator: plarkin@coolcat
Organization: Interphase Corporation - Dallas Texas
Date: Wed, 14 Oct 1992 20:41:58 GMT


Well, After posting the following 2 questions in 'comp.unix.admin' 
(the system in question was a Sequent) I got a fair amount of mail... 
(1) What is the purpose/benefit of setting a sticky-bit on a DIRECTORY??
(2) Why do all files created take on the group id of its parent directory
    and ignore the group id of the user?
While none of the mail answered the second question, thanks go out to
the following people for pointing me in the right direction and/or answering
question number (1): Theodore S. Kapela <kapela@poly.edu>
                     Jim Davis <jdavis@noao.edu>
                     Ross Alexander <rwa@cs.athabascau.ca>
                     Barry Margolin <barmar@think.com>
                     Vidya Alankar <vidya@akshay.csd.sgi.com>
Forgive me if I've left anyone out......  Here's the jist of what I've learned:
(1)  The sticky bit on executables, we know, keeps the "program" in memory,
reducing (among other things) start-up time.  But on a Directory, it keeps
all files created (usually in a universally writable directory) from being 
deletable by anyone other than the owner.  (Some may not be aware that Write
permission to the DIRECTORY will allow removal of a file regardless of the
FILE's permissions.) This is unrelated to the fact that when we created
a file, it took on the group id of the directory, not the owner.
(2) If this were a Sun (or probably any other BSD system), there is an option
in the 'fstab' file called "grpid" which tells the system to give files 
created in any of this filesystem's subdirectories the group id of the
directory, not the group id of the owner.  On the Sequent however, there 
is no mention of such an option in any of the related man-pages. 
In thier implementation, this is the usual behavior, according to the
man-page for 'creat' (thanks Barry for suggesting I look at creat). 
Here's a couple of excerpts (* in front of lines with operative phrases):
========================================================================
     CREAT(2)                    DYNIX/ptx                    CREAT(2)
          creat - create a new file or rewrite an existing one
(-------cut------)
          If the file exists, the length is truncated to 0 and the
          mode and owner are unchanged.  Otherwise, the file's owner
*         ID is set to the effective user ID of the process, the group
*         ID of the file is set to the group ID of the directory in
          which this file is being created and the low-order 12 bits
          of the file mode are set to the value of mode modified as
          follows:
(-------cut------)
     BCS DIFFERENCES
*         Normally, the group ID of the file is set to the group ID of
*         the directory in which the file is being created.  However,
          for BCS processes, the group ID of the file being created is
          set to the effective group ID of the calling process.

Now, If I only new what BCS was.......





-- 
#  Patrick H. Larkin, Jr.    _| ~-       Interphase Corp.         #
#   System Administrator     \,  _}       13800 Senlac            #
#    plarkin@iphase.com        \(         Dallas, TX 75234-8823   #
#  (These opinions mine and do not reflect those of Interphase)   #
Newsgroups: comp.unix.admin,alt.folklore.urban