no error if can't get interfaces or netmask since networking may not be in
the kernel.
This commit is contained in:
34
sudo.c
34
sudo.c
@@ -597,14 +597,12 @@ static void load_interfaces()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get interface configuration
|
* get interface configuration or return (leaving interfaces NULL)
|
||||||
*/
|
*/
|
||||||
ifconf.ifc_len = sizeof(buf);
|
ifconf.ifc_len = sizeof(buf);
|
||||||
ifconf.ifc_buf = buf;
|
ifconf.ifc_buf = buf;
|
||||||
if (ioctl(sock, SIOCGIFCONF, (char *)(&ifconf)) < 0) {
|
if (ioctl(sock, SIOCGIFCONF, (char *)(&ifconf)) < 0) {
|
||||||
(void) fprintf(stderr, "%s: cannot get interface configuration: ",
|
/* networking probably not installed in kernel */
|
||||||
Argv[0]);
|
|
||||||
perror("");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,23 +647,21 @@ static void load_interfaces()
|
|||||||
/* get the netmask */
|
/* get the netmask */
|
||||||
#ifdef SIOCGIFNETMASK
|
#ifdef SIOCGIFNETMASK
|
||||||
(void) strcpy(ifreq.ifr_name, ifconf.ifc_req[i].ifr_name);
|
(void) strcpy(ifreq.ifr_name, ifconf.ifc_req[i].ifr_name);
|
||||||
if (ioctl(sock, SIOCGIFNETMASK, (char *)(&ifreq)) < 0) {
|
if (ioctl(sock, SIOCGIFNETMASK, (char *)(&ifreq)) >= 0) {
|
||||||
(void) free(interfaces);
|
(void) memcpy(&interfaces[j].netmask,
|
||||||
num_interfaces = 0;
|
&(((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr),
|
||||||
perror("");
|
sizeof(struct in_addr));
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
(void) memcpy(&interfaces[j].netmask,
|
|
||||||
&(((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr),
|
|
||||||
sizeof(struct in_addr));
|
|
||||||
#else
|
#else
|
||||||
if (IN_CLASSC(interfaces[j].addr.s_addr))
|
{
|
||||||
interfaces[j].netmask.s_addr = htonl(IN_CLASSC_NET);
|
|
||||||
else if (IN_CLASSB(interfaces[j].addr.s_addr))
|
|
||||||
interfaces[j].netmask.s_addr = htonl(IN_CLASSB_NET);
|
|
||||||
else
|
|
||||||
interfaces[j].netmask.s_addr = htonl(IN_CLASSA_NET);
|
|
||||||
#endif /* SIOCGIFNETMASK */
|
#endif /* SIOCGIFNETMASK */
|
||||||
|
if (IN_CLASSC(interfaces[j].addr.s_addr))
|
||||||
|
interfaces[j].netmask.s_addr = htonl(IN_CLASSC_NET);
|
||||||
|
else if (IN_CLASSB(interfaces[j].addr.s_addr))
|
||||||
|
interfaces[j].netmask.s_addr = htonl(IN_CLASSB_NET);
|
||||||
|
else
|
||||||
|
interfaces[j].netmask.s_addr = htonl(IN_CLASSA_NET);
|
||||||
|
}
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user