查看和使用 RBAC 缺省值(任务)
在缺省情况下,将为用户指定权限。系统所有用户的权限均在 /etc/security/policy.conf 文件中指定。
查看和使用 RBAC 缺省值(任务列表)
安装 Oracle Solaris 时,您的系统已配置了用户权限和进程权限。在未进行进一步配置的情况下,可使用以下任务列表查看和使用 RBAC。
任务
说明
参考
查看安全属性数据库的内容。
列出系统上的所有授权、权限配置文件以及具有安全属性的命令。
查看权限。
包括列出权限配置文件、授权、特权以及指定的角色。
承担 root 角色。
初始用户获取管理权限。
成为管理员。
有多种方法可供已为其指定了管理权限的用户来使用这些权限。
如何查看所有已定义的安全属性
使用以下命令可列出系统上的所有授权、权限配置文件以及具有安全属性的命令。要列出所有已定义的特权,请参见如何列出系统上的特权。列出所有授权。% getent auth_attr | more
solaris.:::All Solaris Authorizations::help=AllSolAuthsHeader.html
solaris.account.:::Account Management::help=AccountHeader.html
...
solaris.zone.login:::Zone Login::help=ZoneLogin.html
solaris.zone.manage:::Zone Deployment::help=ZoneManage.html
列出所有权限配置文件。% getent prof_attr | more
All:::Execute any command as the user or role:help=RtAll.html
Audit Configuration:::Configure Solaris Audit:auths=solaris.smf.value.audit;
help=RtAuditCfg.html
...
Zone Management:::Zones Virtual Application Environment Administration:
help=RtZoneMngmnt.html
Zone Security:::Zones Virtual Application Environment Security:auths=solaris.zone.*,
solaris.auth.delegate;help=RtZoneSecurity.html ...
列出所有具有安全属性的命令。% getent exec_attr | more
All:solaris:cmd:::*:
Audit Configuration:solaris:cmd:::/usr/sbin/auditconfig:privs=sys_audit
...
Zone Security:solaris:cmd:::/usr/sbin/txzonemgr:uid=0
Zone Security:solaris:cmd:::/usr/sbin/zonecfg:uid=0 ...
如何查看指定的权限
使用以下命令可查看 RBAC 指定。要查看可以指定的所有权限,请参见如何查看所有已定义的安全属性。列出授权。% auths
solaris.device.cdrw,solaris.device.mount.removable,solaris.mail.mailq
这些授权在缺省情况下会指定给所有用户。
列出权限配置文件。% profiles
Basic Solaris User
All
这些权限配置文件在缺省情况下会指定给所有用户。
列出指定的角色。% roles
root
该角色在缺省情况下会指定给初始用户。No roles 表明没有为您指定任何角色。
列出缺省 shell 中的特权。% ppriv $$
1234: /bin/csh
flags =
E: basic
I: basic
P: basic
L: all
缺省情况下,将为每个用户指定基本的特权集。限制特权集为所有特权。% ppriv -vl basic
file_link_any
Allows a process to create hardlinks to files owned by a uid
different from the process' effective uid.
file_read
Allows a process to read objects in the filesystem.
file_write
Allows a process to modify objects in the filesystem.
net_access
Allows a process to open a TCP, UDP, SDP or SCTP network endpoint.
proc_exec
Allows a process to call execve().
proc_fork
Allows a process to call fork1()/forkall()/vfork()
proc_info
Allows a process to examine the status of processes other
than those it can send signals to. Processes which cannot
be examined cannot be seen in /proc and appear not to exist.
proc_session
Allows a process to send signals or trace processes outside its session.
列出权限配置文件中各命令的特权。% profiles -l
Basic Solaris User
/usr/bin/cdda2wav.bin privs=file_dac_read,sys_devices,
proc_priocntl,net_privaddr
/usr/bin/cdrecord.bin privs=file_dac_read,sys_devices,
proc_lock_memory,proc_priocntl,net_privaddr
/usr/bin/readcd.bin privs=file_dac_read,sys_devices,net_privaddr
All
*
用户的权限配置文件可以包括使用特定特权运行的命令。基本 Solaris 用户配置文件包括允许用户读取和写入 CD-ROM 的命令。
示例 9-1 列出用户的授权% auths username
solaris.device.cdrw,solaris.device.mount.removable,solaris.mail.mailq
示例 9-2 列出用户或角色的权限配置文件
以下命令列出了特定用户的权限配置文件。% profiles jdoe
jdoe:
Basic Solaris User
All
以下命令列出了 cryptomgt 角色的权限配置文件。% profiles cryptomgt
cryptomgt:
Crypto Management
Basic Solaris User
All
以下命令列出了 root 角色的权限配置文件。% profiles root
root:
All
Console User
Network Wifi Info
Desktop Removable Media User
Suspend To RAM
Suspend To Disk
Brightness
CPU Power Management
Network Autoconf User
Basic Solaris User
示例 9-3 列出用户的指定角色
以下命令列出了特定用户的指定角色。% roles jdoe
root
示例 9-4 列出特定命令的用户特权
以下命令列出了一般用户的权限配置文件中的特权命令。% profiles -l jdoe
jdoe:
Basic Solaris User
/usr/bin/cdda2wav.bin privs=file_dac_read,sys_devices,
proc_priocntl,net_privaddr
/usr/bin/cdrecord.bin privs=file_dac_read,sys_devices,
proc_lock_memory,proc_priocntl,net_privaddr
/usr/bin/readcd.bin privs=file_dac_read,sys_devices,net_privaddr
All
*
如何承担角色
开始之前
必须已为您指定了角色,并且必须使用该信息更新命名服务。在终端窗口中,确定可以承担的角色。% roles
Comma-separated list of role names is displayed
使用 su 命令承担角色。% su - rolename
Password:
$
su - rolename 命令会将 shell 更改为该角色的配置文件 shell。配置文件 shell 可识别安全属性(例如授权、特权和 set ID 位)。
可选验证您现在是否已承担某种角色。$ /usr/bin/whoami
rolename
您现在可在此终端窗口中执行角色任务。
可选查看角色的功能。
有关过程,请参见如何查看指定的权限。
示例 9-5 承担 root 角色
在以下示例中,初始用户承担 root 角色并列出该角色的 shell 中的特权。% roles
root
% su - root
Password:
# Prompt changes to root prompt
# ppriv $$
1200: pfksh
flags =
E: all
I: basic
P: all
L: all
有关特权的信息,请参见特权(概述)。
如何获取管理权限
运行配置文件 shell 时,管理权限将生效。在缺省情况下,将为角色帐户指定一个配置文件 shell。角色是特殊帐户,系统为其指定了特定的管理权限,这些权限通常针对相关的一组管理活动(例如查看审计文件)。
在 root 角色中,初始用户具有所有管理权限,即初始用户是超级用户。root 角色可以创建其他角色。
开始之前
要管理系统,您必须具有一般用户没有的权限。如果您不是超级用户,必须为您分配一个角色、管理权限配置文件或特定特权或授权。选择以下方法之一来运行管理命令。
打开终端窗口。成为root。% su -
Password: Type the root password
#
注 -无论 root 是用户还是角色,此方法都是可行的。井号 (#) 提示符表明您现在已是超级用户。
承担已为您指定的角色。
在以下示例中,您承担了网络管理角色。此角色包括 Network Management(网络管理)权限配置文件。% su - networkadmin
Password: Type the networkadmin password
$
您现已位于配置文件 shell 中。在该 shell 中,可以运行 snoop、route、dladm 以及其他命令。有关配置文件 shell 的更多信息,请参见配置文件 Shell 和 RBAC。
提示 -使用如何查看指定的权限中介绍的步骤查看角色的功能。
使用 pfbash 命令创建通过管理权限运行的 shell。
例如,以下命令集允许您在 pfbash shell 中检查网络包:% pfbash
$ anoop
如果没有为您分配 net_observability 特权,则 snoop 命令将失败,并出现一条类似于以下内容的错误消息:snoop: cannot open "net0": Permission denied。如果直接或者通过权限配置文件或角色为您指定特权,该命令将运行成功。此外,您还可以在此 shell 中运行其他特权命令。
使用 pfexec 命令创建通过管理权限运行的进程。
结合使用权限配置文件的特权命令名称来运行 pfexec 命令。例如,以下命令允许您检查网络包:% pfexec snoop
应用于 pfexec 的特权限制与应用于 pfbash 的特权限制相同。但要运行其他特权命令,必须在键入该特权命令之前再次键入 pfexec。
示例 9-6 高速缓存验证以便于使用角色
在以下示例中,管理员会配置一个角色来管理网络,但为方便使用该角色,会高速缓存用户的验证。首先,管理员创建并指定角色。# roleadd -K roleauth=user -P "Network Management" netmgt
# usermod -R +netmgt jdoe
当切换到该角色时,如果 jdoe 使用 -c 选项,则在显示 snoop 输出之前需要输入口令。% su - netmgt -c snoop options
Password:
snoop output
如果没有高速缓存验证,jdoe 将立即重新运行该命令,并出现输入口令提示。
管理员配置 pam.conf 文件来高速缓存验证,以便只需要在初次运行时输入口令,以后不再需要输入口令,直到超过某段时间之后。管理员会将所有 pam.conf 定制堆栈放在文件的结尾处。# vi /etc/pam.conf
...
#
## Cache authentication for switched user
#
su auth required pam_unix_cred.so.1
su auth sufficient pam_tty_tickets.so.1
su auth requisite pam_authtok_get.so.1
su auth required pam_dhkeys.so.1
su auth required pam_unix_auth.so.1
创建项之后,管理员将对这些项进行检查,确定是否出现拼写、缺失或重复问题。
需要整个 su 堆栈。pam_tty_tickets.so.1 模块提供高速缓存。有关 PAM 的更多信息,请参见 pam.conf(4) 手册页以及第 15 章。
将 su PAM 堆栈添加到 pam.conf 文件之后,对于 netmgt 角色,当运行一系列命令时仅提示一次输入口令。% su - netmgt -c snoop options
Password:
snoop output
% su - netmgt -c snoop options
snoop output
...