<?Pub UDT _bookmark _target?><?Pub CX solbook(?><chapter id="privtask-1"><?Pub Tag atict:info tracking="off" ref="0"?><?Pub Tag atict:user user="sharonr" fullname="Sharon Veach"?><title>Privileges
(Tasks)</title><highlights><itemizedlist><para>This chapter provides step-by-step instructions for managing privileges
and using privileges on your system. The following is a list of the information
in this chapter.</para><listitem><para><olink targetptr="privtask-3" remap="internal">Managing and Using Privileges
(Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="privtask-14" remap="internal">Managing Privileges (Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="privtask-16" remap="internal">Determining Your Privileges
(Task Map)</olink></para>
</listitem>
</itemizedlist><para>For an overview of privileges, see <olink targetptr="prbac-2" remap="internal">Privileges
(Overview)</olink>. For reference information, see <olink targetptr="privref-1" remap="internal">Chapter&nbsp;12, Privileges (Reference)</olink>.</para>
</highlights><sect1 id="privtask-3"><title>Managing and Using Privileges (Task Map)</title><para><indexterm><primary>privileges</primary><secondary>task map</secondary></indexterm><indexterm><primary>task maps</primary><secondary>managing and using privileges</secondary></indexterm>The following task map points to task
maps for managing privileges and for using privileges.</para><informaltable frame="all" pgwide="1"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="110*"/><colspec colname="col2" colwidth="167*"/><colspec colname="colspec1" colwidth="119*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Use privileges at your site</para>
</entry><entry><para>Involves assigning, removing, adding, and debugging the use of privileges.</para>
</entry><entry><para><olink targetptr="privtask-14" remap="internal">Managing Privileges (Task Map)</olink></para>
</entry>
</row><row><entry><para>Use privileges when you run a command</para>
</entry><entry><para>Involves using the privileges that have been assigned to you.</para>
</entry><entry><para><olink targetptr="privtask-16" remap="internal">Determining Your Privileges (Task Map)</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="privtask-14"><title>Managing Privileges (Task Map)</title><para><indexterm><primary>administering</primary><secondary>privileges</secondary></indexterm><indexterm><primary>managing</primary><secondary>privileges task map</secondary></indexterm><indexterm><primary>privileges</primary><secondary>administering</secondary></indexterm>The following task map points to procedures for viewing
privileges, assigning privileges, and running a script that contains privileged
commands.</para><informaltable frame="all" pgwide="1"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="110*"/><colspec colname="col2" colwidth="167*"/><colspec colname="colspec1" colwidth="119*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Determine what privileges are in a process</para>
</entry><entry><para>Lists the effective, inheritable, permitted, and limit privilege sets
for a process.</para>
</entry><entry><para><olink targetptr="privtask-5" remap="internal">How to Determine the Privileges on a Process</olink></para>
</entry>
</row><row><entry><para>Determine what privileges are missing from a process</para>
</entry><entry><para>Lists the privileges that a failed process requires to succeed.</para>
</entry><entry><para><olink targetptr="privtask-6" remap="internal">How to Determine Which Privileges a Program
Requires</olink></para>
</entry>
</row><row><entry><para>Add privileges to a command</para>
</entry><entry><para>Adds privileges to a command in a rights profile. Users or roles can
be assigned the rights profile. The users can then run the command with the
assigned privileges in a profile shell.</para>
</entry><entry><para><olink targetptr="privtask-7" remap="internal">How to Add Privileges to a Command</olink></para>
</entry>
</row><row><entry><para>Assign privileges to a user</para>
</entry><entry><para>Expands a user's or role's inheritable set of privileges. Use this procedure
with caution.</para>
</entry><entry><para><olink targetptr="privtask-8" remap="internal">How to Assign Privileges to a User or
Role</olink></para>
</entry>
</row><row><entry><para>Restrict a user's privileges</para>
</entry><entry><para>Limits the user's basic set of privileges. Use this procedure with caution.</para>
</entry><entry><para><olink targetptr="privtask-4" remap="internal">How to Limit a User's or Role's Privileges</olink></para>
</entry>
</row><row><entry><para>Run a privileged shell script</para>
</entry><entry><para>Adds privilege to a shell script and to the commands in the shell script.
Then, runs the script in a profile shell.</para>
</entry><entry><para><olink targetptr="privtask-15" remap="internal">How to Run a Shell Script With Privileged
Commands</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="privtask-10"><title>Managing Privileges</title><para>The most secure way to manage privileges for users and roles is to confine
use of privilege to commands in a rights profile. The rights profile is then
included in a role. The role is assigned to a user. When the user assumes
the assigned role, the privileged commands are available to be run in a profile
shell. The following procedures show how to assign privileges, remove privileges,
and debug privilege use.</para><task id="privtask-5"><title>How to Determine the Privileges on a Process</title><indexterm><primary>privileges</primary><secondary>listing on a process</secondary>
</indexterm><indexterm><primary>determining</primary><secondary>privileges on a process</secondary>
</indexterm><indexterm><primary>obtaining</primary><secondary>privileges on a process</secondary>
</indexterm><indexterm><primary>shell process</primary><secondary>listing its privileges</secondary>
</indexterm><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>ppriv</command></tertiary>
</indexterm><tasksummary><para><indexterm><primary><command>ppriv</command> command</primary><secondary>listing privileges</secondary></indexterm>This procedure shows how to determine which
privileges are available to your processes. The listing does not include privileges
that have been assigned to particular commands.</para>
</tasksummary><procedure remap="single-step"><step><para><indexterm><primary><option>v</option> option</primary><secondary><command>ppriv</command> command</secondary></indexterm><indexterm><primary>using</primary><secondary><command>ppriv</command> command</secondary></indexterm><indexterm><primary>double dollar sign ($$)</primary><secondary>parent shell process number</secondary></indexterm><indexterm><primary>$$ (double dollar sign)</primary><secondary>parent shell process number</secondary></indexterm><indexterm><primary>shell commands</primary><secondary>passing parent shell process number</secondary></indexterm><indexterm><primary>using</primary><secondary><command>ppriv</command> command</secondary></indexterm><indexterm><primary>viewing</primary><secondary>privileges on a process</secondary></indexterm>List the privileges that are available
to your shell's process.</para><screen>% ppriv <replaceable>pid</replaceable>
$ ppriv -v <replaceable>pid</replaceable></screen><variablelist><varlistentry><term><replaceable>pid</replaceable></term><listitem><para>Is the process number. Use a double dollar sign (<envar>$$</envar>)
to pass the process number of the parent shell to the command.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option></term><listitem><para>Provides a verbose listing of the privilege names.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="privtask-25"><title>Determining the Privileges in Your Current Shell</title><indexterm><primary>viewing</primary><secondary>privileges in a shell</secondary>
</indexterm><para>In the following example, the privileges in the parent process of the
user's shell process are listed. In the second example, the full names  of
the privileges are listed. The single letters in the output refer to the following
privilege sets:</para><variablelist><varlistentry><term><literal>E</literal></term><listitem><para>Is the effective privilege set.</para>
</listitem>
</varlistentry><varlistentry><term><literal>I</literal></term><listitem><para>Is the inheritable privilege set.</para>
</listitem>
</varlistentry><varlistentry><term><literal>P</literal></term><listitem><para>Is the permitted privilege set.</para>
</listitem>
</varlistentry><varlistentry><term><literal>L</literal></term><listitem><para>Is the limit privilege set.</para>
</listitem>
</varlistentry>
</variablelist><screen>% <userinput>ppriv $$</userinput>
1200:   -csh
flags = &lt;none&gt;
        E: basic
        I: basic
        P: basic
        L: all
% <userinput>ppriv -v $$</userinput>
1200:   -csh
flags = &lt;none&gt;
        E: file_link_any,proc_exec,proc_fork,proc_info,proc_session
        I: file_link_any,proc_exec,proc_fork,proc_info,proc_session
        P: file_link_any,proc_exec,proc_fork,proc_info,proc_session
        L: cpc_cpu,dtrace_kernel,dtrace_proc,dtrace_user,&hellip;,sys_time</screen>
</example><example id="privtask-21"><title>Determining the Privileges of a Role That You Can Assume</title><para>Roles use an administrative shell, or profile shell. You must assume
a role and use the role's shell to list the privileges that have been directly
assigned to the role. In the following example, the role <literal>sysadmin</literal> has
no directly assigned privileges.</para><screen>% <userinput>su - sysadmin</userinput>
Password: <lineannotation>&lt;Type sysadmin password&gt;</lineannotation>
$ <userinput>/usr/ucb/whoami</userinput>
sysadmin
$ <userinput>ppriv -v $$</userinput>
1400:   pfksh
flags = &lt;none&gt;
        E: file_link_any,proc_exec,proc_fork,proc_info,proc_session
        I: file_link_any,proc_exec,proc_fork,proc_info,proc_session
        P: file_link_any,proc_exec,proc_fork,proc_info,proc_session
        L: cpc_cpu,dtrace_kernel,dtrace_proc,dtrace_user,&hellip;,sys_time</screen>
</example>
</task><task id="privtask-6"><title>How to Determine Which Privileges a Program Requires</title><indexterm><primary>troubleshooting</primary><secondary>privilege requirements</secondary>
</indexterm><indexterm><primary>troubleshooting</primary><secondary>lack of privilege</secondary>
</indexterm><tasksummary><para><indexterm><primary>debugging</primary><secondary>privileges</secondary></indexterm><indexterm><primary>privileges</primary><secondary>debugging</secondary></indexterm><indexterm><primary><command>ppriv</command> command</primary><secondary>for debugging</secondary></indexterm>This procedure determines
which privileges a command or process requires to succeed.</para>
</tasksummary><taskprerequisites><para>The command or process must have failed for this procedure to work.</para>
</taskprerequisites><procedure><step><para><indexterm><primary><option>e</option> option</primary><secondary><command>ppriv</command> command</secondary></indexterm><indexterm><primary sortas="d option1"><option>D</option> option</primary><secondary><command>ppriv</command> command</secondary></indexterm>Type the command that is failing as an argument to
the <command>ppriv</command> debugging command.</para><screen>% <userinput>ppriv -eD touch /etc/acct/yearly</userinput>
touch[11365]: missing privilege "file_dac_write" 
     (euid = 130, syscall = 224) needed at ufs_direnter_cm+0x27c
touch: /etc/acct/yearly cannot create</screen>
</step><step><para>Determine which system call is failing by finding the <literal>syscall</literal> number in the <filename>/etc/name_to_sysnum</filename> file.</para><screen>% <userinput>grep 224 /etc/name_to_sysnum</userinput>
creat64                 224</screen>
</step>
</procedure><example id="privtask-31"><title>Using the <command>truss</command> Command to Examine Privilege Use</title><indexterm><primary><command>truss</command> command</primary><secondary>for privilege debugging</secondary>
</indexterm><indexterm><primary>using</primary><secondary><command>truss</command> command</secondary>
</indexterm><para>The <command>truss</command> command can debug privilege use in a regular
shell. For example, the following command debugs the failing <command>touch</command> process:</para><screen>% <userinput>truss -t creat touch /etc/acct/yearly</userinput>
creat64("/etc/acct/yearly", 0666)            
                       Err#13 EACCES [<userinput>file_dac_write</userinput>]
touch: /etc/acct/yearly cannot create</screen><para>The extended <literal>/proc</literal> interfaces report the missing
privilege after the error code in <command>truss</command> output.</para>
</example><example id="privtask-33"><title>Using the <command>ppriv</command> Command to Examine Privilege Use
in a Profile Shell</title><indexterm><primary>privileges</primary><secondary>finding missing</secondary>
</indexterm><para>The <command>ppriv</command> command can debug privilege use in a profile
shell. If you assign a rights profile to a user, and the rights profile includes
commands with privileges, the commands must be typed in a profile shell. When
the privileged commands are typed in a regular shell, the commands do not
execute with privilege. </para><para>In this example, the <literal>jdoe</literal> user can assume the role <literal>objadmin</literal>. The <literal>objadmin</literal> role includes the Object
Access Management rights profile. This rights profile allows the <literal>objadmin</literal> role to change permissions on files that <literal>objadmin</literal> does
not own.</para><para>In the following excerpt, <literal>jdoe</literal> fails to change the
permissions on the <filename>useful.script</filename> file:</para><screen>jdoe% <userinput>ls -l useful.script</userinput>
-rw-r--r--  1 aloe  staff  2303 Mar 11 05:29 useful.script
jdoe% <userinput>chown objadmin useful.script</userinput>
chown: useful.script: Not owner
jdoe% <userinput>ppriv -eD chown objadmin useful.script</userinput>
chown[11444]: missing privilege "file_chown" 
            (euid = 130, syscall = 16) needed at ufs_setattr+0x258
chown: useful.script: Not owner</screen><para>When <literal>jdoe</literal> assumes the <literal>objadmin</literal> role,
the permissions on the file are changed:</para><screen>jdoe% <userinput>su - objadmin</userinput>
Password: <lineannotation>&lt;Type objadmin password&gt;</lineannotation>
$ <userinput>ls -l useful.script</userinput>
-rw-r--r--  1 aloe  staff  2303 Mar 11 05:29 useful.script
$ <userinput>chown objadmin useful.script</userinput>
$ <userinput>ls -l useful.script</userinput>
-rw-r--r--  1 objadmin  staff  2303 Mar 11 05:29 useful.script
$ <userinput>chgrp admin useful.script</userinput>
$ <userinput>ls -l objadmin.script</userinput>
-rw-r--r--  1 objadmin  admin  2303 Mar 11 05:31 useful.script</screen>
</example><example id="privtask-35"><title>Changing a File Owned by the <literal>root</literal> User</title><para>This example illustrates the protections against privilege escalation.
For a discussion, see <olink targetptr="privref-20" remap="internal">Prevention of Privilege
Escalation</olink>. The file is owned by the <literal>root</literal> user.
The less powerful role, <literal>objadmin</literal> role needs all privileges
to change the file's ownership, so the operation fails.</para><screen>jdoe% <userinput>su - objadmin</userinput>
Password: <lineannotation>&lt;Type objadmin password&gt;</lineannotation>
$ <userinput>cd /etc; ls -l system</userinput>
-rw-r--r--  1 root  sys   1883 Mar 20 14:04 system
$ <userinput>chown objadmin system</userinput>
chown: system: Not owner
$ <userinput>ppriv -eD chown objadmin system</userinput>
chown[11481]: missing privilege "ALL" 
     (euid = 101, syscall = 16) needed at ufs_setattr+0x258
chown: system: Not owner</screen>
</example>
</task><task id="privtask-7"><title>How to Add Privileges to a Command</title><indexterm><primary>privileges</primary><secondary>adding to command</secondary>
</indexterm><indexterm><primary>adding</primary><secondary>privileges to command</secondary>
</indexterm><indexterm><primary>assigning</primary><secondary>privileges to commands in a rights profile</secondary>
</indexterm><tasksummary><para>You add privileges to a command when you are adding the command to a
rights profile. The privileges enable the role that includes the rights profile
to run the administrative command, while not gaining any other superuser capabilities.</para>
</tasksummary><taskprerequisites><para>The command or program must be privilege-aware. For a fuller discussion,
see <olink targetptr="prbac-19" remap="internal">How Processes Get Privileges</olink>.</para>
</taskprerequisites><procedure>&rolestepA;<step><para>Open the Solaris Management Console GUI.</para><para>For instructions,
see <olink targetptr="rbactask-21" remap="internal">How to Assume a Role in the Solaris Management
Console</olink>.</para>
</step><step><para>Use the Rights tool to update an appropriate profile.</para><para>Select
the command to include. For each included command, add the privileges that
the command requires.</para><caution><para>When you include commands in a rights profile and add privileges
to the commands, the commands execute with those privileges when the commands
are run in a profile shell.</para><para>The order of profiles is important.
The profile shell executes a command or action with the security attributes
that are specified in the earliest profile in the account's list of profiles.
For example, if the <command>chgrp</command> command is in the Object Access
Management rights profile with privileges, and Object Access Management is
the first profile in which the <command>chgrp</command> command is found,
then the <command>chgrp</command> command executes with the privileges specified
in the Object Access Management profile.</para>
</caution>
</step>
</procedure>
</task><task id="privtask-8"><title>How to Assign Privileges to a User
or Role</title><indexterm><primary>privileges</primary><secondary>assigning to user or role</secondary>
</indexterm><indexterm><primary>assigning</primary><secondary>privileges to user or role</secondary>
</indexterm><indexterm><primary>adding</primary><secondary>privileges directly to user or role</secondary>
</indexterm><indexterm><primary>obtaining</primary><secondary>privileges</secondary>
</indexterm><indexterm><primary>roles</primary><secondary>assigning privileges to</secondary>
</indexterm><indexterm><primary>users</primary><secondary>assigning privileges to</secondary>
</indexterm><tasksummary><para>You might trust some users with a particular privilege all the time.
Very specific privileges that affect a small part of the system are good candidates
for assigning to a user. For a discussion of the implications of directly
assigned privileges, see <olink targetptr="rbac-10" remap="internal">Security Considerations
When Directly Assigning Security Attributes</olink>.</para><para>The following procedure enables user <literal>jdoe</literal> to use
high resolution timers.</para>
</tasksummary><procedure>&rolePAstep;<step><para><indexterm><primary>using</primary><secondary><command>usermod</command> command</secondary></indexterm><indexterm><primary sortas="k2"><option>K</option> option</primary><secondary><command>usermod</command> command</secondary></indexterm>Add
the privilege that affects high resolution times to the user's initial inheritable
set of privileges.</para><screen>$ <userinput>usermod -K defaultpriv=basic,proc_clock_highres jdoe</userinput></screen>
</step><step><para>Read the resulting <filename>user_attr</filename> entry.</para><screen>$ <userinput>grep jdoe /etc/user_attr</userinput>
jdoe::::type=normal;defaultpriv=basic,proc_clock_highres</screen>
</step>
</procedure><example id="privtask-17"><title>Creating a Role With Privileges to Configure System Time</title><para><indexterm><primary>using</primary><secondary><command>smrole</command> command</secondary></indexterm>In this example, a role is created whose only task
is to handle time on the system.</para><screen>$ <userinput>/usr/sadm/bin/smrole -D nisplus:/examplehost/example.domain \</userinput>
<userinput>-r primaryadm -l</userinput> <replaceable>&lt;Type primaryadm password&gt;</replaceable> <userinput>\</userinput>
<userinput>add -- -n clockmgr \</userinput>
<userinput>-c "Role that sets system time" \</userinput>
<userinput>-F "Clock Manager" \</userinput>
<userinput>-s /bin/pfksh \</userinput>
<userinput>-u 108 \</userinput>
<userinput>-P</userinput> <replaceable>&lt;Type clockmgr password&gt;</replaceable> <userinput>\</userinput>
<userinput>-K defaultpriv=basic,proc_priocntl,sys_cpu_config,</userinput>
<userinput>proc_clock_highres,sys_time</userinput></screen><para>The <literal>-K</literal> line is wrapped for display purposes.</para><para>If the role was created locally, the <literal>user_attr</literal> entry
for the role would appear similar to the following:</para><screen>clockmgr:::Role that sets system time:
type=role;defaultpriv=basic,proc_priocntl,sys_cpu_config,
proc_clock_highres,sys_time</screen>
</example>
</task><task id="privtask-4"><title>How to Limit a User's or Role's Privileges</title><indexterm><primary>privileges</primary><secondary>limiting use by user or role</secondary>
</indexterm><indexterm><primary>limiting</primary><secondary>use of privileges by user or role</secondary>
</indexterm><tasksummary><para>You can limit the privileges that are available to a user or role by
reducing the basic set, or by reducing the limit set. You should have good
reason to limit the user's privileges in this way, because such limitations
can have unintended side effects.</para><caution><para>You should thoroughly test any user's capabilities where the
basic set or the limit set has been modified for a user.</para><itemizedlist><listitem><para>When the basic set is less than the default, users can be
prevented from using the system.</para>
</listitem><listitem><para>When the limit set is less than all privileges, processes
that need to run with an effective <literal>UID=0</literal> might fail.</para>
</listitem>
</itemizedlist>
</caution>
</tasksummary><procedure><step><para>Determine the privileges in a user's basic set and limit set.</para><para>For the procedure, see <olink targetptr="privtask-5" remap="internal">How to Determine
the Privileges on a Process</olink>.</para>
</step><step performance="optional"><para><indexterm><primary>restricting</primary><secondary>user privileges</secondary></indexterm><indexterm><primary>removing</primary><secondary>privileges from basic set</secondary></indexterm><indexterm><primary>privileges</primary><secondary>removing from basic set</secondary></indexterm><indexterm><primary>users</primary><secondary>restricting basic privileges</secondary></indexterm>Remove one of the privileges from the basic set.</para><screen>$ usermod -K defaultpriv=basic,!<replaceable>priv-name username</replaceable></screen><para>By removing the <literal>proc_session</literal> privilege, you prevent
the user from examining any processes outside the user's current session.
By removing the <literal>file_link_any</literal> privilege, you prevent the
user from making hard links to files that are not owned by the user.</para><caution><para>Do not remove the <literal>proc_fork</literal> or the <literal>proc_exec</literal> privilege. Without these privileges, the user would not be able
to use the system. In fact, these two privileges are only reasonably removed
from daemons that should not <function>fork</function> or <function>exec</function> other
processes.</para>
</caution>
</step><step performance="optional"><para>Remove one of the privileges from the limit
set.</para><screen>$ usermod -K limitpriv=all,!<replaceable>priv-name username</replaceable></screen>
</step><step><para>Test the capabilities of <replaceable>username</replaceable>.</para><para>Log in as <replaceable>username</replaceable> and try to perform the
tasks that <replaceable>username</replaceable> must perform on the system.</para>
</step>
</procedure><example id="privtask-37"><title>Removing Privileges From a User's Limit Set</title><para><indexterm><primary>removing</primary><secondary>privileges from limit set</secondary></indexterm><indexterm><primary>privileges</primary><secondary>removing from limit set</secondary></indexterm>In the following example, all sessions
that originate from <literal>jdoe</literal>'s initial login are prevented
from using the <constant>sys_linkdir</constant> privilege. That is, the user
cannot make hard links to directories, nor can the user unlink directories,
even after the user runs the <command>su</command> command.</para><screen>$ <userinput>usermod -K limitpriv=all,!sys_linkdir jdoe</userinput>
$ <userinput>grep jdoe /etc/user_attr</userinput>
jdoe::::type=normal;defaultpriv=basic;limitpriv=all,!sys_linkdir</screen>
</example><example id="privtask-39"><title>Removing Privileges From a User's Basic Set</title><para>In the following example, all sessions that originate from <literal>jdoe</literal>'s
initial login are prevented from using the <constant>proc_session</constant> privilege.
That is, the user cannot examine any processes outside the user's session,
even after the user runs the <command>su</command> command.</para><screen>$ <userinput>usermod -K defaultpriv=basic,!proc_session jdoe</userinput></screen><screen>$ <userinput>grep jdoe /etc/user_attr</userinput>
jdoe::::type=normal;defaultpriv=basic,!proc_session;limitpriv=all</screen>
</example>
</task><task id="privtask-15"><title>How to Run a Shell Script With Privileged Commands</title><indexterm><primary>privileges</primary><secondary>using in shell script</secondary>
</indexterm><indexterm><primary>scripts</primary><secondary>use of privileges in</secondary>
</indexterm><indexterm><primary>assigning</primary><secondary>privileges to commands in a script</secondary>
</indexterm><tasksummary><note><para>When you create a shell script that runs commands with inherited
privileges, the appropriate rights profile must contain the commands with
privileges assigned to them.</para>
</note>
</tasksummary><procedure><step><para><indexterm><primary>shell scripts</primary><secondary>writing privileged</secondary></indexterm>Start the script with <filename>/bin/pfsh</filename>,
or any other profile shell, on the first line.</para><screen>#!/bin/pfsh
# Copyright (c) 2003 by Sun Microsystems, Inc.</screen>
</step><step><para>Determine the privileges that the commands in the script need.</para><screen>% ppriv -eD <replaceable>script-full-path</replaceable></screen>
</step><step><para>Open the Solaris Management Console GUI.</para><para>For instructions,
see <olink targetptr="rbactask-21" remap="internal">How to Assume a Role in the Solaris Management
Console</olink>. Choose a role, such as Primary Administrator, that can create
a rights profile.</para>
</step><step><para>Use the Rights tool to create or update an appropriate profile.</para><para>Select the script, and include in the rights profile each of the commands
in the shell script that need privileges to run. For each included command,
add the privileges that the command requires.</para><caution><para>The order of rights profiles is important. The profile shell
executes the earliest instance of a command in the list of profiles. For example,
if the <command>chgrp</command> command is in the Object Access Management
rights profile, and Object Access Management is the first profile in which
the <command>chgrp</command> command is found, then the <command>chgrp</command> command
executes with the privileges that are specified in the Object Access Management
profile.</para>
</caution>
</step><step><para>Add the rights profile to a role and assign the role to a user.</para><para>To execute the profile, the user assumes the role and runs the script
in the role's profile shell.</para>
</step>
</procedure>
</task>
</sect1><sect1 id="privtask-16"><title>Determining Your Privileges (Task Map)</title><para><indexterm><primary>privileges</primary><secondary>how to use</secondary></indexterm><indexterm><primary>determining</primary><secondary>privileges task map</secondary></indexterm><indexterm><primary>using</primary><secondary>privileges task map</secondary></indexterm>The following task map points to procedures
for using the privileges that have been assigned to you.</para><informaltable frame="all" pgwide="1"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="110*"/><colspec colname="col2" colwidth="167*"/><colspec colname="colspec1" colwidth="119*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>View your privileges as a user in any shell</para>
</entry><entry><para>Shows the privileges that have been directly assigned to you. All of
your processes run with these privileges.</para>
</entry><entry><para><olink targetptr="privtask-9" remap="internal">How to Determine the Privileges That You
Have Been Directly Assigned</olink></para>
</entry>
</row><row><entry><para>Determine which commands you can run with privilege</para>
</entry><entry><para>When privileges are assigned to executables in a rights profile, the
executable must be typed in a profile shell.</para>
</entry><entry><para><olink targetptr="privtask-22" remap="internal">How to Determine the Privileged Commands
That You Can Run</olink></para>
</entry>
</row><row><entry><para>Determine which commands a role can run with privileges</para>
</entry><entry><para>Assumes the role to determine which commands the role can run with privileges.</para>
</entry><entry><para><olink targetptr="privtask-24" remap="internal">How to Determine the Privileged Commands
That a Role Can Run</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="privtask-20"><title>Determining Your Assigned Privileges</title><para><indexterm><primary>using</primary><secondary>privileges</secondary></indexterm>When a user is directly assigned privileges, the privileges are
in effect in every shell. When a user is not directly assigned privileges,
then the user must open a profile shell. For example, when commands with assigned
privileges are in a rights profile that is in the user's list of rights profiles,
then the user must execute the command in a profile shell.</para><task id="privtask-9"><title>How to Determine the Privileges That You Have
Been Directly Assigned</title><indexterm><primary>privileges</primary><secondary>determining directly assigned ones</secondary>
</indexterm><indexterm><primary>users</primary><secondary>determining directly assigned privileges</secondary>
</indexterm><tasksummary><para>The following procedure shows how to determine if you have been directly
assigned privileges.</para><caution><para>Inappropriate use of directly assigned privileges can result
in unintentional breaches of security. For a discussion, see <olink targetptr="rbac-10" remap="internal">Security Considerations When Directly Assigning Security
Attributes</olink>.</para>
</caution>
</tasksummary><procedure><step><para>List the privileges that your processes can use.</para><para>See <olink targetptr="privtask-5" remap="internal">How to Determine the Privileges on a Process</olink> for
the procedure.</para>
</step><step><para>Invoke actions and run commands in any shell.</para><para>The
privileges that are listed in the effective set are in effect throughout your
session. If you have been directly assigned privileges in addition to the
basic set, the privileges are listed in the effective set.</para>
</step>
</procedure><example id="privtask-23"><title>Determining Your Directly-Assigned Privileges</title><indexterm><primary>viewing</primary><secondary>directly assigned privileges</secondary>
</indexterm><para>If you have been directly assigned privileges, then your basic set contains
more than the default basic set. In this example, the user always has access
to the <envar>proc_clock_highres</envar> privilege.</para><screen>% <userinput>/usr/ucb/whoami</userinput>
jdoe
% <userinput>ppriv -v $$</userinput>
1800:   pfksh
flags = &lt;none&gt;
        E: file_link_any,&hellip;,<userinput>proc_clock_highres</userinput>,proc_session
        I: file_link_any,&hellip;,<userinput>proc_clock_highres</userinput>,proc_session
        P: file_link_any,&hellip;,<userinput>proc_clock_highres</userinput>,proc_session
        L: cpc_cpu,dtrace_kernel,dtrace_proc,dtrace_user,&hellip;,sys_time
% <userinput>ppriv -vl proc_clock_highres</userinput>
        Allows a process to use high resolution timers.</screen>
</example><example id="privtask-27"><title>Determining a Role's Directly-Assigned Privileges</title><indexterm><primary>roles</primary><secondary>determining directly assigned privileges</secondary>
</indexterm><indexterm><primary>viewing</primary><secondary>privileges in a shell</secondary>
</indexterm><para>Roles use an administrative shell, or profile shell. Users who assume
a role can use the role's shell to list the privileges that have been directly
assigned to the role. In the following example, the role <literal>realtime</literal> has
been directly assigned privileges to handle date and time programs.</para><screen>% <userinput>su - realtime</userinput>
Password: <lineannotation>&lt;Type realtime password&gt;</lineannotation>
$ <userinput>/usr/ucb/whoami</userinput>
realtime
$ <userinput>ppriv -v $$</userinput>
1600:   pfksh
flags = &lt;none&gt;
        E: file_link_any,&hellip;,proc_clock_highres,proc_session,sys_time
        I: file_link_any,&hellip;,proc_clock_highres,proc_session,sys_time
        P: file_link_any,&hellip;,proc_clock_highres,proc_session,sys_time
        L: cpc_cpu,dtrace_kernel,dtrace_proc,dtrace_user,&hellip;,sys_time</screen>
</example>
</task><task id="privtask-22"><title>How to Determine the Privileged Commands That
You Can Run</title><indexterm><primary>users</primary><secondary>determining own privileged commands</secondary>
</indexterm><indexterm><primary>commands</primary><secondary>determining user's privileged commands</secondary>
</indexterm><tasksummary><para>When a user is not directly assigned privileges, then the user gets
access to privileged commands through a rights profile. Commands in a rights
profile must be executed in a profile shell.</para>
</tasksummary><taskprerequisites><para>The user or role who authenticates to the Solaris Management Console
must have the <systemitem>solaris.admin.usermgr.read</systemitem> authorization.
The Basic Solaris User rights profile includes this authorization.</para>
</taskprerequisites><procedure><step><para>Determine the rights profiles that you have been assigned.</para><screen>$ <userinput>/usr/sadm/bin/smuser list -- -n <replaceable>username</replaceable> -l</userinput>
Authenticating as user: admin
&hellip; Please enter a string value for: password :: 
&hellip;
User name:      <replaceable>username</replaceable>
User ID (UID):  130
Primary group:  staff
Secondary groups: 
Comment: object mgt jobs
Login Shell: /bin/sh
Home dir server: <replaceable>system</replaceable>
Home directory: /export/home/<replaceable>username</replaceable>
AutoHome setup: True
Mail server: <replaceable>system</replaceable>
<userinput>Rights: Object Access Management</userinput>
Assigned Roles:</screen>
</step><step><para>Locate the line that begins with &ldquo;Rights:&rdquo;.</para><para>The &ldquo;Rights&rdquo;
line lists the names of the rights profiles that have been directly assigned
to you.</para>
</step><step><para>Find the names of the rights profiles in the <filename>exec_attr</filename> database.</para><screen>$ <userinput>cd /etc/security</userinput>
$ <userinput>grep "Object Access Management" exec_attr</userinput> 
Object Access Management:solaris:cmd:::/usr/bin/chgrp:privs=file_chown
Object Access Management:solaris:cmd:::/usr/bin/chown:privs=file_chown
Object Access Management:suser:cmd:::/usr/bin/chgrp:euid=0
Object Access Management:suser:cmd:::/usr/bin/chmod:euid=0
&hellip;</screen><para>The commands with added privileges are listed at the end of <literal>solaris</literal> policy entries.</para>
</step><step><para>Type the commands that require privileges in a profile shell.</para><para>When the commands are typed in a regular shell, the commands do not
run with privilege, and do not succeed.</para><screen>% <userinput>pfsh</userinput>
$</screen>
</step>
</procedure><example id="privtask-34"><title>Running Privileged Commands in a Profile Shell</title><para>In the following example, the user <literal>jdoe</literal> cannot change
the group permissions on a file from his regular shell. However, <literal>jdoe</literal> can
change the permissions when typing the command in a profile shell.</para><screen>% <userinput>whoami</userinput>
jdoe
% <userinput>ls -l useful.script</userinput>
-rwxr-xr-- 1 nodoe eng 262 Apr 2 10:52 useful.script
<userinput>chgrp staff useful.script</userinput>
chgrp: useful.script: Not owner
% <userinput>pfksh</userinput>
$ <userinput>/usr/ucb/whoami</userinput>
jdoe
$ <userinput>chgrp staff useful.script</userinput>
$ <userinput>chown jdoe useful.script</userinput>
$ <userinput>ls -l useful.script</userinput>
-rwxr-xr-- 1 jdoe staff 262 Apr 2 10:53 useful.script</screen>
</example>
</task><task id="privtask-24"><title>How to Determine the Privileged Commands That
a Role Can Run</title><indexterm><primary>roles</primary><secondary>determining role's privileged commands</secondary>
</indexterm><tasksummary><para>A role gets access to privileged commands through a rights profile that
contains commands with assigned privileges. The most secure way to provide
a user with access to privileged commands is to assign a role to them. After
assuming the role, the user can execute all the privileged commands that are
included in the rights profiles for that role.</para>
</tasksummary><taskprerequisites><para>The user or role who authenticates to the Solaris Management Console
must have the <systemitem>solaris.admin.usermgr.read</systemitem> authorization.
The Basic Solaris User rights profile includes this authorization.</para>
</taskprerequisites><procedure><step><para>Determine the roles that you can assume.</para><screen>$ <userinput>/usr/sadm/bin/smuser list -- -n <replaceable>username</replaceable> -l</userinput>
Authenticating as user: primadmin
&hellip;
User name:      <replaceable>username</replaceable>
User ID (UID):  110
Primary group:  staff
Secondary groups: 
Comment: Has admin roles
Login Shell: /bin/sh
&hellip;
Rights: 
Assigned Roles: primadmin, admin</screen>
</step><step><para>Locate the line that begins with &ldquo;Assigned Roles:&rdquo;.</para><para>The &ldquo;Assigned Roles&rdquo; line lists the roles that you can assume.</para>
</step><step><para>Determine the rights profiles that are included in one of your
roles.</para><screen>$ <userinput>/usr/sadm/bin/smuser list -- -n admin -l</userinput>
Authenticating as user: primadmin
&hellip;
User name:      admin
User ID (UID):  101
Primary group:  sysadmin
Secondary groups:
Comment: system administrator
Login Shell: /bin/pfksh
&hellip;
Rights: System Administrator
Assigned Roles:</screen>
</step><step><para>Locate the names of the rights profiles for the role in the &ldquo;Rights:&rdquo;
line.</para>
</step><step><para>Find the rights profiles in the <filename>prof_attr</filename> database.</para><para>Because the System Administrator profile is a collection of profiles,
you need to list the profiles in the System Administrator profile.</para><screen>$ <userinput>cd /etc/security</userinput>
$ <userinput>grep "System Administrator" prof_attr</userinput> 
System Administrator:::Can perform most non-security administrative
tasks:profiles=Audit Review,Printer Management,Cron Management,
Device Management,File System Management,Mail Management,Maintenance
and Repair,Media Backup,Media Restore,Name Service Management,Network
Management,Object Access Management,Process Management,Software
Installation,User Management,All;help=RtSysAdmin.html</screen>
</step><step><para>For each rights profile, find the rights profiles in the <filename>exec_attr</filename> database.</para><para>For example, the Network Management profile
is a supplementary profile of the System Administrator profile. The Network
Management profile includes a number of privileged commands.</para><screen>$ <userinput>cd /etc/security</userinput>
$ <userinput>grep "Network Management" exec_attr</userinput> 
Network Management:<userinput>solaris</userinput>:cmd:::/usr/sbin/ifconfig:<userinput>privs=sys_net_config</userinput>
Network Management:<userinput>solaris</userinput>:cmd:::/usr/sbin/route:<userinput>privs=sys_net_config</userinput>
&hellip;</screen><para>The commands and their assigned privileges are the final two fields
of <literal>solaris</literal> policy entries. You can run these commands in
the profile shell of your role.</para>
</step>
</procedure><example id="privtask-36"><title>Running the Privileged Commands in Your Role</title><para>When a user assumes a role, the shell becomes a profile shell. Therefore,
the commands are executed with the privileges that were assigned to the commands.
In the following example, the <literal>admin</literal> role can change the
permissions on the <filename>useful.script</filename> file.</para><screen>% <userinput>whoami</userinput>
jdoe
% <userinput>ls -l useful.script</userinput>
-rwxr-xr-- 1 elsee eng 262 Apr 2 10:52 useful.script
<userinput>chgrp admin useful.script</userinput>
chgrp: useful.script: Not owner
% <userinput>su - admin</userinput>
Password: <lineannotation>&lt;Type admin password&gt;</lineannotation>
$ <userinput>/usr/ucb/whoami</userinput>
admin
$ <userinput>chgrp admin useful.script</userinput>
$ <userinput>chown admin useful.script</userinput>
$ <userinput>ls -l useful.script</userinput>
-rwxr-xr-- 1 admin admin 262 Apr 2 10:53 useful.script</screen>
</example>
</task>
</sect1>
</chapter><?Pub *0000042804 0?>