Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have directory /home/git/repositories with rights 770 and uid=git,gid=git

user1@gitserver:~$ ls -la /home/git/ | grep repo
drwxrws--- 42 git  git  4096 Jun 30 17:02 repositories

I have user 'www-data', which added into 'git' group

user1@gitserver:~$ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data),1001(git)
user1@gitserver:~$ id -G www-data
33 1001

From 'www-data' user running python-script which calling os.listdir('/home/git/repositories') and failing with message OSError: [Errno 13] Permission denied: '/home/git/repositories/'

def functn()
    repo_dir = '/home/git/repositories'
    logg('CURRENT USER: getresuid && getresgid')
    logg(os.getresuid())
    logg(os.getresgid())
    logg('CURRENT USER: getgroups')
    logg(os.getgroups())
    logg(os.listdir(repo_dir))  <-- here is fault

Here is output:

'CURRENT USER: getresuid && getresgid'
(33, 33, 33)
(33, 33, 33)

'CURRENT USER: getgroups'
[33]                            <-- 'git' group not showing =(

User 'www-data' added to git group. Why he cant list that directory?!

upd here is namei -mo /home/git/repositories:

user1@gitserver:~$ namei -mo /home/git/repositories
f: /home/git/repositories
 drwxr-xr-x root root /
 drwxr-xr-x root root home
 drwxr-xr-x git  git  git
 drwxrws--- git  git  repositories
share|improve this question

closed as off-topic by Anthon, Michael Homer, cuonglm, Jander, slm Jul 16 at 21:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Anthon, Michael Homer, cuonglm, Jander, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

    
The permissions of /home/git also matter. Add the output of namei -mo /home/git/repositories to your question. Also, you may need to restart the web server process for new group memberships to take effect. –  muru Jul 16 at 3:12
    
@muru user1@gitserver:~$ id -G www-data say: 33 1001 but user1@gitserver:~$ id -g www-data say: 33 So, it mean that effective groups not contain 'git'. Is restart web-server can help me? Or i should reboot computer? –  user28828 Jul 16 at 3:29
    
There can only be one effective group ID, so that's correct. However, if the process started before you added www-data to the new group, it think won't be affected. If you can restart just the web server, try it. –  muru Jul 16 at 3:35

1 Answer 1

up vote 2 down vote accepted

This comment was right; the web server was started before I added www-data to the git group. The web server was restarted when I rebooted for other reasons and the problem went away.

share|improve this answer

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