Permissions assignment:
Task:
1. Create a folder shared which contains multiple subfolders who are created based on each user who logins to the server.
2. Each folder should only be accessible to that one user, and that one user can not change permissions on the parent folder(thus giving access to others.
In this case my challenge was to create the permissions part, so that is what I will elaborate here.
I used the tool setfacl which gives the option of restricting a user access to files/folders, even though they are the owners of such folders.
To solve the problem I created a test scenario on a Linux Mint 19.1 machine and here is what I came up with:
First I created two user accounts, lets call them foo and baruseradd foo
useradd bar
I then proceeded with creating the test folders for the two users. As the root user I did:mkdir -p /test/foo /test/bar
I then made sure that both folders are owned by the root user and in the root group and made sure that only those have access.chmod 700 /test/foo /test/bar
Now that both folders are created and are owned by root, I proceed with the ACL permissions.setfacl -m u:foo:rwx /test/foo
setfacl -m u:bar:rwx /test/bar
Now users foo and bar have their own little folder which only they can access, and they can’t change the permissions on the parent folder /test/foo or /test/bar.
Cheers.
Recent Comments