18.9. ACL - Access Control List

$ sudo modprobe loop
$ dd if=/dev/zero of=file bs=1k count=100
$ sudo losetup /dev/loop0 file
$ sudo mkfs.ext3 /dev/loop0
$ sudo mkdir /mnt/loop
$ sudo mount -o rw,acl /dev/loop0 /mnt/loop/
$ sudo chown neo.neo -R /mnt/loop
$ cd /mnt/loop/
		

18.9.1. getfacl - get file access control lists

UGO

$ touch file
$ ls -l file
-rw-r--r-- 1 neo neo 0 2008-12-22 15:28 file
			

ACL

$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
group::r--
other::r--
			

display the default access control list only

neo@netkiller:/mnt/loop$ getfacl  dir
# file: dir
# owner: neo
# group: neo
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:svnroot:rw-
default:group::r-x
default:group:nagios:rw-
default:mask::rwx
default:other::r-x

neo@netkiller:/mnt/loop$ getfacl -d dir
# file: dir
# owner: neo
# group: neo
user::rwx
user:svnroot:rw-
group::r-x
group:nagios:rw-
mask::rwx
other::r-x
			

recurse into subdirectories

$ getfacl -R dir
# file: dir
# owner: neo
# group: neo
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:svnroot:rw-
default:group::r-x
default:group:nagios:rw-
default:mask::rwx
default:other::r-x

# file: dir/file1
# owner: neo
# group: neo
user::rw-
user:svnroot:rw-
group::r-x                      #effective:r--
group:nagios:rw-
mask::rw-
other::r--
			

18.9.2. setfacl - set file access control lists

18.9.2.1. set

add a user svnroot to file

neo@netkiller:/mnt/loop$ setfacl -m u:svnroot:rw file
				

if you can see a '+' at last, it's successed

$ ls -l file
-rw-rw-r--+ 1 neo neo 0 2008-12-22 15:44 file
				

let me see acl.

neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
user:svnroot:rw-
group::r--
mask::rw-
other::r--
				

add a user cvsroot to file again

neo@netkiller:/mnt/loop$ setfacl -m u:cvsroot:rw file
neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
user:cvsroot:rw-
user:svnroot:rw-
group::r--
mask::rw-
other::r--
				

add a user and group for that

neo@netkiller:/mnt/loop$ setfacl -m u:gnump3d:rwx,g:nagios:r file
neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
user:gnump3d:rwx
user:cvsroot:rw-
user:svnroot:rw-
group::r--
group:nagios:r--
mask::rwx
other::r--
				

modify the current ACL(s) of file(s)

neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
user:svnroot:rw-
group::r--
mask::rw-
other::r--

neo@netkiller:/mnt/loop$ setfacl -m u:svnroot:r-x file
neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
user:svnroot:r-x
group::r--
mask::r-x
other::r--
				

18.9.2.2. default

neo@netkiller:/mnt/loop$ setfacl -d -m u:svnroot:rw dir/
neo@netkiller:/mnt/loop$ getfacl dir/
# file: dir
# owner: neo
# group: neo
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:svnroot:rw-
default:group::r-x
default:mask::rwx
default:other::r-x

neo@netkiller:/mnt/loop$ setfacl -d -m g:nagios:rw dir/
neo@netkiller:/mnt/loop$ getfacl dir/
# file: dir
# owner: neo
# group: neo
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:svnroot:rw-
default:group::r-x
default:group:nagios:rw-
default:mask::rwx
default:other::r-x
				

the file1 will inherit acl by default.

neo@netkiller:/mnt/loop$ touch dir/file1
neo@netkiller:/mnt/loop$ getfacl dir/file1
# file: dir/file1
# owner: neo
# group: neo
user::rw-
user:svnroot:rw-
group::r-x                      #effective:r--
group:nagios:rw-
mask::rw-
other::r--

18.9.2.3. remove

remove entries from the ACL(s) of file(s)

neo@netkiller:/mnt/loop$ setfacl -x u:cvsroot file
neo@netkiller:/mnt/loop$ setfacl -x g:nagios file
neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
user:gnump3d:rwx
user:svnroot:rw-
group::r--
mask::rwx
other::r--
				

remove all extended ACL entries

neo@netkiller:/mnt/loop$ setfacl -b file
neo@netkiller:/mnt/loop$ getfacl file
# file: file
# owner: neo
# group: neo
user::rw-
group::r--
	other::r--
				

18.9.2.4. backup and restore

backup

$ getfacl -R dir > dir.acl
				

restore

$ setfacl --restore dir.acl
			

原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

时间: 2024-08-03 15:59:53

18.9. ACL - Access Control List的相关文章

ZooKeeper 笔记(5) ACL(Access Control List)访问控制列表

zk做为分布式架构中的重要中间件,通常会在上面以节点的方式存储一些关键信息,默认情况下,所有应用都可以读写任何节点,在复杂的应用中,这不太安全,ZK通过ACL机制来解决访问权限问题,详见官网文档:http://zookeeper.apache.org/doc/r3.4.6/zookeeperProgrammers.html#sc_ZooKeeperAccessControl 总体来说,ZK的节点有5种操作权限: CREATE.READ.WRITE.DELETE.ADMIN 也就是 增.删.改.查

Declarations and Access Control (1)

access 1) Declarations and Access Control Objective 1Write code that declares, constructs and initializes arrays of any base type using any of the permitted forms, both for declaration and for initialization. 1.    Arrays are Java objects. (An object

Swift中的Access Control权限控制介绍

  这篇文章主要介绍了Swift中的Access Control权限控制介绍,本文讲解了private.internal.public三个关键字的使用,需要的朋友可以参考下 如果您之前没有接触过权限控制,先来听一个小故事: 小明是五道口工业学院的一个大一新生,最近他有点烦恼,因为同屋经常用他的热水壶,好像那是自己家的一样,可是碍于同学情面,又不好意思说.直到有一天,他和学姐小K吐槽. 学姐听了之后,说:大学集体生活里面,大部分东西都是默认室友可以共用的.如果你不想别人拿,我可以帮你做封印,只要打

【原创】RabbitMQ 之 Access Control(翻译)

Access Control  When the server first starts running, and detects that its database is uninitialised or has been deleted, it initialises a fresh database with the following resources: 当服务器启动运行后,检测到所使用的数据库未进行过初始化,或者被删除了,则会使用如下资源初始化一个新的数据库:  a virtual

新的RBAC:基于资源的权限管理(Resource-Based Access Control)

本文讨论以角色概念进行的权限管理策略及主要以基于角色的机制进行权限管理是远远不够的.同时将讨论一种更好的权限管理方式. What is a Role? 什么是角色 当说到程序的权限管理时,人们往往想到角色这一概念.角色是代表一系列行为或责任的实体,用于限定你在软件系统中能做什么.不能做什么.用户帐号往往与角色相关联,因此,一个用户在软件系统中能"做"什么取决于与之关联的各个角色. 例如,一个用户以关联了"项目管理员"角色的帐号登录系统,那这个用户就可以做项目管理员能

Windows Azure AppFabric 入门教学系列 (五):初探Access Control Service

本文是Windows Azure AppFabric入门教学的第五篇文章.本文会对AppFabric中的Access Control Service(ACS)做初步的讲解.为了使后续的学习顺利进行请确保已浏览本教程的第一篇文章,并以按照该文完成了AppFabric项目和命名空间的创建.我们知道,AppFabirc由Service Bus 和 Access Control Service组成,在前一篇教程中我们已介绍过Service Bus,所以本文将简略的介绍如何使用ACS服务来确保安全性. 同

Swift中的Access Control权限控制介绍_Swift

如果您之前没有接触过权限控制,先来听一个小故事: 小明是五道口工业学院的一个大一新生,最近他有点烦恼,因为同屋经常用他的热水壶,好像那是自己家的一样,可是碍于同学情面,又不好意思说.直到有一天,他和学姐小K吐槽. 学姐听了之后,说:大学集体生活里面,大部分东西都是默认室友可以共用的.如果你不想别人拿,我可以帮你做封印,只要打上private标记,它们就看不到你的东西,更加用不了你的东西了. 小明说哇靠学姐你还会妖法...... Swift语言从Xcode 6 beta 5版本起,加入了对权限控制

获得客房端的MAC(Media Access Control)地址

Get the clients MAC(Media Access Control) address, a hardware address that uniquely identifies each node of a network. Works great on LAN's. Firewalls and Proxy's will be an issue depending what side of them you're coding for. Can't Copy and Paste th

Distributed Access Control System 1.4.27发布 访问控制系统

Distributed Access Control System简称DACS,是一个轻量级单点登录的http://www.aliyun.com/zixun/aggregation/38609.html">访问控制系统.它提供了灵活.模块化的验证方法,强大.透明的规则为基础的Web服务授权检查,CGI程序或几乎任何程序. Distributed Access Control System 1.4.27该版本进行了一些轻微的错误修正版,升级到第三方的支持包,包括Mac OS X10.7.2升