From 628652a2af87f2e388365addad0ded9cf09a5f0f Mon Sep 17 00:00:00 2001 From: pst Date: Tue, 23 Jan 1996 01:58:00 +0000 Subject: Fix conflicts from 2.4.3 merge --- libexec/bootpd/.indent.pro | 3 -- libexec/bootpd/Makefile | 4 +-- libexec/bootpd/bootpd.c | 79 ++++++++++++++++++++++++++++++---------------- libexec/bootpd/getether.c | 27 ++++++++++------ 4 files changed, 71 insertions(+), 42 deletions(-) delete mode 100644 libexec/bootpd/.indent.pro (limited to 'libexec/bootpd') diff --git a/libexec/bootpd/.indent.pro b/libexec/bootpd/.indent.pro deleted file mode 100644 index 177ed73..0000000 --- a/libexec/bootpd/.indent.pro +++ /dev/null @@ -1,3 +0,0 @@ - -nbad -nbap -nbbb -nbc -br -bli4 -c33 -cd33 -cdb -ce -ci4 - -cli0 -cp1 -d0 -di0 -nfc1 -nfca -i4 -ip4 -l75 -lp -npcs - -psl -sc -nsob -nss -ts4 diff --git a/libexec/bootpd/Makefile b/libexec/bootpd/Makefile index e923968..659e3aa 100644 --- a/libexec/bootpd/Makefile +++ b/libexec/bootpd/Makefile @@ -1,11 +1,11 @@ # bootpd/Makefile -# $Id: Makefile,v 1.2 1995/05/30 05:45:45 rgrimes Exp $ +# $Id: Makefile,v 1.3 1995/07/25 23:38:40 wpaul Exp $ PROG= bootpd CFLAGS+= -DETC_ETHERS CFLAGS+= -DSYSLOG -DDEBUG -DVEND_CMU -SUBDIR= tools +SUBDIR= bootpgw tools SRCS= bootpd.c dovend.c readfile.c hash.c dumptab.c \ lookup.c getif.c hwaddr.c report.c tzone.c rtmsg.c diff --git a/libexec/bootpd/bootpd.c b/libexec/bootpd/bootpd.c index cf693fd..6ab769e 100644 --- a/libexec/bootpd/bootpd.c +++ b/libexec/bootpd/bootpd.c @@ -20,10 +20,6 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ************************************************************************/ -#ifndef lint -static char rcsid[] = "$Id: bootpd.c,v 1.1.1.1 1994/09/30 05:45:04 pst Exp $"; -#endif - /* * BOOTP (bootstrap protocol) server daemon. * @@ -49,6 +45,7 @@ static char rcsid[] = "$Id: bootpd.c,v 1.1.1.1 1994/09/30 05:45:04 pst Exp $"; #include #include #include +#include #include #include @@ -57,6 +54,7 @@ static char rcsid[] = "$Id: bootpd.c,v 1.1.1.1 1994/09/30 05:45:04 pst Exp $"; #ifndef NO_UNISTD #include #endif + #include #include #include @@ -71,11 +69,6 @@ static char rcsid[] = "$Id: bootpd.c,v 1.1.1.1 1994/09/30 05:45:04 pst Exp $"; # include /* for O_RDONLY, etc */ #endif -#ifdef SVR4 -/* Using sigset() avoids the need to re-arm each time. */ -#define signal sigset -#endif - #ifndef USE_BFUNCS # include /* Yes, memcpy is OK here (no overlapped copies). */ @@ -164,9 +157,11 @@ char *pktbuf; /* Receive packet buffer */ int pktlen; char *progname; char *chdir_path; -char hostname[MAXHOSTNAMELEN]; /* System host name */ struct in_addr my_ip_addr; +struct utsname my_uname; +char *hostname; + /* Flags set by signal catcher. */ PRIVATE int do_readtab = 0; PRIVATE int do_dumptab = 0; @@ -198,6 +193,9 @@ main(argc, argv) int n, ba_len, ra_len; int nfound, readfds; int standalone; +#ifdef SA_NOCLDSTOP /* Have POSIX sigaction(2). */ + struct sigaction sa; +#endif progname = strrchr(argv[0], '/'); if (progname) progname++; @@ -255,6 +253,12 @@ main(argc, argv) stmp = NULL; timeout = &actualtimeout; + if (uname(&my_uname) < 0) { + fprintf(stderr, "bootpd: can't get hostname\n"); + exit(1); + } + hostname = my_uname.nodename; + /* * Read switches. */ @@ -315,7 +319,7 @@ main(argc, argv) "bootpd: missing hostname\n"); break; } - strncpy(hostname, stmp, sizeof(hostname)-1); + hostname = stmp; break; case 'i': /* inetd mode */ @@ -369,12 +373,7 @@ main(argc, argv) /* * Get my hostname and IP address. */ - if (hostname[0] == '\0') { - if (gethostname(hostname, sizeof(hostname)) == -1) { - fprintf(stderr, "bootpd: can't get hostname\n"); - exit(1); - } - } + hep = gethostbyname(hostname); if (!hep) { fprintf(stderr, "Can not get my IP address\n"); @@ -481,6 +480,20 @@ main(argc, argv) /* * Set up signals to read or dump the table. */ +#ifdef SA_NOCLDSTOP /* Have POSIX sigaction(2). */ + sa.sa_handler = catcher; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + if (sigaction(SIGHUP, &sa, NULL) < 0) { + report(LOG_ERR, "sigaction: %s", get_errmsg()); + exit(1); + } + if (sigaction(SIGUSR1, &sa, NULL) < 0) { + report(LOG_ERR, "sigaction: %s", get_errmsg()); + exit(1); + } +#else /* SA_NOCLDSTOP */ + /* Old-fashioned UNIX signals */ if ((int) signal(SIGHUP, catcher) < 0) { report(LOG_ERR, "signal: %s", get_errmsg()); exit(1); @@ -489,13 +502,20 @@ main(argc, argv) report(LOG_ERR, "signal: %s", get_errmsg()); exit(1); } +#endif /* SA_NOCLDSTOP */ /* * Process incoming requests. */ for (;;) { + struct timeval tv; + readfds = 1 << s; - nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, timeout); + if (timeout) + tv = *timeout; + + nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, + (timeout) ? &tv : NULL); if (nfound < 0) { if (errno != EINTR) { report(LOG_ERR, "select: %s", get_errmsg()); @@ -532,7 +552,7 @@ main(argc, argv) } if (n < sizeof(struct bootp)) { if (debug) { - report(LOG_INFO, "received short packet"); + report(LOG_NOTICE, "received short packet"); } continue; } @@ -580,9 +600,8 @@ catcher(sig) do_readtab = 1; if (sig == SIGUSR1) do_dumptab = 1; -#ifdef SYSV - /* For older "System V" derivatives with no sigset(). */ - /* XXX - Should just do it the POSIX way (sigaction). */ +#if !defined(SA_NOCLDSTOP) && defined(SYSV) + /* For older "System V" derivatives with no sigaction(). */ signal(sig, catcher); #endif } @@ -676,8 +695,8 @@ HW addr type is IEEE 802. convert to %s and check again\n", /* * XXX - Add dynamic IP address assignment? */ - if (debug > 1) - report(LOG_INFO, "unknown client %s address %s", + if (debug) + report(LOG_NOTICE, "unknown client %s address %s", netname(bp->bp_htype), haddrtoa(bp->bp_chaddr, bp->bp_hlen)); return; /* not found */ @@ -698,7 +717,7 @@ HW addr type is IEEE 802. convert to %s and check again\n", hp = (struct host *) hash_Lookup(iphashtable, hashcode, iplookcmp, &dummyhost); if (hp == NULL) { - if (debug > 1) { + if (debug) { report(LOG_NOTICE, "IP address not found: %s", inet_ntoa(bp->bp_ciaddr)); } @@ -911,7 +930,9 @@ HW addr type is IEEE 802. convert to %s and check again\n", if (debug > 2) report(LOG_INFO, "bootfile=\"%s\"", clntpath); +#ifdef CHECK_FILE_ACCESS null_file_name: +#endif /* CHECK_FILE_ACCESS */ /* @@ -994,7 +1015,7 @@ sendreply(forward, dst_override) struct in_addr dst; u_short port = bootpc_port; unsigned char *ha; - int len; + int len, haf; /* * XXX - Should honor bp_flags "broadcast" bit here. @@ -1033,11 +1054,14 @@ sendreply(forward, dst_override) len = bp->bp_hlen; if (len > MAXHADDRLEN) len = MAXHADDRLEN; + haf = (int) bp->bp_htype; + if (haf == 0) + haf = HTYPE_ETHERNET; if (debug > 1) report(LOG_INFO, "setarp %s - %s", inet_ntoa(dst), haddrtoa(ha, len)); - setarp(s, &dst, ha, len); + setarp(s, &dst, haf, ha, len); } if ((forward == 0) && @@ -1206,7 +1230,6 @@ dovend_rfc1048(bp, hp, bootsize) { int bytesleft, len; byte *vp; - char *tmpstr; static char noroom[] = "%s: No room for \"%s\" option"; diff --git a/libexec/bootpd/getether.c b/libexec/bootpd/getether.c index 724a376..71d576a 100644 --- a/libexec/bootpd/getether.c +++ b/libexec/bootpd/getether.c @@ -11,9 +11,14 @@ #include #include +#ifndef NO_UNISTD +#include +#endif + #include #include +#include "getether.h" #include "report.h" #define EALEN 6 @@ -168,10 +173,12 @@ getether(ifname, eap) #include #include #include +#include #ifndef NULL #define NULL 0 #endif +int getether(ifname, eap) char *ifname; /* interface name from ifconfig structure */ char *eap; /* Ether address (output) */ @@ -308,30 +315,31 @@ getether(ifname, eap) #endif /* SVR4 */ -#ifdef linux +#ifdef __linux__ /* * This is really easy on Linux! This version (for linux) - * written by Nigel Metheringham + * written by Nigel Metheringham and + * updated by Pauline Middelink * * The code is almost identical to the Ultrix code - however * the names are different to confuse the innocent :-) * Most of this code was stolen from the Ultrix bit above. */ +#include #include #include /* struct ifreq */ +#include /* Needed for IOCTL defs */ -/* In a properly configured system this should be either sys/socketio.h - or sys/sockios.h, but on my distribution these don't line up correctly */ -#include /* Needed for IOCTL defs */ - +int getether(ifname, eap) char *ifname, *eap; { int rc = -1; int fd; struct ifreq phys; - bzero(&phys, sizeof(phys)); + + memset(&phys, 0, sizeof(phys)); strcpy(phys.ifr_name, ifname); if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { report(LOG_ERR, "getether: socket(INET,DGRAM) failed"); @@ -340,7 +348,7 @@ getether(ifname, eap) if (ioctl(fd, SIOCGIFHWADDR, &phys) < 0) { report(LOG_ERR, "getether: ioctl SIOCGIFHWADDR failed"); } else { - bcopy(phys.ifr_hwaddr, eap, EALEN); + memcpy(eap, &phys.ifr_hwaddr.sa_data, EALEN); rc = 0; } close(fd); @@ -348,11 +356,12 @@ getether(ifname, eap) } #define GETETHER -#endif /* linux */ +#endif /* __linux__ */ /* If we don't know how on this system, just return an error. */ #ifndef GETETHER +int getether(ifname, eap) char *ifname, *eap; { -- cgit v1.1