Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check wheter POSIX ACL is enabled for a given path

Tags:

bash

unix

posix

acl

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?

like image 221
Mr. Mr. Avatar asked Jun 07 '11 16:06

Mr. Mr.


People also ask

How do I know if my ACL is enabled?

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.

What is Posix ACL?

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.

How do I read Posix permissions?

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).

What is ACL explain ACL in detail with command and example?

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.


1 Answers

{
  # 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
}
like image 55
linuts Avatar answered Oct 05 '22 05:10

linuts