What's the purpose of set-group ID bit for directories?

What's the purpose of set-group ID bit for directories?

Post by Carl Muell » Wed, 16 Nov 1994 09:34:30



Well, I think I may have answered my question already, but
I'll go ahead and post it just to verify myself.

I've been searching various man pages to find out what's the
point of the set-group ID bit on directories.

For instance, consider this directory:

drwxr-sr-x  3 root          512 Nov  8 19:29 etc/
      ^
I've been trying to figure out what happens with the 's' bit
set and what doesn't happen.  I think I finally found out from
an IBM man page (chmod(2)):

  S_ISGID       Enables the setgid attribute for an executable file.  A
  process executing this  program acquires the access rights of the
  group of the file. Also, enables the group-inheritance attribute
  for  a directory.  Files created in this directory have  a  group
  equal to the group of the directory.

From this, I gather that directories with this bit set change
the group of any files created in them to be of the same group
as the directory itself, rather than of the user making the files.

Why was this information so hard to find?  That is, why wasn't it in
the obvious place (chmod(1) or chmod(2)) in the man pages for DEC, Sun,
or HP systems?


 
 
 

What's the purpose of set-group ID bit for directories?

Post by Alan Robs » Wed, 16 Nov 1994 17:54:30


: Well, I think I may have answered my question already, but
: I'll go ahead and post it just to verify myself.

[snip]

: From this, I gather that directories with this bit set change
: the group of any files created in them to be of the same group
: as the directory itself, rather than of the user making the files.

Exactly right. Well done.

: Why was this information so hard to find?  That is, why wasn't it in
: the obvious place (chmod(1) or chmod(2)) in the man pages for DEC, Sun,
: or HP systems?

Because this is unix! :-)

--
Best wishes,

Alan
----
                                           _

The Internet Company of New Zealand     /  /\  

 
 
 

What's the purpose of set-group ID bit for directories?

Post by Carl Muell » Sun, 20 Nov 1994 08:40:14




>: From this, I gather that directories with this bit set change
>: the group of any files created in them to be of the same group
>: as the directory itself, rather than of the user making the files.

>Exactly right. Well done.

Actually, upon further investigation, I found out that the
treatment of this mode bit depends upon the filesystem you
are using.  On the system I tried (HPUX), the above description
only seems to apply to local file systems.  With NFS file
systems, the directories seem to behave as if the g+s bit
is always set.  On AFS file systems, it was not possible to
set this bit on directories (odd!).