开发者

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

开发者 https://www.devze.com 2023-03-11 20:12 出处:网络
Af开发者_开发问答ter 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.

Af开发者_开发问答ter 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?


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号