Skip to Content

Solaris 10

Solaris 10

Compiling the universal TUN/TAP driver on Solaris 10

I was compiling the TUN/TAP driver and bumped into problems getting it to work in Solaris 10 on SPARC64.

After much searching, I found the solution at http://openvpn.net/archive/openvpn-users/2007-03/msg00254.html.

The important parts are (edited a bit):

# Sun Studio targetting 64 bit SPARC
% cc -D_KERNEL -xarch=v9 -c tun.c
# Sun Studio targetting 64 bit x86
%cc -D_KERNEL -xarch=amd64 -xmodel=kernel -c tun.c
# Sun Studio targetting 32 bit
% cc -D_KERNEL -c tun.c
# GNU C Compiler targetting 64 bit SPARC ( optional: mtune=ultrasparc -O2 )
% gcc -D_KERNEL -m64 -mcpu=v9 -mcmodel=medlow -fno-pic -mno-fpu -ffreestanding -nodefaultlibs -c tun.c
# GNU C Compiler targetting 64 bit x86 ( optional: mtune=opteron -O2 )
% gcc -D_KERNEL -m64 -mcmodel=kernel -mno-red-zone -ffreestanding -nodefaultlibs -c tun.c
# GNU C Compiler targetting 32 bit
% gcc -D_KERNEL -ffreestanding -nodefaultlibs -c tun.c

The linking is the same for all
% usr/ccs/bin/ld -r -o tun tun.o

The destination is different depending on the architecture:
# 64 bit sparc
cp tun /usr/kernel/drv/sparcv9/tun
# 64 bit x86
cp tun /usr/kernel/drv/amd64/tun
# 32 bit
cp tun /usr/kernel/drv/tun

Compiling and making packages in Solaris 10

It's frustating that whenever you compile a package, it doesn't actually compile like you want. In Solaris 10, these are a few things that I have found useful.

1. Edit your PATH to have these:
/usr/bin:/sbin:/usr/local/bin:/usr/openwin/bin:/usr/dt/bin

2. Edit your LD_LIBRARY_PATH to have these:
/lib:/usr/lib:/usr/local/lib

3. The cc compiler doesn't usually get things right. Use the GNU C compiler (gcc). You can download gcc from http://sunfreeware.com/ and install it with pkgadd.

While you're at it, you might also want to consider getting the latest version of Sun Studio from http://developers.sun.com/sunstudio/downloads/index.jsp. Registration for the Sun Developer Network is free, so just register and get your free full license copy of Sun Studio.

4. There is a version of make at /usr/ccs/bin/make, but I have found it doesn't always work somehow. I prefer to use /usr/sfw/bin/gmake.

Patch xxxxxx-xx failed to install due to a failure produced by pkgadd.

Just sharing some solutions to problems I have faced. This problem was found in Solaris 10 when installing Solaris OS patches. It's an old workaround, but somehow we still need to do it today....

I was installing some patches, and got this:

# ./install_patches.sh
Installing patch 118683-03
Validating patches...
Loading patches installed on the system...
Done!
Loading patches requested to install.
Done!
Checking patches that you specified for installation.
Done!
Approved patches will be installed in this order:
118683-03
Checking installed patches...
Verifying sufficient filesystem capacity (dry run method)...
Patch 118683-03 failed to install due to a failure produced by pkgadd.
See /var/sadm/patch/118683-03/log for details
Patchadd is terminating.

If you have ever encountered similar errors, check into the log file generated. If you see something like pkgadd: ERROR: checkinstall script did not complete successfully, then here are some answers.

When installing a patch, the patch installation procedure will execute the script "checkinstall" with uid nobody. If any of the patch files or if any part of the path leading up to the patch directory cannot be read by nobody, an error pkgadd: ERROR: checkinstall script did not complete successfully will appear:

It seems that at some point the patchadd process does an su to the user install if one exists, otherwise to the user nobody. If the patch files and all parent directories are not readable by either install or nobody, you get the above error messages.

Here are two workarounds, but i prefer the second one:

1. Set the execute permission for all on /var/spool/patch so that the user nobody can read all patch files and execute a pwd in the patch directory hierarchy.

2. Add an account for user install to the system:

useradd -u 0 -o -g 1 -c "Install user" -d / -s /bin/true install

Syndicate content