Solaris patch epiphany

While debugging some Solaris patch problems this week, I came across an interesting piece of information. The /usr/sbin/patchadd command that is invoked to apply a patch is actually a binary wrapper for the shell script /usr/lib/patch/patchadd:

$ strings /usr/sbin/patchadd | grep “/usr/lib/patch/patchadd”
/usr/lib/patch/patchadd
/usr/lib/patch/patchadd
/usr/lib/patch/patchadd

If you haven’t looked though /usr/lib/patch/patchadd, I highly recommend doing so. It contains the complete set of patch return codes, and has some useful options for controlling the patch process (setting these will most likely void patch support). Nifty!

Mirroring boot devices with Solaris jumpstart

A few years back I developed a script to mirror the primary boot device as part of the jumpstart process. I was amazed that jumpstart didn’t support automated mirroring, and was hopeful that Sun would eventually provide a solution to address this. Someone at Sun was obviously paying attention to the numerous RFEs that were filed, and as of Solaris 9 you can mirror your boot device by adding “mirror” and “metadb” statements to a client profile:

$ egrep ‘(filesys|metadb)’ profile

filesys         mirror:d0    c0t0d0s0 c0t1d0s0  free  /     logging
filesys         mirror:d10   c0t0d0s1 c0t1d0s1  1024 swap
metadb          c0t0d0s7     size 8192 count 3
metadb          c0t1d0s7     size 8192 count 3

I haven’t found a way to use references to disk0 and disk1, but will report back when I do. This is cool!

Sending breaks through ssh

I have a small lab at home, and periodically need to gain console access to one or more of the machines. Since I don’t have a KVM switch or a monitor to devote to each machine, I will typically hook up a serial cable to port A on machine one, and serial port B on machine two. Once the connection is in place, I use minicom or tip to connect to node one once I establish an SSH session to node two. Since tip and SSH both default to using “~” as the escape character, issues will arise if you need to send a break remotely. To avoid this issue, I always use the ssh client’s “-e” (escape character to use) option to set an escape character that doesn’t conflict with tip:

$ ssh -C -e ^ host

This caused me some grief today, since the box I was SSH’ed into didn’t have my .profile installed (my default profile contains an ssh alias with “-e”). Tip is c-well!

Linker search paths

As part of my job as a systems administrator, I occassionally need to develop scripts to start applications at system bootstrap. Periodically while developing these scripts I will encounter an application that relies on libraries in obscure locations. To allow my scripts to work with these applications, I typically need to set LD_LIBRARY_PATH so the runtime linker can locate the libraries needed to make the application work ( I say typically since setrpath can be used on occassion ). Since the Solaris linker searches for libraries in the following order:

1. Check for libraries by traversing the directories in the LD_LIBRARY_PATH environment variable

2. Check for libraries by traversing the directories in the executables’s RPATH

3. Check for libraries by traversing /lib and /usr/lib

It is usually unnecessary to explicitly add /lib and /usr/lib to the search path. To see this first hand, the ldd utility can be invoked with the “-s” (display search path) option and an executable to process:

$ ldd -s slapd

   find object=libdb-4.3.so; required by /usr/local/openldap-2.2.26/libexec/slapd
    search path=/lib:/usr/lib  (default)
    trying path=/lib/libdb-4.3.so
    trying path=/usr/lib/libdb-4.3.so
        libdb-4.3.so =>  (file not found)

   find object=libsasl.so.1; required by /usr/local/openldap-2.2.26/libexec/slapd
    search path=/lib:/usr/lib  (default)
    trying path=/lib/libsasl.so.1
    trying path=/usr/lib/libsasl.so.1
        libsasl.so.1 =>  /usr/lib/libsasl.so.1
  
   [ ..... ]

Each stanza contains the name of a library that the executable requires, along with the directories that are searched to locate the library. This is some useful stuff!