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).\n\n",argv[0]);
return 1;
}

printf("Changing the host id of the current machine...\n");

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

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

}