【问题标题】:How to check wheter POSIX ACL is enabled for a given path如何检查是否为给定路径启用了 POSIX ACL
【发布时间】:2011-06-07 16:26:03
【问题描述】:

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

有什么建议吗?

【问题讨论】:

  • getfacl path;if [ $? -ne 0 ]; then echo "NO ACL"; fi 不起作用?
  • @Let_Me_Be:不,即使使用不支持 ACL 的内核也是成功的。 (我猜它会将文件模式位转换为 ACL)
  • @Mat:没错。 getfacl 表示是否设置了 acl。但如果底层文件系统启用了 acl,则不会。
  • 您有w 访问权限吗?你能用复杂的东西创建一个临时的setfacl吗?
  • @vladr:我也想过这个,但我想说这更像是一个 hack

标签: bash unix acl posix


【解决方案1】:
{
  # 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
}

【讨论】:

  • 哪部分不起作用? 'acl' 挂载选项是否暗示 NFS acls 或他的脚本在 NFS 挂载上以某种方式中断?
  • @Mr. Mr.: AFAIK NFS 从不支持 ACL……只是普通的 UNIX 权限。也许它改变了,但我不这么认为。
  • @Tomas : NFS 从 v4 开始就有 ACL
猜你喜欢
  • 2011-09-04
  • 1970-01-01
  • 1970-01-01
  • 2018-02-05
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 2021-02-17
  • 2014-02-20
相关资源
最近更新 更多