9.5. POSIX Access Control Lists

POSIX Access Control Lists (ACLs) allows you to assign different permissions for different users or groups even though they do not correspond to the original owner or the owning group.
For example: User John creates a file. He does not allow anyone in the group to access the file, except for another user, Antony (even if there are other users who belong to the group john).
This means, in addition to the file owner, the file group, and others, additional users and groups can be granted or denied access by using POSIX ACLs.

9.5.1. Setting POSIX ACLs

You can set two types of POSIX ACLs, that is, access ACLs and default ACLs. You can use access ACLs to grant permission for a specific file or directory. You can use default ACLs only on a directory but if a file inside that directory does not have an ACL, it inherits the permissions of the default ACLs of the directory.
For a file, ACLs can be configured:
  • Per user
  • Per group
  • Via the effective right mask
  • For users not in the user group for the file Setting Access ACLs

You can apply access ACLs to grant permission for both files and directories.
To set or modify Access ACLs
You can set or modify access ACLs use the following command:
# setfacl –m entry type file 
The ACL entry types are the POSIX ACLs representations of owner, group, and other.
Permissions must be a combination of the characters r (read), w (write), and x (execute). You must specify the ACL entry in the following format and can specify multiple entry types separated by commas.
ACL Entry Description
u:uid:<permission> Sets the access ACLs for a user. You can specify user name or UID
g:gid:<permission> Sets the access ACLs for a group. You can specify group name or GID.
m:<permission> Sets the effective rights mask. The mask is the combination of all access permissions of the owning group and all of the user and group entries.
o:<permission> Sets the access ACLs for users other than the ones in the group for the file.
If a file or directory already has an POSIX ACLs, and the setfacl command is used, the additional permissions are added to the existing POSIX ACLs or the existing rule is modified.
For example, to give read and write permissions to user antony:
# setfacl -m u:antony:rw /mnt/gluster/data/testfile Setting Default ACLs

New files and directories inherit ACL information from their parent directory if that parent has an ACL that contains default entries. You can set default ACL entries only on directories.
To set default ACLs
You can set default ACLs for files and directories using the following command:
# setfacl –m –-set entry type directory
For example, to set the default ACLs for the /data directory to read for users not in the user group:
# setfacl –m --set o::r /mnt/gluster/data


An access ACL set for an individual file can override the default ACL permissions.
Effects of a Default ACLs
The following are the ways in which the permissions of a directory's default ACLs are passed to the files and subdirectories in it:
  • A subdirectory inherits the default ACLs of the parent directory both as its default ACLs and as an access ACLs.
  • A file inherits the default ACLs as its access ACLs.