Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
According to "man chmod" on Solaris, "g+s" (aka, the 2000 bit) must be
specified symbolically (that is as "g+s", not as 2000).  And, indeed, my
testing shows this to be the case.  "chmod 2755 /some/dir" sets it to 755.

Questions
1) Why is this?
2) Is it true on any other Unixes?


Report this thread to moderator Post Follow-up to this message
Old Post
Kenny McCormack
10-23-04 01:56 AM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
gazelle@yin.interaccess.com (Kenny McCormack) writes:

> According to "man chmod" on Solaris, "g+s" (aka, the 2000 bit) must be
> specified symbolically (that is as "g+s", not as 2000).  And, indeed, my
> testing shows this to be the case.  "chmod 2755 /some/dir" sets it to 755.
>
> Questions
> 	1) Why is this?

I can't see any valid reason why.


> 	2) Is it true on any other Unixes?

It's not true on linux, nor on NeXTSTEP, OPENSTEP or MacOSX (4.3SBD,  4.4BSD
).

--
__Pascal Bourguignon__                     http://www.informatimago.com/

Voting Democrat or Republican is like choosing a cabin in the Titanic.

Report this thread to moderator Post Follow-up to this message
Old Post
Pascal Bourguignon
10-23-04 01:57 AM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
On Sat, 23 Oct 2004 00:02:14 +0200, Steve Graegert wrote:

> Kenny McCormack wrote: 

> % touch test

The OP is discussing directories, not files.


Report this thread to moderator Post Follow-up to this message
Old Post
Dave Uhring
10-23-04 01:57 AM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
gazelle@yin.interaccess.com (Kenny McCormack) writes:

>According to "man chmod" on Solaris, "g+s" (aka, the 2000 bit) must be
>specified symbolically (that is as "g+s", not as 2000).  And, indeed, my
>testing shows this to be the case.  "chmod 2755 /some/dir" sets it to 755.

Absolute changes do not work for the set-group-ID bit  of  a
*directory*. You must use g+s or g-s.

>Questions
>	1) Why is this?

To make set-gid inheritance work for directories and prevent you
from accidentily removing it.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

Report this thread to moderator Post Follow-up to this message
Old Post
Casper H.S. Dik
10-23-04 01:56 PM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
In <417a13ff$0$36860$e4fe514c@news.xs4all.nl> Casper H.S. Dik <Casper.Dik@Su
n.COM> writes:

>gazelle@yin.interaccess.com (Kenny McCormack) writes:
 

>    Absolute changes do not work for the set-group-ID bit  of  a
>    *directory*. You must use g+s or g-s.
 

>To make set-gid inheritance work for directories and prevent you
>from accidentily removing it.

We ran into this problem with Casper's install_check script.
Here's what I had to do to fix it:

dontfix || {
mkdir -p $dir &&
chown $owner $dir &&
chgrp $group $dir &&
chmod $mode $dir
case $mode in
2???)
chmod g+s $dir
;;
esac
} || error "Can't mkdir $dir"


--
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-

Report this thread to moderator Post Follow-up to this message
Old Post
Gary Mills
10-23-04 08:56 PM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
In article <417a13ff$0$36860$e4fe514c@news.xs4all.nl>,
Casper H.S. Dik  <Casper.Dik@Sun.COM> wrote:
>gazelle@yin.interaccess.com (Kenny McCormack) writes:
> 
>
>    Absolute changes do not work for the set-group-ID bit  of  a
>    *directory*. You must use g+s or g-s.
> 
>
>To make set-gid inheritance work for directories and prevent you
>from accidentily removing it.

Aha.  I see.  So that if you do your normal: chmod 755 .
it won't have any effect on this bit.  And I see now that this property
does in fact inherit down the tree.

Quite natty, in fact.  Wonder why other Unixes didn't follow suit.
(Linux does do the inheritance thing.  But the chmod program doesn't
require g+s/g-s)


Report this thread to moderator Post Follow-up to this message
Old Post
Kenny McCormack
10-23-04 08:56 PM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
In comp.unix.solaris Kenny McCormack <gazelle@yin.interaccess.com> wrote:
> According to "man chmod" on Solaris, "g+s" (aka, the 2000 bit) must be
> specified symbolically (that is as "g+s", not as 2000).  And, indeed, my
> testing shows this to be the case.  "chmod 2755 /some/dir" sets it to 755.
>
> Questions
>        1) Why is this?

To stop you accidently removing it by typing (say) chmod 755.
It's basically separating the feature that g+s sets from the permissions
that chmod xxx sets.

That fact that you also need to add it using g+s is really just a side
effect, rather than a specific feature.

Scott

Report this thread to moderator Post Follow-up to this message
Old Post
Scott Howard
10-24-04 01:55 AM


Re: chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
In article <4179e4c7$0$59445$ed2619ec@ptn-nntp-reader03.plus.net>,
beardy@beardy.net says...
>
> Yup - you have to be pretty determined/certain to hold the shit key down

I still have a "Dammit!" key that came with a bunch or marketing crap one
time years ago, which sits where the "Esc" key used to be, but I've never
seen a "Shit" key.  It's a good idea though.


--
Randy Howard (2reply remove FOOBAR)


Report this thread to moderator Post Follow-up to this message
Old Post
Randy Howard
10-27-04 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:34 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.