Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1276903
  • 博文数量: 554
  • 博客积分: 10425
  • 博客等级: 上将
  • 技术积分: 7555
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 09:49
文章分类

全部博文(554)

文章存档

2012年(1)

2011年(1)

2009年(8)

2008年(544)

分类:

2008-04-14 11:41:00


新SolarisACL模型
第7 章• 使用ACL保护ZFS 文件101
表7–1ACL项类型(续)
ACL 项类型说明
everyone@ 指定向不与其他任何ACL项匹配的任何用户或组授予的访问权限。
user 通过用户名指定向对象的其他用户授予的访问权限。必须包括ACL 项ID,
其中包含用户名或用户ID。如果该值不是有效的数字UID 或用户名,则该
ACL项的类型无效。
group 通过组名指定向对象的其他组授予的访问权限。必须包括ACL 项ID,其中
包含组名或组ID。如果该值不是有效的数字UID 或组名,则该ACL项的类
型无效。
下表介绍了ACL访问权限。
表7–2ACL访问权限
访问权限缩写访问权限说明
add_file w 向目录中添加新文件的权限。
add_subdirectory p 在目录中创建子目录的权限。
append_data p 对文件修改文件内容的权限。
delete d 删除文件的权限。
delete_child D 删除目录中的文件或目录的权限。
execute x 执行文件或搜索目录内容的权限。
list_directory r 列出目录内容的权限。
read_acl c 读取ACL的权限(ls)。
read_attributes a 读取文件的基本属性(非ACL)的权限。将基本属性视为状
态级别属性。允许此访问掩码位意味着该实体可以执行ls(1)
和stat(2)。
read_data r 读取文件内容的权限。
read_xattr R 读取文件的扩展属性或在文件的扩展属性目录中执行查找的
权限。
synchronize s 占位符,此时不使用。
write_xattr A 创建扩展属性或向扩展属性目录进行写入的权限。
向用户授予此权限意味着用户可为文件创建扩展属性目录。
属性文件的权限可以控制用户对属性的访问。
write_data w 修改或替换文件内容的权限。
write_attributes W 将与文件或目录关联的时间更改为任意值的权限。
新SolarisACL模型
102 Solaris ZFS 管理指南• 2006 年10 月
表7–2ACL访问权限(续)
访问权限缩写访问权限说明
write_acl C 编写ACL的权限或使用chmod 命令修改ACL的能力。
write_owner o 更改文件的属主或组的权限,或者对文件执行chown 或chgrp
命令的能力。
获取文件拥有权的权限或将文件的组拥有权更改为由用户所
属组的权限。如果要将文件或组的拥有权更改为任意用户或
组,则需要PRIV_FILE_CHOWN 权限。
ACL继承
使用ACL继承的目的是使新创建的文件或目录可以继承其本来要继承的ACL,但不忽略父
目录的现有权限位。
缺省情况下,不会传播ACL。如果设置某个目录的显式ACL,则该显式ACL不会继承到任
何后续目录。必须对文件或目录指定ACL的继承。
下表介绍了可选的继承标志。
表7–3ACL继承标志
继承标志缩写继承标志说明
file_inherit f 仅将ACL从父目录继承到该目录中的文件。
dir_inherit d 仅将ACL从父目录继承到该目录的子目录。
inherit_only i 从父目录继承ACL,但仅适用于新创建的文件或子目录,
而不适用于该目录自身。该标志要求使用file_inherit 标志
或dir_inherit 标志,或同时使用两者来表示要继承的内
容。
no_propagate n 仅将ACL从父目录继承到该目录的第一级内容,而不是
第二级或后续内容。该标志要求使用file_inherit 标志或
dir_inherit 标志,或同时使用两者来表示要继承的内容。
此外,还可以使用aclinherit 文件系统属性对文件系统设置更为严格或更为宽松的缺省
ACL继承策略。有关更多信息,请参见下一节。
ACL属性模式
ZFS 文件系统包括与ACL相关的两种属性模式:
 aclinherit-此属性可确定ACL继承的行为。包括以下属性值:
 discard-对于新对象,创建文件或目录时不会继承任何ACL项。文件或目录的ACL
等效于该文件或目录的权限模式。
新SolarisACL模型
第7 章• 使用ACL保护ZFS 文件103
 noallow-对于新对象,仅继承访问类型为deny 的可继承ACL项。
 secure-对于新对象,继承ACL项时将删除write_owner 和write_acl 权限。
 passthrough-对于新对象,将继承可继承的ACL项,并且不会对其进行更改。实际
上,此模式会禁用secure 模式。
aclinherit 的缺省模式为secure。
 aclmode-每次chmod 命令修改文件或目录的模式或最初创建文件时,此属性都将修改
ACL的行为。包括以下属性值:
 discard-删除所有ACL项,但定义文件或目录的模式所需的项除外。
 groupmask-除非用户项与文件或目录的属主具有相同的UID,否则将减少用户或组
的ACL权限,以使其不会大于组权限位。然后,减少ACL权限,以使其不会大于属
主权限位。
 passthrough-对于新对象,将继承可继承的ACL项,并且不会对其进行更改。
aclmode 属性的缺省模式为groupmask。
设置ZFS 文件的ACL
正如ZFS 所实现的那样,ACL由ACL项的数组构成。ZFS 提供了一个纯ACL模型,其中所
有文件都包括ACL。通常,ACL很普通,因为它仅表示传统的UNIX owner/group/other
项。
ZFS 文件仍然具有权限位和模式,但这些值大部分是ACL所表示内容的高速缓存。因此,
如果更改文件的权限,该文件的ACL也会相应地更新。此外,如果删除授予用户对文件或
目录的访问权限的显式ACL,则由于该文件或目录的权限位会将访问权限授予组或各用
户,因此该用户仍可访问这一文件或目录。所有访问控制决策都由文件或目录的ACL中表
示的权限来管理。
对于ZFS 文件,ACL访问权限的主要规则如下:
 ZFS 按照ACL项在ACL中的排列顺序从上至下对其进行处理。
 仅处理具有与访问权限的请求者匹配的“对象”的ACL项。
 一旦授予允许权限,同一ACL权限集当中的后续ACL拒绝项即不能拒绝此权限。
 无条件地授予文件属主write_acl 权限,即使显式拒绝此权限时也是如此。否则,将拒
绝仍未指定的所有权限。
如果拒绝权限或缺少访问权限,权限子系统将确定为文件属主或超级用户授予的访问请
求。此机制可以防止文件属主无法访问其文件,并允许超级用户修改文件以进行恢复。
如果设置某个目录的显式ACL,则该目录的子目录不会自动继承该ACL。如果设置了显式
ACL并希望目录的子目录将其继承,则必须使用ACL继承标志。有关更多信息,请参见表
7–3 和第115 页中的“以详细格式对ZFS 文件设置ACL继承”。
创建新文件时,根据umask 值将应用类似如下的缺省的普通ACL:
设置ZFS 文件的ACL
104 Solaris ZFS 管理指南• 2006 年10 月
$ ls -v file.1
-r--r--r-- 1 root root 206663 May4 11:52 file.1
0:owner@:write_data/append_data/execute:deny
1:owner@:read_data/write_xattr/write_attributes/write_acl/write_owner
:allow
2:group@:write_data/append_data/execute:deny
3:group@:read_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
请注意,本示例中的每个用户类别(owner@, group@, everyone@) 都有两个ACL项。一项用于
deny 权限,另一项用于allow 权限。
此文件ACL的说明如下:
0:owner@ 拒绝属主对文件的执行权限(execute:deny)。
1:owner@ 属主可以读取和修改文件的内容(read_data/write_data/append_data)。属
主还可以修改文件的属性,如时间标记、扩展属性和ACL
(write_xattr/write_attributes/write_acl)。此外,属主还可以修改文件
的拥有权(write_owner:allow)。
2:group@ 拒绝组对文件的修改和执行权限
(write_data/append_data/execute:deny)。
3:group@ 授予组对文件的读取权限(read_data:allow)。
4:everyone@ 拒绝用户或组之外的所有用户执行或修改文件内容和修改文件的任何属性
的权限(write_data/append_data/write_xattr/execute/
write_attributes/write_acl/write_owner:deny)。
5:everyone@ 向用户或组之外的所有用户授予对文件和文件属性的读取权限
(read_data/read_xattr/read_attributes/read_acl/
synchronize:allow)。synchronize 访问权限当前未实现。
创建新目录时,根据umask 值,缺省目录ACL将类似如下:
$ ls -dv dir.1
设置ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件105
drwxr-xr-x 2 root root 2 Feb 23 10:37 dir.1
0:owner@::deny
1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
2:group@:add_file/write_data/add_subdirectory/append_data:deny
3:group@:list_directory/read_data/execute:allow
4:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
5:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
此目录ACL的说明如下:
0:owner@ 目录的属主拒绝列表为空(::deny)。
1:owner@ 属主可以读取和修改目录内容
(list_directory/read_data/add_file/write_data/
add_subdirectory/append_data),搜索内容(execute) 并修改文件的属
性,如时间标记、扩展属性和ACL
(write_xattr/write_attributes/write_acl)。此外,属主还可以修改目录
的拥有权(write_owner:allow)。
2:group@ 组不能添加或修改目录内容
(add_file/write_data/add_subdirectory/append_data
:deny)。
3:group@ 组可以列出并读取目录内容。此外,组还具有搜索目录内容的执行权限
(list_directory/read_data/execute:allow)。
4:everyone@ 对用户或组之外的所有用户拒绝添加或修改目录内容的权限
(add_file/write_data/add_subdirectory/append_data)。此外,还会拒绝
修改目录的任何属性的权限(write_xattr
/write_attributes/write_acl/write_owner:deny)。
5:everyone@ 向用户或组之外的所有用户授予对目录内容和目录属性的读取和执行权限
(list_directory/read_data/read_xattr/execute/read_
attributes/read_acl/synchronize:allow)。synchronize 访问权限当前未实
现。
设置ZFS 文件的ACL
106 Solaris ZFS 管理指南• 2006 年10 月
以详细格式设置和显示ZFS 文件的ACL
可以使用chmod 命令修改ZFS 文件的ACL。以下用于修改ACL的chmod 语法使用acl 规范来
确定ACL的格式。有关acl 规范的说明,请参见第100 页中的“ACL设置语法的说明”。
 添加ACL项
 为用户添加ACL项
% chmod A+acl-specification filename
 按index-ID 添加ACL项
% chmod Aindex-ID+acl-specification filename
此语法可用于在指定的index-ID 位置插入新的ACL项。
 替换ACL项
% chmod Aindex-ID=acl-specification filename
% chmod A=acl-specification filename
 删除ACL项
 按index-ID 删除ACL项
% chmod Aindex-ID- filename
 由用户删除ACL项
% chmod A-acl-specification filename
 从文件中删除所有显式ACE
% chmod A- filename
详细ACL信息是通过使用ls -v 命令来显示的。例如:
# ls -v file.1
-rw-r--r-- 1 root root 206663 Feb 16 11:00 file.1
0:owner@:execute:deny
1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
2:group@:write_data/append_data/execute:deny
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件107
3:group@:read_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
有关使用缩写ACL格式的信息,请参见第127 页中的“以缩写格式设置和显示ZFS 文件的
ACL”。
示例7–1 修改ZFS 文件的普通ACL
本节提供了设置和显示普通ACL的示例。
在以下示例中,普通ACL存在于file.1 中:
# ls -v file.1
-rw-r--r-- 1 root root 206663 Feb 16 11:00 file.1
0:owner@:execute:deny
1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
2:group@:write_data/append_data/execute:deny
3:group@:read_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
在以下示例中,为group@ 授予了write_data 权限。
# chmod A2=group@:append_data/execute:deny file.1
# chmod file.1
# ls -v file.1
以详细格式设置和显示ZFS 文件的ACL
108 Solaris ZFS 管理指南• 2006 年10 月
示例7–1 修改ZFS 文件的普通ACL (续)
-rw-rw-r-- 1 root root 206663 May3 16:36 file.1
0:owner@:execute:deny
1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
2:group@:append_data/execute:deny
3:group@:read_data/write_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
在以下示例中,对file.1 的权限重新设置为644。
# chmod 644 file.1
# ls -v file.1
-rw-r--r-- 1 root root 206663 May3 16:36 file.1
0:owner@:execute:deny
1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
2:group@:write_data/append_data/execute:deny
3:group@:read_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件109
示例7–1 修改ZFS 文件的普通ACL (续)
:allow
示例7–2 设置ZFS 文件的显式ACL
本节提供了设置和显示普通ACL的示例。
在以下示例中,为用户gozer 添加了对test.dir 目录的read_data/execute 权限。
# chmod A+user:gozer:read_data/execute:allowtest.dir
# ls -dv test.dir
drwxr-xr-x+ 2 root root 2 Feb 16 11:12 test.dir
0:user:gozer:list_directory/read_data/execute:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
3:group@:add_file/write_data/add_subdirectory/append_data:deny
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
在以下示例中,为用户gozer 删除了read_data/execute 权限。
# chmod A0- test.dir
# ls -dv test.dir
drwxr-xr-x 2 root root 2 Feb 16 11:12 test.dir
0:owner@::deny
以详细格式设置和显示ZFS 文件的ACL
110 Solaris ZFS 管理指南• 2006 年10 月
示例7–2 设置ZFS 文件的显式ACL (续)
1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
2:group@:add_file/write_data/add_subdirectory/append_data:deny
3:group@:list_directory/read_data/execute:allow
4:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
5:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
示例7–3 与ZFS 文件权限的ACL交互
以下ACL示例说明了如何在设置显式ACL和随后更改文件或目录的权限位之间进行交互。
在以下示例中,普通ACL存在于file.2 中:
# ls -v file.2
-rw-r--r-- 1 root root 2703 Feb 16 11:16 file.2
0:owner@:execute:deny
1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
2:group@:write_data/append_data/execute:deny
3:group@:read_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件111
示例7–3 与ZFS 文件权限的ACL交互(续)
:allow
在以下示例中,将从everyone@ 中删除ACL允许权限。
# chmod A5- file.2
# ls -v file.2
-rw-r----- 1 root root 2703 Feb 16 11:16 file.2
0:owner@:execute:deny
1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
2:group@:write_data/append_data/execute:deny
3:group@:read_data:allow
4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
在此输出中,文件的权限位从655 重置为650。为everyone@ 删除ACL允许权限时,已有效
地从文件的权限位中删除了对everyone@ 的读取权限。
在以下示例中,现有ACL将替换为对everyone@ 的read_data/write_data 权限。
# chmod file.3
# ls -v file.3
-rw-rw-rw-+ 1 root root 1532 Feb 16 11:18 file.3
0:everyone@:read_data/write_data:allow
在此输出中,chmod 语法有效地将现有ACL中的read_data/write_data:allow 权限替换为对
属主、组和everyone@ 的读取/写入权限。在此模型中,everyone@ 用于指定对任何用户或组
的访问权限。由于不存在用以覆盖属主和组的权限的owner@ 或group@ ACL项,因此权限位
会设置为666。
在以下示例中,现有ACL将替换为对用户gozer 的读取权限。
以详细格式设置和显示ZFS 文件的ACL
112 Solaris ZFS 管理指南• 2006 年10 月
示例7–3 与ZFS 文件权限的ACL交互(续)
# chmod A=user:gozer:read_data:allowfile.3
# ls -v file.3
----------+ 1 root root 1532 Feb 16 11:18 file.3
0:user:gozer:read_data:allow
在此输出中,文件权限计算结果为000,这是因为不存在对应owner@、group@ 或everyone@
的ACL项,这些项用于表示文件的传统权限组成部分。文件属主可通过重置权限(和
ACL)来解决此问题,如下所示:
# chmod 655 file.3
# ls -v file.3
-rw-r-xr-x+ 1 root root 0 Mar 8 13:24 file.3
0:user:gozer::deny
1:user:gozer:read_data:allow
2:owner@:execute:deny
3:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
4:group@:write_data/append_data:deny
5:group@:read_data/execute:allow
6:everyone@:write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:deny
7:everyone@:read_data/read_xattr/execute/read_attributes/read_acl
/synchronize:allow
示例7–4 恢复ZFS 文件的普通ACL
可以使用chmod 命令来删除文件或目录的所有显式ACL。
在以下示例中,test5.dir 中存在2 个显式ACE:
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件113
示例7–4 恢复ZFS 文件的普通ACL (续)
# ls -dv test5.dir
drwxr-xr-x+ 2 root root 2 Feb 16 11:23 test5.dir
0:user:gozer:read_data:file_inherit:deny
1:user:lp:read_data:file_inherit:deny
2:owner@::deny
3:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
4:group@:add_file/write_data/add_subdirectory/append_data:deny
5:group@:list_directory/read_data/execute:allow
6:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
7:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
在以下示例中,删除了用户gozer 和lp 的显式ACL。剩余的ACL包含用于owner@、group@
和everyone@ 的六个缺省值。
# chmod A- test5.dir
# ls -dv test5.dir
drwxr-xr-x 2 root root 2 Feb 16 11:23 test5.dir
0:owner@::deny
1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
以详细格式设置和显示ZFS 文件的ACL
114 Solaris ZFS 管理指南• 2006 年10 月
示例7–4 恢复ZFS 文件的普通ACL (续)
2:group@:add_file/write_data/add_subdirectory/append_data:deny
3:group@:list_directory/read_data/execute:allow
4:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
5:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
以详细格式对ZFS 文件设置ACL继承
可以确定如何在文件和目录中继承或不继承ACL。缺省情况下,不会传播ACL。如果设置
某个目录的显式ACL,则任何后续目录都不会继承该ACL。必须对文件或目录指定ACL的
继承。
此外,还提供了可在文件系统中进行全局设置的两个ACL属性:aclinherit 和aclmode。缺
省情况下,aclinherit 设置为secure,aclmode 设置为groupmask。
有关更多信息,请参见第103 页中的“ACL继承”。
示例7–5 缺省ACL继承
缺省情况下,ACL不通过目录结构传播。
在以下示例中,为用户gozer 应用了针对test.dir 的显式ACE
read_data/write_data/execute。
# chmod A+user:gozer:read_data/write_data/execute:allow test.dir
# ls -dv test.dir
drwxr-xr-x+ 2 root root 2 Feb 17 14:45 test.dir
0:user:gozer:list_directory/read_data/add_file/write_data/execute:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件115
示例7–5 缺省ACL继承(续)
/write_owner:allow
3:group@:add_file/write_data/add_subdirectory/append_data:deny
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
如果创建了test.dir 子目录,则不会传播用户gozer 的ACE。如果对sub.dir 的权限授予用
户gozer 作为文件属主、组成员或everyone@ 进行访问的权限,则该用户只能访问
sub.dir。
# mkdir test.dir/sub.dir
# ls -dv test.dir/sub.dir
drwxr-xr-x 2 root root 2 Feb 17 14:46 test.dir/sub.dir
0:owner@::deny
1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
2:group@:add_file/write_data/add_subdirectory/append_data:deny
3:group@:list_directory/read_data/execute:allow
4:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
5:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
以详细格式设置和显示ZFS 文件的ACL
116 Solaris ZFS 管理指南• 2006 年10 月
示例7–6 对文件和目录授予ACL继承
以下一系列示例标识了设置file_inherit 标志时应用的文件和目录的ACE。
在以下示例中,为用户gozer 添加了对test.dir 目录中的文件的read_data/write_data 权
限,以便该用户对于任何新创建的文件都具有读取访问权限。
# chmod A+user:gozer:read_data/write_data:file_inherit:allow test2.dir
# ls -dv test2.dir
drwxr-xr-x+ 2 root root 2 Feb 17 14:47 test2.dir
0:user:gozer:read_data/write_data:file_inherit:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
3:group@:add_file/write_data/add_subdirectory/append_data:deny
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
在以下示例中,用户gozer 的权限应用于新创建的test2.dir/file.2 文件。向ACL继承授予
read_data:file_inherit:allow 意味着用户gozer 可以读取任何新创建的文件的内容。
# touch test2.dir/file.2
# ls -v test2.dir/file.2
-rw-r--r--+ 1 root root 0 Feb 17 14:49 test2.dir/file.2
0:user:gozer:write_data:deny
1:user:gozer:read_data/write_data:allow
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件117
示例7–6 对文件和目录授予ACL继承(续)
2:owner@:execute:deny
3:owner@:read_data/write_data/append_data/write_xattr/write_attributes+
/write_acl/write_owner:allow
4:group@:write_data/append_data/execute:deny
5:group@:read_data:allow
6:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
7:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
由于此文件的aclmode 设置为缺省模式groupmask,因此用户gozer 对file.2 不具有
write_data 权限,这是因为该文件的组权限不允许使用此权限。
请注意,设置file_inherit 或dir_inherit 标志时所应用的inherit_only 权限用来通过目
录结构传播ACL。因此,除非用户gozer 是文件的属主或文件所属组的成员,否则仅授予或
拒绝该用户everyone@ 权限中的权限。例如:
# mkdir test2.dir/subdir.2
# ls -dv test2.dir/subdir.2
drwxr-xr-x+ 2 root root 2 Feb 17 14:50 test2.dir/subdir.2
0:user:gozer:list_directory/read_data/add_file/write_data:file_inherit
/inherit_only:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
3:group@:add_file/write_data/add_subdirectory/append_data:deny
以详细格式设置和显示ZFS 文件的ACL
118 Solaris ZFS 管理指南• 2006 年10 月
示例7–6 对文件和目录授予ACL继承(续)
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
以下一系列示例标识了同时设置file_inherit 和dir_inherit 标志时所应用的文件和目录的
ACL。
在以下示例中,向用户gozer 授予了继承用于新创建的文件和目录的读取、写入和执行权
限。
# chmod A+user:gozer:read_data/write_data/execute:file_inherit/dir_inherit:allow test3.dir
# ls -dv test3.dir
drwxr-xr-x+ 2 root root 2 Feb 17 14:51 test3.dir
0:user:gozer:list_directory/read_data/add_file/write_data/execute
:file_inherit/dir_inherit:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
3:group@:add_file/write_data/add_subdirectory/append_data:deny
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件119
示例7–6 对文件和目录授予ACL继承(续)
/read_acl/synchronize:allow
# touch test3.dir/file.3
# ls -v test3.dir/file.3
-rw-r--r--+ 1 root root 0 Feb 17 14:53 test3.dir/file.3
0:user:gozer:write_data/execute:deny
1:user:gozer:read_data/write_data/execute:allow
2:owner@:execute:deny
3:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
4:group@:write_data/append_data/execute:deny
5:group@:read_data:allow
6:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
7:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
# mkdir test3.dir/subdir.1
# ls -dv test3.dir/subdir.1
drwxr-xr-x+ 2 root root 2 May4 15:00 test3.dir/subdir.1
0:user:gozer:list_directory/read_data/add_file/write_data/execute
:file_inherit/dir_inherit/inherit_only:allow
1:user:gozer:add_file/write_data:deny
2:user:gozer:list_directory/read_data/add_file/write_data/execute:allow
以详细格式设置和显示ZFS 文件的ACL
120 Solaris ZFS 管理指南• 2006 年10 月
示例7–6 对文件和目录授予ACL继承(续)
3:owner@::deny
4:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
5:group@:add_file/write_data/add_subdirectory/append_data:deny
6:group@:list_directory/read_data/execute:allow
7:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
8:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
在以下示例中,由于group@ 和everyone@ 的父目录的权限位拒绝写入和执行权限,因此拒
绝了用户gozer 的写入和执行权限。缺省的aclmode 属性为secure,这意味着未继承
write_data 和execute 权限。
在以下示例中,向用户gozer 授予了继承用于新创建的文件的读取、写入和执行权限,但未
将这些权限传播给该目录的后续内容。
# chmod A+user:gozer:read_data/write_data/execute:file_inherit/no_propagate:allow test4.dir
# ls -dv test4.dir
drwxr-xr-x+ 2 root root 2 Feb 17 14:54 test4.dir
0:user:gozer:list_directory/read_data/add_file/write_data/execute
:file_inherit/no_propagate:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件121
示例7–6 对文件和目录授予ACL继承(续)
3:group@:add_file/write_data/add_subdirectory/append_data:deny
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
如以下示例所示,创建新子目录时,用户gozer 对文件的read_data/write_data/execute 权
限不会传播给新的sub4.dir 目录。
# mkdir test4.dir/sub4.dir
# ls -dv test4.dir/sub4.dir
drwxr-xr-x 2 root root 2 Feb 17 14:57 test4.dir/sub4.dir
0:owner@::deny
1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
2:group@:add_file/write_data/add_subdirectory/append_data:deny
3:group@:list_directory/read_data/execute:allow
4:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
5:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
如以下示例所示,gozer 对文件的read_data/write_data/execute 权限不会传播给新创建的
文件。
以详细格式设置和显示ZFS 文件的ACL
122 Solaris ZFS 管理指南• 2006 年10 月
示例7–6 对文件和目录授予ACL继承(续)
# touch test4.dir/file.4
# ls -v test4.dir/file.4
-rw-r--r--+ 1 root root 0 May4 15:02 test4.dir/file.4
0:user:gozer:write_data/execute:deny
1:user:gozer:read_data/write_data/execute:allow
2:owner@:execute:deny
3:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
4:group@:write_data/append_data/execute:deny
5:group@:read_data:allow
6:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
7:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
示例7–7 ACL模式设置为Passthrough 时的ACL继承
如果tank/cindy 文件系统的aclmode 属性设置为passthrough,则用户gozer 将继承为新创
建的file.4 应用于test4.dir 的ACL,如下所示:
# zfs set aclmode=passthrough tank/cindy
# touch test4.dir/file.4
# ls -v test4.dir/file.4
-rw-r--r--+ 1 root root 0 Feb 17 15:15 test4.dir/file.4
0:user:gozer:read_data/write_data/execute:allow
1:owner@:execute:deny
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件123
示例7–7 ACL模式设置为Passthrough 时的ACL继承(续)
2:owner@:read_data/write_data/append_data/write_xattr/write_attributes
/write_acl/write_owner:allow
3:group@:write_data/append_data/execute:deny
4:group@:read_data:allow
5:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
6:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
此输出说明对父目录test4.dir 设置的
read_data/write_data/execute:allow:file_inherit/dir_inherit ACL会传递给用户
gozer。
示例7–8 ACL模式设置为Discard 时的ACL继承
如果将文件系统的aclmode 属性设置为discard,则目录的权限位更改时,可能会废弃
ACL。例如:
# zfs set aclmode=discard tank/cindy
# chmod A+user:gozer:read_data/write_data/execute:dir_inherit:allow test5.dir
# ls -dv test5.dir
drwxr-xr-x+ 2 root root 2 Feb 16 11:23 test5.dir
0:user:gozer:list_directory/read_data/add_file/write_data/execute
:dir_inherit:allow
1:owner@::deny
2:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
以详细格式设置和显示ZFS 文件的ACL
124 Solaris ZFS 管理指南• 2006 年10 月
示例7–8 ACL模式设置为Discard 时的ACL继承(续)
3:group@:add_file/write_data/add_subdirectory/append_data:deny
4:group@:list_directory/read_data/execute:allow
5:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
6:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
如果以后决定要加强目录的权限位,则会废弃显式ACL。例如:
# chmod 744 test5.dir
# ls -dv test5.dir
drwxr--r-- 2 root root 2 Feb 16 11:23 test5.dir
0:owner@::deny
1:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
2:group@:add_file/write_data/add_subdirectory/append_data/execute:deny
3:group@:list_directory/read_data:allow
4:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/execute/write_attributes/write_acl/write_owner:deny
5:everyone@:list_directory/read_data/read_xattr/read_attributes/read_acl
/synchronize:allow
示例7–9 ACL继承模式设置为Noallow 时的ACL继承
在以下示例中,设置了两个包含文件继承的显式ACL。一个ACL允许read_data 权限,一
个ACL拒绝read_data 权限。此示例还说明了如何可在同一chmod 命令中指定两个ACE。
以详细格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件125
示例7–9 ACL继承模式设置为Noallow 时的ACL继承(续)
# zfs set aclinherit=nonallowtank/cindy
# chmod A+user:gozer:read_data:file_inherit:deny,user:lp:read_data:file_inherit:allowtest6.dir
# ls -dv test6.dir
drwxr-xr-x+ 2 root root 2 May4 14:23 test6.dir
0:user:gozer:read_data:file_inherit:deny
1:user:lp:read_data:file_inherit:allow
2:owner@::deny
3:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
/append_data/write_xattr/execute/write_attributes/write_acl
/write_owner:allow
4:group@:add_file/write_data/add_subdirectory/append_data:deny
5:group@:list_directory/read_data/execute:allow
6:everyone@:add_file/write_data/add_subdirectory/append_data/write_xattr
/write_attributes/write_acl/write_owner:deny
7:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
/read_acl/synchronize:allow
如以下示例所示,创建新文件时,将废弃允许read_data 权限的ACL。
# touch test6.dir/file.6
# ls -v test6.dir/file.6
-rw-r--r--+ 1 root root 0 May4 13:44 test6.dir/file.6
0:user:gozer:read_data:deny
1:owner@:execute:deny
2:owner@:read_data/write_data/append_data/write_xattr/write_attributes
以详细格式设置和显示ZFS 文件的ACL
126 Solaris ZFS 管理指南• 2006 年10 月
示例7–9 ACL继承模式设置为Noallow 时的ACL继承(续)
/write_acl/write_owner:allow
3:group@:write_data/append_data/execute:deny
4:group@:read_data:allow
5:everyone@:write_data/append_data/write_xattr/execute/write_attributes
/write_acl/write_owner:deny
6:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
:allow
以缩写格式设置和显示ZFS 文件的ACL
可通过使用14 个唯一字母表示权限的缩写格式来设置和显示ZFS 文件的权限。表7–2 和表
7–3 中列出了表示缩写权限的字母。
可以使用ls -V 命令显示用于文件和目录的缩写ACL列表。例如:
# ls -V file.1
-rw-r--r-- 1 root root 206663 Feb 16 11:00 file.1






以下介绍了缩写的ACL输出:
owner@ 拒绝属主对文件的执行权限(x=execute)。
owner@ 属主可以读取和修改文件的内容(rw=read_data/write_data、
p=append_data)。属主还可以修改文件的属性,如时间标记、扩展属性和
以缩写格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件127
ACL(A=write_xattr、W=write_attributes、C=write_acl)。此外,属主还
可以修改文件的拥有权(O=write_owner)。
group@ 拒绝组对文件的修改和执行权限(rw=read_data/write_data、p=append_data
和x=execute)。
group@ 授予组对文件的读取权限(r=read_data)。
everyone@ 对用户或组之外的所有用户拒绝执行或修改文件内容以及修改文件的任何属
性的权限(w=write_data、x=execute、p=append_data、A=write_xattr、
W=write_attributes、C=write_acl 和o=write_owner)。
everyone@ 向用户或组之外的所有用户授予对文件和文件属性的读取权限
(r=read_data、a=append_data、R=read_xattr、c=read_acl 和
s=synchronize)。synchronize 访问权限当前未实现。
与详细ACL格式相比,缩写ACL格式具有以下优点:
 可将权限指定为chmod 命令的位置参数。
 可以删除用于标识无权限的连字符(-) 字符,并且只需指定必需的字母。
 可以同一方式设置权限和继承标志。
有关使用详细ACL格式的信息,请参见第107 页中的“以详细格式设置和显示ZFS 文件的
ACL”。
示例7–10 以缩写格式设置和显示ACL
在以下示例中,普通ACL存在于file.1 中:
# ls -V file.1
-rw-r-xr-x 1 root root 206663 Feb 16 11:00 file.1






在本示例中,为用户gozer 添加了对file.1 的read_data/execute 权限。
# chmod A+user:gozer:rx:allowfile.1
以缩写格式设置和显示ZFS 文件的ACL
128 Solaris ZFS 管理指南• 2006 年10 月
示例7–10 以缩写格式设置和显示ACL (续)
# ls -V file.1
-rw-r-xr-x+ 1 root root 206663 Feb 16 11:00 file.1
user:gozer:r-x-----------:------:allow






为用户gozer 添加相同权限的另一种方法是在特定位置(例如4)插入新ACL。这样,位于
位置4-6 的现有ACL将被下推。例如:
# chmod A4+user:gozer:rx:allowfile.1
# ls -V file.1
-rw-r-xr-x+ 1 root root 206663 Feb 16 11:00 file.1




user:gozer:r-x-----------:------:allow


在以下示例中,通过使用缩写ACL格式向用户gozer 授予了继承用于新创建的文件和目录
的读取、写入和执行权限。
以缩写格式设置和显示ZFS 文件的ACL
第7 章• 使用ACL保护ZFS 文件129
示例7–10 以缩写格式设置和显示ACL (续)
# chmod A+user:gozer:rwx:f:allow dir.1
# ls -dV dir.1
drwxr-xr-x+ 2 root root 2 Feb 23 10:37 dir.1
user:gozer:rwx-----------:f-----:allow






另外,还可以剪切ls -V 输出中的权限和继承标志并将其粘贴到缩写的chmod 格式中。例
如,要将用户gozer 对dir.1 的权限和继承标志复制给用户cindys,可将权限和继承标志
(rwx-----------:f-----:allow) 复制并粘贴到chmod 命令中。例如:
# chmod A+user:cindys:rwx-----------:f-----:allow dir.1
# ls -dV dir.1
drwxr-xr-x+ 2 root root 2 Feb 23 10:37 dir.1
user:cindys:rwx-----------:f-----:allow
user:gozer:rwx-----------:f-----:allow






以缩写格式设置和显示ZFS 文件的ACL
130 Solaris ZFS 管理指南• 2006 年10 月
ZFS 高级主题
本章介绍仿真卷、在安装了区域的Solaris 系统中使用ZFS、ZFS 备用根池以及ZFS 权限配置
文件。
本章包含以下各节:
 第131 页中的“仿真卷”
 第132 页中的“在安装了区域的Solaris 系统中使用ZFS”
 第136 页中的“ZFS 备用根池”
 第138 页中的“ZFS 权限配置文件”
仿真卷
仿真卷是表示块设备的数据集,其使用方式与任何块设备类似。ZFS 卷被标识为
/dev/zvol/{dsk,rdsk}/path 目录中的设备。
以下示例将创建5GB的ZFS 卷tank/vol。
# zfs create -V 5gb tank/vol
创建卷时,会自动将预留空间设置为卷的初始大小。预留空间大小一直等于卷的大小,因
此可防止出现意外行为。例如,如果卷大小减小,则可能导致数据受损。更改卷大小时请
务必小心。
如果使用安装了区域的Solaris 系统,则不能在非全局区域中创建或克隆ZFS 卷。在非全局
区域中创建或克隆卷的任何尝试都将失败。有关在全局区域中使用ZFS 卷的信息,请参见
第134 页中的“向非全局区域中添加ZFS 卷”。
作为交换设备或转储设备的仿真卷
要设置交换区域,请创建一个特定大小的ZFS 卷,然后在该设备中启用交换。在ZFS 文件
系统中,不要交换到文件。不支持ZFS 交换文件配置。
8第8 章
131
在以下示例中,会添加一个5GB的tank/vol 卷作为交换设备。
# swap -a /dev/zvol/dsk/tank/vol
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 32,33 16 1048688 1048688
/dev/zvol/dsk/tank/vol 254,1 16 10485744 10485744
不支持使用ZFS 卷作为转储设备。请使用dumpadm 命令设置转储设备。
在安装了区域的Solaris 系统中使用ZFS
可将ZFS 数据集作为通用文件系统或委托数据集添加到区域中。
通过添加通用文件系统,非全局区域可与全局区域共享空间,但区域管理员不能在基础文
件系统分层结构中控制属性或创建新文件系统。这与向区域中添加其他任何类型的文件系
统相同,应该在主要目的只是为了共享公用空间时才这样做。
使用ZFS,还可将数据集委托给非全局区域,从而授予区域管理员对数据集及其所有子级的
完全控制。区域管理员可以在此数据集中创建和销毁文件系统,并可修改数据集的属性。
区域管理员无法影响尚未添加到区域中的数据集,也不能超过对所引入区域的数据集所设
置的任何顶层配额。
向非全局区域中添加ZFS 文件系统
如果目标只是与全局区域共享空间,则可添加ZFS 文件系统作为通用文件系统。添加到非
全局区域的ZFS 文件系统必须将其mountpoint 属性设置为legacy。
可以使用zonecfg 命令的add fs 子命令将ZFS 文件系统添加到非全局区域中。例如:
在以下示例中,全局区域中的全局管理员会向非全局区域中添加一个ZFS 文件系统。
# zonecfg -z zion
zion: No such zone configured
Use ’create’ to begin configuring a new zone.
zonecfg:zion> create
zonecfg:zion> add fs
在安装了区域的Solaris 系统中使用ZFS
132 Solaris ZFS 管理指南• 2006 年10 月
zonecfg:zion:fs> set type=zfs
zonecfg:zion:fs> set special=tank/zone/zion
zonecfg:zion:fs> set dir=/export/shared
zonecfg:zion:fs> end
此语法可向挂载在/export/shared 中的区域zion 中添加ZFS 文件系统tank/zone/zion。文
件系统的mountpoint 属性必须设置为legacy,并且该文件系统不能已在其他位置挂载。区
域管理员可在文件系统中创建和销毁文件。不能在其他位置重新挂载文件系统,区域管理
员也不能更改该文件系统的属性,如atime、readonly、compression 等。全局区域管理员负
责设置和控制文件系统的属性。
有关zonecfg 命令以及使用zonecfg 配置资源类型的信息,请参见《System Administration
Guide: Solaris Containers-Resource Management and Solaris Zones》中的第二部分,“Zones”。
将数据集委托给非全局区域
如果主要目标是将存储管理委托给区域,则ZFS 支持通过使用zonecfg 命令的add dataset
子命令向非全局区域中添加数据集。
在以下示例中,全局区域中的全局管理员会将一个ZFS 文件系统委托给非全局区域。
# zonecfg -z zion
zion: No such zone configured
Use ’create’ to begin configuring a new zone.
zonecfg:zion> create
zonecfg:zion> add dataset
zonecfg:zion:dataset> set name=tank/zone/zion
zonecfg:zion:dataset> end
与添加文件系统不同,此语法会使ZFS 文件系统tank/zone/zion 在区域zion 中可见。区域
管理员可以设置文件系统属性,也可以创建其子级。此外,区域管理员还可以拍摄快照、
创建克隆或控制整个文件系统分层结构。
有关区域内所允许的操作的更多信息,请参见第134 页中的“区域内的属性管理”。
 
 
 
以上文章转自于 : http://developers.sun.com.cn/
阅读(520) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~