Friday, May 23, 2014

GNOME Nautilus toolbar

The events of life are always interposing with our plans.
My goals have been delayed and added since my original plans.
Never mind, I'll persevere and keep on working on them.

By the way, I've been busy with another University degree.
This month I've also attended to the 30 years meeting of my Air Force class.
It was great; memories, regrets, new hopes, but still the same ideals and values.

OK, all that isn't Solaris.
Let's focus :-)

Let me register how to somewhat enhance GNOME Nautilus toolbar.
This is just a collection of a few Internet and personal findings.

GNOME Nautilus is delivered with a reasonable configuration in Solaris 11.
Here's how it typically looks like:


Actually there's not so much to tweak and extend.
Even so, I'd like to customize the toolbar to something that better fit my needs.
Here's the final result of my attempt:


I hope the change will be well apparent.
There's a new separator and 2 buttons were added and 1 moved:
  
  • The ZFS snapshots button has been moved.
    IMO the ZFS snapshot button was misplaced, so I've "corrected" it.
      
  • A button for deleting files (move to Trash).
    I'm still not sure of the advantage of the move to Trash button.
    The Del key is always available anyway (at least on English keyboards).
       
  • A create folder (not a ZFS file system) button.
    I think it frequently saves a click which seems good to me.
    But there may be cases where a ZFS file system would be better.
    (see GNOME Nautilus scripts)
       
Here's how it's done:

# cd /usr/share/nautilus/ui
# cp -p nautilus-navigation-window-ui{,-original}.xml
# vim nautilus-navigation-window-ui.xml

BEFORE

# tail -19 nautilus-navigation-window-ui-original.xml  
<toolbar name="Toolbar">
    <toolitem name="Back" action="Back"/>
    <toolitem name="Forward" action="Forward"/>
    <toolitem name="Up" action="Up"/>
    <toolitem name="Stop" action="Stop"/>
    <toolitem name="Reload" action="Reload"/>
    <toolitem name="Restore" action="Restore"/>
    <separator/>
    <toolitem name="Home" action="Home"/>
    <toolitem name="Computer" action="Go to Computer"/>
    <separator/>
    <toolitem name="Zoom" action="Zoom"/>
    <toolitem name="ViewAs" action="ViewAs"/>
    <toolitem name="Search" action="Search"/>
    <placeholder name="Extra Buttons Placeholder">
        <placeholder name="Extension Actions"/>
    </placeholder>
</toolbar>
</ui>


AFTER

# tail -24 nautilus-navigation-window-ui.xml
<toolbar name="Toolbar">
    <toolitem name="Back" action="Back"/>
    <toolitem name="Forward" action="Forward"/>
    <toolitem name="Up" action="Up"/>
    <toolitem name="Stop" action="Stop"/>
    <toolitem name="Reload" action="Reload"/>
    <separator/>
    <toolitem name="Home" action="Home"/>
    <toolitem name="Computer" action="Go to Computer"/>
    <separator/>
    <toolitem name="Zoom" action="Zoom"/>
    <toolitem name="ViewAs" action="ViewAs"/>
    <toolitem name="Search" action="Search"/>

    <!-- Begin customizations -->
    <separator/>

    <toolitem name="Restore" action="Restore"/>
    <toolitem name="Trash" action="Trash"/>
   
<toolitem name="New Folder" action="New Folder"/> 
    <!-- End customizations -->
    <placeholder name="Extra Buttons Placeholder">
        <placeholder name="Extension Actions"/>
    </placeholder>

</toolbar>
</ui>


Finally, back to the regular user GNOME session, kill all Nautilus processes (in order to refresh for the new settings):

$ pkill nautilus
   
Alternatively, you could have attempted to issue the more graceful:

$ nautilus -q
  

Wednesday, April 30, 2014

Administrative files & pfedit

Here's another great tool from the Solaris 11.1  arsenal: pfedit (1M).
It's the per-file authorized edit of administrative text files.

Great, great tool! And it's even audit enabled!
Imagine the cumbersome work to approach (not match) it with sudo!

For the auditing I think it's worthy to quote the man page:
          ..., in  the  case  of  a  successful  update,  an
attempt  to make unauthorized use, or if an error occurs, an
audit record is generated to capture the subject,  the  file
name,  the  authorization  used, the file change if any, and
the success or failure of the  operation
.  The  audit  event
type and default class is one of:


  AUE_admin_edit:edit administrative file:as
  AUE_admin_file_create:create administrative file:as
  AUE_admin_file_remove:remove administrative file:as

The fundamental idea is rather straightforward.
Add the proper Solaris authorization related to the administrative file.

Example:

Let's authorize user1 to edit /etc/hosts.
The following is just for quick learning, don't do it exactly this way.
In fact, the proper way of doing it is to create a RBAC profile or a role.

# usermod -A +solaris.admin.edit/etc/hosts user1
UX: usermod: user1 is currently logged in, 

some changes may not take effect until next login.

# getent user_attr user1
user1::::auths=solaris.admin.edit/etc/hosts;...


In the above example, user1 happened to be logged in.
But that won't be an issue for this particular case.
Otherwise, it's necessary to get a new session.

user1$ pfedit /etc/hosts
...

#
::1              localhost
127.0.0.1        localhost        loghost

#

...
~

~
"/tmp/hosts.pfedit.AXaGmg" 25L, 587C

Hadn't been for the given Solaris authorization user1 would get:

user1$ pfedit /etc/hosts
pfedit: User user1 is not authorized...


Or at best (typically after a w!):

user1$ vi /etc/hosts
...
"/etc/hosts"
"/etc/hosts" E212: Can't open file for writing
Press ENTER or type command to continue


The pfedit command can also be used to create administrative text files.
Those files can also be deleted (removed) with the -r option.



It isn't a good practice to apply the authorization on a per-user basis.
Let's see a more realistic approach.

In general, it's recommended to:
  • Gather related authorizations in a profile.
  • Assign the profile to a role and the role to authorized logins (users).

For instance:

Assume that user1 and role1 already exist, of course.
Let's invent a level 0 type 1 administration profile.

# profiles -p "Admin L0 T1"
profiles: Admin L0 T1> set auths=solaris.admin.edit/etc/hosts

profiles: Admin L0 T1> set desc="Level 0 Type 1 Administrator"
profiles: Admin L0 T1> exit

# rolemod -P +"Admin L0 T1" role1
# usermod -R +role1 user1

But as in the man page it may be OK (or enough) to not require a role.
Simply assign the profile directly to the login.

# usermod -P +"Admin L0 T1" user1

The trade-offs should be clear:
Directly assigning profiles to logins complicates account management, whereas assigning profiles to roles requires inputing a password every time roles are used (but still better than having a sudo password timeout or a sudo su -).
  

Solaris 11.2 Beta availability

Yesterday was a great day!
Solaris 11.2 Beta was made available for downloading!

I don't recall a Beta version of Solaris for a long time.
I can only think of it as a matter of marketing competition and so on.
Nevertheless, I still haven't no other option but to reinstate that:
It continues raising the bar.
Tremendous enhancements and new features.
Oracle is definitely sustaining Solaris.
  
Once more, since the beginning of this blog I can say:
If it must run, it runs on Solaris!
 

Friday, April 11, 2014

NIS & logins - troubleshooting #1

Despite all the quality and stability of Solaris 11 sometimes things go wrong.
Before pinning up anything it's important to assess all the variables.

For instance, upon forcibly rebooting a x86 with a few Solaris 11 zones, one of them acting as a NFS server, within a NIS services infrastructure something odd happened; the following values simply vanished:
  • The config/* of name-service/switch SMF service.
  • The config/domainname of nis/domain SMF service.
  • The sharectl nfsmapid_domain.
  
The resolution was simply reentering the correct values, of course.
But until narrow down to what was wrong the symptoms were diverse:
  • The NIS users were not being able to log in.
  • The NFS server was not resolving any uid and gid.
  • The NIS clients were listing nobody for user and group.

Nevertheless it's most important to determine the cause.
In my specific case I suspect of the well known:
Using ZFS Storage Pools in VirtualBox
Yes, I'm using VirtualBox for composing many posts.
Yes, due to a video adapter failure the host system had to be halted for repair.
And, yes, I haven't enabled the cache flushing on the VMs.
  

Tuesday, April 8, 2014

NIS & roles

I've already posted about NIS & logins.
This post is a similar one but about NIS & roles.

A role is an account that is used to indirectly access the system.
As a login it posses the concepts of credential and home directory.
Those resources are conveniently centrally managed by NIS services.
Unfortunately NIS can't provide nowadays security requirements.
Nevertheless, it may still be very useful on restricted scenarios.

I reinstate the assumptions listed on NIS & logins.
Nevertheless I make one exception (just for illustration):
the NIS master host nis-1 is an immutable zones of host-1.

On this example, I'll create a role called nis.
The goal is to manage NIS through this role avoiding the cumbersome sudo.

To perform the series of changes on nis-1 reboot it into read-write mode:
(when finished, reboot it once again to reenter the read-only mode)

host-1# zoneadm -z nis-1 reboot -w

Create the role account on the NIS master:

nis-1# roleadd -c "NIS" -K roleauth=user nis

nis-1# getent passwd nis
nis:x:103:10:NIS:/export/home/nis:/usr/bin/pfbash


nis-1# passwd nis
New Password:
Re-enter new Password:
passwd: password successfully changed for nis


Copy the role basic configuration to the appropriate maps' sources:

nis-1# grep nis /etc/passwd >> /var/nis/acct/passwd
nis-1# grep nis /etc/shadow >> /var/nis/acct/shadow

Clean up the local role account from the NIS master:

nis-1# roledel nis

Edit the group and home directory configuration on the passwd map.
It should look like as follows:

nis-1# grep nis /var/nis/acct/passwd
nis:x:103:1001:NIS:/home/nis:/usr/bin/pfbash


nis-1# grep nis /var/nis/group
nis::1001:

Edit the netgroup configuration.
It should look somewhat similar to:
 
nis-1# cat /var/nis/netgroup
...
nisadmin ... (-,nis,business.corp) ...
...

Edit the project configuration on the project map.
It should look like as follows:

nis-1# grep nis /var/nis/project
nisadmin:200:NISAdmin:nis::


nis-1# grep nis /var/nis/user_attr  
nis::::type=role;project=nisadmin;profiles=All;roleauth=user

Edit the automounter configuration on the auto_home map.
It should look like as follows:

nis-1# grep nis /var/nis/auto_home
nis nfs-1.business.corp:/export/home/&


Run make on the updated sources:

nis-1:/var/yp# make
updated passwd
pushed passwd
updated ageing
updated netid
pushed netid
updated project
pushed project
updated netgroup
pushed netgroup
updated auto.home
pushed auto.home
updated user_attr
pushed user_attr


Verify that the maps were correctly updated:

nis-2$ ypmatch -k nis passwd
nis: nis:...:103:1001:NIS:/home/nis:/usr/bin/pfbash

 
nis-2$ ypmatch -k nis auto.home
nis: nfs-1.business.corp:/export/home/&

 
nis-2$ ypmatch -k nisadmin project
nisadmin: nisadmin:102:NISAdmin:nis::

nis-2$ ypmatch -k nis user_attr
nis: nis::::project=nisadmin;type=role;roleauth=user;...

 
nis-2$ ypcat -k netgroup | grep nis
nisadmin (-,nis,business.corp)


Create and export the home directory:

nfs-1# zfs create \
> -o quota=1g \
> -o share.nfs.sec.sys.rw="desktops:servers" \
> rpool/export/home/nis

nfs-1# cp /etc/skel/.profile /export/home/nis
nfs-1# cp /etc/skel/.bashrc /export/home/nis

nfs-1# chown -R nis:root /export/home/nis

nfs-1# ll -a /export/home/nis
total 11
drwxr-xr-x   5 root     root    ... ..
drwxr-xr-x   2 nis     
nis     ... .
-rw-r--r--   1 nis     
nis     ... .profile
-r--r--r--   1 nis     
nis     ... .bashrc

nfs-1# zfs set share.nfs=on rpool/export/home/nis

nfs-1# zfs get -o value share rpool/export/home/nis
VALUE
name=...,path=/export/home/nis,...,rw=servers:desktops


In addition to the update of NIS maps, if there were changes on any NIS netgroup that's referenced on some NFS share, then it's necessary to refresh the NFS service.

In order to be useful, roles must be associated with logins.
To associate the role nis with the login user2 alter the user_attr NIS map.

nis-1# grep nis /var/nis/user_attr  
nis::::project=project1;roles=nis

Then run make on the updated source:

nis-1:/var/yp# make
...

   
NOTE
It's important to note that during this processes there were no disruption of service to clients as all NIS clients should have been associated only to NIS slave servers.