#!/bin/sh
#newhostid
#Solaris 1.x only
#Author: Jean-Louis Faraut [jlf]
#Organization: Ecole Superieure en Sciences Informatiques (Universite de Nice Sophia-Antipolis)
#Address: Sophia-Antipolis (France)
#run a command with a new hostid
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose. You use
# this program at your own risk. The author disclaims responsibility for
# any damages that might result from the use of this program, even
# if they result from negligence on the part of the author.
# 
# Also, please don't use this program to steal software. The intended
# use is for emergency situations where an application has to be moved from
# one computer to another (e.g. in the event of a hardware malfunction)
# and licence keys cannot be obtained quickly from the vendor. Many
# vendors will not supply licence keys outside of business hours.
#
if [ $# -lt 2 ] 
then
	echo Usage:newhostid hostid command [args]
	exit 1
fi
(cd /tmp
cat > gethostid.c <<!
gethostid()
{
  return 0x$1;
}
!
cc -c gethostid.c
ld gethostid.o -assert pure-text -o gethostid.so
rm gethostid.o gethostid.c
)

shift
LD_PRELOAD="/tmp/gethostid.so" $*
rm /tmp/gethostid.so
