I have asked this on askubuntu but didn't get a single response in days, so I will try it here.
I have directory structure like this:
/path/dir1 - all users in group1 must have rwx permissions, including subdirs and newly created dirs
/path/dir1/dir2 - also users in group2 must have rwx permissions
So what I tried is that I used ACL.
getfacl /path/dir1
# file: /path/dir1
# owner: root
# group: nogroup
user::rwx
group::---
group:group1:rwx
mask::rwx
other::---
default:user::rwx
default:group::---
default:group:group1:rwx
default:mask::rwx
default:other::---
getfacl /path/dir1/dir2
# file: /path/dir1/dir2
# owner: root
# group: nogroup
user::rwx
group::---
group:group1:rwx
group:group2:rwx
mask::rwx
other::---
default:user::rwx
default:group::---
default:group:group1:rwx
default:group:group2:rwx
default:mask::rwx
default:other::---
That shows that I have granted rwx to group1 in /path/dir1 and rwx to group1 and group2 in /path/dir1/dir2.
Now it gets interesting. Let's assume, that user2 is member of group2.
If I issue commands as user2:
cd /path/dir1/dir2
mkdir foo
Then folder is succesfully created.
However, if I do this:
mkdir /path/dir1/dir2/foo
I get permission denied error.
I have tried extensively to resolve the problem. What I have found is that ACL is to blame. If I add permissions to group2 in /path/dir1 it starts to work. Also if I completely remove /path/dir1 ACL it starts to work.
Obviously I am missing something VERY basic. I don't have much experience with linux, but this is a no-brainer on Windows. I have spent way too many hours to resolve this basic requirement.
If you need more information, I will try to update the question, so feel free to ask!