LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Understanding permissions needed to mv directory (using Posix ACLs) (https://www.linuxquestions.org/questions/linux-security-4/understanding-permissions-needed-to-mv-directory-using-posix-acls-4175733409/)

swami77 02-01-2024 02:14 AM

Understanding permissions needed to mv directory (using Posix ACLs)
 
I have a folder A inside a folder B, which is in turn in a folder C (all on the same file system). I want to mv A from B to C, but I get a permission denied error.

I can mv A within B (i.e. rename A)

Now I mv A to C as the root user (successfully)

I can now mv/rename A within C

└── [drwxrwx---] C
├── [drwxrwx---] B
│ └── [drwxr-x---] A

getfacl C
# file: C
# owner: root
# group: root
user::rwx
user:myuser:rwx
group::rwx
mask::rwx
other::---

getfacl B
# file: B
# owner: root
# group: root
user::rwx
user:myuser:rwx
group::rwx
mask::rwx
other::---

getfacl A
# file: A
# owner: otheruser
# group: othergroup
user::rwx
user:myuser #effective:r-x
group::rwx #effective:r-x
mask::r-x
other::---

mv A ..
mv: cannot move ‘A’ to ‘C’: Permission denied
This doesn't make sense to me, since I understood moving a directory only requires write permissions on the current parent and the target directory. Since I can rename the dir in both directories, surely I should be able to mv it from one to the other!

Additional notes:

The permission is granted via an ACL named user entry (myuser), that exists on both B and C and which has rwx permissions
These folders are contained within a Samba share - but even if I stop the smb service I still have the same problem, so I don't think that has any impact.
SELinux is in Permissive mode
There is no existing folder in C also named A
If I do sudo chmod g+w A, then I can move A successfully. But why does the permissions on the folder being moved have an impact?
OS is CentOS 7, and the file system is ext4. The file system was not mounted explicitly with acl support (but acls seem to work nonetheless - except for this one issue). tune2fs -l shows "Default mount options: user_xattr acl"

lvm_ 02-01-2024 03:07 AM

Moving A to a different parent directory requires modification of .. entry within A which requires write access to A which you don't have.


All times are GMT -5. The time now is 12:11 PM.