如何检查是否为给定路径启用了POSIX ACL

时间:2011-06-07 16:26:03

标签: bash unix acl posix

在阅读getfacl / setfacl的手册页后,我找不到一个明显/健壮/优雅的方法来检查是否为(ba)sh中的给定路径启用了acl。

有什么建议吗?

1 个答案:

答案 0 :(得分:4)

{
  # 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
}