Home > Archive > Unix Programming > October 2004 > chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
chmod: Why must "g+s" be specified symbolically (at least in Solaris) ?
|
|
| Kenny McCormack 2004-10-22, 8:56 pm |
| 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?
| |
| Pascal Bourguignon 2004-10-22, 8:57 pm |
| 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.
| |
| Dave Uhring 2004-10-22, 8:57 pm |
| On Sat, 23 Oct 2004 00:02:14 +0200, Steve Graegert wrote:
> Kenny McCormack wrote:
[color=darkred]
> % touch test
The OP is discussing directories, not files.
| |
| Casper H.S. Dik 2004-10-23, 8:56 am |
| 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.
| |
| Gary Mills 2004-10-23, 3:56 pm |
| In <417a13ff$0$36860$e4fe514c@news.xs4all.nl> Casper H.S. Dik <Casper.Dik@Sun.COM> writes:
>gazelle@yin.interaccess.com (Kenny McCormack) writes:
[color=darkred]
> Absolute changes do not work for the set-group-ID bit of a
> *directory*. You must use g+s or g-s.
[color=darkred]
>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-
| |
| Kenny McCormack 2004-10-23, 3:56 pm |
| 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)
| |
| Scott Howard 2004-10-23, 8:55 pm |
| 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
| |
| Randy Howard 2004-10-27, 3:57 am |
| 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)
|
|
|
|
|