2011-06-07 57 views
10

在閱讀getfacl/setfacl的手冊頁後,我無法找到一個明顯/強大/優雅的方法來檢查(ba)sh中是否啓用了給定路徑的acl 。如何檢查給定路徑上是否啓用了POSIX ACL

有什麼建議嗎?

+0

'getfacl path; if [$? -ne 0];然後回顯「NO ACL」; fi'不起作用? – 2011-06-07 16:35:13

+0

@Let_Me_Be:不,即使是沒有ACL支持的內核,也是如此。 (它將文件模式位轉換爲ACL我猜) – Mat 2011-06-07 16:37:17

+0

@Mat:的確如此。 'getfacl'指示是否設置了acl。但是,如果底層文件系統啓用了acl,則不行。 – 2011-06-08 06:20:38

回答

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 
} 
+0

不幸的是,這在nfs掛載點上失敗。 – 2011-06-13 11:13:04

+0

哪部分不起作用? NFS acls的含義不是由'acl'mount選項表示的,還是他的腳本在NFS掛載上以某種方式中斷? – synthesizerpatel 2011-07-07 09:10:41

+0

@Mr。先生:AFAIK NFS從不支持ACL ......只是普通的UNIX權限。也許它改變了,但我不這麼認爲。 – TMS 2011-07-24 10:51:50

相關問題