Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Red Hat Linux (http://www.linux-archive.org/red-hat-linux/)
-   -   Răspuns: chmod behaviour (http://www.linux-archive.org/red-hat-linux/594494-rae-spuns-chmod-behaviour.html)

RuceLee 11-04-2011 06:27 AM

Răspuns: chmod behaviour
 
Sure,

Here's the input:

[root@core2duo ~]# mkdir my_directory
[root@core2duo ~]# ll -d my_directory/
drwxr-xr-x 2 root root 4096 Nov 4 08:16 my_directory/

[root@core2duo ~]# chmod g+s my_directory/
[root@core2duo ~]# ll -d my_directory/
drwxr-sr-x 2 root root 4096 Nov 4 08:16 my_directory/

[root@core2duo ~]# chmod 0755 my_directory/ #set perm in octal mode
[root@core2duo ~]# ll -d my_directory/ #no effect on SGIT bit
drwxr-sr-x 2 root root 4096 Nov 4 08:16 my_directory/

[root@core2duo ~]# chmod g-s my_directory/ #set perm in symbolic mode
[root@core2duo ~]# ll -d my_directory/ #get back to the execution bit
drwxr-xr-x 2 root root 4096 Nov 4 08:16 my_directory/

I'm confused cuz up until now I assumed the octal and symbolic mode are interchangeable and here is an example where I rather have to use a single mode to get to expected result.


________________________________
De la: Cameron Simpson <cs@zip.com.au>
Către: General Red Hat Linux discussion list <redhat-list@redhat.com>
Trimis: Vineri, 4 Noiembrie 2011 1:41:37
Subiect: Re: chmod behaviour

On 03Nov2011 10:22, RuceLee <bors_ruslan@yahoo.com> wrote:
| Recently I was playing with directory permissions on a ext4 filesystem and I have stumbled
| at a situation when setting up setting up directory SGID behaves not as expected, at least for me.
|
| For example:
|
| chmod g+s my_directory works the same as chmod 2755 my_directory
|
| On the other hand:
|
| chmod g-s my_directory doesn't work the same as chmod 0755 my_directory
|
| the latest doing absolutely nothing *to remove the intended SGID bit.
|
| The latest package I have is coreutils-8.4-13.el6.x86_64

You should probably post a transcript with:

* ls -ld my_directory

before and after each chmod command just so people can see exactly what
the permission state is.

Cheers,
--
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

All my life I have searched for a car that feels a certain way, powerful
like a gorilla, yet soft and yielding like a nerf ball. - Homer Simpson

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

Jonathan S Billings 11-04-2011 11:29 AM

Răspuns: chmod behaviour
 
On 11/04/2011 03:27 AM, RuceLee wrote:

[root@core2duo ~]# chmod 0755 my_directory/ #set perm in octal mode
[root@core2duo ~]# ll -d my_directory/ #no effect on SGIT bit
drwxr-sr-x 2 root root 4096 Nov 4 08:16 my_directory/

[root@core2duo ~]# chmod g-s my_directory/ #set perm in symbolic mode
[root@core2duo ~]# ll -d my_directory/ #get back to the execution bit
drwxr-xr-x 2 root root 4096 Nov 4 08:16 my_directory/

I'm confused cuz up until now I assumed the octal and symbolic mode
are interchangeable and here is an example where I rather have to use a
single mode to get to expected result.


The documentation from coreutils:
https://www.gnu.org/s/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html#Directory-Setuid-and-Setgid

Basically, you can't use the numeric modes to clear a directory's
set-user-id and set-group-id bits. You have to use the symbolic mode to
clear them.


The RHEL6 man page for 'chmod' actually mentions this in the "SETUID AND
SETGID BITS" section:


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.


--
Jonathan Billings <jsbillin@umich.edu>
College of Engineering - CAEN - Unix and Linux Support

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list


All times are GMT. The time now is 07:42 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.