2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-01 06:45:10 +00:00

works on ISC again

This commit is contained in:
Todd C. Miller
1995-12-20 20:52:17 +00:00
parent 479248730a
commit 6d0d2c8bad

View File

@@ -104,11 +104,11 @@ extern char **Argv;
void load_interfaces() void load_interfaces()
{ {
unsigned long localhost_mask;
struct ifconf *ifconf; struct ifconf *ifconf;
char ifconf_buf[sizeof(struct ifconf) + BUFSIZ]; char ifconf_buf[sizeof(struct ifconf) + BUFSIZ];
struct ifreq ifreq; struct ifreq ifreq, *ifr;
struct sockaddr_in *sin; struct sockaddr_in *sin;
unsigned long localhost_mask;
int sock, n, i; int sock, n, i;
#ifdef _ISC #ifdef _ISC
struct strioctl strioctl; struct strioctl strioctl;
@@ -129,18 +129,15 @@ void load_interfaces()
ifconf = (struct ifconf *) ifconf_buf; ifconf = (struct ifconf *) ifconf_buf;
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf)); ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf));
ifconf->ifc_len = sizeof(ifconf_buf) - sizeof(struct ifconf); ifconf->ifc_len = sizeof(ifconf_buf) - sizeof(struct ifconf);
/* networking may not be installed in kernel */
#ifdef _ISC #ifdef _ISC
STRSET(SIOCGIFCONF, (caddr_t) ifconf, sizeof(ifconf_buf)); STRSET(SIOCGIFCONF, (caddr_t) ifconf, sizeof(ifconf_buf));
if (ioctl(sock, I_STR, (caddr_t) &strioctl) < 0) { if (ioctl(sock, I_STR, (caddr_t) &strioctl) < 0)
/* networking probably not installed in kernel */
return;
}
#else #else
if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0) { if (ioctl(sock, SIOCGIFCONF, (caddr_t) ifconf) < 0)
/* networking probably not installed in kernel */
return;
}
#endif /* _ISC */ #endif /* _ISC */
return;
/* /*
* get the maximum number of interfaces that *could* exist. * get the maximum number of interfaces that *could* exist.
@@ -160,18 +157,25 @@ void load_interfaces()
/* /*
* for each interface, get the ip address and netmask * for each interface, get the ip address and netmask
*/ */
for (i = 0; i < ifconf->ifc_len; ) { for (ifreq.ifr_name[0] = '\0', i = 0; i < ifconf->ifc_len; ) {
/* setup ifreq struct */ /* get a pointer to the current interface */
ifreq = *((struct ifreq *) &ifconf->ifc_buf[i]); ifr = (struct ifreq *) ((caddr_t) ifconf->ifc_req + i);
/* set i to the subscript of the next interface */ /* set i to the subscript of the next interface */
#ifdef HAVE_SA_LEN #ifdef HAVE_SA_LEN
if (ifreq.ifr_addr.sa_len > sizeof(ifreq.ifr_addr)) i += sizeof(ifreq.ifr_name) + ifreq.ifr_addr.sa_len;
i += sizeof(ifreq.ifr_name) + ifreq.ifr_addr.sa_len; #else
else i += sizeof(struct ifreq);
#endif /* HAVE_SA_LEN */ #endif /* HAVE_SA_LEN */
i += sizeof(ifreq);
/* skip duplicates and interfaces with NULL addresses */
sin = (struct sockaddr_in *) &ifr->ifr_addr;
if (sin->sin_addr.s_addr == 0 ||
strncmp(ifr->ifr_name, ifreq.ifr_name, sizeof(ifr->ifr_name)) == 0)
continue;
/* make a working copy... */
ifreq = *ifr;
/* get the ip address */ /* get the ip address */
#ifdef _ISC #ifdef _ISC
@@ -190,11 +194,6 @@ void load_interfaces()
} }
sin = (struct sockaddr_in *) &ifreq.ifr_addr; sin = (struct sockaddr_in *) &ifreq.ifr_addr;
/* make sure we don't have a dup (usually consecutive) */
if (num_interfaces && interfaces[num_interfaces - 1].addr.s_addr ==
sin->sin_addr.s_addr)
continue;
/* store the ip address */ /* store the ip address */
interfaces[num_interfaces].addr.s_addr = sin->sin_addr.s_addr; interfaces[num_interfaces].addr.s_addr = sin->sin_addr.s_addr;
@@ -206,6 +205,8 @@ void load_interfaces()
#else #else
if (ioctl(sock, SIOCGIFNETMASK, (caddr_t) &ifreq) == 0) { if (ioctl(sock, SIOCGIFNETMASK, (caddr_t) &ifreq) == 0) {
#endif /* _ISC */ #endif /* _ISC */
sin = (struct sockaddr_in *) &ifreq.ifr_addr;
/* store the netmask */ /* store the netmask */
interfaces[num_interfaces].netmask.s_addr = sin->sin_addr.s_addr; interfaces[num_interfaces].netmask.s_addr = sin->sin_addr.s_addr;
} else { } else {