21
john@ubuntu01:~$ sudo ls -l /var/opt/gitlab/git-data/repositories/GL/www.git
total 25068
drwxr-xr-x  2 git  git      4096 aug 14 19:58 branches
-rw-r--r--  1 git  git        66 aug 14 19:58 config
drwxrwxrwx  2 root root     4096 aug 15 14:56 custom_hooks
-rw-r--r--  1 git  git        73 aug 14 19:58 description
-rw-r--r--  1 git  git        23 aug 14 19:58 HEAD
lrwxrwxrwx  1 git  git        47 aug 14 19:58 hooks -> /opt/gitlab/embedded/service/gitlab-shell/hooks
drwxr-xr-x  2 git  git      4096 aug 14 19:58 hooks.old.1471193907
-rw-r--r--  1 git  git      1329 aug 15 14:48 index
drwxr-xr-x  2 git  git      4096 aug 15 13:58 info
drwxr-xr-x 71 git  git      4096 aug 15 14:55 objects
-rw-r--r--  1 git  git        98 aug 15 13:58 packed-refs
-rw-r--r--  1 git  git  25618530 aug 15 14:03 post-receive.log
drwxr-xr-x  5 git  git      4096 aug 14 20:31 refs
john@ubuntu01:~$ ls -l /var/opt/gitlab/git-data/repositories/GL/www.git
ls: cannot access '/var/opt/gitlab/git-data/repositories/GL/www.git': Permission denied

Here are ACLs

john@ubuntu01:~$ sudo lsattr /var/opt/gitlab/git-data/repositories/GL/www.git/custom_hooks
-------------e-- /var/opt/gitlab/git-data/repositories/GL/www.git/custom_hooks/post-receive

I have never seen this before. No permission to LS even with 777? I need to share this folder for more convenient development. How can I solve it? Thank you.

EDITED: (here are your requests)

john@ubuntu01:~$ sudo ls -ld /var/opt/gitlab/git-data/repositories/GL/www.git
drwxrwxrwx 8 git git 4096 aug 15 14:48 /var/opt/gitlab/git-data/repositories/GL/www.git
john@ubuntu01:~$ sudo ls -ld /var/opt/gitlab/git-data/repositories/GL/www.git/custom_hooks
drwxrwxrwx 2 root root 4096 aug 15 14:56 /var/opt/gitlab/git-data/repositories/GL/www.git/custom_hooks

EDITED MORE

sudo ls -ld /var/opt/gitlab/git-‌​data/repositories/GL/‌​www.git
ls: cannot access '/var/opt/gitlab/git-‌​data/repositories/GL/‌​www.git': No such file or directory

hmmm... what is this?

10
  • 1
    the permissions of the directory you are ls ing are not shown? – Zanna Aug 15 '16 at 12:32
  • is custom_hooks and have drwxrwxrwx 2 root root, see above – user1797147 Aug 15 '16 at 12:34
  • 1
    ls: cannot access '/var/opt/gitlab/git-data/repositories/GL/www.git': Permission denied so show us what happens when you ls -ld /var/opt/gitlab/git-data/repositories/GL/www.git – Zanna Aug 15 '16 at 12:38
  • 1
    could you please do what I asked? if you don't have execute permission on the parent directory then 777 on this one will not help you – Zanna Aug 15 '16 at 12:43
  • 2
    Apparently your problem is higher up the tree then. Keep going up a level and examining the permissions, and you will find that one of them has no x permission for o, for example drwxr-x--- – Zanna Aug 15 '16 at 12:57
28

This happens because there is a directory higher in the tree where you do not have execute permission. If a parent directory has no execute permission for some user, then that user cannot stat any subdirectories regardless of the permissions on those subdirectories.

Example:

$ ls -l cake
drwxr-xr-x 2 zanna zanna 4096 Jul 12 11:43 brownies
$ chmod 666 cake
$ ls -l cake/brownies
ls: cannot access 'cake/brownies': Permission Denied

Even though I am the owner of the directory 'brownies' and all users have permission to read and enter it, I can't access it if its parent directory has no execute permission.

It's better to use groups to manage permissions than give to give directories 777 permission. Are you sure you need to do that?

How to fix the problem in a more secure way:

Let's assume on /var/opt/gitlab directory you have something like this:

drwxr-x--- 5 git git 4096 aug 14 17:30 gitlab

Add yourself and all the other users who need permission to the git group, for example:

sudo usermod -a -G john git

Users have to log out and back in for this to take effect. Even if write permission is needed on a subdirectory, you don't need to add it on a parent directory, by the way, so you don't have to use chmod at all. You might want to change your subdirectory permissions to prevent anyone from being able to write to it:

chmod 775 /var/opt/gitlab/git‌​-data/repositories/GL‌​/www.git/custom_hooks

or

chmod o-w /var/opt/gitlab/git‌​-data/repositories/GL‌​/www.git/custom_hooks
1
  • 1
    Thanks again, no, I was just testing some script. Feel much more comfortable to edit with N++ on windows than rudimentary Gedit. Also rudimentary Nautilus which isn't able to CUT something then PASTE with making a new folder in the same time... or right click -> New Folder. – user1797147 Aug 15 '16 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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