added Andy's new ISC changes
This commit is contained in:
54
sudo.c
54
sudo.c
@@ -91,6 +91,9 @@ static char rcsid[] = "$Id$";
|
||||
#include <sys/sioctl.h>
|
||||
#include <sys/stropts.h>
|
||||
#include <net/errno.h>
|
||||
#define STRSET(cmd, param, len) {strioctl.ic_cmd=(cmd);\
|
||||
strioctl.ic_dp=(param);\
|
||||
strioctl.ic_len=(len);}
|
||||
#endif /* _ISC */
|
||||
#ifdef _MIPS
|
||||
#include <net/soioctl.h>
|
||||
@@ -595,18 +598,15 @@ static void load_interfaces()
|
||||
char buf[BUFSIZ];
|
||||
int sock, i, j;
|
||||
#ifdef _ISC
|
||||
struct ifreq *ifrp;
|
||||
struct ifreq *ifr;
|
||||
struct ifconf *ifc;
|
||||
struct strioctl strioctl;
|
||||
#endif /* _ISC */
|
||||
|
||||
/* so we can skip localhost and its ilk */
|
||||
localhost_mask = inet_addr("127.0.0.0");
|
||||
|
||||
#ifdef _ISC
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
#else
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
#endif /* _ISC */
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0) {
|
||||
perror("socket");
|
||||
exit(1);
|
||||
@@ -618,32 +618,27 @@ static void load_interfaces()
|
||||
ifconf.ifc_len = sizeof(buf);
|
||||
ifconf.ifc_buf = buf;
|
||||
#ifdef _ISC
|
||||
strioctl.ic_cmd = SIOCGIFCONF;
|
||||
strioctl.ic_dp = (char *)&ifconf;
|
||||
strioctl.ic_len = sizeof(ifconf);
|
||||
ifc = (struct ifconf *)buf;
|
||||
ifc->ifc_len = sizeof (buf) - sizeof(struct ifconf);
|
||||
STRSET(SIOCGIFCONF, (caddr_t)ifc, sizeof(buf));
|
||||
if (ioctl(sock, I_STR, &strioctl) < 0) {
|
||||
/* networking probably not installed in kernel */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Still can't get any more than the loopback interface out
|
||||
* of the INTERACTIVE ioctl :-(
|
||||
*/
|
||||
num_interfaces = 1;
|
||||
ifconf = *ifc;
|
||||
|
||||
#else
|
||||
if (ioctl(sock, SIOCGIFCONF, (char *)(&ifconf)) < 0) {
|
||||
/* networking probably not installed in kernel */
|
||||
return;
|
||||
}
|
||||
#endif /* _ISC */
|
||||
|
||||
/*
|
||||
* find out how many interfaces exist
|
||||
*/
|
||||
num_interfaces = ifconf.ifc_len / sizeof(struct ifreq);
|
||||
|
||||
#endif /* _ISC */
|
||||
/*
|
||||
* malloc() space for interfaces array
|
||||
*/
|
||||
@@ -658,19 +653,31 @@ static void load_interfaces()
|
||||
/*
|
||||
* for each interface, get the ip address and netmask
|
||||
*/
|
||||
#ifdef _ISC
|
||||
ifr = (struct ifreq *)(ifc->ifc_req);
|
||||
for (i = 0, j = 0; i < num_interfaces; i++, ifr++) {
|
||||
(void) strncpy(ifreq.ifr_name, ifr->ifr_name,
|
||||
sizeof(ifr->ifr_name));
|
||||
|
||||
/* get the ip address */
|
||||
STRSET(SIOCGIFADDR, (caddr_t)ifr, sizeof(ifreq));
|
||||
if (ioctl(sock, I_STR, &strioctl) < 0) {
|
||||
/* non-fatal error if interface is down or not supported */
|
||||
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT)
|
||||
continue;
|
||||
|
||||
(void) fprintf(stderr, "%s: Error, ioctl: SIOCGIFADDR ", Argv[0]);
|
||||
perror("");
|
||||
exit(1);
|
||||
}
|
||||
sin = (struct sockaddr_in *)&ifr->ifr_addr;
|
||||
#else
|
||||
for (i = 0, j = 0; i < num_interfaces; i++) {
|
||||
(void) strncpy(ifreq.ifr_name, ifconf.ifc_req[i].ifr_name,
|
||||
sizeof(ifreq.ifr_name));
|
||||
|
||||
/* get the ip address */
|
||||
#ifdef _ISC
|
||||
strioctl.ic_cmd = SIOCGIFADDR;
|
||||
strioctl.ic_dp = (char *)&ifreq;
|
||||
strioctl.ic_len = sizeof(ifreq);
|
||||
if (ioctl(sock, I_STR, &strioctl) < 0) {
|
||||
#else
|
||||
if (ioctl(sock, SIOCGIFADDR, (caddr_t)(&ifreq))) {
|
||||
#endif /* _ISC */
|
||||
/* non-fatal error if interface is down or not supported */
|
||||
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT)
|
||||
continue;
|
||||
@@ -680,6 +687,7 @@ static void load_interfaces()
|
||||
exit(1);
|
||||
}
|
||||
sin = (struct sockaddr_in *)&ifreq.ifr_addr;
|
||||
#endif /* _ISC */
|
||||
|
||||
/* make sure we don't have a dupe (usually consecutive) */
|
||||
if (j > 0 && memcmp(&interfaces[j-1].addr, &(sin->sin_addr),
|
||||
|
Reference in New Issue
Block a user