Go to main content

手册页部分 1:用户命令

退出打印视图

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

profiles(1)

名称

profiles - 列出和管理权限配置文件

用法概要

profiles [-lx] [-c command] [user ...] [-S repository]
profiles [-la] [-S repository]
profiles -p profile [-S repository] [subcommand]
profiles -p profile [-S repository] -f command_file
profiles help

描述

profiles 实用程序会在本地文件名称服务或 LDAP 名称服务中的 prof_attr(5)exec_attr(5) 数据库中创建和修改权限配置文件的配置。一个权限配置文件配置由一个配置文件名称和多个属性组成。

profiles 子命令的以下概要适用于交互式用法:

profiles –p profile [–S 
repository] [subcommand]

profiles 命令在标准输出上输出已分配给您(或可选择指定的用户或角色名)的权限配置文件的名称。配置文件是用于枚举执行特定函数所需的命令和授权的一种绑定机制。如果进程是由特权命令解释程序启动的,则随每个可执行程序一起列出的还有进程运行时使用的进程属性,例如有效的用户和组 ID。请参见 pfexec(1) 手册页。配置文件可以包含 prof_attr(5) 中定义的其他配置文件。

可以组合多个配置文件来构造合适的访问控制。分配配置文件时,授权将添加到现有的集合中。如果同一命令出现在多个配置文件中,则将第一次出现(根据配置文件的顺序确定)的命令用于进程属性设置。为方便起见,可指定一个通配符以匹配所有命令。

特殊配置文件 "Stop"(停止)会截断对后续配置文件的评估。将不会对位于 "Stop"(停止)配置文件后的配置文件进行评估,也不会使用它们来查找其他命令。This profile can be used to sidestep profiles listed in /etc/security/policy.conf with the PROF_GRANTED key and the authorizations listed with AUTH_GRANTED in that file.

解释配置文件时,将从 user_attr(5) 装入配置文件列表。对于每个用户,共有两组配置文件,即已验证集和未验证集。用户在执行与已验证配置文件集中的条目匹配的命令之前,需要进行重新验证。See pfexec(1).如果在 /etc/security/policy.conf 中定义了任何缺省配置文件(请参见 policy.conf(5)),则缺省配置文件的列表将添加到从 user_attr(5) 装入的列表中。prof_attr(5) 中的匹配条目提供了授权列表,exec_attr(5) 中的匹配条目提供了命令列表。

属性

使用 –p 选项调用时,可以管理指定配置文件的属性及其相关联的可执行文件的属性。不过,为维护系统完整性,此命令不能修改由 Oracle Solaris 维护的那些配置文件。此类配置文件只能在系统更新期间通过 pkg 命令进行修改。

(可选)还可通过 pkg 命令将其他配置文件声明为不可修改的。

为防止特权升级,可根据用户的授权来限制属性值。至少要授予管理员 "Rights Management"(权限管理)配置文件。此外,要修改由委托授权控制的安全相关属性,必须向管理员授予 "Rights Delegation"(权限委托)配置文件。有关详细信息,请参见 exec_attr(5)prof_attr(5) 及以下摘要。

属性值可以是简单字符串,也可以是简单字符串的逗号分隔列表。包含空格的简单字符串必须括在双引号中。

profiles 命令在 profilecommand 上下文中运行。profile 上下文是初始状态,在此状态下,可管理各种配置文件属性。下表概述了 profile 上下文中的属性:

Property Name   Value Type         Required Authorizations

name            simple             none
annotation      simple             solaris.account.setpolicy
auths           list of simple     solaris.auth.{assign/delegate}
profiles        list of simple     solaris.profile.{assign/delegate}
privs           list of simple     solaris.privilege.{assign/delegate}
limitpriv       list of simple     solaris.privilege.{assign/delegate}
defaultpriv     list of simple     solaris.privilege.{assign/delegate}
always_audit    list of simple     solaris.audit.assign
never_audit     list of simple     solaris.audit.assign
access_times    list of simple     solaris.account.setpolicy
desc            simple             none
help            simple             none
pam_policy      simple             solaris.account.setpolicy
cmd             simple/new context none

通过指定 cmd 属性可进入 command 上下文。在 command 上下文中,可管理当前命令的属性。

下表概述了 command 上下文中的属性:

Property Name   Value Type         Required Authorizations

id              simple             none
privs           list of simple     solaris.privilege.{assign/delegate}
limitprivs      list of simple     solaris.privilege.{assign/delegate}
euid            simple             solaris.profile.cmd.setuid
uid             simple             solaris.profile.cmd.setuid
egid            simple             solaris.group.{assign/delegate}
gid             simple             solaris.group.{assign/delegate}
clearance       simple             solaris.label.delegate

以下列表介绍了可在 profile 上下文属性中指定的值如以下列表中所指定,在属性与属性值之间需要有一个等号 (=)。

always_audit

用来将事件类指定为始终审计的审计标志。在登录和执行 su 命令时,只会应用该属性的第一个实例(在用户的 user_attr(5) 条目中或者在所分配的配置文件的有序列表中)。

annotation

指定是否提示用户提供审计记录注释说明。yes 要求用户在提示时提供注释说明。optional 允许用户在提示时指定注释说明。no 不提示用户提供注释说明,这是缺省选择。

审计记录注释说明是一个文本行,以应用程序的 PAM 对话功能返回的换行符结尾。注释文本包括在用户生成的每个审计记录中。

auths

要添加到新配置文件中的一个或多个以逗号分隔的授权。如果在授权名称中使用了通配符 (*),则名称必须括在双引号 (") 中。

cmd

可执行文件的全限定路径或星号 (*),后者用于指定所有命令。替换路径名中文件名组件的星号用于指示某个特定目录中的所有文件。

这是一个特殊属性,用于进入 command 上下文以管理命令的安全属性。

可以将数字 ID 或名称用于这些 ID。

id

此属性初始设置为由前面的 cmd 属性指定的值,但是可以修改。与 select 子命令一起使用时,可以克隆现有命令的属性以进行后续编辑。

pam_policy

要应用于用户的 PAM 策略。pam_policy 必须是 pam.conf(5) 格式文件的绝对路径名,或者是位于 /etc/security/pam_policypam.conf(5) 格式文件的文件名。有关更多信息,请参见 pam_user_policy(7)

access_times

一个或多个以逗号分隔的规则,指定可以访问相应应用程序集和服务集的天数和次数。

检查特定服务名称的次数时,计算以通过用户的 user_attr(5) 数据库中的 access_times 指定的规则开始,后跟用户配置文件和子配置文件中的 access_times,直到找到匹配的服务名称或通配符条目。如果未找到匹配项,将对用户免除该服务的时间限制。有关更多信息,请参见 user_attr(5)

privs

应用于可执行进程的可继承集的特权集。缺省值为 basic。

limitprivs

应用于可执行进程的限制集的特权集。缺省值为 all。

euid

通过该命令执行的进程的有效用户 ID。

uid

通过该命令执行的进程的实际用户 ID。

egid

通过该命令执行的进程的有效组 ID。

gid

通过该命令执行的进程的实际组 ID。

clearance

通过该命令执行的进程的安全许可。

defaultpriv

分配给用户的进程集的缺省特权集。在登录和执行 su 命令时,只会应用该属性的第一个实例(在用户的 user_attr(5) 条目中或者在所分配的配置文件的有序列表中)。

desc

新配置文件的说明。文本必须括在引号中。

help

新配置文件的帮助文件名称。The help file is copied to the /usr/lib/help/profiles/locale/locale directory, where locale is the value of the user's locale, or C if none is specified.只有在文件系统信息库中才适合指定此属性。

limitpriv

无论是通过 su(8) 还是任何其他方式,用户或用户启动的任何进程可以获得的最大特权集。在登录和执行 su 命令时,只会应用该属性的第一个实例(在用户的 user_attr(5) 条目中或者在所分配的配置文件的有序列表中)。

name

配置文件的名称。名称的初始值是在命令行中使用 –p 选项指定的。如果名称发生更改,当前的配置文件属性将应用于新命名的配置文件。通过这种方式,可以克隆现有的配置文件以进行后续编辑。名称不得与某个现有的配置文件相同。

never_audit

用来将事件类指定为从不审计的审计标志。在登录和执行 su 命令时,只会应用该属性的第一个实例(在用户的 user_attr(5) 条目中或者在所分配的配置文件的有序列表中)。

privs

可使用 pfexec(1) 命令的 P 选项指定的特权集。

profiles

要添加到新配置文件中的一个或多个以逗号分隔的辅助配置文件。

选项

支持以下选项:

–a

列出指定的系统信息库中的所有配置文件名称。If no repository is specified, it follows whatever is configured for prof_attr in nsswitch.conf(5).

–x

仅列出用户的已验证配置文件集中的配置文件名。缺省情况下,仅列出用户的未验证配置文件中的配置文件。

–f command_file

指定 profiles 命令文件的名称。command_file 是包含 profiles 的子命令的文本文件,一行一个。

–l [user]

Provides information about all rights profiles that are assigned to user and lists the commands and their special process attributes such as user and group IDs.Without the user argument, provides this information about the user who is running the command.

–c command

Provides the name of the Rights Profile and the matching id that would be used if the command were executed using a profile shell by the current user or the specified user(s).当指定了 –l 时,还提供相应进程属性。–x 选项将搜索限制在需要进行验证的用户配置文件。如果未找到某个指定用户的匹配项,则退出状态设置为 1。否则将设置为 0。

–p profile

指定配置文件名称。

–S repository

有效的系统信息库包括 filesldap


注 -  更新 ldap 系统信息库时,LDAP 服务器和客户机都必须已配置 EnableShadowUpdate=true

repository 指定将更新哪个名称服务。The default repository is files.

子命令

使用 –p 选项调用时,可在命令行中或以交互方式提供子命令。可在命令行上指定以分号分隔的多个子命令,并且需要将整个子命令集括在引号中。未提供子命令意味着交互式会话,在此会话期间,可通过使用 TAB 键调用子命令的自动完成。

可使用 addselect 子命令选择一个特定的命令,从而使上下文更改为该命令的上下文。在交互式会话期间,command 上下文由提示字符串中的命令基名标识。The end and cancel subcommands are used to complete the command specification, at which time the context is reverted to the profile context.

可导致破坏性操作或导致工作丢失的子命令具有一个强制执行操作的 –F 选项。如果输入来自终端设备,系统会在适当的时候提示用户。如果指定子命令时没有使用 –F 选项,这就有可能发生。其他情况下,不允许执行操作,并向标准错误写入一条诊断消息。

属性值可以是一个简单值,对于接受列表的属性来说,则是简单值的列表。支持以下子命令:

add cmd=pathname

profile 上下文中,开始指定给定的命令。上下文将更改为 command 类型。

add property-name=property-value

将指定值添加到当前属性值。此子命令仅可应用于接受列表的属性。

cancel

End the command specification and reset context to profile.放弃任何部分指定的资源。cancel 仅适用于 command 上下文。

clear property-name

清除属性的值。

commit

将当前配置从内存提交到稳定存储器。必须提交配置才能使更改生效。在提交内存中的配置之前,可以使用 revert 子命令删除更改。在 profiles 会话完成时,会自动尝试 commit 操作。因为配置必须是正确的才能提交,因此该操作将自动执行 verify

delete [–F]

从内存和稳定存储器中删除指定的配置文件。如果该配置文件是同一系统信息库中另一个配置文件的子配置文件,则不允许此操作。但是会提供包含该配置文件的配置文件的列表,用户可在删除该配置文件之前手动将其移除。使用 –F 选项强制执行操作:如果允许删除,其操作是即时的,会话将终止。

end

结束命令指定。此子命令仅适用于 command 上下文。profiles 命令验证是否完整指定了当前命令。如果是,当前命令将添加到内存中的配置(有关将其保存到稳定存储器的信息,请参见 commit),且上下文将恢复为 profile 上下文。如果指定不完整,它将发出相应的错误消息。

exit [–F]

退出 profiles 会话。如果需要,会自动尝试 commit。还可使用 EOF 字符退出 profiles。可使用 –F 选项强制执行操作。

export [–f output-fle ]

将配置列显到标准输出。使用 –f 选项可将配置输出至输出文件。此选项以适合在命令文件选项中使用的格式生成输出。

help [usage | subcommands | properties | subcommand | property]

列显常规帮助或有关特定主题的帮助。

info [property-name]

显示有关当前配置文件或指定属性的信息。

remove cmd=fullpath

从配置文件中删除指定的命令。此子命令仅在 profile 上下文中有效。

remove [–F] cmd

从配置文件中删除所有命令。如果未使用 –F 选项,则需要确认。此子命令仅在 profile 上下文中有效。

remove property-name=property-value

从属性中删除指定的值。这仅可应用于接受列表的属性。

revert [–F]

将配置恢复到上次提交时的状态。可使用 –F 选项强制执行操作。

select cmd=fullpath

选择与给定路径名标准相匹配的命令以进行修改。此子命令仅适用于 profile 上下文。

set property-name=property-value

将给定属性名称设置为给定值。某些属性(如 namedesc)仅在 profile 上下文中有效,而某些属性则仅在 command 上下文中有效。此子命令同时适用于 profilecommand 上下文。

verify

检验当前配置是否正确:

  • 是否指定了必需的属性。

  • 各个值是否对每个关键字都有效。

  • 用户是否有权指定这些值。

示例

示例 1 使用 profiles 命令

profiles 命令的输出具有以下格式:

example% profiles tester01 tester02
tester01 : Audit Management, All Commands
tester02 : Device Management, All Commands
示例 2 使用 list 选项
example% profiles -l tester01 tester02
tester01 :
    Audit Management:
      /usr/sbin/audit          euid=root
      /usr/sbin/auditconfig    euid=root    egid=sys
    All Commands:
      *
tester02 :
    Device Management:
      /usr/bin/allocate:       euid=root
      /usr/bin/deallocate:     euid=root
    All Commands
      *
示例 3 创建新的配置文件

The following creates a new “User Manager” profile in LDAP.The new profile description is “Manage users and groups”, and the authorization assigned is solaris.user.manage.The supplementary profile assigned is “Mail Management”.

example% profiles -p "User Manager" -S ldap
profiles:User Manager> set desc="Manage users and groups"
profiles:User Manager> set auths=solaris.user.manage
profiles:User Manager> set profiles="Mail Management"
profiles:User Manager> exit
示例 4 Displaying Information Regarding a Profile

The following command displays information regarding the “User Manager” profile:

example% profiles -p "User Manager" -S ldap info
name=User Manager
desc=Manage users and  groups
auths=solaris.user.manage
profiles=Mail Management
示例 5 Deleting a Profile

The following command deletes the “User Manager” profile from LDAP:

example% profiles -p "User Manager" -S ldap delete -F
示例 6 Modifying a Profile

The following modifies the “User Manager” profile in LDAP.The new profile description is “Manage world”, the new authorization assignment is solaris.user.* authorizations, and the new supplementary profile assignment is All.

example% profiles -p "User Manager" -S ldap
profiles:User Manager> set desc="Manage world"
profiles:User Manager> set auths="solaris.user.*"
profiles:User Manager> set profiles=All
profiles:User Manager> exit
示例 7 创建 exec_attr 数据库条目

The following command creates a new exec_attr entry for the “User Manager” profile in LDAP.将添加 /usr/bin/cp 条目。此命令的有效用户 ID 为 0,有效组 ID 为 0

example% profiles -p "User Manager" -S ldap
profiles:User Manager> add cmd=/usr/bin/cp
profiles:User Manager:cp> set euid=0
profiles:User Manager:cp> set egid=0
profiles:User Manager:cp> end
profiles:User Manager> exit
示例 8 删除 exec_attr 数据库条目

The following example deletes an exec_attr database entry for the “User Manager” profile from LDAP.将删除为命令 /usr/bin/cp 指定的条目。

example% profiles -p "User Manager" -S ldap
profiles:User Manager> remove cmd=/usr/bin/cp
profiles:User Manager> exit
示例 9 修改 exec_attr 数据库条目

以下命令为 LDAP 中的 User Manager 配置文件修改 exec_attr 数据库条目的属性。将 /usr/bin/cp 条目修改为以实际用户 ID 0 和实际组 ID 0 执行。

example% profiles -p "User Manager" -S ldap
profiles:User Manager> select cmd=/usr/bin/cp
profiles:User Manager:cp> clear euid
profiles:User Manager:cp> clear egid
profiles:User Manager:cp> set uid=0
profiles:User Manager:cp> set gid=0
profiles:User Manager:cp> end
profiles:User Manager> exit
示例 10 显示与命令关联的属性

下面显示当两个用户 John 和 Mary 使用配置文件 shell 执行命令 /usr/sbin/useradd 时,将对该命令应用的进程属性。

example% profiles -lc /usr/sbin/useradd john mary
john:
name=User Management
id=/usr/sbin/useradd
euid=0

mary:
name=All
id=*

退出状态

将返回以下退出值:

0

成功完成

1

出现错误或者没有为用户分配与命令匹配的配置文件

文件

/etc/security/exec_attr

/etc/security/prof_attr

/etc/user_attr

/etc/security/policy.conf

属性

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

属性类型
属性值
可用性
system/core-os

另请参见

auths(1), pfexec(1), pkg(1), roles(1), getprofattr(3C), auth_attr(5), exec_attr(5), nsswitch.conf(5), pam.conf(5), policy.conf(5), prof_attr(5), user_attr(5), attributes(7), audit_flags(7), pam_user_policy(7), privileges(7), rbac(7)

Working With Oracle Solaris 11.4 Directory and Naming Services: LDAP