[SOLVED] What's wrong with uppercase X on permissions?

General support questions
Post Reply
toty_Centos
Posts: 27
Joined: 2017/04/01 00:45:49

[SOLVED] What's wrong with uppercase X on permissions?

Post by toty_Centos » 2017/04/21 20:14:46

Hi again!!
Sorry for my so many questions :S, so as root created this simple script which once executed shows a "Hello World" message. The thing is I want no one except root has executable permission over that script but I want OTHERS can enter the directory which holds the script itself, so:

Code: Select all

[root@Centos7]-[test]$ chmod 700 test1
[root@Centos7]-[test]$ cd ..
[root@Centos7]-[data]$ chmod 700 test/
[root@Centos7]-[test]$ ls -l
drwx------. 2 root root 19 Apr 21 15:22 test
[root@Centos7]-[test]$ chmod -R o+rX test/
[root@Centos7]-[test]$ ls -l
drwx---r-x. 2 root root 19 Apr 21 15:22 test
[root@Centos7]-[test]$ su lisa
[lisa@Centos7]-[data]$ cd test/
[lisa@Centos7]-[test]$ ls -l
-rwx---r-x. 2 root root 32 Apr 21 15:22 test1
[lisa@Centos7]-[test]$ ./test1
Hello World!!
[lisa@Centos7]-[test]$
so? Why the -R switch gives test1 execution permission when I clearly stated an uppercase X? Shouldn't apply directories only?

Once again, thank you!!!

edit: I forgot to mention that I get the same results with setfacl -R -m o:rX test/
User finally can execute the script as well!
Last edited by toty_Centos on 2017/04/21 23:59:20, edited 2 times in total.

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: What's wrong with uppercase X on permissions?

Post by avij » 2017/04/21 22:54:09

Careful reading of man chmod tells us this of X:
execute/search only if the file is a directory or already has execute permission for some user (X)
(emphasis mine)

If the file was executable by root and you applied X, it will make the file executable by other users as well.

toty_Centos
Posts: 27
Joined: 2017/04/01 00:45:49

Re: What's wrong with uppercase X on permissions?

Post by toty_Centos » 2017/04/21 23:57:34

avij wrote:Careful reading of man chmod tells us this of X:
execute/search only if the file is a directory or already has execute permission for some user (X)
(emphasis mine)

If the file was executable by root and you applied X, it will make the file executable by other users as well.
Thank you very much avij!!!!! I totally misinterpreted man page for chmod!!!!! I run some tests and finally got it ;)

Permission to close guys!!!

Post Reply