Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having issues setting permissions for a specific user.

I have a directory /srv/git/ in which I'm trying to create a sub-directory test containing one file testfile (owned by www:www-data). testfile should only readable and writable by user and group and nobody else.

[root@bartplatak ~]# cd /srv/git
[root@bartplatak git]# mkdir test && touch test/testfile
[root@bartplatak git]# chown -R www:www-data test
[root@bartplatak git]# chmod o= test/testfile
[root@bartplatak git]# chmod -R ug=rw test
[root@bartplatak git]# sync
[root@bartplatak git]# su www

However for some unknown reason, I cannot cd into the directory (and listing it shows very incomplete information)

bash-4.1$ pwd
/srv/git

bash-4.1$ ls -la test
ls: cannot access test/.: Permission denied
ls: cannot access test/testfile: Permission denied
ls: cannot access test/..: Permission denied
total 0
d????????? ? ? ? ?            ? .
d????????? ? ? ? ?            ? ..
-????????? ? ? ? ?            ? testfile

bash-4.1$ cd test
bash: cd: test: Permission denied

What strikes me as odd is the fact that .. shows incomplete information despite being accessible (drwxr-xr-x 6 root root 4096 Mar 1 19:02 .).

EDIT: The machine I'm running this on is a VPS with CentOS release 6.5 (Final).

Linux bartplatak.com 2.6.32-042stab078.28 #1 SMP Mon Jul 8 10:17:22 MSK 2013 x86_64 x86_64 x86_64 GNU/Linux

SELinux is (as far as I can see) disabled

[root@bartplatak ~]# sestatus 
SELinux status:                 disabled

Permissions on the directory (and parents) are set as

drwxr-xr-x 6 root root     4096 Mar  1 19:02 /
drwxr-xr-x 5 root root     4096 Mar  1 14:16 /srv
drwxr-xr-x 6 root root     4096 Mar  1 19:02 /srv/git
drw-rw-r-x 2 www  www-data 4096 Mar  1 19:02 /srv/git/test
-rw-rw---- 1 www  www-data    0 Mar  1 19:02 /srv/git/test/testfile

[root@bartplatak git]# stat /srv/git/test
  File: `/srv/git/test'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 5ae0b691h/1524676241d   Inode: 404068      Links: 2
Access: (0665/drw-rw-r-x)  Uid: (  497/     www)   Gid: (  496/www-data)


[root@bartplatak git]# stat /srv/git/test/testfile
  File: `/srv/git/test/testfile'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 5ae0b691h/1524676241d   Inode: 404071      Links: 1
Access: (0660/-rw-rw----)  Uid: (  497/     www)   Gid: (  496/www-data)

After su www, id shows uid=497(www) gid=497(www) groups=497(www),496(www-data)

share|improve this question

1 Answer 1

up vote 7 down vote accepted

The obvious problem is that /srv/git/test does not have the executable x bit set for owner and group. Thus it is not possible to traverse the directory.

Resolve the issue with:

chmod ug+x /srv/git/test
share|improve this answer
    
Thanks a lot! :) Now that you mention it, I do remember reading this was a thing but it had completely escaped my mind. –  Bart Platak Mar 2 at 1:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.