hostid command shows 16 hex digits instead of 8

I have created a c program to change the hostid. You can see the code below. It works OK when I specify 8 hex digits if the first one is 7 or lower. But for values bigger than 8 the host id is changed to 16 hex values instead of 8 starting with 0xFFFFFFFF… See the examples:

Change is OK:
ema1:/etc/init.d # ./change_hostid 7FFFFFFF
Changing the host id of the current machine…
host:/etc/init.d # hostid
0x7fffffff

Changed is not OK:
ema1:/etc/init.d # ./change_hostid 8FFFFFFF
Changing the host id of the current machine…
ema1:/etc/init.d # hostid
0xffffffff8fffffff

I also tried removing the /etc/hostid file and setting an IP address in eth0 interface to match the hostid I want, but still the same behavior. For hostid starting with 8… it will always add FFFFFFFF at the beginning and complete with the other 8 hexadecimal digits I specified. I have a software with a license service expecting a hostid 8xxxxxxx, with only 8 digits. How can I achieve this??

Thank you very much.

#cat change_hostid.c

#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{

if(argc < 2)
{
fprintf(stderr," Missing new hostid argument: please assign one (example 728b7432).

",argv[0]);
return 1;
}

printf("Changing the host id of the current machine…
");

sethostid(
strtoul(argv[1],NULL,16));
return 0;

printf("hostid changed, please run ./hostid command to see the results…
");

}

Out of curiosity, which version/SP of SLES? What is the exact version of
the coreutils package (from which ‘hostid’ originates)?


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

SLES 11 /SP1

rpm -qf /etc/SuSE-release /etc/issue

sles-release-11.1-1.152
sles-release-11.1-1.152

rpm -qa | grep -i coreutils

coreutils-lang-6.12-32.17
coreutils-6.12-32.17

Thank you.

I tried now with SP4 and it works OK.

Thanks.

Thank-you for posting back your results.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…