Bug#60099: sethostid returns '-1' when trying to set the hostid
Package: libc6
Version: 2.1.3-6
When I use sethostid() to set the hostid, sethostid returns '-1' and
perror() reports 'sethostid: No such file or directory'. After 'mkdir
/var/adm/' (thanks to 'njs' from irc.debian.org) it works correctly and
creates '/var/adm/hostid'. I couldn't find the part about
'/var/adm/hostid' in any documentation. This should be mentioned
somewhere.
Here's the source I used:
-----------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<errno.h>
#include<unistd.h>
void main(int argc, char **argv)
{
unsigned long hid;
if(argc == 1)
{
hid = gethostid();
printf("hid: %lX ... %li\n", hid, hid);
}else{
if( 1 != sscanf(argv[1], "%lx", &hid) )
printf("error\n");
else
sethostid(hid);
switch (errno)
{
case EPERM:
printf("no permission\n");
break;
case ENOSYS:
printf("ENOSYS stuff\n");
break;
default:
perror("sethostid: ");
printf("errno: %s\n", strerror(errno));
}
}
}
-------------------------------------------------------------------------
Reply to: