Python on Solaris: Wrong ELF class: ELFCLASS64

If “pip” installed 64-bit libraries, while python is a 32-bit binary, “pkg” might stop working with the following error messages:

ImportError: ld.so.1: bootadm: fatal: /usr/lib/python2.7/site-packages/lxml/etree.so: wrong ELF class: ELFCLASS64
ImportError: ld.so.1: python2.7: fatal: /usr/lib/python2.7/site-packages/_cffi_backend.so: wrong ELF class: ELFCLASS64
$ file `which python`
/usr/bin/python:	ELF 32-bit LSB executable 80386 Version 1 [SSE], dynamically linked, not stripped

The workaround is to remove the corresponding python packages (in this case cffi and lxml), download and recompile them manually with “-m32”:

$ export CFLAGS="-m32"

One-liner: how to get image URLs from Google Image search

Let’s search for “red apple”:

For Solaris (use gsed instead of sed):

curl -A "Mozilla/5.0 (X11; SunOS i86pc; rv:52.0) Gecko/20100101 Firefox/52.0" \
'https://www.google.nl/search?q=red+apple&tbm=isch' 2>/dev/null | \ 
tail -1 | gsed -e 's/,"ow":/*/g' -e 's/,"ou":/*Image:/g' | \ 
tr '*' '\n' | grep "^Image" | sed -e 's/^Image:"//' -e 's/"$//' 

For Linux:

curl -A "Mozilla/5.0 (X11; SunOS i86pc; rv:52.0) Gecko/20100101 Firefox/52.0" \
'https://www.google.nl/search?q=red+apple&tbm=isch' 2>/dev/null | \ 
tail -1 | sed -e 's/,"ow":/*/g' -e 's/,"ou":/*Image:/g' | \ 
tr '*' '\n' | grep "^Image" | sed -e 's/^Image:"//' -e 's/"$//' 

How to install and keep an obsolete Solaris package

If you (like me) are still using Solaris (why BTW, if I may ask?), then you might stumble upon the problem of disappearing packages. Let’s take, for example, gimp:

# pkg list -af gimp
NAME (PUBLISHER)          VERSION                    IFO
image/editor/gimp         2.6.10-5.12.0.0.0.97.0     --o
image/editor/gimp         2.6.10-0.175.3.0.0.26.0    ---
image/editor/gimp         2.6.10-0.175.2.0.0.27.0    ---
image/editor/gimp         2.6.10-0.175.1.0.0.24.0    ---
image/editor/gimp         2.6.10-0.175.0.0.0.2.0     ---
image/editor/gimp         0.5.11-0.151.0.1           ---

Flag “o” means “obsolete”. If you have version “2.6.10-0.175.3.0.0.26.0” installed, and it gets updated to “2.6.10-5.12.0.0.0.97.0” (which is obsolete), your package will get removed. If this what happened, here’s the path to restore it.

First, install the latest version before “o”:

pkg install -v image/editor/gimp@2.6.10-0.175.3.0.0.26.0

Then “freeze” it:

# pkg freeze image/editor/gimp

Now if you run pkg list again, you will see two new flags:
“i” – installed
“f” – frozen

# pkg list -af gimp
NAME (PUBLISHER)            VERSION                    IFO
image/editor/gimp           2.6.10-5.12.0.0.0.97.0     --o
image/editor/gimp           2.6.10-0.175.3.0.0.26.0    if-
image/editor/gimp           2.6.10-0.175.2.0.0.27.0    ---
image/editor/gimp           2.6.10-0.175.1.0.0.24.0    ---
image/editor/gimp           2.6.10-0.175.0.0.0.2.0     ---
image/editor/gimp           0.5.11-0.151.0.1           ---

# pkg freeze
NAME               VERSION            DATE            COMMENT
image/editor/gimp  2.6.10-0.175.3.0.0.26.0:20150705T202845Z 15 Feb 2017 23:01:02 CET None

One-liner: how to check the SSL certificate expiration of several servers

for i in cnn.com bbc.co.uk
do
  exp=`echo | openssl s_client -connect $i:443  2>/dev/null | 
  openssl x509 -noout -dates | fgrep notAfter | sed -e 's/^.*=//'`
  echo "$i        $exp"
done

cnn.com	    Feb  6 12:00:00 2018 GMT
bbc.co.uk   Apr 20 10:01:10 2017 GMT

One-liner: how to count the total amount of specific lines in several files

Let’s calculate the amount of lines, containing the word “extended” in */*.conf files:

egrep -c extended */*.conf | 
awk 'BEGIN {FS=":"; sum=0;}{sum +=$2} END {print sum}'  

BTW, using awk alone is slower:

time awk 'BEGIN {sum=0;}/extended/{sum++} END {print sum}' */*.conf
110653

real	0m0.94s
user	0m0.91s
sys	0m0.01s

time egrep -c extended */*.conf | 
awk 'BEGIN {FS=":"; sum=0;}{sum +=$2} END {print sum}'
110653

real	0m0.13s
user	0m0.10s
sys	0m0.02s

fgrep is slower than egrep:

time fgrep -c extended */*.conf | 
awk 'BEGIN {FS=":"; sum=0;}{sum +=$2} END {print sum}'
110653

real	0m0.21s
user	0m0.17s
sys	0m0.03s

Firefox 18.0 crashes on Solaris

Update: fixed in v19.0beta (at least v19.0b1 build3 looks good):
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/ (19b1 does not save sessions, though πŸ˜‰

Firefox 18 (all betas and 18.0) crashes on Solaris 11 and OpenSolaris. The workaround is to set the following variables to “false”:

browser.cache.disk.enable
browser.cache.memory.enable
browser.cache.disk_cache_ssl

See bug 827971.

Default passwords

Solaris 11: root/solaris
Cyclades console servers (e.g. ACS4): root/tslinux
Avocent ACS5000 console servers: root/avocent
Avocent ACS6000 console servers: admin/avocent or root/linux
Cisco VPN3000: admin/admin
Cisco ASA: empty
Netscreen: netscreen/netscreen
Avocent/Cyclades PM IPDU: admin/pm8 root/linux

Solaris 11 EA (b173) ZFS pool versions

 

Solaris 11 EA (Sep 2011 build 173) updated zpool version to 33:

$ zpool upgrade -v
This system is currently running ZFS pool version 33.

The following versions are supported:

VER DESCRIPTION
--- --------------------------------------------------------
1 Initial ZFS version
2 Ditto blocks (replicated metadata)
3 Hot spares and double parity RAID-Z
4 zpool history
5 Compression using the gzip algorithm
6 bootfs pool property
7 Separate intent log devices
8 Delegated administration
9 refquota and refreservation properties
10 Cache devices
11 Improved scrub performance
12 Snapshot properties
13 snapused property
14 passthrough-x aclinherit
15 user/group space accounting
16 stmf property support
17 Triple-parity RAID-Z
18 Snapshot user holds
19 Log device removal
20 Compression using zle (zero-length encoding)
21 Deduplication
22 Received properties (Solaris Nevada b130 Dec 2009)
23 Slim ZIL
24 System attributes
25 Improved scrub stats
26 Improved snapshot deletion performance
27 Improved snapshot creation performance
28 Multiple vdev replacements (ZFS for Linux)
29 RAID-Z/mirror hybrid allocator
30 Encryption
31 Improved 'zfs list' performance (Solaris 11 Express b151a Nov 2010)
32 One MB blocksize
33 Improved share support (Solaris 11 EA b173 Sep 2011)