Setfacl using LDAP Groups

Setfacl using LDAP Groups

Setfacl using LDAP Groups

This is the classic scenario of where you have a NFS/Samba share, and you want to make sure that when new Files/Folders are created that they receive the proper permissions for the group, so others in the group have access as well.

login to your file server, and switch to the root user

chgrp HR /home/facl and chmod -R 770 /home/facl on the nas2 file server

create a new test directory to test ACL’s

Same screenshot: chgrp HR and chmod -R 770 on the /home/facl test directory

now set permissions as you normally would

chgrp HR /home/facl and chmod -R 770 /home/facl setting normal permissions

in this case we are setting the group to be HR, and giving ONLY root, and members of the HR group access.

BEFORE we do anything, take a look at the default FACL

getfacl /home/facl before the ACL: owner root, group HR, other no access

so as we can see, only root/HR has access, now let’s apply the FACL

setfacl -m d:g:HR:rwx /home/facl applying a default ACL for the HR group

in this case we are using the -m option to create file mask, d for default, g is the group, in this case it’s the HR group we want to be applied to all new files, and then the permissions is rwx for read/write/execute, and the folder you are applying it to.

now that we have applied the FACL, let’s verify it’s set correctly

getfacl /home/facl showing default:group:HR:rwx entries after setfacl

looks good, now let’s create a file to verify it actually works.

ls -l showing folder1 and folder2 with the + ACL marker, group HR

bam! works properly, now any new file/folder created in this folder will inherit the permissions we set.

Set ACL Recursive to sub files/folder

use the -R option

How can i tell if a file/folder has a FACL?

ls -l drwxrwx---+ on folder1 and folder2, the + means a FACL is set

if you do a “ls -l” this will show a tiny “+” at the end of the file/folder

Backups:

if you use Rsync for backups, add the -A option, otherwise it will not backup ACL’s

if you are using TAR for backups, add the –acl option

Removing a FACL

That’s it!

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Remove FACL from a Folder/File Recursively | Understanding Linux File Permissions

Leave a Reply

Your email address will not be published. Required fields are marked *