pfedit - 在文件经过授权的情况下编辑管理文件
pfedit [-r] [-s] file
pfedit 命令允许授权用户编辑系统配置文件。file 参数表示要编辑的文件的路径名。如果该文件不采用绝对路径名,则在该文件前面会附加当前工作目录的路径名,所有后续处理会将该路径名当作参数继续进行。调用方用户必须具有授权 solaris.admin.edit/path_to_file 或整体授权 solaris.admin.edit。pfedit 命令还会通过检查文件的 realpath(3C) 的授权以支持使用符号链接。
pfedit 命令将为调用方用户拥有的文件创建一个副本,然后使用调用方用户的 ID 和特权对该文件调用编辑器。缺省编辑器为 /usr/bin/vi,但可以通过使用 EDITOR 或 VISUAL 环境变量进行选择;如果同时设置了这两者,则优先使用 VISUAL。如果在用户退出编辑器时,复制的文件已更新,则更新的内容将以原子方式应用于该文件。文件的所有自主访问属性(所有者、组、权限和 ACL)以及原始文件上的任何系统或扩展属性都会保留。在任何情况下,pfedit 退出之前都会删除用户拥有的文件副本。
如果文件不存在,则会使用所有者 root、组 root 创建该文件。文件权限将为 644 (-rw-r--r--),除非选择 –s 选项,这时文件权限为 600 (-rw-------)。创建文件后,前面所述的操作将应用于该文件。如果已使用 pfedit 创建和修改文件,则可以使用 –r 选项删除文件。
pfedit 命令会对文件设置自主锁定,因此不能通过 pfedit 同时进行更新。
pfedit 命令会尽量避免中断与其他文件的硬链接。由于原子更新需要将现有文件替换为具有更新内容的新文件,因此 pfedit 将拒绝对链接计数大于一的文件执行操作。
pfedit 命令仅限于编辑文本文件,不支持包含非文本字符 (NUL) 的更新。
如果在成功更新后尝试在未经授权的情况下使用该文件或者更新出现错误,但配置了审计记录,则系统将生成一个审计记录,用于捕获主题、文件名、所用授权、文件更改(如果有)和操作的成功或失败状态。审计事件类型和缺省类可为以下值之一:
AUE_admin_edit:edit administrative file:as AUE_admin_file_create:create administrative file:as AUE_admin_file_remove:remove administrative file:as
支持以下选项:
Remove specified file (if file has been created by pfedit).
将文件标记为“敏感”(只有在使用pfedit 创建文件时才有效)。The file will be created with 0600 permissions and will have the "sensitive" System Attribute.
要通过可以分配给用户的 solaris.admin.edit 授权创建配置文件以修改 /etc/syslog.conf,请使用profiles(1) 命令。
% profiles -p "syslog Configure" profiles: syslog Configure> set auths=solaris.admin.edit/etc/syslog.conf profiles: syslog Configure> set desc="Edit syslog configuration" profiles: syslog Configure> exit示例 2 Modifying /etc/syslog.conf
如果用户具有上一示例中配置的 "syslog Configure" 配置文件,则调用:
# pfedit /etc/syslog.conf
...可为该用户拥有的 /etc/syslog.conf 创建一个副本,并在缺省情况下以该用户身份对该副本调用 /usr/bin/vi。用户退出编辑器时,/etc/syslog.conf 将以原子方式使用用户保存的内容进行更新。
如果 pfedit 命令成功完成,则退出值为 0;如果该操作的任何部分失败,则退出值为非零值。
有关下列属性的说明,请参见 attributes(7):
|
auths(1)、passwd(1)、profiles(1)、fgetattr(3C)、realpath(3C)、attributes(7)、fsattr(7)、groupadd(8)、groupdel(8)、groupmod(8)、useradd(8)、userdel(8)、usermod(8)
Oracle Solaris 包含管理配置文件,不建议对这些文件使用 pfedit 和 solaris.admin.edit/ path_to_file 授权。可以使用备用命令,这些命令特定于域,并且更安全。例如,对于 /etc/passwd、/etc/shadow 或 /etc/user_attr 文件,请改用 passwd(1)、useradd(8)、userdel(8) 或 usermod(8)。对于 /etc/group 文件,请改用 groupadd(8)、groupdel(8) 或 groupmod(8)。要更新 /etc/security/auth_attr、/etc/security/exec_attr 或 /etc/security/prof_attr,首选命令为 profiles(1)。
可以通过修改某些配置文件的内容来提升分配给用户的特权。分配编辑此类文件的授权或分配包含此类授权的配置文件,应视为等效于提供完全访问特权。
Files with the "sensitive" System Attribute, including those created with the –s option, do not have the contents or content changes included in the audit record.
The –s option and special handling of files with the "sensitive" System Attribute was added in Oracle Solaris 11.2.0.
The pfedit command was added in Oracle Solaris 11.1.0.