redhat hostid ändern
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i;
unsigned long id;
char *str;
printf("Hostid tool for Linux/x86 platform\n");
if (argc < 2) { Thu Aug 1 12:43:36
CST 2002
id = gethostid();
printf("Hostid is: %X\n", id);
exit(0);
}
str = argv[1];
id = 0l;
i = 0;
while (str && i < 8) {
if (isdigit(str)) id = (id << 4) + str - '0';
else if (isxdigit(str))
id = (id << 4) + toupper(str) + 10 - 'A';
else break;
++i;
}
if ( i == 8) {
sethostid(id);
printf("Hostid changed to: %X\n", id);
} else printf("Error : incorrect hostid (%s)\n", str);
}