您的位置:首页 > 其它

FACL额外访问控制权限

2016-05-11 16:24 351 查看
一、简介

       FACL(Filesystem Access Control List)是指文件访问控制列表,该属性可以利用文件扩展保存额外的访问控制权限,比如有一下情况:storm用需要创建一个test文件,他需要cathy用户同样具有rw权限,通常的权限控制做法是需要修改test文件的other权限为rw,但是这样做以后所有的用户都具有rw权限,带来极大的安全隐患,此时就该facl发挥作用的时候了。

       FACL常用的命令有2个:setfacl和getfacl,这两个命令普通用户都具有执行权限。

二、查看文件的acl权限

[storm@centos common]$ touch test
[storm@centos common]$ getfacl test
# file: test
# owner: storm
# group: storm
user::rw-
group::rw-
other::r--

可以看到,test文件只有基本的user、group、other权限,该文件对于other用户是只读文件

三、设置文件的acl权限

[storm@centos common]$ setfacl -m u:cathy:rw test
[storm@centos common]$ getfacl test
# file: test
# owner: storm
# group: storm
user::rw-
user:cathy:rw-
group::rw-
mask::rw-
other::r--
[storm@centos common]$ ll
total 4
-rw-rw-r--+ 1 storm storm 0 May 11 00:39 test

☞ 当设置完facl权限以后利用getfacl查看发现多了一行:user:cathy:rw- ,表名该文件针对于cathy用户拥有额外的权限rw,此时用户cathy就具有对文件test的读写权限,但对于其他用户该文件是只读的

☞ 如果用ls -al查看该文件,在权限一列的显示为:-rw-rw-r--+多了个+号,表示该文件具有额外的权限,使用getfacl命令即可查看

☞ 添加额外组权限只需将setfacl -m u:cathy:rw test命令中的u改为g即可

四、取消权限

[storm@centos common]$ setfacl -x u:cathy test


五、参数说明

[storm@host1 common]$ setfacl --help
setfacl 2.2.49 -- set file access control lists
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl        modify the current ACL(s) of file(s) # 修改
-M, --modify-file=file  read ACL entries to modify from file # 根据配置文件修改
-x, --remove=acl        remove entries from the ACL(s) of file(s) # 取消acl权限
-X, --remove-file=file  read ACL entries to remove from file # 根据配置文件取消
-b, --remove-all        remove all extended ACL entries # 移除所有acl权限
-k, --remove-default    remove the default ACL # 移除默认acl权限
--set=acl           set the ACL of file(s), replacing the current ACL
--set-file=file     read ACL entries to set from file
--mask              do recalculate the effective rights mask
-n, --no-mask           don't recalculate the effective rights mask
-d, --default           operations apply to the default ACL
-R, --recursive         recurse into subdirectories
-L, --logical           logical walk, follow symbolic links
-P, --physical          physical walk, do not follow symbolic links
--restore=file      restore ACLs (inverse of `getfacl -R')
--test              test mode (ACLs are not modified)
-v, --version           print version and exit
-h, --help              this help text
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: