Let's give the user "rara" the right to use the
snoop command.
Step 1: Creating the role
First, let us check if there's already a role defined:
---
root@solcluster04:~> roles
No roles
root@solcluster04:~>
---
Nope, so let's create a role. The handling of roles is quite similar to regular UNIX accounts and pretty easy to understand. Just have a look at this:
---
root@solcluster04:~> roleadd -m -d /export/roles/snoopy snoopy
64 blocks
root@solcluster04:~> passwd snoopy
New Password:
Re-enter new Password:
passwd: password successfully changed for snoopy
root@solcluster04:~>
---
As you can see, we added the role using the
roleadd command and assigned a password with
passwd.
Next, we need to tell Solaris that "rara" should be able to assume this role. We use
usermod for this, since we me modify a user profile here.
---
root@solcluster04:~> usermod -R snoopy rara
UX: usermod: rara is currently logged in, some changes may not take effect until next login.
root@solcluster04:~>
---
Unlike common user data, this is not stored in
/etc/passwd, but in
/etc/user_attr instead. Give it a try:
---
root@solcluster04:~> grep rara /etc/user_attr
rara::::type=normal;roles=snoopy;profiles=ZFS File System Management
root@solcluster04:~>
---
The
ZFS File System Management entry is a leftover from chapter II, just ignore it. The important part of the entry is
roles=snoopy. Please take note that the path of the user attribute database is
/etc/user_attr, and not
/etc/security/user_attr.
Okay, now we have the role, but we have not defined what the user is allowed to do with it.
Step 2: Creating the profile
First, we create a simple profile. Profiles are stored in the profile attribute database,
/etc/security/prof_attr
---
root@solcluster04:~> echo "Snooper:::Snoop user role:" > /etc/security/prof_attr
---
This line defines a profile called "Snooper". It has "Snoop user role" as a comment. Don't forget the ":" at the end of the line, that's important.
Good. So far we have create a
role and a
profile. Let's tie these two together.
---
root@solcluster04:~> rolemod -P Snooper snoopy
root@solcluster04:~>
---
Okay, done. The
/etc/user_attr file will now reflect this change. Let's have a look at it.
---
root@solcluster04:~> grep snoopy /etc/user_attr
rara::::type=normal;roles=snoopy;profiles=ZFS File System Management,Primary Administrator
snoopy::::type=role;profiles=Snooper
root@solcluster04:~>
---
Step 3: Linking the profile to the snoop command
There's one more step needed, because our role has still no idea what all that fuzz is about. Let's link it to the
snoop command now.
---
root@solcluster04:~> echo"Snooper:suser:cmd:::/usr/sbin/snoop:uid=0" > /etc/security/exec_attr
root@solcluster04:~>
---
As you can see, this entry contains three important fields.
First comes
Snooper, the profile name, which is needed for linking the profile and the
snoop command together.
Second,
/usr/sbin/snoop is the path to the
snoop binary. If you want to give a role access to more commands than just one, you create a single line for each of the commands. Since every line has the "Snooper" identifier, this won't create a problem. Multiple lines are a common practice.
Third,
uid=0 defines the uid under which the command will be executed, in our case it's the
root uid.
Ignore the other fields for now. Read the man page after you became familiar with what we did now; RBAC is one of the Solaris topics which is very easy and straight forward, but if you look into the official documentation, you'll get the impression that you need to obtain a mountain of knowledge first. Concentrate on the important stuff instead, you can still learn the rest later.
Step 4: Using the role
Okay, let's give it a try. Log in as the user "rara" and then assume the role by using the
su command. If it works, you tell "rara" the
snoopy password and you can be 100% sure that "rara" is able to snoop the network - and nothing else.
rara@solcluster04:~> /usr/sbin/snoop
snoop: /dev/bge0: Permission denied
See? "rara" cannot use the "snoop" command by default. He has to assume the role first, because only the role is allowed to do this. That's way better than using
pfexec, because you did not destroy your last security barrier.
---
rara@solcluster04:~> su snoopy
Password:
---
"rara" assumed the role now. Let's give it a try.
---
$ /usr/sbin/snoop
Using device /dev/bge0 (promiscuous mode)
solcluster04 -> solrara.webde.local TCP D=56773 S=22 Push Ack=153967203 Seq=1239235026 Len=64 Win=49640
solrara.webde.local -> solcluster04 TCP D=22 S=56773 Ack=1239235026 Seq=153967203 Len=0 Win=49640
[...]
---
Congratulations

Feel free to have a look at
/var/adm/sulog now. Assuming the role by "rara" is logged. That's another difference to
pfexec.
In the next chapter, which will also be the last, we'll learn how to link roles to the SMF. For instance, this enables us to give "rara" the right to
restart a service, but not to
disable it. You want to know how this works in case your company has operators or developers with the urge to restart their stuff from time to time, but who are not educated enough to be granted full root privileges.
Posted by Ralf Ramge