From owner-freebsd-ports Tue Jan 23 14:40:23 2001 Delivered-To: freebsd-ports@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id E93D237B698 for ; Tue, 23 Jan 2001 14:40:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f0NMe1O00361; Tue, 23 Jan 2001 14:40:01 -0800 (PST) (envelope-from gnats) Received: from greywolf.tamu.edu (greywolf.tamu.edu [128.194.177.19]) by hub.freebsd.org (Postfix) with ESMTP id CFA8F37B402 for ; Tue, 23 Jan 2001 14:34:54 -0800 (PST) Received: (from root@localhost) by greywolf.tamu.edu (8.11.1/8.11.1) id f0NMYsg16600; Tue, 23 Jan 2001 16:34:54 -0600 (CST) (envelope-from root) Message-Id: <200101232234.f0NMYsg16600@greywolf.tamu.edu> Date: Tue, 23 Jan 2001 16:34:54 -0600 (CST) From: daved@tamu.edu Reply-To: daved@tamu.edu To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: ports/24580: cfengine Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 24580 >Category: ports >Synopsis: cfengine giving errors when invoked >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jan 23 14:40:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: David J Duchscher >Release: FreeBSD 4.2-RELEASE i386 >Organization: Texas A&M University >Environment: Clean install of 4.2-RELEASE. >Description: cfengine produces the following errors when invoked: : No such network device : ioctl: Device not configured >How-To-Repeat: Just have to run the command. Does not matter what is in the configuration file. >Fix: I peaked at the code and it looks like it is not handling the scanning of the ifconf list that is returned by the ioctl call. It is assuming that all the ifrec structures are a fixed size that is determined by the size of the ifrec structure. This seems not to be the case. Below is a patach that I whipped up. It definately needs review and some more clean up. It should probably also test for HAVE_SOCKADDR_SA_LEN but it doesn't seem to exist in 4.2-RELEASE. Hope this helps someone. --- src/misc.c.orig Fri Dec 15 16:33:05 2000 +++ src/misc.c Tue Jan 23 11:33:40 2001 @@ -279,10 +279,11 @@ void GetInterfaceInfo(void) { int fd,len,i,j; - struct ifreq ifbuf[64],ifr; + struct ifreq *ifr; struct ifconf list; struct sockaddr_in *sin; struct hostent *hp; + char *ifbuf, *ptr; if ((fd=socket(AF_INET, SOCK_DGRAM, 0)) == -1) { @@ -290,8 +291,10 @@ exit(1); } -list.ifc_len = sizeof(ifbuf); -list.ifc_req = ifbuf; +len = 64 * sizeof(struct ifreq); +ifbuf = malloc(len); +list.ifc_len = len; +list.ifc_req = (struct ifreq *) ifbuf; if (ioctl(fd, SIOCGIFCONF, &list) == -1 || (list.ifc_len < (sizeof(struct ifreq)))) { @@ -299,23 +302,23 @@ exit(1); } -len=list.ifc_len/sizeof(struct ifreq); -Debug("Found: %d interfaces\n",len); - -for (j=0;jifr_name); + + ptr += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len; - strncpy(ifr.ifr_name,ifbuf[j].ifr_name,sizeof(ifbuf[j].ifr_name)); - if (ioctl(fd,SIOCGIFFLAGS,&ifr) == -1) + if (ioctl(fd,SIOCGIFFLAGS,ifr) == -1) { CfLog(cferror,"No such network device","ioctl"); return; } - if ((ifr.ifr_flags & IFF_UP) && !(ifr.ifr_flags & IFF_LOOPBACK)) + if ((ifr->ifr_flags & IFF_UP) && !(ifr->ifr_flags & IFF_LOOPBACK) && (ifr->ifr_addr.sa_family == AF_INET)) { - sin=(struct sockaddr_in *)&ifbuf[j].ifr_addr; + sin=(struct sockaddr_in *)&ifr->ifr_addr; if ((hp=gethostbyaddr((char *)&(sin->sin_addr.s_addr),sizeof(sin->sin_addr.s_addr),AF_INET)) == NULL) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message