[OmniOS-discuss] /usr/bin/chmod and the set-gid-bit

Hugh McIntyre lists at mcintyreweb.com
Wed Aug 7 23:30:09 UTC 2013


On 8/7/13 10:14 AM, Tim Rice wrote:
> On Wed, 7 Aug 2013, Tobias Oetiker wrote:
>
>> Hi,
>>
>> /usr/bin/chmod seems to ignore the set-group-id bit when called
>> with an octal permission string. try this on a zfs filesystem
>
> That behavior seems to be intentional for directories and is documented
> in the man page.
> It has been that way a long time. Probably since the SVR4.0 days.

I always this assumed this was because of the typical usage on 
directories of setting the SGID bit at the top level of a directory and 
expecting the bit to then be set (and stay set) on all subsequently 
created directories all the way down.  Including in the presence of 
older software that just said "chmod 755".

FWIW, Linux (e.g. Ubuntu 12.04) also does not allow you to clear the bit 
with octal mode, although they do allow you to set the SGID bit this 
way.  Arguably this is a better solution, but whether people will want 
to change the Illumos chmod at this point is debatable.  From Linux:

        chmod preserves a directory's set-user-ID and set-group-ID bits
        unless you explicitly specify otherwise.  You can set or clear
        the bits with symbolic modes like u+s and g-s, and you can set
        (but not clear) the bits with a numeric mode.

Hugh.



More information about the OmniOS-discuss mailing list