Chinaunix首页 | 论坛 | 博客
  • 博客访问: 649081
  • 博文数量: 109
  • 博客积分: 6081
  • 博客等级: 准将
  • 技术积分: 1318
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-24 10:28
文章分类
文章存档

2011年(8)

2010年(39)

2009年(62)

分类: LINUX

2009-10-24 10:58:48

使用setfacl划分权限收藏
在认识setfacl之前,对Linux文件系统细分权限这个问题一直困扰着我
使用Samba来构建Linux文件系统可谓是功能强大,凡架设过MS Windows网络的人都知道MS Windows网络的核心是SMB/CIFS,而samba也是一套基于UNIX类系统、实现SMB/CIFS协议的软件,作为UNIX的克隆,Linux也可以运行这套软件。和NT相比较,samba的文件服务功能一点也不亚于NT,效率很高,借助Linux本身,可以实现用户磁盘空间限制功能,NT到4.0版本还是无法实现这点。可是要深刻地去认识Samba并不是一天两天的事情,samba由samba小组(http;//samba.org)开发,更新速度很快,目前最高的版本是3.0.7版,每个更新版本在功能上都所增强,也修复了已知的BUG,要使用Samba强大的功能,看来需要一段时间去探究,去理解,去不断地实践,才能领略到Samba。
现在我面临的问题只要是构建文件服务器的权限细分问题,一个100多人的企业,对公司的员工的管理是非常严格的,在文件的共享,员工的资源使用,员工的权限等等都是一样。文件服务器只要是共享日常工作的文档资料,一些共用的资料,一些对部分人保密的资料,一些普通员工不允许看到的文档资料……可见,文件服务器权限的细分有多的重要。另外,公司需要共享的目录实在是太多了,如果使用samba来一个一个目录地去配置,可谓是工程浩大。
OK,现在转入正题。我使用的系统是RedHat Enterpise Linux 3.0 Up3,价钱可性能方面,不用说我想大家也知道了。我做之前,其实我也考虑过使用samba来细分文件共享的权限,但是由于时间的问题,在紧急的关头,我发现了setfacl这个功能。
在使用setfacl之前,首先要检查系统的内核是否支持setfacl啦,另外还需要编辑/etc/fstab文件,对需要setfacl的分区激活acl的功能。
ACL 有两种:存取 ACL(access ACLs)和默认 ACL(default ACLs)。存取 ACL 是对指定文件或目录的存取控制列表。默认 ACL 只能和目录相关。如果目录中的文件没有存取 ACL,它就会使用该目录的默认 ACL。默认 ACL 是可选的。
ACL 可以按以下条件配置:

每用户
每组群
通过有效权限屏蔽
为不属于文件用户组群的用户配置
其实用户打开访问文件服务器时,他看见的只有两个共享的目录,这两个共享目录是samba共享出来的,分配给所有的用户(everyoen组)都有写的权限(rwx),由于系统的权限行前与samba的权限,所以我在系统中设置了所有用户(everyone组)只有r-x的权限,所有在共享出来的目录中,每个用户在这个目录下不能写了。
 
setfacl 工具为文件和目录设置 ACL。使用 -m 来添加或修改文件或目录的 ACL:
setfacl -m

规则()必须使用以下格式指定。同一条命令中可以指定多项规则,只要它们是用逗号分开即可。

u::
为用户设置存取 ACL。用户名或 UID 必须被指定。用户可以是系统上的任何合法用户。
g::
为组群设置存取 ACL。组群名称或 GID 必须被指定。组群可以是系统上的任何合法组群。
m:
设置有效权限屏蔽。该屏蔽是组群所有者和所有用户和组群项目的权限的合集。
o:
为文件的组群用户之外的用户设置存取 ACL。
空格被忽略。权限()必须是代表读、写、和执行的字符(r、w、x)的组合。
如果某文件或目录已经有了一个 ACL,而 setfacl 命令仍被使用了,额外的规则就会被添加到已存在的 ACL 中,或用来修改已存在的规则。
例如,要给用户 tfox 以读写权限:
setfacl -m u:tfox:rw /project/somefile

要删除用户、组群或其它人的所有权限,使用 -x 选项,并且不指定任何权限:
setfacl -x

例如,删除 UID 为 500 的用户的所有权限:
setfacl -x u:500 /project/somefile
 

下面要做的是对samba 共享出来的目录下的各个目录进行权限的细分,例如对于共享目录share1下有两个目录
、,其中user1和同组人(doc)对目录aaa 可以读写执行,但是只能读bbb,user2和同组人(eng)只能读bbb,不能读aaa。
首先是,所有的用户都加入到everyone组中,使用下面的命令就可以实现了:
setfacl -R -m g:everyone:r-x share1
setfacl -R -m g:doc:rwx,d:g:doc:rwx,g:everyone:--- /share1/aaa
setfacl -R -m g:doc:r-x,d:g:doc:r-x /share1/bbb
其实有很的需求都是需要具体地去拼合的,有些目录实在是太深了,对权限的细分可能有点难度,但是使用setfacl就可以对目录分得很细。
有关setfacl的用法可以参考下面的内容:
NAME
     setfacl - modify the Access Control List (ACL) for a file or
     files
SYNOPSIS
     setfacl [ -r ]  -s acl_entries file
     setfacl [ -r ]  -md acl_entries file
     setfacl [ -r ]  -f acl_filefile
DESCRIPTION
     For each file specified, setfacl  will  either  replace  its
     entire  ACL, including the default ACL on a directory, or it
     will add, modify, or delete one or more ACL entries, includ-
     ing default entries on directories.
     Setting an ACL on a file also modifies the file's permission
     bits.  The  user   entry  modifies the file owner permission
     bits. If you don't specify a mask  entry,  the  group  entry
     modifies  the  file  group  owner  permission  bits.  If you
     specify a mask entry, the file group owner  permission  bits
     are  modified based on the intersection (bitwise AND) of the
     group and mask entries. The other entry modifies  the  other
     permission bits.
     If  you use the chmod(1) command to change  the  file  group
     owner  permissions on a file with ACL entries, both the file
     group owner permissions and the ACL mask are changed to  the
     new  permissions. Be aware that the new ACL mask permissions
     may change the effective permissions  for  additional  users
     and groups who have ACL entries on the file.
     A directory may contain default ACL entries. If  a  file  or
     directory  is  created  in a directory that contains default
     ACL entries, the newly created file  will  have  permissions
     generated  according to the  intersection of the default ACL
     entries and the permissions requested at creation time.  The
     umask(1)  will  not  be  applied  if  the directory contains
     default ACL entries. If a default ACL  is  specified  for  a
     specific  user  (or users), the file will have a regular ACL
     created; otherwise, only the mode bits will  be  initialized
     according  to  the intersection described above. The default
     ACL should be thought of as the maximum discretionary access
     permissions that may be granted.
  acl_entries Syntax
     For the -m and -s  options,  acl_entries  are  one  or  more
     comma-separated ACL entries.
     An ACL entry consists of the following fields  separated  by
     colons:
          entry_type
                Type of ACL entry on which to  set  file  permis-
                sions.  For  example, entry_type can be user (the
                owner of a file) or mask (the ACL mask).
          uid or gid
                User name  or  user  identification  number.  Or,
                group name or group identification number.
          perms Represents  the  permissions  that  are  set   on
                entry_type.  perms  can  be indicated by the sym-
                bolic characters rwx or a number (the  same  per-
                missions numbers used with the chmod command).
     The following table shows the  valid  ACL  entries  (default
     entries may only be specified for directories):
     ACL Entry                     Description
     u[ser]::perms                 File owner permissions.
     g[roup]::perms                File group owner permissions.
     o[ther]:perms                 Permissions for  users  other  than
                                   the  file  owner or members of file
                                   group owner.
     m[ask]:perms                  The ACL mask. The mask entry  indi-
                                   cates   the   maximum   permissions
                                   allowed for users (other  than  the
                                   owner)  and for groups. The mask is
                                   a quick way to  change  permissions
                                   on all the users and groups.
     u[ser]:uid:perms              Permissions for  a  specific  user.
                                   For  uid,  you can specify either a
                                   user name or a numeric UID.
     g[roup]:gid:perms             Permissions for a  specific  group.
                                   For  gid,  you can specify either a
                                   group name or a numeric GID.
     d[efault]:u[ser]::perms       Default file owner permissions.
     d[efault]:g[roup]::perms      Default file  group  owner  permis-
                                   sions.
     d[efault]:o[ther]:perms       Default permissions for users other
                                   than  the  file owner or members of
                                   the file group owner.
     d[efault]:m[ask]:perms        Default ACL mask.
     d[efault]:u[ser]:uid:perms    Default permissions for a  specific
                                   user.  For  uid,  you  can  specify
                                   either a user  name  or  a  numeric
                                   UID.
     d[efault]:g[roup]:gid:perms   Default permissions for a  specific
                                   group.  For  gid,  you  can specify
                                   either a group name  or  a  numeric
                                   GID.
     For the -d  option,  acl_entries  are  one  or  more  comma-
     separated  ACL  entries  without  permissions. Note that the
     entries for file owner, file group owner, ACL mask, and oth-
     ers may not be deleted.
OPTIONS
     The options have the following meaning:
     -s acl_entries
           Set a file's ACL. All old ACL entries are removed  and
           replaced  with  the  newly  specified ACL. The entries
           need not be in any specific order. They will be sorted
           by the command before being applied to the file.
           Required entries:
              o  Exactly one user entry specified  for  the  file
                 owner.
              o  Exactly one  group  entry  for  the  file  group
                 owner.
              o  Exactly one other entry specified.
     If there are additional user and group entries:
              o  Exactly one mask entry  specified  for  the  ACL
                 mask  that  indicates  the  maximum  permissions
                 allowed for users (other  than  the  owner)  and
                 groups.
              o  Must not be duplicate user entries with the same
                 uid.
              o  Must not be duplicate  group  entries  with  the
                 same gid.
     If file is a directory, the following  default  ACL  entries
     may be specified:
              o  Exactly one default  user  entry  for  the  file
                 owner.
              o  Exactly one default group  entry  for  the  file
                 group owner.
              o  Exactly one default mask entry for the ACL mask.
              o  Exactly one default other entry.
           There may be additional default user entries and addi-
           tional  default group entries specified, but there may
           not be duplicate additional default user entries  with
           the  same uid, or duplicate default group entries with
           the same gid.
     -m acl_entries
           Add one or more new ACL entries to  the  file,  and/or
           modify  one  or more existing ACL entries on the file.
           If an entry already exists for a specified uid or gid,
           the  specified  permissions  will  replace the current
           permissions. If an entry does not exist for the speci-
           fied uid or gid, an entry will be created.
     -d acl_entries
           Delete one or more entries from the file. The  entries
           for  the  file owner, the file group owner, and others
           may not be deleted from the ACL. Note that deleting an
           entry  does  not  necessarily  have the same effect as
           removing all permissions from the entry.
     -f acl_file
           Set a file's ACL with the ACL entries contained in the
           file named acl_file. The same constraints on specified
           entries hold as with the -s option.  The  entries  are
           not  required to be in any specific order in the file.
           Also, if you specify a dash '-' for acl_file, standard
           input is used to set the file's ACL.
           The character "#" in acl_file may be used to  indicate
           a comment. All characters, starting with the "#" until
           the end of the line, will be ignored. Note that if the
           acl_file  has  been  created as the output of the get-
           facl(1) command, any effective permissions, which will
           follow a "#", will be ignored.
     -r    Recalculate the permissions for the  ACL  mask  entry.
           The  permissions  specified  in the ACL mask entry are
           ignored and replaced by the maximum permissions neces-
           sary  to grant the access to all additional user, file
           group owner, and additional group entries in the  ACL.
           The  permissions  in  the  additional user, file group
           owner,  and  additional   group   entries   are   left
           unchanged.
EXAMPLES
     Example 1: Adding read permission only
     The following example adds one ACL entry to file abc,  which
     gives user shea read permission only.
     setfacl -m user:shea:r-- abc
     Example 2: Replacing a file's entire ACL
     The following example replaces the entire ACL for  the  file
     abc,  which  gives  shea  read  access,  the  file owner all
     access, the file group owner read access only, the ACL  mask
     read/write access, and others no access.
     setfacl -s user:shea:rwx,user::rwx,group::rw-,mask:r--,other:--- abc
     Note that after this command, the file permission  bits  are
     rwxr-----.  Even  though  the  file group owner was set with
     read/write permissions, the ACL mask entry limits it to have
     only  read  permissions.  The  mask entry also specifies the
     maximum permissions available to  all  additional  user  and
     group ACL entries. Once again, even though the user shea was
     set with all access, the mask limits it to  have  only  read
     permissions.  The  ACL mask entry is a quick way to limit or
     open access to all the user and group entries in an ACL. For
     example,  by changing the mask entry to read/write, both the
     file group owner and user shea  would  be  given  read/write
     access.
     Example 3: Setting the same ACL on two files
     The following example sets the same ACL on file abc  as  the
     file xyz.
     getfacl xyz | setfacl -f - abc
其实Linux系统中有许多功能我还没有用到,因为没有这个需求,呵呵
 

Linux ACL 体验 
 
  文档选项
  打印本页
 
   将此页作为电子邮件发送
 
 
 
级别: 初级
高 延斌 (), 软件工程师,WPLC部门,IBM中国软件开发中心

2006 年 6 月 22 日
在安全管理日益重要的今天,传统的 Unix 文件系统的 UGO 权限管理方式已经无法满足日常系统管理工作的需要。而 ACL 机制逐渐成为主流的权限管理方式。本文主要介绍了在基于 Linux2.6 内核的发行版 Fedora Core 上进行的一些 ACL 基本功能的实验。
ACL 简介
用户权限管理始终是 Unix 系统管理中最重要的环节。大家对 Linux/Unix 的 UGO 权限管理方式一定不陌生,还有最常用的 chmod 命令。为了实现一些比较复杂的权限管理,往往不得不创建很多的组,并加以详细的记录和区分(很多时候就是管理员的噩梦)。可以针对某一个用户对某一文件指定一个权限,恐怕管理员都期待的功能。比如对某一个特定的文件,用户A可以读取,用户B所在的组可以修改,惟独用户B不可以……。于是就有了IEEE POSIX 1003.1e这个ACL的标准。所谓ACL,就是Access Control List,一个文件/目录的访问控制列表,可以针对任意指定的用户/组分配RWX权限。现在主流的商业Unix系统都支持ACL。FreeBSD也提供了对ACL的支持。Linux在这个方面也不会落后,从2.6版内核开始支持ACL。
 
 

 回页首
 
 
准备工作
支持ACL需要内核和文件系统的支持。现在2.6内核配合EXT2/EXT3, JFS, XFS, ReiserFS等文件系统都是可以支持ACL的。用自己工作用的物理分区体验ACL,总是不明智的行为。万一误操作导致分区的损坏,造成数据的丢失,损失就大了。作一个loop设备是个安全的替代方法。这样不需要一个单独的分区,也不需要很大的硬盘空间,大约有个几百KB就足够进行我们的体验了。OK,下面我使用Fedora Core 5和Ext3文件开始对Linux的ACL的体验。
首先创建一个512KB的空白文件:

[root@FC3-vm opt]#  dd if=/dev/zero of=/opt/testptn count=512
512+0 records in
512+0 records out
 

和一个loop设备联系在一起:

[root@FC3-vm opt]#  losetup /dev/loop0 /opt/testptn
 

创建一个EXT2的文件系统:

[root@FC3-vm opt]#  mke2fs /dev/loop0
mke2fs 1.35 (28-Feb-2004)
max_blocks 262144, rsv_groups = 32, rsv_gdb = 0
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
32 inodes, 256 blocks
12 blocks (4.69%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
32 inodes per group
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
 

挂载新建的文件系统(注意mount选项里的acl标志,我们靠它来通知内核我们需要在这个文件系统中使用ACL):

[root@FC3-vm opt]#  mount -o rw,acl /dev/loop0 /mnt
[root@FC3-vm opt]#  cd /mnt
[root@FC3-vm mnt]#  ls
lost+found
 

现在我已经得到了一个小型的文件系统。而且是支持ACL的。并且即使彻底损坏也不会影响硬盘上其他有价值的数据。可以开始我们的ACL体验之旅了。
 
 

 回页首
 
 
体验1 - ACL的基本操作:添加和修改
我首先新建一个文件作为实施ACL的对象:

[root@FC3-vm mnt]#  touch file1
[root@FC3-vm mnt]#  ls -l file1
-rw-r--r-- 1 root root     7 Dec 11 00:28 file1
 

然后看一下这个文件缺省的ACL,这时这个文件除了通常的UGO的权限之外,并没有ACL:

[root@FC3-vm mnt]#  getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
group::r--
other::r-
 

*注意:即使是不支持ACL的情况下,getfacl仍然能返回一个这样的结果。不过setfacl是不能工作的。
下面添加几个用户和组,一会我将使用ACL赋予他们不同的权限:

[root@FC3-vm mnt]#  groupadd testg1
[root@FC3-vm mnt]#  useradd testu1
[root@FC3-vm mnt]#  useradd testu2
[root@FC3-vm mnt]#  usermod -G testg1 testu1
 

现在我们看看testu1能做什么:

[root@FC3-vm mnt]# su testu1
[testu1@FC3-vm mnt]$ echo "testu1" >> file1
bash: file1: Permission denied
 

失败了。因为file1并不允许除了root以外的用户写。我们现在就通过修改file1的ACL赋予testu1足够的权限:

[root@FC3-vm mnt]# setfacl -m u:testu1:rw file1
[root@FC3-vm mnt]# su testu1
[testu1@FC3-vm mnt]$ echo "testu1" >> file1
[testu1@FC3-vm mnt]$ cat file1
testu1
 

修改成功了,用户testu1可以对file1做读写操作了。我们来看一下file1的ACL:

[testu1@FC3-vm mnt]$ getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:testu1:rw-
group::r--
mask::rw-
other::r-
 

我们ls看一下:

[root@FC3-vm mnt]# ls -l file1
-rw-rw-r--+ 1 root root     7 Dec 11 00:28 file1
 

可以看到那个"+"了么?就在通常我们看到的权限位的旁边。这个说明file1设置了ACL, 接下来我们修改一下testu1的权限,同时给testg1这个组以读的权限:

[root@FC3-vm mnt]# setfacl -m u:testu1:rwx,g:testg1:r file1
[root@FC3-vm mnt]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:testu1:rwx
group::r--
group:testg1:r--
mask::rwx
other::r-
 

可以看到设置后的权限,testu1已经有了执行的权限,而testg1这个组也获得了读取文件内容的权限。也许有人已经注意到了两个问题:首先,file1的组权限从r--变成了rw-。其次,mask是什么?为什么也变化了呢?我们先从mask说起。如果说acl的优先级高于UGO,那么mask就是一个名副其实的最后一道防线。它决定了一个用户/组能够得到的最大的权限。这样我们在不破坏已有ACL的定义的基础上,可以临时提高或是降低安全级别:

[root@FC3-vm mnt]# setfacl -m mask::r file1
[root@FC3-vm mnt]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:testu1:rwx                 #effective:r--
group::r--
group:testg1:r--
mask::r--
other::r--
[root@FC3-vm mnt]# ls -l file1
-rw-r--r--+ 1 root root 7 Dec 11 00:28 file1
 

在testu1对应的ACL项的后边出现了effective的字样,这是实际testu1得到的权限。Mask只对其他用户和组的权限有影响,对owner和other的权限是没有任何影响的。执行ls的结果也显示UGO的设置也有了对应的变化。因为在使用了ACL的情况下,group的权限显示的就是当前的mask。通常我们把mask设置成rwx,以不阻止任何的单个ACL项。
*需要注意的是,每次修改或添加某个用户或组的ACL项的时候,mask都会随之修改以使最新的修改能够真正生效。所以如果需要一个比较严格的mask的话,可能需要每次都重新设置一下mask。
 
 

 回页首
 
 
体验2 - ACL的其他功能:删除和覆盖
我们来看一下其他的ACL操作。首先如何删除已有的ACL项呢?

[root@FC3-vm mnt]# setfacl -x g:testg1 file1
[root@FC3-vm mnt]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:testu1:rwx
group::r--
mask::rwx
other::r--
 

我们看到testg1的权限已经被去掉了。如果需要去掉所有的ACL可以用-b选项。所有的ACL项都会被去掉。

[root@FC3-vm mnt]# setfacl -b file1
[root@FC3-vm mnt]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
group::r--
other::r--
 

我们可以用--set 设置一些新的ACL项,并把原有的ACL项全部都覆盖掉。和-m不同,-m选项只是修改已有的配置或是新增加一些。--set选项会把原有的ACL项都删除,用新的替代,需要注意的是一定要包含UGO的设置,不能象-m一样只是添加ACL就可以了。比如下边这一段:

[root@FC3-vm mnt]# setfacl --set u::rw,u:testu1:rw,g::r,o::- file1
[root@FC3-vm mnt]# getfacl file1
# file: file1
# owner: root
# group: root
user::rw-
user:testu1:rw-
group::r--
mask::rw-
other::---
 

o::-是另一个需要注意的地方。其实完整的写法是other::---,正如u::rw的完整写法是user::rw-。通常我们可以把"-"省略,但是当权限位只包含"-"时,必须至少保留一个。如果写成了o::,就会出现错误。
如果希望对目录下的所有子目录都设置同样的ACL,可以使用-R参数:

[root@FC3-vm mnt]# setfacl --set u::rw,u:testu1:rw,g::r,o::- dir1
 

如果希望能从一个文件来读入ACL,并修改当前的文件的ACL,可以用-M参数:

[root@FC3-vm mnt]# cat test.acl
user:testu1:rw-
user:testu2:rw-
group:testg1:r--
group:testg2:r--
mask::rw-
other::---
 
 
 

 回页首
 
 
体验3 - 目录的默认ACL
如果我们希望在一个目录中新建的文件和目录都使用同一个预定的ACL,那么我们可以使用默认(Default) ACL。在对一个目录设置了默认的ACL以后,每个在目录中创建的文件都会自动继承目录的默认ACL作为自己的ACL。用setfacl的-d选项就可以做到这一点:

[root@FC3-vm mnt]# setfacl -d --set g:testg1:rwx dir1
[root@FC3-vm mnt]# getfacl dir1
# file: dir1
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::r-x
default:group:testg1:rwx
default:mask::rwx
default:other::r-x
 

可以看到默认ACL已经被设置了。建立一个文件试试:

[root@FC3-vm mnt]# touch dir1/file1
[root@FC3-vm mnt]# getfacl dir1/file1
# file: dir1/file1
# owner: root
# group: root
user::rw-
group::r-x                      #effective:r--
group:testg1:rwx                #effective:rw-
mask::rw-
other::r--
 

file1自动继承了dir1对testg1设置的ACL。只是由于mask的存在使得testg1只能获得rw-权限。
 
 

 回页首
 
 
体验4 - 备份和恢复ACL
主要的文件操作命令cp和mv都支持ACL,只是cp命令需要加上-p 参数。但是tar等常见的备份工具是不会保留目录和文件的ACL信息的。 如果希望备份和恢复带有ACL的文件和目录,那么可以先把ACL备份到一个文件里。以后用--restore选项来回复这个文件中保存的ACL信息:

[root@FC3-vm mnt]# getfacl -R dir1 > dir1.acl
[root@FC3-vm mnt]# ls -l dir1.acl
total 16
-rw-r--r--  1 root root   310 Dec 12 21:10 dir1.acl
 

我们用-b选项删除所有的ACL数据,来模拟从备份中回复的文件和目录:

[root@FC3-vm mnt]# setfacl -R -b dir1
[root@FC3-vm mnt]# getfacl -R dir1
# file: dir1
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
# file: dir1/file1
# owner: root
# group: root
user::rw-
group::r--
other::r--
 

现在我们从dir1.acl中恢复被删除的ACL信息:

[root@FC3-vm mnt]# setfacl --restore dir1.acl
[root@FC3-vm mnt]# getfacl -R dir1
# file: dir1
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::r-x
default:group:testg1:rwx
default:mask::rwx
default:other::r-x
# file: dir1/file1
# owner: root
# group: root
user::rw-
group::r-x                      #effective:r--
group:testg1:rwx                #effective:rw-
mask::rw-
other::r--
 
 
 

 回页首
 
 
结语
ACL 的引入使得大规模的复杂权限管理可以很容易的在 Linux 上实现。对于 /home 这样存放大量用户文件的分区,可以做到更有效的管理。但是我们也看到在备份工具等方面的欠缺,好在 FC2 中已经开始包含了 star 这样的支持 ACL 的备份工具,虽然还是 alpha 版。
在单个文件的 ACL 条目的数量上,不同的文件系统有不同的限制。Ext2 和 Ext3 只能支持每个文件 25 个 ACL 条目。ReiserFS 和 JFS 可以支持超过 8,000 个条目。这个方面 Ext* 文件系统还需要加强。
无论多么复杂的系统中,文件系统的权限管理都是最基础的内容。而 Linux 对 ACL的支持,无疑是一把管理海量用户系统的利器,对 Linux 在大规模的企业级应用中更方便的发挥更大的作用添了一把火。
 
阅读(4175) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~