Go to main content

手册页部分 1:用户命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

setlabel(1)

名称

setlabel - 更改文件的有效敏感标签

用法概要

/usr/bin/setlabel newlabel filename...

描述

setlabel 命令可将指定标签应用于多级别 ZFS 文件系统中的文件或目录。请参阅 setflabel(3TSOL) 手册页,了解有关满足此命令所需的条件以及执行此命令所需的特权的完整说明。

启用 Trusted Extensions 时,setlabel 也可以与单级别文件系统一起使用。在这种情况下,文件将移动到其标签对应于 newlabel 的区域。调整旧的文件路径名,使其相对于新区域的根路径名。如果文件父目录的旧路径名在新区域中没有作为一个目录而存在,则不移动该文件。一旦移动,可能再也无法在当前区域中访问该文件。

除非已指定 newlabelfilename,否则不设置任何标签。

标签由站点的安全管理员定义。系统始终以大写字母形式显示标签。用户可以大写字母和小写字母的任何组合形式输入标签。支持对标签的增量更改。

退出状态

setlabel 在以下值之一时退出:

0

成功完成。

1

用法错误。

2

获取、设置或转换标签时出错。

用法

在命令行中,给标签加上双引号,除非标签只有一个字。如果没有引号,则被空格分隔开的另一个字或字符会被解释为另一个参数。

% setlabel SECRET somefile
% setlabel "TOP SECRET" somefile

使用大写字母和小写字母的任何组合。可在标签中通过空白、制表符、逗号或斜杠 (/) 来分隔各项。不要使用任何其他标点。

% setlabel "ts a b" somefile
% setlabel "ts,a,b" somefile
% setlabel "ts/a b" somefile
% setlabel " TOP SECRET A B   " somefile

示例

示例 1 Set a Label

要将 somefile 的标签设置为 SECRET A

example% setlabel "Secret a" somefile
示例 2 启用区间

可使用加号和减号修改现有标签。加号可以启用 somefile 的标签的指定区间。

example% setlabel +b somefile
示例 3 禁用区间

减号可禁用与分类相关联的区间。要禁用区间 A(位于 somefile 标签中):

example% setlabel -A somefile

If an incremental change is being made to an existing label and the first character of the label is a hyphen (-), a preceding double-hyphen (--) is required.

要禁用区间 -A(位于 somefile 的标签中):

example% setlabel -- -A somefile

属性

有关下列属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
system/file_labeling
接口稳定性
Committed(已确定)

另请参见

setflabel(3TSOL), label_encodings(5), attributes(7), labels(7), zfs(8)

附注

有关更多信息,请参见 label_encodings(5) 手册页。

History

The setlabel command was added to Solaris in Solaris 10 4/08 (Update 5).Prior to that it was included in the Trusted Extensions add-on for Solaris.