Linux下的ACL
ACL理论概述
9位的属主/属组/其他人访问控制系统已经得到证明是强大的,足以满足大多数管理方面的需求。
事实上,在所有非UNIX操作系统上都采用了一种实质上更为复杂的方式来管理对于文件的访问:访问控制列表(access control list),简称ACL。ACL不限制长度,可以包含用于多个用户或者用户组的权限规定。更先进的系统能让系统管理员指定部分权限的集合或者否定方式的权限。
因为在POSIX规范中增加了ACL,所以许多UNIX的变体也开始支持一种相当标准的ACL机制,这种机制和传统的UNIX 9位权限模式平行地发挥左右。
Linux的ACL主要是对标准的9位权限模型直接进行扩展。ACL可以按照用户和用户组的任意组合独立地设置rwx权限位。
ACL的主要命令
getfacl 命令可以显示一个文件当前的ACL
$ getfacl --help
getfacl 2.2. -- get file access control lists
Usage: getfacl [-aceEsRLPtpndvh] file ...
-a, --access display the file access control list only
-d, --default display the default access control list only
-c, --omit-header do not display the comment header
-e, --all-effective print all effective rights
-E, --no-effective print no effective rights
-s, --skip-base skip files that only have the base entries
-R, --recursive recurse into subdirectories
-L, --logical logical walk, follow symbolic links
-P, --physical physical walk, do not follow symbolic links
-t, --tabular use tabular output format
-n, --numeric print numeric user/group identifiers
-p, --absolute-names don't strip leading '/' in pathnames
-v, --version print version and exit
-h, --help this help text
setfacl 命令可以修改或者设置文件当前的ACL
$ setfacl --help
setfacl 2.2. -- 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)
-X, --remove-file=file read ACL entries to remove from file
-b, --remove-all remove all extended ACL entries
-k, --remove-default remove the default 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
ACL实例
1. ACL随着chmod命令对权限模式位的修改而自动更新
$ touch example
$ ls -l example
-rw-rw-r-- eric eric Dec : example
$ getfacl example
# file: example
# owner: eric
# group: eric
user::rw-
group::rw-
other::r--
$ chmod example
$ getfacl --omit-header example
user::rw-
group::r--
other::---
2. Mask规定了ACL能够给单个组和用户访问权限的上限。扩充上一个例子里的ACL,让它包括对某个特定用户和组的ACL,setfacl会自动提供一个合适的mask
$ ls -l example
-rw-r----- eric eric Dec : example
$ setfacl -m user::r,user:squid:rw,group:squid:rw example
$ ls -l example
-r--rw----+ eric eric Dec : example
$ getfacl --omit-header example
user::r--
user:squid:rw-
group::r--
group:squid:rw-
mask::rw-
other::---
如上所示,setfacl命令产生了一个mask,让ACL中赋予的所有权限都发生了作用。在尝试访问文件的时候,要把有效UID同该文件属主的UID进行对比。如果他们一样,那么ACL中user::项权限就决定了能否访问。否则,匹配某个特定用户的ACL项,那么ACL项连同ACL的mask就一起决定了能否访问。如果没有特定于某个用户,那么文件系统会尝试找有效的组ACL项;如果还没有匹配项,那么在用other::这个ACL项。
3. 如果在一个有ACL的文件上,用chmod来控制组的访问权限,那么修改只对mask有影响。
$ getfacl --omit-header example
user::r--
user:squid:rw-
group::r--
group:squid:rw-
mask::rw-
other::---
$ ls -l example
-r--rw----+ eric eric Dec : example
$ chmod example
$ ls -l example
-rwxrwx---+ eric eric Dec : example
$ getfacl --omit-header example
user::rwx
user:squid:rw-
group::r--
group:squid:rw-
mask::rwx
other::---
这里的ls输出有点误导性。尽管表面上看给组权限,但是没有人因为是组成员而有权执行该文件,为了让组有这样的权限,必须用setfacl编辑ACL本上。
Linux下的ACL的更多相关文章
- linux下通过acl配置灵活目录文件权限(可用于ftp,web服务器的用户权限控制)
linux下通过acl配置灵活目录文件权限(可用于ftp,web服务器的用户权限控制) 发表于2012//07由feng linux 本身的ugo rwx的权限,对于精确的权限控制很是力不从心的,ac ...
- Shell初学(八)linux下的ACL
[1]ACL的作用 简单直接解释一下ACL的作用,即把权限的个别化额外添加. 可以解决如下问题~~比如: [1.1]基于用户: 我有10个用户a1-a10,我有一个文件夹/tmp/test,我想给a1 ...
- 构建LINUX下的入侵检测系统——LIDS 系统管理命令--vlock
构建LINUX下的入侵检测系统——LIDS 系统管理命令--vlock http://blog.chinaunix.net/uid-306663-id-2440200.html LIDS官方网站: ...
- Linux下Nagios的安装与配置
一.本文说明 本文是在参考:http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html David_Tang文章以及网上的一些资料完 ...
- linux下恢复误删除的文件方法(ext2及ext3)
linux下恢复误删除的文件方法(ext2及ext3) 2009-12-19 15:23:47 分类: LINUX 如果是ext2文件系统的,直接用debugfs是可以恢复出来的,但对于ext3,d ...
- Linux下部署Symfony2对app/cache和app/logs目录的权限设置
在linux下部署完Symfony2,可能在访问的时候会报app/logs或者app/cache目录没有写权限的错误.在linux下,如果我们在命令行登陆的用户和web应用服务器(apache.ngi ...
- Linux UGO和ACL权限管理
自主访问控制(Discretionary Access Control, DAC)是指对象(比如程序.文件.进程)的拥有者可以任意修改或者授予此对象相应的权限.Linux的UGO(User, Grou ...
- linux下添加删除,修改,查看用户和用户组
一.组操作 1.创建组: groupadd test #增加一个test组 2.修改组 groupmod -n test2 test #将test组的名子改成test2 3.删除组 groupdel ...
- linux下磁盘相关工具(待整理)
一.概述: fsck tune2fs mke2fs badblocks mkfs* fdisk mount umount mknod e2label blkid hdparm mkswap swapo ...
随机推荐
- uplift model学习笔记
一.解决的问题: 通常的 Propensity Model 和 Response Model 只是给目标用户打了个分,并没有确保模型的结果可以使得活动的提升最大化:它没有告诉市场营销人员,哪个用户最有 ...
- ubuntu18.04.1LTS系统远程工具secureCRT
ubuntu18.04.1LTS类windows的系统下安装远程管理工具 本地电脑之前安装的是win10,疲于win10频繁的更新和各种兼容问题,果断放弃win10系统,安装了Ubuntu 18.04 ...
- Linux系统完整安装在虚拟机Mini
打开VMware Workstation虚拟机,然后如下图一步到位: 此处只是简单的安装Linux系统,要想查看安装后的IP等配置看: https://www.cnblogs.com/gentle-a ...
- 模块pandas
python之pandas简单介绍及使用(一) https://www.cnblogs.com/misswangxing/p/7903595.html
- source insight插件
直使用sourceinsight编辑C/C++代码,sourceinsight是一个非常好用的编辑工具可以任意定位,跳转,回退,本人一直 使用该工具做C/C++开发,sourceinsight能够满足 ...
- C++基础 C++对类的管理——封装
1.封装 两层含义: (1)把事物的属性和方法结合成个整体. (2)对类的属性和方法进行访问控制,对不信的进行信息屏蔽. 2.访问控制 控制分为 类的内部,类的外部. public 修饰的成员,可在内 ...
- POJ:1703-Find them, Catch them(并查集好题)(种类并查集)
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 49867 Accepted: 153 ...
- [BZOJ2243][SDOI2011]染色(树链剖分)
[传送门] 树链剖分就行了,注意线段树上颜色的合并 Code #include <cstdio> #include <algorithm> #define N 100010 # ...
- Smail 中的一些点
smali中所有操作都需要经过寄存器, 本地寄存器以v开头, 参数寄存器以p开头, 非static方法中p0是this 没有-object后缀的操作指令表示操作的对象是基本类型 invoke-dire ...
- Ubuntu 16.04上安装并配置Postfix作为只发送SMTP服务器
如果大家已经在使用第三方邮件服务方案发送并收取邮件,则无需运行自己的邮件服务器.然而,如果大家管理一套云服务器,且其中安装的应用需要发送邮件通知,那么运行一套本地只发送SMTP服务器则更为理想. 如何 ...