Article 13079 of alt.sources:
Newsgroups: alt.sources
Path: nntpd.lkg.dec.com!sousa.amt.tay1.dec.com!pa.dec.com!decwrl!genmagic!sgigate.sgi.com!swrinde!newsfeed.internetmci.com!howland.reston.ans.net!ix.netcom.com!netcom.com!henderso
From: henderso@netcom.com (Mark C. Henderson)
Subject: change sun hostid 1.6.1 -- part 1/5
Message-ID: <hendersoDJyIvL.232@netcom.com>
Organization: Netcom
Date: Thu, 21 Dec 1995 22:09:21 GMT
Lines: 1671
Sender: henderso@netcom12.netcom.com


This is a new version (1.6.1) of my change-sun-hostid package. The 
main advantage here is that nvram.info has been updated to give 
_much_ simpler procedures for reprogramming the IDPROM part of the 
NVRAM (hostid and ethernet address) of a Sun workstation from the 
OpenBoot monitor. I recently discovered that there are commands built 
into the OpenBoot monitor to reprogram the IDPROM, which I missed 
before (mkp, mkpl). 

You can also get this new version of change-sun-hostid from either of the
following ftp sites:

ftp://ftp.netcom.com/pub/he/henderso/change-sun-hostid-1.6.1.tar.gz
ftp://ftp.wimsey.com/pub/crypto/sun-stuff/change-sun-hostid-1.6.1.tar.gz

#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 12/21/1995 22:06 UTC by henderso@netcom12
# Source directory /u1/henderso
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   1304 -rw------- hid-1.6.1/hostid-by-egid-modload/README
#   2536 -rw------- hid-1.6.1/hostid-by-egid-modload/kern_hostid.c
#    282 -rw------- hid-1.6.1/hostid-by-egid-modload/makefile
#   1197 -rw------- hid-1.6.1/hostid-by-egid-modload/sethostid.c
#     60 -rwx------ hid-1.6.1/hostid-by-egid-modload/sethostid.exec
#   2686 -rw------- hid-1.6.1/hostid-by-egid/README
#   1700 -rw------- hid-1.6.1/hostid-by-egid/kern_hostid.c
#   1085 -rw------- hid-1.6.1/hostid-by-egid/sethostid.c
#   1121 -rw------- hid-1.6.1/hostid-by-egid-solaris2/sid.c
#   5649 -rw------- hid-1.6.1/hostid-by-egid-solaris2/sethostid.c
#    518 -rw------- hid-1.6.1/hostid-by-egid-solaris2/makefile
#   2119 -rw------- hid-1.6.1/hostid-by-egid-solaris2/README
#   3998 -rw------- hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~
#   5668 -rw------- hid-1.6.1/hostid-by-egid-solaris2/sethostid.o
#   5840 -rw------- hid-1.6.1/hostid-by-egid-solaris2/sethostid
#     27 -rw------- hid-1.6.1/hostid-by-egid-solaris2/sethostid.h
#   6036 -rwx------ hid-1.6.1/hostid-by-egid-solaris2/sid
#    209 -rw------- hid-1.6.1/run/makefile
#   1385 -rw------- hid-1.6.1/run/run.c
#   1816 -rw------- hid-1.6.1/run/README
#    767 -rw------- hid-1.6.1/sethostid-simple-4.1/README
#   1992 -rw------- hid-1.6.1/sethostid-simple-4.1/kern_hostid.c
#    282 -rw------- hid-1.6.1/sethostid-simple-4.1/makefile
#   1083 -rw------- hid-1.6.1/sethostid-simple-4.1/sethostid.c
#     60 -rwx------ hid-1.6.1/sethostid-simple-4.1/sethostid.exec
#   2009 -rwx------ hid-1.6.1/spoof-solaris1/README
#     50 -rwx------ hid-1.6.1/spoof-solaris1/hid_flags.h
#   4596 -rwx------ hid-1.6.1/spoof-solaris1/kern_hostid.c
#    282 -rwx------ hid-1.6.1/spoof-solaris1/makefile
#   1539 -rwx------ hid-1.6.1/spoof-solaris1/sethostid.c
#     60 -rwx------ hid-1.6.1/spoof-solaris1/sethostid.exec
#   3460 -rwx------ hid-1.6.1/spoof-solaris2/README
#     50 -rwx------ hid-1.6.1/spoof-solaris2/hid_flags.h
#    511 -rwx------ hid-1.6.1/spoof-solaris2/makefile
#  11397 -rwx------ hid-1.6.1/spoof-solaris2/sethostid.c
#   1374 -rwx------ hid-1.6.1/spoof-solaris2/sid.c
#   7239 -rwx------ hid-1.6.1/spoof-solaris2/sethostid.c~
#   8207 -rw------- hid-1.6.1/00README.FIRST
#  18561 -rw------- hid-1.6.1/INSTRUCTIONS
#   7466 -rw------- hid-1.6.1/chenet.c
#   2852 -rw------- hid-1.6.1/getobphostid.c
#   3055 -rw------- hid-1.6.1/hid.c
#   2057 -rw------- hid-1.6.1/hid_solaris2.c
#   3147 -rwx------ hid-1.6.1/newhostid
#   1289 -rwx------ hid-1.6.1/newhostid.old
#  11254 -rw------- hid-1.6.1/nvram.c
#  22487 -rw------- hid-1.6.1/nvram.info
#   7012 -rw------- hid-1.6.1/nvram_old.c
#   6378 -rw------- hid-1.6.1/sidump.c
#   3434 -rw------- hid-1.6.1/sidump_old.c
#   3235 -rw------- hid-1.6.1/changelog
#  10093 -rw------- hid-1.6.1/nvram-sol2.c
#    695 -rw------- hid-1.6.1/sysinfo.c
#   3026 -rw------- hid-1.6.1/dloverlay.c
#    547 -rw------- hid-1.6.1/CREDITS
#   2058 -rw------- hid-1.6.1/hid_solaris2x86.c
#   2232 -rw------- hid-1.6.1/sethostid-simple-5.x/README
#    641 -rw------- hid-1.6.1/sethostid-simple-5.x/makefile
#   4092 -rw------- hid-1.6.1/sethostid-simple-5.x/sethostid.c
#   1086 -rw------- hid-1.6.1/sethostid-simple-5.x/sid.c
#   3237 -rw------- hid-1.6.1/sethostid-simple-5.x/sethostid.c~
#  27831 -rw------- hid-1.6.1/nvram.info.old
#
# ============= hid-1.6.1/hostid-by-egid-modload/README ==============
if test ! -d 'hid-1.6.1'; then
    echo 'x - creating directory hid-1.6.1'
    mkdir 'hid-1.6.1'
fi
if test ! -d 'hid-1.6.1/hostid-by-egid-modload'; then
    echo 'x - creating directory hid-1.6.1/hostid-by-egid-modload'
    mkdir 'hid-1.6.1/hostid-by-egid-modload'
fi
if test -f 'hid-1.6.1/hostid-by-egid-modload/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-modload/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-modload/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-modload/README' &&
This is based, in part, upon an anonymous contribution. I've improved
it by making it loadable, so one does not have to build a new kernel.
You'll find the original contribution in ../hostid-by-egid
X
This will probably only work on versions of Sun OS later than 4.1.1.
Certainly there is no support for Solaris 5.x
X
to use this:
make load
make sethostid
./sethostid 0 72000000
X
which should modify the hostid for processes with gid 900.
X
You can remove the sethostid call by using modunload. You can check
whether or not it is currently installed with modstat.
X
X     This package check running process's effective gid and user's gid
to determine which hostid should be returned.  If the gid is between
900 to 909, the specified hostid will be returned.  Otherwise, the original
hostid will be returned.  Therefore, you can setgid the target checking
excutable file and it will get what you want when the gethostid system
call is called.  For example, we run '/bin/sethostid 0 12345678'.  All
running processes with gid 900 will get hostid as 12345678 rather than
the real hostid.  Remember the hostid above are all hexadecimal values.
X
N.B. sethostid.exec must be executable. Depending upon where you got
the distribution you might have to chmod +x it.
X
see ../run for a small utility for use with this.
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-modload/README ||
echo 'restore of hid-1.6.1/hostid-by-egid-modload/README failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-modload/README'`"
test 1304 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-modload/README: original size 1304, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-modload/kern_hostid.c ==============
if test -f 'hid-1.6.1/hostid-by-egid-modload/kern_hostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-modload/kern_hostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-modload/kern_hostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-modload/kern_hostid.c' &&
/*
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.
X
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.
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sun/vddrv.h>
X
#define NHOSTID 10
X
static unsigned hostid[NHOSTID]={0};
X
int sethostid();
X
static struct sysent sethostid_sysent = { 2, sethostid } ;
X
static struct vdlsys vd = {
X  VDMAGIC_SYS, /* magic number */
X  "sethostid", /* name */
X  0, /* syscall number (filled in automagically) */
X  &sethostid_sysent /* description of syscall */
};
X
X
Gethostid()
{
X    unsigned machineid;
X    u_short gid;
X    int i;
X
X    gethostid();
X    machineid = u.u_r.r_val1;
X
X    gid = u.u_gid;
X    if (gid >= 900 && gid < 900+NHOSTID) {
X        u.u_r.r_val1 = hostid[gid-900] ? hostid[gid-900] : machineid;
X        return;
X    }
X
X    i = 0;
X    while (gid=u.u_groups[i++]) {
X        if (gid >= 900 && gid < 900+NHOSTID) {
X            u.u_r.r_val1 = hostid[gid-900] ? hostid[gid-900] : machineid;
X            return;
X        }
X    }
X    u.u_r.r_val1 = machineid;
X    return;
}
X
sethostid(uap)
X    register struct a {
X        int n;
X        unsigned hostid;
X    } *uap;
{
X    if (!suser()) {
X        u.u_error = EACCES;
X        return;
X    }
X
X    if ((uap->n >= NHOSTID )||(uap->n < 0)) {  
X        u.u_error = EINVAL;
X        return;
X    }
X
X    u.u_r.r_val1 = hostid[uap->n] = uap->hostid;
X    u.u_error = 0;
X    return;
}
X
X
sethostidinit(function_code, vdp, vdi, vds)
unsigned int function_code;
struct vddrv *vdp;
addr_t vdi;
struct vdstat *vds;
{
X  switch (function_code) {
X  case VDLOAD:
X    vdp->vdd_vdtab = (struct vdlinkage *)&vd;
X    sysent[SYS_gethostid].sy_narg = 2;
X    sysent[SYS_gethostid].sy_call = Gethostid;
X    return 0;
X  case VDUNLOAD:
X    sysent[SYS_gethostid].sy_narg = 2;
X    sysent[SYS_gethostid].sy_call = gethostid;
X    return 0;
X  case VDSTAT:
X    return 0;
X  default:
X    return EIO;
X  }
}
X
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-modload/kern_hostid.c ||
echo 'restore of hid-1.6.1/hostid-by-egid-modload/kern_hostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-modload/kern_hostid.c'`"
test 2536 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-modload/kern_hostid.c: original size 2536, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-modload/makefile ==============
if test -f 'hid-1.6.1/hostid-by-egid-modload/makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-modload/makefile (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-modload/makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-modload/makefile' &&
CFLAGS = -DKERNEL
ASFLAGS = -P
X
load: kern_hostid.o
X	chmod +x sethostid.exec
X	/usr/etc/modload kern_hostid.o -v -entry _sethostidinit -exec sethostid.exec
X
sethostid: sethostid.o sethostid.h
X	cc -o sethostid -I. sethostid.c
X
clean:
X	rm -f core *.o sethostid kern_hostid sethostid.h
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-modload/makefile ||
echo 'restore of hid-1.6.1/hostid-by-egid-modload/makefile failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-modload/makefile'`"
test 282 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-modload/makefile: original size 282, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-modload/sethostid.c ==============
if test -f 'hid-1.6.1/hostid-by-egid-modload/sethostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-modload/sethostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-modload/sethostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-modload/sethostid.c' &&
/*
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.
X
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.
*/
X
#include <stdio.h>
#include <sys/syscall.h>
#include <errno.h>
#include "sethostid.h"
X
main(argc, argv)
int argc;
char *argv[];
{
X  unsigned hostid;
X  int n;
X
X  if (argc<3) {
X    fprintf(stderr, "%s <n> <hostid>\n", argv[0]);
X    exit(1);
X  }
X  n=atoi(argv[1]);
X  sscanf(argv[2], "%x", &hostid);
X  fprintf(stderr, "will set hostid for group %d set to %08x\n", 900+n,hostid);
X  if (syscall(SYS_sethostid, n, hostid)==-1) {
X    perror(argv[0]);
X    exit(1);
X  }
}  
X
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-modload/sethostid.c ||
echo 'restore of hid-1.6.1/hostid-by-egid-modload/sethostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-modload/sethostid.c'`"
test 1197 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-modload/sethostid.c: original size 1197, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-modload/sethostid.exec ==============
if test -f 'hid-1.6.1/hostid-by-egid-modload/sethostid.exec' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-modload/sethostid.exec (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-modload/sethostid.exec (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-modload/sethostid.exec' &&
#!/bin/csh -f
echo "#define SYS_sethostid $3" > sethostid.h
SHAR_EOF
chmod 0700 hid-1.6.1/hostid-by-egid-modload/sethostid.exec ||
echo 'restore of hid-1.6.1/hostid-by-egid-modload/sethostid.exec failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-modload/sethostid.exec'`"
test 60 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-modload/sethostid.exec: original size 60, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid/README ==============
if test ! -d 'hid-1.6.1/hostid-by-egid'; then
    echo 'x - creating directory hid-1.6.1/hostid-by-egid'
    mkdir 'hid-1.6.1/hostid-by-egid'
fi
if test -f 'hid-1.6.1/hostid-by-egid/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid/README' &&
Contributed by someone who wishes to remain anonymous. 
X
I've made a couple of minor modifications. - markh@wimsey.bc.ca
X
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.
X
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.
X
--
X
X     Most commericial packages are bounded to machine hostid for protection.
This ID is built in PROM on Sun Sparc machine.  The purpose of this program
is to let you specify the hostid freely and you can run the commericial
programs on another machine with differnet machine hostid.  This package is
tested and works fine on SunOS 4.1.2, 4.1.3 and 4.1.3_U1.
X
INSTALLATION:
X
step 1.
X  Copy kern_hostid.c into /sys/os
X
step 2.
X  Add the following line in /sys/conf.common/files.cmn
X	os/kern_hostid.c	standard
X
step 3.
X  Replace gethostid declartion with Gethostid, and add the new declartion
of sethostid.  Change system call 143 into sethostid.  The modified version
of /sys/os/init_sysent.c should contain the following lines.
X
line 25:
int     Gethostid(),sethostname(),gethostname(),getpid();
line 32:
int	sethostid();
line 362:
X        2, Gethostid,                   /* 142 = gethostid */
X        2, sethostid,                   /* 143 = old sethostid */
X
step 4:
X  Configure your own kernel and rebuild it.  Install it in /vmunix and
reboot.
X
step 5:
X  Compile sethostid.c and install sethostid in /bin.
X
step 6:
X  Done.
X
USAGE:
X     This package check running process's effective gid and user's gid
to determine which hostid should be returned.  If the gid is between
900 to 909, the specified hostid will be returned.  Otherwise, the original
hostid will be returned.  Therefore, you can setgid the target checking
excutable file and it will get what you want when the gethostid system
call is called.  For example, we run '/bin/sethostid 0 12345678'.  All
running processes with gid 900 will get hostid as 12345678 rather than
the real hostid.  Remember the hostid above are all heximal value.
X     If you have any problem, try to see the source code.  No help is
provided.
X
see ../run for a small utility for use with this.
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid/README ||
echo 'restore of hid-1.6.1/hostid-by-egid/README failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid/README'`"
test 2686 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid/README: original size 2686, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid/kern_hostid.c ==============
if test -f 'hid-1.6.1/hostid-by-egid/kern_hostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid/kern_hostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid/kern_hostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid/kern_hostid.c' &&
/*
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.
X
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.
*/
X
#include <sys/user.h>
#define NHOSTID 10
X
static unsigned hostid[NHOSTID]={0};
X
Gethostid()
{
X    unsigned machineid;
X    u_short gid;
X    int i;
X
X    gethostid();
X    machineid = u.u_r.r_val1;
X
X    gid = u.u_gid;
X    if (gid >= 900 && gid < 900+NHOSTID) {
X        u.u_r.r_val1 = hostid[gid-900] ? hostid[gid-900] : machineid;
X        return;
X    }
X
X    i = 0;
X    while (gid=u.u_groups[i++]) {
X        if (gid >= 900 && gid < 900+NHOSTID) {
X            u.u_r.r_val1 = hostid[gid-900] ? hostid[gid-900] : machineid;
X            return;
X        }
X    }
X    u.u_r.r_val1 = machineid;
X    return;
}
X
sethostid(uap)
X    register struct a {
X        int n;
X        unsigned hostid;
X    } *uap;
{
X    if (!suser()) {
X        u.u_error = EACCES;
X        return;
X    }
X
X    if ((uap->n >= NHOSTID )||(uap->n < 0)) {  /* small change - markh */
X        u.u_error = EINVAL;
X        return;
X    }
X
X    u.u_r.r_val1 = hostid[uap->n] = uap->hostid;
X    u.u_error = 0;
X    return;
}
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid/kern_hostid.c ||
echo 'restore of hid-1.6.1/hostid-by-egid/kern_hostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid/kern_hostid.c'`"
test 1700 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid/kern_hostid.c: original size 1700, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid/sethostid.c ==============
if test -f 'hid-1.6.1/hostid-by-egid/sethostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid/sethostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid/sethostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid/sethostid.c' &&
/*
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.
X
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.
*/
X
#include <stdio.h>
#include <sys/syscall.h>
#include <errno.h>
X
main(argc, argv)
int argc;
char *argv[];
{
X  unsigned hostid;
X  int n;
X
X  if (argc<3) {
X    fprintf(stderr, "%s <n> <hostid>\n", argv[0]);
X    exit(1);
X  }
X  n=atoi(argv[1]);
X  sscanf(argv[2], "%x", &hostid);
X  if (syscall(143, n, hostid)==-1) {
X    perror(argv[0]);
X    exit(1);
X  }
}  
X
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid/sethostid.c ||
echo 'restore of hid-1.6.1/hostid-by-egid/sethostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid/sethostid.c'`"
test 1085 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid/sethostid.c: original size 1085, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sid.c ==============
if test ! -d 'hid-1.6.1/hostid-by-egid-solaris2'; then
    echo 'x - creating directory hid-1.6.1/hostid-by-egid-solaris2'
    mkdir 'hid-1.6.1/hostid-by-egid-solaris2'
fi
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sid.c' &&
/*
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.
X
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.
*/
X
#include <stdio.h>
#include <sys/syscall.h>
#include <errno.h>
#include "sethostid.h"
X
main(argc, argv)
int argc;
char *argv[];
{
X  unsigned hostid;
X  int n;
X
X  if (argc<3) {
X    fprintf(stderr, "%s <n> <hostid>\n", argv[0]);
X    exit(1);
X  }
X  n=atoi(argv[1]);
X  hostid=strtoul(argv[2], NULL, 16);
X  if (syscall(SYS_sethostid, n, hostid)==-1) {
X    perror(argv[0]);
X    exit(1);
X  }
}  
X
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/sid.c ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sid.c'`"
test 1121 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sid.c: original size 1121, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sethostid.c ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sethostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sethostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c' &&
/*
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.
X
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.
X
before you install this modify /etc/name_to_sysnum to bind sethostid to 
an _unused_ system call number
X
As far as I can determine the details of how to load system calls in
Solaris 2.3 are undocumented. I've done this by poking around in the
header files in sys and the man pages, and extrapolating from what 
I know about how loadable device drivers work and how the procedure 
works in Solaris 1.1
X
Mark Henderson <markh@wimsey.bc.ca>
14 Aug 1994
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/modctl.h>
#include <sys/cred.h>
#include <sys/systeminfo.h>
X
#define NHOSTID 10
X
static char serials[NHOSTID][16];
char xyzzy_rbuf[16];
X
int sethostid();
X
struct sysent sethostid_sysent = {2,0,sethostid,0};
X
extern struct mod_ops mod_syscallops;
X
static struct modlsys modlsys = {
&mod_syscallops,
"kern_hostid v1.10", 
&sethostid_sysent,
};
X
#ifdef PRE_SOLARIS_2_5
extern systeminfo();
#else
extern longlong_t systeminfo();
#endif
X
static struct modlinkage modlinkage = {
X    MODREV_1, /* magic number */
X    &modlsys, 
X    0
};
X
#ifdef PRE_SOLARIS_2_5
struct as2 {int command; char *buf; long count;};
int new_systeminfo(struct as2 *uap, rval_t *foo)
{
X    int ret,i,bsize;
X    gid_t gid;
X    cred_t *creds = CRED();
X    systeminfo(uap,foo);
X    ret = foo->r_val1;
X    if (uap->command == SI_HW_SERIAL) {
X        gid = creds->cr_gid;
X        bsize = (uap->count > 16) ? 16 : uap->count; /* min(16,count)*/
X        if (gid >= 900 && gid < 900+NHOSTID) {
X            if (serials[gid - 900][0]) {
X                for (i=0;i < bsize - 1;i++)
X                    xyzzy_rbuf[i]  = serials[gid-900][i];
X                xyzzy_rbuf[bsize - 1] = 0;
X                ret = strlen(xyzzy_rbuf) + 1;
X                if (copyout(xyzzy_rbuf,uap->buf,ret) < 0)
X                    return EFAULT;
X            }
X        }
X        for (gid = 900; gid < 900+NHOSTID; gid++) {
X            if (groupmember(gid, creds)) {
X                if (serials[gid - 900][0]) {
X                    for (i=0;i< bsize - 1;i++)
X                        xyzzy_rbuf[i]  = serials[gid-900][i];
X                    xyzzy_rbuf[bsize - 1] = 0;
X                    ret = strlen(xyzzy_rbuf) + 1;
X                    if (copyout(xyzzy_rbuf,uap->buf,ret) < 0)
X                        return EFAULT;
X                    break;
X                }
X            }
X        }
X    }
X    foo->r_val1 = ret;
X    return 0;
}
#else 
longlong_t new_systeminfo(int command, char *buf, long count) 
{
X	longlong_t ret;
X	int bsize,i,modified = 0;
X    gid_t gid;
X    cred_t *creds = CRED();
X	ret = systeminfo(command, buf, count);
X    if (command == SI_HW_SERIAL) {
X        gid = creds->cr_gid;
X        bsize = (count > 16) ? 16 : count; /* min(16,count)*/
X        if (gid >= 900 && gid < 900+NHOSTID) {
X            if (serials[gid - 900][0]) {
X                for (i=0;i < bsize - 1;i++)
X                    xyzzy_rbuf[i]  = serials[gid-900][i];
X                xyzzy_rbuf[bsize - 1] = 0;
X                ret = strlen(xyzzy_rbuf) + 1;
X				modified = 1;
X                if (copyout(xyzzy_rbuf,buf,ret) < 0)
X                    return EFAULT;
X            }
X        }
X        for (gid = 900; gid < 900+NHOSTID; gid++) {
X            if (groupmember(gid, creds)) {
X                if (serials[gid - 900][0]) {
X                    for (i=0;i< bsize - 1;i++)
X                        xyzzy_rbuf[i]  = serials[gid-900][i];
X                    xyzzy_rbuf[bsize - 1] = 0;
X                    ret = strlen(xyzzy_rbuf) + 1;
X					modified = 1;
X                    if (copyout(xyzzy_rbuf,buf,ret) < 0)
X                        return EFAULT;
X                    break;
X                }
X            }
X        }
X    }
X	if (modified)
X		return (ret << 32);
X	else
X		return ret;
}
#endif
X
struct as {int n; unsigned int hostid;};
X
sethostid(struct as *uap, rval_t *foo)
{
X    cred_t *creds = CRED();
X    if (!suser(creds)) {
X        return EACCES;
X    }
X
X    if ((uap->n >= NHOSTID )||(uap->n < 0)) {  
X        return EINVAL;
X    }
X    numtos( (unsigned long)uap->hostid, &serials[uap->n][0]);
X    foo->r_val1 = uap->hostid;
X    return 0;
}
X
_init(void)
{
X    int i,status;
X    status = mod_install(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
#ifdef PRE_SOLARIS_2_5
X        sysent[SYS_systeminfo].sy_call = new_systeminfo;
#else
X		sysent[SYS_systeminfo].sy_callc = new_systeminfo;
#endif
X        for (i=0; i < NHOSTID; i++) 
X            serials[i][0] = 0;
X    }
X    return status;
}
_fini(void)
{
X    int status;
X    status = mod_remove(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
#ifdef PRE_SOLARIS_2_5
X        sysent[SYS_systeminfo].sy_call = systeminfo;
#else
X		/* for Solaris 2.5 and (hopefully) later */
X        sysent[SYS_systeminfo].sy_callc = systeminfo;
#endif
X    }
X    return status;
}
X
_info(struct modinfo *modinfop)
{
X    return (mod_info(&modlinkage, modinfop));
}
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/sethostid.c ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sethostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c'`"
test 5649 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c: original size 5649, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/makefile ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/makefile (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/makefile' &&
CFLAGS = -D_KERNEL    # -DPRE_SOLARIS_2_5
ASFLAGS = -P
CC = /opt/SUNWspro/bin/cc
X
load: sethostid
X	/usr/sbin/modload ./sethostid
X
sethostid: sethostid.o
X	/usr/ccs/bin/ld -r -o sethostid sethostid.o
X
sid: sid.c
X	grep sethostid /etc/name_to_sysnum | sed 's/^/#define SYS_/' >sethostid.h
X	$(CC) -o sid -I. sid.c
X
install: sethostid sid
X	/usr/sbin/install -f /kernel/sys -m 0755 -u root -g sys ./sethostid
X	/usr/sbin/install -f /usr/local/bin -m 0755 -u root -g sys ./sid
X
clean:
X	rm -f core *.o sid sethostid sethostid.h
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/makefile ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/makefile failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/makefile'`"
test 518 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/makefile: original size 518, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/README ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/README' &&
This appears to work correctly under Solaris 2.3 and 2.4.
X
Instructions:
X
You need to do everything below as root.
X
1. Add an entry to /etc/name_to_sysnum for the sethostid system call.
For instance, I use the following line.
sethostid       177
X
Do not put any leading whitespace on the line in /etc/name_to_sysnum.
X
The important thing is to pick an unused syscall number. There
is also a limit on the number you can pick, which is determined
by the size of the sysent table. To find out what the limit is
you can use adb (only for 2.3, just be reasonable for Solaris 2.4)
X
adb -k /dev/ksyms /dev/mem
sysentsize/D
^D        #  i.e. control-D
X
It appears that in 2.5 you can use the NSYSCALL define in 
/usr/include/sys/systm.h
X
You should be able to pick any unused syscall number between 1 and the
number output by adb above minus 1. Alternatively just use an unused
number which is less than the largest number which occurs in
/etc/name_to_sysnum
X
After modifying /etc/name_to_sysnum you must reboot for the change
to take effect.
X
2. Look at the makefile and check that the location of the C compiler is
right for your system. You do NOT want to get /usr/ucb/cc. gcc should
be OK.
X
Also if you are running Solaris 2.3 or 2.4 be sure to uncomment the define
-DPRE_SOLARIS_2_5 in the makefile
X
3. Type
make load
X
This should load the sethostid call. 
X
4. Type 
make sid
X
This makes the program that allows you to modify the hostid for
a particular group.
X
e.g. Now you can modify the hostid for group 900 to be 23000000 by typing
./sid 0 23000000
X
6. You can unload the system call as follows.
X
Type
/usr/sbin/modinfo
X
X You'll get output which includes a line which looks something like
76 fc42d000   621 177   1  sethostid (kern_hostid v1.0)
X
To remove the module type
/usr/sbin/modunload -i 76
Replace 76 by the first number in the line output by modinfo.
X
7. If you like you can install sid and sethostid by typing
make install
X
If you do this, when you reboot, the sethostid module will be
automatically loaded when sethostid is called (i.e. when you run sid).
X
see ../run for a small utility for use with this.
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/README ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/README failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/README'`"
test 2119 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/README: original size 2119, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~ ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~ (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~ (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~' &&
/*
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.
X
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.
X
before you install this modify /etc/name_to_sysnum to bind sethostid to 
an _unused_ system call number
X
As far as I can determine the details of how to load system calls in
Solaris 2.3 are undocumented. I've done this by poking around in the
header files in sys and the man pages, and extrapolating from what 
I know about how loadable device drivers work and how the procedure 
works in Solaris 1.1
X
Mark Henderson <markh@wimsey.bc.ca>
14 Aug 1994
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/modctl.h>
#include <sys/cred.h>
#include <sys/systeminfo.h>
X
#define NHOSTID 10
X
static char serials[NHOSTID][16];
char xyzzy_rbuf[16];
X
int sethostid();
X
struct sysent sethostid_sysent = {2,0,sethostid,0};
X
extern struct mod_ops mod_syscallops;
X
static struct modlsys modlsys = {
&mod_syscallops,
"kern_hostid v1.02", 
&sethostid_sysent,
};
X
extern systeminfo();
X
static struct modlinkage modlinkage = {
X    MODREV_1, /* magic number */
X    &modlsys, 
X    0
};
X
struct as2 {int command; char *buf; long count;};
int new_systeminfo(struct as2 *uap, rval_t *foo)
{
X    int ret,i,bsize;
X    gid_t gid;
X    cred_t *creds = CRED();
X    systeminfo(uap,foo);
X    ret = foo->r_val1;
X    if (uap->command == SI_HW_SERIAL) {
X        gid = creds->cr_gid;
X        bsize = (uap->count > 16) ? 16 : uap->count; /* min(16,count)*/
X        if (gid >= 900 && gid < 900+NHOSTID) {
X            if (serials[gid - 900][0]) {
X                for (i=0;i < bsize - 1;i++)
X                    xyzzy_rbuf[i]  = serials[gid-900][i];
X                xyzzy_rbuf[bsize - 1] = 0;
X                ret = strlen(xyzzy_rbuf) + 1;
X                if (copyout(xyzzy_rbuf,uap->buf,ret) < 0)
X                    return EFAULT;
X            }
X        }
X        for (gid = 900; gid < 900+NHOSTID; gid++) {
X            if (groupmember(gid, creds)) {
X                if (serials[gid - 900][0]) {
X                    for (i=0;i< bsize - 1;i++)
X                        xyzzy_rbuf[i]  = serials[gid-900][i];
X                    xyzzy_rbuf[bsize - 1] = 0;
X                    ret = strlen(xyzzy_rbuf) + 1;
X                    if (copyout(xyzzy_rbuf,uap->buf,ret) < 0)
X                        return EFAULT;
X                    break;
X                }
X            }
X        }
X    }
X    foo->r_val1 = ret;
X    return 0;
}
X
struct as {int n; unsigned int hostid;};
X
sethostid(struct as *uap, rval_t *foo)
{
X    cred_t *creds = CRED();
X    if (!suser(creds)) {
X        return EACCES;
X    }
X
X    if ((uap->n >= NHOSTID )||(uap->n < 0)) {  
X        return EINVAL;
X    }
X    numtos( (unsigned long)uap->hostid, &serials[uap->n][0]);
X    foo->r_val1 = uap->hostid;
X    return 0;
}
X
_init(void)
{
X    int i,status;
X    status = mod_install(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
X        sysent[SYS_systeminfo].sy_call = new_systeminfo;
X        for (i=0; i < NHOSTID; i++) 
X            serials[i][0] = 0;
X    }
X    return status;
}
_fini(void)
{
X    int status;
X    status = mod_remove(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
X        sysent[SYS_systeminfo].sy_call = systeminfo;
X    }
X    return status;
}
X
_info(struct modinfo *modinfop)
{
X    return (mod_info(&modlinkage, modinfop));
}
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~ ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~ failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~'`"
test 3998 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.c~: original size 3998, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sethostid.o ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.o' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sethostid.o (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sethostid.o (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.o' &&
XELFXX�X�X���X	94/07/29 SMItallXX
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/sethostid.o ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sethostid.o failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.o'`"
test 5668 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.o: original size 5668, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sethostid ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sethostid' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sethostid (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sethostid (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sethostid' &&
XELFXXX�X�X���Xh	1.8	93/05/03 SMISMId.c�X�
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/sethostid ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sethostid failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sethostid'`"
test 5840 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sethostid: original size 5840, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sethostid.h ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.h' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sethostid.h (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sethostid.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.h' &&
#define SYS_sethostid		177
SHAR_EOF
chmod 0600 hid-1.6.1/hostid-by-egid-solaris2/sethostid.h ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sethostid.h failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.h'`"
test 27 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sethostid.h: original size 27, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hostid-by-egid-solaris2/sid ==============
if test -f 'hid-1.6.1/hostid-by-egid-solaris2/sid' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hostid-by-egid-solaris2/sid (File already exists)'
else
echo 'x - extracting hid-1.6.1/hostid-by-egid-solaris2/sid (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hostid-by-egid-solaris2/sid' &&
XELFX|�HT��X$`�0�l�X<�|��X$0<HT`lXXX|���HT��X$`�0�l�X<eva/bootstrap/3.0.1/boot3/bin/sparc/SC3.0.1/../bin/../SC3.0.1/bin/cc -c -O -DELF -o values-xt.o  ../src/values-Xt.c -W0,-xp||���
SHAR_EOF
chmod 0700 hid-1.6.1/hostid-by-egid-solaris2/sid ||
echo 'restore of hid-1.6.1/hostid-by-egid-solaris2/sid failed'
Wc_c="`wc -c < 'hid-1.6.1/hostid-by-egid-solaris2/sid'`"
test 6036 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hostid-by-egid-solaris2/sid: original size 6036, current size' "$Wc_c"
fi
# ============= hid-1.6.1/run/makefile ==============
if test ! -d 'hid-1.6.1/run'; then
    echo 'x - creating directory hid-1.6.1/run'
    mkdir 'hid-1.6.1/run'
fi
if test -f 'hid-1.6.1/run/makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/run/makefile (File already exists)'
else
echo 'x - extracting hid-1.6.1/run/makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/run/makefile' &&
# comment out next line for Solaris 1
CFLAGS = -DSOLARIS2
run: run.c
X	$(CC) $(CFLAGS) -o run run.c
X	chmod 4755 run
install: run
X	cp run /usr/local/bin
X	chmod 4755 /usr/local/bin/run
clean:
X	rm -f *.o core run
SHAR_EOF
chmod 0600 hid-1.6.1/run/makefile ||
echo 'restore of hid-1.6.1/run/makefile failed'
Wc_c="`wc -c < 'hid-1.6.1/run/makefile'`"
test 209 -eq "$Wc_c" ||
	echo 'hid-1.6.1/run/makefile: original size 209, current size' "$Wc_c"
fi
# ============= hid-1.6.1/run/run.c ==============
if test -f 'hid-1.6.1/run/run.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/run/run.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/run/run.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/run/run.c' &&
/* 
X * run a program with a group from the range 900,...,909 added to the
X *   group list
X * Mark Henderson <markh@wimsey.bc.ca>
X * 11 Aug 1994 
X * e.g.
X *  run 0 hostid
X * executes hostid with group 900 added to the group list
X *
X * must be installed setuid root. I recommend 4755 or 4711 for the
X *  permissions
X */
X
X
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <sys/types.h>
X
#ifdef SOLARIS2
#define GID_T gid_t
#else
#define GID_T int 
#endif
X  /* should be gid_t for Solaris 2, but it really doesn't matter */
X
GID_T grouplist[NGROUPS_MAX];
#define NHOSTID 10
main(argc,argv)
int argc;
char *argv[];
{
X    int i,j;
X
X    if (argc < 3) {
X        fprintf(stderr, "usage: run <int> command\n");
X        exit(1);
X    }
X    
X    i = getgroups(NGROUPS_MAX, grouplist);
#ifdef DEBUG
X    for (j=0; j< i ; j++)
X        fprintf(stderr, "%d\n", grouplist[j]);
#endif
X    grouplist[i] = (GID_T)(atoi(argv[1]) + 900);
X    if (grouplist[i] < 900 || grouplist[i] >= NHOSTID + 900) {
X        fprintf(stderr, "usage: run <int> command\n<int> is out of range\n");
X        exit(1);
X    }
X
X    if (i >= NGROUPS_MAX) {
X        fprintf(stderr, "already in NGROUPS_MAX groups\n");
X        exit(1);
X    }
X    i = setgroups(i+1, grouplist);
X    if (i < 0) {
X        fprintf(stderr, "setgroups failed\n");
X        exit(1);
X    }
X    seteuid(getuid());
X    execvp(argv[2], argv+2);
}
SHAR_EOF
chmod 0600 hid-1.6.1/run/run.c ||
echo 'restore of hid-1.6.1/run/run.c failed'
Wc_c="`wc -c < 'hid-1.6.1/run/run.c'`"
test 1385 -eq "$Wc_c" ||
	echo 'hid-1.6.1/run/run.c: original size 1385, current size' "$Wc_c"
fi
# ============= hid-1.6.1/run/README ==============
if test -f 'hid-1.6.1/run/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/run/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/run/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/run/README' &&
run.c is a small program to run a program with any group in the
range 900,...,909 added to the group list.
X
Take a look at the makefile to make sure you have the correct settings
for CC and CFLAGS
X
You might want to install it in /usr/local/bin setuid root. Anyway,
that's what the install program does. I'm not an expert on writing
"safe" setuid programs, so please check this out carefully before you
install it. (General good instructios for any setuid root program!)
X
An example of its use (with the solaris 2 hostid-by-egid module) is
as follows:
X
(edit /etc/name_to_sysnum as described in the documentation for 
X hostid-by-egid-solaris2)
X
ratatosk# cd hostid-by-egid-solaris2
ratatosk# make load
/opt/SUNWspro/bin/cc -D_KERNEL  -c  sethostid.c
ld -r -o sethostid sethostid.o
/usr/sbin/modload ./sethostid
ratatosk# make sid
grep sethostid /etc/name_to_sysnum | sed 's/^/#define SYS_/' ratatosk#sethostid.h
/opt/SUNWspro/bin/cc -o sid -I. sid.c
ratatosk# ./sid 0 24000000
ratatosk# ./sid 1 25000000
ratatosk# cd ../run
ratatosk# make
cc -o run run.c
chmod 4755 run
ratatosk# hostid
80512f45
ratatosk# ./run 0 hostid
24000000
ratatosk# ./run 1 hostid
25000000
ratatosk# ./run 2 hostid
80512f45
ratatosk# ./run 0 lmhostid
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "24000000"
ratatosk# ./run 0 lmhostid
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "25000000"
ratstosk# ./run 0 csh
ratatosk# hostid
24000000
ratatosk# lmhostid
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "24000000"
ratatosk# modinfo
...
X 78 fc6a50a0   a62 277   1  sethostid (kern_hostid v1.02)
...
ratatosk# modunload -i 78
ratatosk# hostid
80512f45
ratatosk# ./run 0 hostid
80512f45
SHAR_EOF
chmod 0600 hid-1.6.1/run/README ||
echo 'restore of hid-1.6.1/run/README failed'
Wc_c="`wc -c < 'hid-1.6.1/run/README'`"
test 1816 -eq "$Wc_c" ||
	echo 'hid-1.6.1/run/README: original size 1816, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-4.1/README ==============
if test ! -d 'hid-1.6.1/sethostid-simple-4.1'; then
    echo 'x - creating directory hid-1.6.1/sethostid-simple-4.1'
    mkdir 'hid-1.6.1/sethostid-simple-4.1'
fi
if test -f 'hid-1.6.1/sethostid-simple-4.1/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-4.1/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-4.1/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-4.1/README' &&
This is based, in part, upon an anonymous contribution. I've improved
it by making it loadable, so one does not have to build a new kernel.
You'll find the original contribution in ../hostid-by-egid
X
This will probably only work on versions of Sun OS later than 4.1.
X
I've tried it on both a Sun 3 and Sun 4.
X
to use this:
make load
make sethostid
./sethostid 72000000
X
All numbers are in hex. Do NOT put in the leading 0x.
X
You can remove the sethostid call by using modunload. You can check
whether or not it is currently installed with modstat.
X
N.B. sethostid.exec must be executable. Depending upon where you got
the distribution you might have to chmod +x it.
X
Calling sethostid with the hostid of 0 will restore the hostid to the
default.
X
e.g.
./sethostid 0
X
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-4.1/README ||
echo 'restore of hid-1.6.1/sethostid-simple-4.1/README failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-4.1/README'`"
test 767 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-4.1/README: original size 767, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-4.1/kern_hostid.c ==============
if test -f 'hid-1.6.1/sethostid-simple-4.1/kern_hostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-4.1/kern_hostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-4.1/kern_hostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-4.1/kern_hostid.c' &&
/*
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.
X
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.
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sun/vddrv.h>
X
static unsigned hostid = 0;
X
int sethostid();
X
static struct sysent sethostid_sysent = { 1, sethostid } ;
X
static struct vdlsys vd = {
X  VDMAGIC_SYS, /* magic number */
X  "sethostid", /* name */
X  0, /* syscall number (filled in automagically) */
X  &sethostid_sysent /* description of syscall */
};
X
X
Gethostid()
{
X    gethostid();
X
X    if (hostid)  
X    u.u_r.r_val1 = hostid;
X    u.u_error = 0;
X    return;
}
X
sethostid(uap)
X    register struct a {
X        unsigned hostid;
X    } *uap;
{
X    if (!suser()) {
X        u.u_error = EACCES;
X        return;
X    }
X
X    hostid = uap->hostid;
X
X    u.u_r.r_val1 = hostid;
X    u.u_error = 0;
X    return;
}
X
X
sethostidinit(function_code, vdp, vdi, vds)
unsigned int function_code;
struct vddrv *vdp;
addr_t vdi;
struct vdstat *vds;
{
X  switch (function_code) {
X  case VDLOAD:
X    vdp->vdd_vdtab = (struct vdlinkage *)&vd;
X    sysent[SYS_gethostid].sy_narg = 2;
X    sysent[SYS_gethostid].sy_call = Gethostid;
X    return 0;
X  case VDUNLOAD:
X    sysent[SYS_gethostid].sy_narg = 2;
X    sysent[SYS_gethostid].sy_call = gethostid;
X    return 0;
X  case VDSTAT:
X    return 0;
X  default:
X    return EIO;
X  }
}
X
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-4.1/kern_hostid.c ||
echo 'restore of hid-1.6.1/sethostid-simple-4.1/kern_hostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-4.1/kern_hostid.c'`"
test 1992 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-4.1/kern_hostid.c: original size 1992, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-4.1/makefile ==============
if test -f 'hid-1.6.1/sethostid-simple-4.1/makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-4.1/makefile (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-4.1/makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-4.1/makefile' &&
CFLAGS = -DKERNEL
ASFLAGS = -P
X
load: kern_hostid.o
X	chmod +x sethostid.exec
X	/usr/etc/modload kern_hostid.o -v -entry _sethostidinit -exec sethostid.exec
X
sethostid: sethostid.o sethostid.h
X	cc -o sethostid -I. sethostid.c
X
clean:
X	rm -f core *.o sethostid kern_hostid sethostid.h
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-4.1/makefile ||
echo 'restore of hid-1.6.1/sethostid-simple-4.1/makefile failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-4.1/makefile'`"
test 282 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-4.1/makefile: original size 282, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-4.1/sethostid.c ==============
if test -f 'hid-1.6.1/sethostid-simple-4.1/sethostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-4.1/sethostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-4.1/sethostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-4.1/sethostid.c' &&
/*
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.
X
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.
*/
X
#include <stdio.h>
#include <sys/syscall.h>
#include <errno.h>
#include "sethostid.h"
X
main(argc, argv)
int argc;
char *argv[];
{
X  unsigned hostid;
X
X  if (argc<2) {
X    fprintf(stderr, "%s <hostid>\n", argv[0]);
X    exit(1);
X  }
X  sscanf(argv[1], "%x", &hostid);
X  if (syscall(SYS_sethostid, hostid)==-1) {
X    perror(argv[0]);
X    exit(1);
X  }
}  
X
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-4.1/sethostid.c ||
echo 'restore of hid-1.6.1/sethostid-simple-4.1/sethostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-4.1/sethostid.c'`"
test 1083 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-4.1/sethostid.c: original size 1083, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-4.1/sethostid.exec ==============
if test -f 'hid-1.6.1/sethostid-simple-4.1/sethostid.exec' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-4.1/sethostid.exec (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-4.1/sethostid.exec (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-4.1/sethostid.exec' &&
#!/bin/csh -f
echo "#define SYS_sethostid $3" > sethostid.h
SHAR_EOF
chmod 0700 hid-1.6.1/sethostid-simple-4.1/sethostid.exec ||
echo 'restore of hid-1.6.1/sethostid-simple-4.1/sethostid.exec failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-4.1/sethostid.exec'`"
test 60 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-4.1/sethostid.exec: original size 60, current size' "$Wc_c"
fi
# ============= hid-1.6.1/spoof-solaris1/README ==============
if test ! -d 'hid-1.6.1/spoof-solaris1'; then
    echo 'x - creating directory hid-1.6.1/spoof-solaris1'
    mkdir 'hid-1.6.1/spoof-solaris1'
fi
if test -f 'hid-1.6.1/spoof-solaris1/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/spoof-solaris1/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/spoof-solaris1/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/spoof-solaris1/README' &&
Mark Henderson <markh@wimsey.bc.ca>, <henderso@netcom.com>
X
This package allows you modify the hostname and hostid returned
by gethostname and gethostid depending upon the group membership
of the process calling gethostname and gethostid.
X
It has been tested under Solaris 1.1.
X
Together with vif-1.0 by Steinar Haug, this allows you to also spoof IP addresses
X  in a limited sense. You can get vif-1.0 from the following ftp sites:
X
X  ftp.netcom.com:/pub/he/henderso
X  ftp.rahul.net:/pub/mch
X  ugle.unit.no:/pub/unix/network/vif-1.0.tar.gz
X  any alt.sources archive (posted on 15 Jan 1995 00:45:27 GMT)
X
to use this:
X
example/instructions
X         - you want certain processes to see the hostname joe.test.com
X         - the "real" hostname of the host is ratatosk
X
You'll need to be root to do most of this. 
X
0. make sure that joe.test.com is in /etc/hosts, the YP hosts database or
X   DNS as appropriate.
1. fetch, unpack, make, and install vif-1.0
2. install run (source is in ../run)
3. make load
4. make sethostid
5. ./sethostid 0 72000000 joe.test.com
X   which should modify the hostid and hostname for processes with gid 900
X   to be 0x72000000 and joe.test.com resp.
6. /usr/etc/ifconfig vif0 joe.test.com up
X   now "telnet joe.test.com" should connect to the local host
7. /usr/etc/route add joe.test.com ratatosk 0
8. If you want another host (say squirrel) to also be able to communicate
X   with ratatosk as joe.test.com, login to squirrel and do
X   /usr/etc/route add joe.test.com ratatosk 1
X   go back to ratatosk
9. run 0 /bin/sh
X   hostname will return joe.test.com
X   hostid will return 0x72000000
X   most programs that run in group 900 and try to determine the IP address of 
X       the machine will think it is the IP address of joe.test.com. The point 
X       is that this will spoof many licence manager daemons which are locked to 
X       hostname and/or IP address.
X
N.B. sethostid.exec must be executable. Depending upon where you got
the distribution you might have to chmod +x it.
X
SHAR_EOF
chmod 0700 hid-1.6.1/spoof-solaris1/README ||
echo 'restore of hid-1.6.1/spoof-solaris1/README failed'
Wc_c="`wc -c < 'hid-1.6.1/spoof-solaris1/README'`"
test 2009 -eq "$Wc_c" ||
	echo 'hid-1.6.1/spoof-solaris1/README: original size 2009, current size' "$Wc_c"
fi
# ============= hid-1.6.1/spoof-solaris1/hid_flags.h ==============
if test -f 'hid-1.6.1/spoof-solaris1/hid_flags.h' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/spoof-solaris1/hid_flags.h (File already exists)'
else
echo 'x - extracting hid-1.6.1/spoof-solaris1/hid_flags.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/spoof-solaris1/hid_flags.h' &&
#define HID_HOSTID 0x01
#define HID_HOSTNAME 0x02
SHAR_EOF
chmod 0700 hid-1.6.1/spoof-solaris1/hid_flags.h ||
echo 'restore of hid-1.6.1/spoof-solaris1/hid_flags.h failed'
Wc_c="`wc -c < 'hid-1.6.1/spoof-solaris1/hid_flags.h'`"
test 50 -eq "$Wc_c" ||
	echo 'hid-1.6.1/spoof-solaris1/hid_flags.h: original size 50, current size' "$Wc_c"
fi
true || echo 'restore of hid-1.6.1/spoof-solaris1/kern_hostid.c failed'
echo End of part 1, continue with part 2
exit 0
-- 
Mark Henderson -- markh@wimsey.bc.ca, henderso@netcom.com (personal accounts)
ViaCrypt PGP Key Fingerprint: 21 F6 AF 2B 6A 8A 0B E1  A1 2A 2A 06 4A D5 92 46
cryptography archive maintainer -- ftp://ftp.wimsey.com/pub/crypto
ftp://ftp.wimsey.com/pub/crypto/sun-stuff/change-sun-hostid-1.6.1.tar.gz


