POSIX ACL support for Linux and Mac OS X
5月 13th, 2006 Comments Off
Linux
我是在 RHEL4 及 FC5 底下使用的
預設的 Kernel 就已經支援了,所以,只要在 mount 時(或 fstab 裡) 加上參數,就可以啟用 ACL 的支援了
啟用 ACL support
$ mount -t ext3 -o remount,acl /
in fstab:
LABEL=/ / ext3 defaults,acl 1 1
相關指令
* setfacl
* getfacl
* chacl
舉例如下:
-m 表示修改與新增權限
-x 表示移除權限
[root@acer:~] setfacl -m u:candyz:rw test.txt [root@acer:~] getfacl test.txt # file: test.txt # owner: root # group: root user::rw- user:candyz:rw- group::r-- mask::rw- other::r-- [root@acer:~] setfacl -m u:apache:r test.txt [root@acer:~] getfacl test.txt # file: test.txt # owner: root # group: root user::rw- user:apache:r-- user:candyz:rw- group::r-- mask::rw- other::r-- [root@acer:~] setfacl -x u:candyz test.txt [root@acer:~] getfacl test.txt # file: test.txt # owner: root # group: root user::rw- user:apache:r-- group::r-- mask::r-- other::r--
用 d: 來指定預設的 ACL
[root@acer:~] setfacl -m d:o:rx /var/ftp
使用 chacl 指令
[root@acer:~] chacl -l test.txt test.txt [u::rw-,u:apache:r--,g::r--,m::r--,o::r--] [root@acer:~] chacl u::rwx,g::r-x,o::r--,u:candyz:rwx,m::r-x test.txt [root@acer:~] chacl -l test.txt test.txt [u::rwx,u:candyz:rwx,g::r-x,m::r-x,o::r--] [root@acer:~] chacl u::rwx,g::r-x,o::r--,u:candyz:rwx,g:apache:r--,m::r-x test.txt [root@acer:~] chacl -l test.txt test.txt [u::rwx,u:candyz:rwx,g::r-x,g:apache:r--,m::r-x,o::r--] [root@acer:~]
其他注意事項
Samba 在編譯時有加入 –with-acl-support 選項,所以有支援 ACL (RHEL4 and FC5)
NFS 也支援 ACL, 可以在 export 時加入 no_acl 來 disable
使用 tar 指令並無法備份 ACLs
所以要改用 star 指令才行
$ star -acl
Mac OS X
Tiger (10.4) 之後就有支援 ACL 了,在 Mac OS X Server 版上,還有提供一個圖形的管理介面
不過,在 Mac OS X 版上,就沒有了,且預設也是沒用啟用 ACL 的
啟用/停用 ACL support
啟用:
$ sudo fsaclctl -p / -e
若要停用:
$ sudo fsaclctl -p / -d
十分的簡單地
相關指令
在我的 Mac OS X 上,找不到如 Linux 下的 setfacl、getfacl 等指令
原來,在 Mac OS X 上要用 ‘chmod’ 這個指令來設定權限
* chmod +a/-a/=a
詳細指令用法請 man chmod 的 ACL 部份
而 ls 的 -e 選項(要跟 -l 選項合用) 則可以用來列出該檔案的 ACL
舉例如下:
+a 用來新增而 -a 則是用來刪除
[candyz@ibook:~/Desktop] chmod +a "admin deny read" test.txt [candyz@ibook:~/Desktop] ls -le test.txt -rw-r--r-- + 1 candyz candyz 5 May 13 18:13 test.txt 0: group:admin deny read [candyz@ibook:~/Desktop] chmod +a "root allow write" test.txt [candyz@ibook:~/Desktop] ls -le test.txt -rw-r--r-- + 1 candyz candyz 5 May 13 18:13 test.txt 0: group:admin deny read 1: user:root allow write [candyz@ibook:~/Desktop] chmod -a "root allow write" test.txt [candyz@ibook:~/Desktop] ls -le test.txt -rw-r--r-- + 1 candyz candyz 5 May 13 18:13 test.txt 0: group:admin deny read [candyz@ibook:~/Desktop]
ACL 適合用在多人共同使用的 Server 上,以補足原本 Unix 權限不足之處