After reading the man page of getfacl
/ setfacl
I could not find an obvious/robust/elegant method to check whether acl is enabled for a given path in (ba)sh.
Any suggestions?
A common way to enable acl support on a filesystem is to add the acl option to a filesystems mount options in /etc/fstab . We can check if that has been done on this system by using the mount command. In this case the acl option has not been added but that doesn't mean our filesystem doesn't have acl's enabled.
POSIX Access Control Lists (ACLs) are more fine-grained access rights for files and directories. An ACL consists of entries specifying access permissions on an associated object. ACLs can be configured per user, per group or via the effective rights mask.
The traditional POSIX file system object permission model defines three classes of users called owner, group, and other. Each of these classes is associated with a set of permissions. The permissions defined are read (r), write (w), and execute (x).
Basically, ACLs are used to make a flexible permission mechanism in Linux. From Linux man pages, ACLs are used to define more fine-grained discretionary access rights for files and directories. setfacl and getfacl are used for setting up ACL and showing ACL respectively. For example : getfacl test/declarations.h.
{
# Determine what the mount point for the path is:
MOUNT_POINT=$(df -P $FILENAME | tail -n 1 | awk '{print $6}')
# Get the mount options for the path:
MOUNT_OPTS=$(awk '$2=="'$MOUNT_POINT'" { print $4 }' /proc/mounts)
# Check to see if acl is one of the mount points:
echo $MOUNT_OPTS | tr , \\\n | grep '^acl$' -q
if [ $? -eq 0 ]; then
echo "ACLs enabled"
else
echo "ACLs disabled"
fi
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With