Subject: Re: How to change host ID under Solarix 2.x?

From: [email-masked] (Jason C. Austin)
Date: 06 May 1994 19:39:03 GMT

In article <[email-masked]> [email-masked] (Morry Katz) writes:
-> In article <[email-masked]> [email-masked] (Jack Morrison) writes:
-> > 
-> > In article [email-masked], [email-masked] (Hseuh-Lin Kung) writes:
-> >>   I am curious about is there any way to change hostid
-> >>under Solaris 2.x except physical changing EPROM on the
-> >>system board?
-> > 
-> > I am curious why you'd want to, other than stealing licensed software?
-> > ---
-> > "How am I typing? Call 1-818-354-7782"               [email-masked]
-> > Jack Morrison/Jet Propulsion Lab/MS107-102 4800 Oak Grove Dr, Pasadena CA 91109
-> > 
-> I would like to do this on both 4.1.3 and 2.3 because we have backup
-> hardware for our server if it dies.  We want to be able to reboot the
-> backup hardware so that it will be indistinguishable from the original
-> server in the event of failure.  I do not believe that this is
-> stealing licensed software as it will only be used when the hardware
-> on which the software is licensed is physically dead.

	I can help you with 4.1.3, but I haven't looked at 2.3 yet. 

Run:
adb -w -k /vmunix /dev/mem

Now enter this and hit return twice:
_gethostid+4/i

You'll get this:

_gethostid+4:   call    _machineid
_gethostid+8:   nop

The trick is to replace these eight bytes with machine code that will
load the hostid you want into %o0.

At gethostid+4, we want to use SETHI to set the top bits of %o0, and
at gethostid+8, we want to binary or in the low bits.  Here's an
algorithm for coming up with the right values:

#define HIMASK 0x3FFFFF
#define LOWMASK 0x3ff
#define SETHI 0x11000000
#define OR    0x90122000

wordone = SETHI | ((newid>>10)&HIMASK);
wordtwo = OR | (newid&LOWMASK);

I don't remember how I came up with this, and I haven't had enough
coffee to try and figure it out again.

For an example, say we want to set the hostid to 0x12345678.  Using
the above algorithm, wordone would be 0x11048D15 and wordtwo would be
0x90122278.  Install these instructions with adb like this:

_gethostid+4/W0x11048D15
_gethostid+8/W0x90122278

The hostid function will now kick out 12345678.  This change is made
in memory and will go away at the next reboot.

If anyone figures out how to do this same thing under 2.3, please send
it to me, as I doubt I will have a chance to work on it.
--
Jason C. Austin
[email-masked]

---

From: [email-masked] (Bob Dowling)
Date: 6 May 1994 20:19:58 GMT

Here's a simple way to do it under Solaris 2.3.  
I'm no adb guru so there may well be a better way.

Because adb doesn't show a prompt, I'm indenting adb's responses with a couple of
spaces.

$ lmhostid            
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "572043da"

$ su
Password: 
# adb -kw /kernel/unix /dev/mem
  physmem 1b0e
hw_serial/s
  hw_serial:
  hw_serial:      1461732314		(Decimal version of the hostid)
hw_serial/w '12'
  hw_serial:      0x3134  =       0x3132
hw_serial+2/w '34'
  hw_serial+2:    0x3631  =       0x3334
hw_serial+4/w '56'
  hw_serial+4:    0x3733  =       0x3536
hw_serial+6/w '78'
  hw_serial+6:    0x3233  =       0x3738
hw_serial+8/w '90'
  hw_serial+8:    0x3134  =       0x3930
hw_serial/s
  hw_serial:
  hw_serial:      1234567890
^D
# ^D

$ lmhostid     
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "499602d2"

The hostid remains changed until the next reboot.

--------
Bob Dowling:                    UNIX Support,
                                University of Cambridge Computing Service,
[email-masked]              New Museums Site, Pembroke Street,
+44 223 334728                  Cambridge, UK.  CB2 3QG.

---

From: [email-masked] (Casper H.S. Dik)
Date: 7 May 1994 13:44:16 GMT

>load the hostid you want into %o0.

Why don't you replace the gethostid() system call in
/usr/kvm/sys/init_sysent.c with one that returns the
hostid you want it to return?  (Or implement a sethostid/gethostid
system call pair)?

Much safer and easier to do than mucking with adb.

Casper