From ff4d046f39e3ed641bc5d9925f61d48010c56bfb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 29 Dec 1996 09:49:44 +0000 Subject: After George Sipe's changes. svn path=/trunk/; revision=704 --- interface.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'interface.c') diff --git a/interface.c b/interface.c index 85ca85d8..dce5267e 100644 --- a/interface.c +++ b/interface.c @@ -14,13 +14,11 @@ #ifdef linux #include -#include #include #include #include #include #include -#include #include "fetchmail.h" static struct in_addr interface_address; @@ -47,9 +45,8 @@ static int _get_ifinfo_(int socket_fd, FILE *stats_file, const char *ifname, /* see if the interface is up */ strcpy(request.ifr_name, ifname); - errno = 0; if (ioctl(socket_fd, SIOCGIFFLAGS, &request) < 0) - error(PS_IOERR, errno, "interface status check failed"); + return(FALSE); if (!(request.ifr_flags & IFF_RUNNING)) return(FALSE); @@ -106,7 +103,9 @@ static int get_ifinfo(const char *ifname, ifinfo_t *ifinfo) void interface_parse(void) { + int socket_fd = socket(AF_INET, SOCK_DGRAM, 0); char *cp1, *cp2; + struct ifreq request; /* in the event we point to a null string, make pointer null */ if (interface && !*interface) @@ -123,6 +122,13 @@ void interface_parse(void) (void) error(PS_SYNTAX, 0, "missing IP interface address"); *cp1++ = '\000'; + /* validate specified interface exists */ + strcpy(request.ifr_name, interface); + if (ioctl(socket_fd, SIOCGIFFLAGS, &request) < 0) + (void) error(PS_SYNTAX, 0, "no such interface device '%s'", + interface); + close(socket_fd); + /* find and isolate just the netmask */ if (!(cp2 = strchr(cp1, '/'))) cp2 = "255.255.255.255"; -- cgit v1.2.3