Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Oracle Solaris 11 Advanced Administration Cookbook.docx
Скачиваний:
3
Добавлен:
01.07.2025
Размер:
3 Мб
Скачать
☆

Getting ready

This recipe requires a virtual machine (VirtualBox or VMware) running Oracle Solaris 11 and with at least 2 GB RAM.

How to do it…

We are going to learn both the methods to allow a regular user to be able to reboot a system, that is, using the pfexec command (simpler) and RBAC's role (more complex).

Using the pfexec command is easy. First, create the aborges regular user with

hacker123! as the password, as shown in the following commands:

root@solaris11-1:~# useradd -d /export/home/aborges -m -s /bin/bash aborges

80 blocks

root@solaris11-1:~# passwd aborges

New Password: hacker123!

Re-enter new Password: hacker123!

passwd: password successfully changed for aborges

Configuring and Administering RBAC and Least Privileges

The main idea is to associate a profile (that is, a set of commands) directly to the user (aborges). In this case, the desired profile already exists; if not, we have to create a new one. To avoid creating an unnecessary profile, verify that there is a line in the /etc/security/ exec_attr.d/core-os file with the reboot command by executing the following command:

root@solaris11-1:~# cat /etc/security/exec_attr.d/core-os | grep reboot

Maintenance and Repair:solaris:cmd:RO::/usr/sbin/reboot:uid=0

This is excellent! There is one profile named "Maintenance and Repair" that includes the reboot command. For accomplishing our task, associate this profile (using the –P option) with the aborges user, as shown in the following command:

root@solaris11-1:~# usermod -P "Maintenance and Repair" aborges root@solaris11-1:/# more /etc/user_attr.d/local-entries | grep aborges aborges::::profiles=Maintenance and Repair

As we realized, it created an entry for the aborges user in the /etc/ user_attr.d/ local-entries file. However, even including this entry, which associates the aborges user with the "Maintenance and Repair" profile, the user is still not able to reboot the system, as shown in the following command:

root@solaris11-1:/# su – aborges

Oracle Corporation SunOS 5.11 11.1 September 2012

aborges@solaris11-1:~$ reboot

reboot: permission denied

Nonetheless, if the aborges user wants to execute the same command using pfexec, the result will be different, as shown in the following command:

aborges@solaris11-1:~$ pfexec reboot

It worked! The system will be rebooted as expected.

The approach using the pfexec command is wonderful, but the mode chosen to configure it (taking a ready profile) can bring about two little side effects:

f The "Maintenance and Repair" profile has other commands, and we have also assigned these commands to the aborges user, as shown in the following command:

root@solaris11-1:~# cat /etc/security/exec_attr.d/core-os | grep

-i "Maintenance and Repair"

Maintenance and Repair:solaris:cmd:RO::/usr/bin/mdb:privs=all

Maintenance and Repair:solaris:cmd:RO::/usr/bin/ coreadm:euid=0;privs=proc_owner

Maintenance and Repair:solaris:cmd:RO::/usr/sbin/croinfo:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/bin/date:euid=0

Chapter 7

Maintenance and Repair:solaris:cmd:RO::/usr/bin/ldd:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/bin/vmstat:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/eeprom:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/halt:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/init:uid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/pcitool:privs=all Maintenance and Repair:solaris:cmd:RO::/usr/sbin/poweroff:uid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/prtconf:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/reboot:uid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/syslogd:euid=0 Maintenance and Repair:solaris:cmd:RO::/usr/sbin/bootadm:euid=0

Maintenance and Repair:solaris:cmd:RO::/usr/sbin/ ucodeadm:privs=all

Maintenance and Repair:solaris:cmd:RO::/usr/sbin/ cpustat:privs=basic,cpc_cpu

Maintenance and Repair:solaris:cmd:RO::/usr/bin/ pgstat:privs=basic,cpc_cpu

Maintenance and Repair:solaris:cmd:RO::/usr/bin/ kstat:privs=basic,cpc_cpu

Maintenance and Repair:solaris:cmd:RO::/usr/sbin/ ilomconfig:privs=sys_config,sys_ip_config,sys_dl_config

Maintenance and Repair:solaris:cmd:RO::/usr/lib/ilomconfig. builtin:privs=sys_config,sys_ip_config,sys_dl_config

To prevent this, it would be better to create a new profile and assign only the reboot command to it.

f The second side effect is that the procedure using the pfexec command should be done for each user that needs to use the reboot command, but it can take additional time.

The second method to reach our goal is using roles, profiles, and/or authorizations together. The advantage in this case is that privileges are not associated with users directly, but they are assigned to roles instead. Then, if a regular user needs to reboot the system (for example), it assumes the role using the su command and executes the appropriate command.

Create another user (different from the previous one) to be used in this method by running the following command:

root@solaris11-1:~# useradd -d /export/home/rbactest -m -s /bin/bash rbactest

80 blocks

root@solaris11-1:~# passwd rbactest

New Password: oracle123!

Configuring and Administering RBAC and Least Privileges

Re-enter new Password: oracle123!

passwd: password successfully changed for rbactest

To confirm that the brbactest user can't reboot the system, execute the following commands:

root@solaris11-1:~# su - rbactest

Oracle Corporation SunOS 5.11 11.1 September 2012

rbactest@solaris11-1:~$ reboot

reboot: permission denied

Create a role that will be configured later by running the following commands:

root@solaris11-1:~# roleadd -m -d /export/home/r_reboot -s /bin/pfbash r_reboot

80 blocks

root@solaris11-1:~# grep r_reboot /etc/passwd r_reboot:x:103:10::/export/home/r_reboot:/bin/bash root@solaris11-1:~# grep r_reboot /etc/shadow r_reboot:UP:::::::

As we have mentioned previously, profiles are very important and are used during RBAC configuration. The system already has some defined system profiles that are configured in the /etc/security/prof_attr.d/core-os file, as shown in the following command:

root@solaris11-1:~# more /etc/security/prof_attr.d/core-os (truncated output)

All:RO::\

Execute any command as the user or role:\ help=RtAll.html

Administrator Message Edit:RO::\ Update administrator message files:\ auths=solaris.admin.edit/etc/issue,\ solaris.admin.edit/etc/motd;\ help=RtAdminMsg.html

Audit Configuration:RO::\ Configure Solaris Audit:\ auths=solaris.smf.value.audit;\ help=RtAuditCfg.html

Chapter 7

Audit Control:RO::\ Control Solaris Audit:\

auths=solaris.smf.manage.audit;\ help=RtAuditCtrl.html

(truncated output)

Therefore, according to the suggested steps in the introduction of this recipe, create a profile

named Reboot at the end of the profile configuration file, as shown in the following commands:

root@solaris11-1:~# vi /etc/security/prof_attr

#

# The system provided entries are stored in different files

# under "/etc/security/prof_attr.d". They should not be

# copied to this file.

#

# Only local changes should be stored in this file.

# This line should be kept in this file or it will be overwritten.

#

Reboot:RO::\

For authorized users to reboot the system:\ help=RebootByRegularUser.html

We know from this file that the profile name is Reboot and the RO (read-only) characters indicate that it isn't modifiable by any tool that changes this database. The lines that follow denote the description and the help file (it is unnecessary to create it). It will be possible

to bind authorizations (the auths key), other profiles (the profiles key), and privileges (the priv key) to this Reboot profile.

Following the profile creation, we have to assign one or more commands to this profile, and local modifications occur by editing the /etc/security/exec_attr file, as shown in the following command:

root@solaris11-1:~# vi /etc/security/exec_attr

#

# The system provided entries are stored in different files

# under "/etc/security/exec_attr.d". They should not be

# copied to this file.

#

# Only local changes should be stored in this file.

# This line should be kept in this file or it will be overwritten.

#

Reboot:solaris:cmd:RO::/usr/sbin/reboot:uid=0

Configuring and Administering RBAC and Least Privileges

The components of the last line of the preceding code snippet can be explained as follows:

f Reboot: This is the profile name.

f solaris: This is the security policy associated with the Reboot profile. This security policy is able to recognize privileges. Oracle Solaris 11 has another possible value for this field named suser (not shown previously), which is very similar to the solaris value, but it is not able to understand and recognize privileges.

f cmd: This is a type of object. In this case, it is a command to be executed by a shell.

f RO: This indicates that this line isn't modifiable by any tool that changes this file.

f /usr/sbin/reboot: This is the command to be executed by a user when they

assume the role that contains this Reboot profile.

f Uid=0: This command is run with the real ID of the user's root (uid=0). This is the case when a user has to run the command; the command will be executed as run by a root user. Other good and useful possible keys are euid (effective user ID, which is similar to running a command with setuid set as the executable) and privs (privileges).

Again, it is very interesting to check the already existing system execute attributes defined in

the /etc/security/exec_attr.d/core-os file, as shown in the following command:

root@solaris11-1:~# more /etc/security/exec_attr.d/core-os (truncated output)

All:solaris:cmd:RO::*:

Audit Control:solaris:cmd:RO::/usr/sbin/audit:privs=proc_owner,sys_audit Audit Configuration:solaris:cmd:RO::/usr/sbin/auditconfig:privs=sys_audit Audit Review:solaris:cmd:RO::/usr/sbin/auditreduce:euid=0

Audit Review:solaris:cmd:RO::/usr/sbin/auditstat:privs=proc_audit Audit Review:solaris:cmd:RO::/usr/sbin/praudit:privs=file_dac_read Contract Observer:solaris:cmd:RO::/usr/bin/ctwatch:\

privs=contract_event,contract_observer

Cron Management:solaris:cmd:RO::/usr/bin/crontab:euid=0 Crypto Management:solaris:cmd:RO::/usr/sbin/cryptoadm:euid=0 Crypto Management:solaris:cmd:RO::/usr/bin/kmfcfg:euid=0 Crypto Management:solaris:cmd:RO::/usr/sfw/bin/openssl:euid=0 Crypto Management:solaris:cmd:RO::/usr/sfw/bin/CA.pl:euid=0

DHCP Management:solaris:cmd:RO::/usr/lib/inet/dhcp/svcadm/ dhcpconfig:uid=0

DHCP Management:solaris:cmd:RO::/usr/lib/inet/dhcp/svcadm/dhtadm:uid=0 DHCP Management:solaris:cmd:RO::/usr/lib/inet/dhcp/svcadm/pntadm:uid=0 (truncated output)

Chapter 7

It's time to bind the r_reboot role to the Reboot profile (the –P option) by executing the following commands:

root@solaris11-1:~# rolemod -P Reboot r_reboot

root@solaris11-1:~# more /etc/user_attr

#

# The system provided entries are stored in different files

# under "/etc/user_attr.d". They should not be copied to this file.

#

# Only local changes should be stored in this file.

# This line should be kept in this file or it will be overwritten.

#

ale::::lock_after_retries=no;profiles=System Administrator;roles=root

r_reboot::::type=role;profiles=Reboot;roleauth=role

According to the previous output, r_reboot is of type role and it is associated with the

Reboot profile.

The r_reboot role does not have any password, so we should set a new password for it by running the following command:

root@solaris11-1:~# passwd r_reboot

New Password: hacker321!

Re-enter new Password: hacker321!

passwd: password successfully changed for r_reboot root@solaris11-1:~# grep r_reboot /etc/shadow

r_reboot:$5$q75Eiy5/$u9mgnYsvlszbNXkSuH4kZwVVnFOhemnCTMF// cvBWD9:16178::::::19216

The RBAC configuration is almost complete. To assume this r_reboot role, the rbactest user must be assigned to it by using the -R option from the usermod command, as shown in the following command:

root@solaris11-1:~# usermod -R r_reboot rbactest

root@solaris11-1:~# more /etc/user_attr

#

# The system provided entries are stored in different files

# under "/etc/user_attr.d". They should not be copied to this file.

#

# Only local changes should be stored in this file.

# This line should be kept in this file or it will be overwritten.

#

Configuring and Administering RBAC and Least Privileges

ale::::lock_after_retries=no;profiles=System Administrator;roles=root r_reboot::::type=role;profiles=Reboot;roleauth=role rbactest::::roles=r_reboot

To confirm every executed task until now, run the following command:

root@solaris11-1:~# roles rbactest r_reboot

root@solaris11-1:~# profiles rbactest

rbactest:

Basic Solaris User All

root@solaris11-1:~# profiles r_reboot

r_reboot:

Reboot

Basic Solaris User All

It is worth remembering that rbactest is a user while r_reboot is a role, and as explained previously, it is not possible to log in to the system using a role. Additionally, the existing profiles are Basic Solaris User, which enables users to use the system according to the established security limits, and All, which provides access to the commands that do not have any security attributes.

Continuing the verification, we have to check the authorizations for the r_reboot role and the rbactest user as well as for the assigned profiles to the r_reboot role. These tasks are done by executing the following sequence of commands:

root@solaris11-1:~# auths r_reboot solaris.admin.wusb.read,solaris.mail.mailq,solaris.network.autoconf.read root@solaris11-1:~# auths rbactest solaris.admin.wusb.read,solaris.mail.mailq,solaris.network.autoconf.read root@solaris11-1:~# profiles -l r_reboot

r_reboot:

Reboot

/usr/sbin/reboot uid=0

Basic Solaris User

auths=solaris.mail.mailq,solaris.network.autoconf.read, solaris.admin.wusb.read

profiles=All

Chapter 7

/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

/usr/bin/cdda2wav.bin privs=file_dac_read, sys_devices,proc_priocntl,net_privaddr

All

*

There are a few points to be highlighted:

f The rbactest user is assigned to the r_reboot role.

f There is no authorization assigned either to the rbactest user or to the

r_reboot role.

f The All profile grants unrestricted access to all unrestricted commands from Oracle Solaris 11. In this case, the r_reboot role is associated with three profiles: Reboot, Basic Solaris User, and All.

f The Basic Solaris User profile can execute some related CD-ROM commands using specific privileges.

Finally, we can verify that the rbactest user is able to reboot the system by executing the following command:

root@solaris11-1:~# id uid=0(root) gid=0(root) root@solaris11-1:~# su - rbactest

Oracle Corporation SunOS 5.11 11.1 September 2012 rbactest@solaris11-1:~$ id

uid=102(rbactest) gid=10(staff) rbactest@solaris11-1:~$ profiles

Basic Solaris User All

rbactest@solaris11-1:~$ su - r_reboot

Password: hacker321!

Oracle Corporation SunOS 5.11 11.1 September 2012 r_reboot@solaris11-1:~$ id

uid=103(r_reboot) gid=10(staff) r_reboot@solaris11-1:~$ profiles

Reboot

Basic Solaris User All

r_reboot@solaris11-1:~$ reboot

Configuring and Administering RBAC and Least Privileges

The system is reinitiated immediately. That's fantastic!

RBAC allows you to integrate all the concepts that you have learned about (roles, profiles, authorizations, and commands) with privileges; therefore, it offers us a more fine-grained and integrated control than a sudo program does.

When working with Oracle Solaris 11, we can use RBAC with services from the SMF framework. For example, the DNS client and DHCP server have the following authorizations:

root@solaris11-1:~# svcprop -p general/action_authorization dns/client

solaris.smf.manage.name-service.dns.client

root@solaris11-1:~# svcprop -p general/action_authorization dhcp/ server:ipv4

solaris.smf.manage.dhcp

Without these appropriate authorizations, the rbactest user isn't able to manage these services, as shown in the following commands:

root@solaris11-1:~# id uid=0(root) gid=0(root) root@solaris11-1:~# su - rbactest

Oracle Corporation SunOS 5.11 11.1 September 2012 rbactest@solaris11-1:~$ id

uid=102(rbactest) gid=10(staff) rbactest@solaris11-1:~$ svcadm restart dns/client

svcadm: svc:/network/dns/client:default: Permission denied. rbactest@solaris11-1:~$ svcadm restart dhcp/server:ipv4 svcadm: svc:/network/dhcp/server:ipv4: Permission denied.

It's easy to solve these problems, assigning the respective authorization to the r_reboot

role, by executing the following command:

root@solaris11-1:~# rolemod -A solaris.smf.manage.name-service.dns. client,solaris.smf.manage.dhcp r_reboot

To verify that the previous command has worked, check the altered file:

root@solaris11-1:~# more /etc/user_attr

#

# The system provided entries are stored in different files

# under "/etc/user_attr.d". They should not be copied to this file.

#

# Only local changes should be stored in this file.

Chapter 7

# This line should be kept in this file or it will be overwritten.

#

ale::::lock_after_retries=no;profiles=System Administrator;roles=root

r_reboot::::type=role;auths=solaris.smf.manage.name-service.dns. client,solaris.smf.manage.dhcp;profiles=Reboot;defaultpriv=basic,file_ dac_read;roleauth=role

rbactest::::defaultpriv=basic,file_dac_read;roles=r_reboot

That's nice! It's time to test whether our modifications have worked by executing the following command:

root@solaris11-1:~# su - rbactest

Oracle Corporation SunOS 5.11 11.1 September 2012 rbactest@solaris11-1:~$ su - r_reboot

Password: hacker321!

Oracle Corporation SunOS 5.11 11.1 September 2012 r_reboot@solaris11-1:~$ svcadm -v restart dns/client Action restart set for svc:/network/dns/client:default. r_reboot@solaris11-1:~$ svcadm -v restart dhcp/server:ipv4 Action restart set for svc:/network/dhcp/server:ipv4.

That's excellent! The integration of RBAC with SMF is perfect, and a normal user such as rbactest is able to manage both the services (the DNS client and the DHCP server) as it is the root user.

If we want to unbind the r_reboot role from the rbactest user to prevent them from rebooting, or to perform any other action on the system, execute the following command:

root@solaris11-1:~# roles rbactest

r_reboot

root@solaris11-1:~# usermod -R "" rbactest root@solaris11-1:~# roles rbactest root@solaris11-1:~#

A final and additional note: it is possible to configure default RBAC authorizations and profiles for every user in the /etc/security/policy.conf file. In the same way, there is the option to configure the default privilege and its limit, as shown in the following command:

root@solaris11-1:~# more /etc/security/policy.conf (truncated output)

AUTHS_GRANTED=

PROFS_GRANTED=Basic Solaris User

Configuring and Administering RBAC and Least Privileges

CONSOLE_USER=Console User

(truncated output)

#

#PRIV_DEFAULT=basic

#PRIV_LIMIT=all

#

(truncated output)

An overview of the recipe

In this section, we learned how to use RBAC in order to allow a regular user to reboot the system. Furthermore, we have tested how to find and grant the necessary authorization to manage services from the SMF framework. The same procedure should be applied for any user and any number of commands.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]