File bootp-DD2.4.3.dif of Package bootp-DD2
--- Makefile
+++ Makefile
@@ -13,7 +13,7 @@
OPTDEFS= -DSYSLOG -DVEND_CMU -DDHCP -DDYNAMIC -DDEBUG
# Uncomment and edit this to choose the facility code used for syslog.
-# LOG_FACILITY= "-DLOG_BOOTP=LOG_LOCAL2"
+LOG_FACILITY= "-DLOG_BOOTP=LOG_DAEMON"
# SYStem DEFinitions:
# Either uncomment some of the following, or do:
@@ -39,7 +39,7 @@
INSTALL=/usr/bin/install
DESTDIR=
BINDIR=/usr/sbin
-MANDIR=/usr/local/man
+MANDIR=/usr/share/man
CFLAGS= $(OPTDEFS) $(SYSDEFS) $(FILEDEFS) $(MOREDEFS)
PROGS= bootpd bootpef bootpgw bootptest
@@ -49,15 +49,18 @@
system: install
-install: $(PROGS)
+install: $(PROGS) install.man
+ $(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
-for f in $(PROGS) ;\
do \
- $(INSTALL) -c -s $$f $(DESTDIR)$(BINDIR) ;\
+ $(INSTALL) -c $$f $(DESTDIR)$(BINDIR) ;\
done
MAN5= bootptab.5
MAN8= bootpd.8 bootpef.8 bootptest.8
install.man: $(MAN5) $(MAN8)
+ $(INSTALL) -d -m 755 $(DESTDIR)$(MANDIR)/man5
+ $(INSTALL) -d -m 755 $(DESTDIR)$(MANDIR)/man8
-for f in $(MAN5) ;\
do \
$(INSTALL) -c -m 644 $$f $(DESTDIR)$(MANDIR)/man5 ;\
@@ -102,7 +105,7 @@
# Linux 1.1.80+
linux:
- $(MAKE) SYSDEFS="-O6 -Wall -fomit-frame-pointer" \
+ $(MAKE) SYSDEFS="-Wall $(RPM_OPT_FLAGS) -pipe" \
SYSLIBS="" \
FILEDEFS='-DCONFIG_FILE=\"/etc/bootptab\" \
-DDUMPTAB_FILE=\"/tmp/bootpd.dump\"'
--- bootp.h
+++ bootp.h
@@ -40,21 +40,21 @@
#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */
struct bootp {
- unsigned char bp_op; /* packet opcode type */
- unsigned char bp_htype; /* hardware addr type */
- unsigned char bp_hlen; /* hardware addr length */
- unsigned char bp_hops; /* gateway hops */
- unsigned int32 bp_xid; /* transaction ID */
+ byte bp_op; /* packet opcode type */
+ byte bp_htype; /* hardware addr type */
+ byte bp_hlen; /* hardware addr length */
+ byte bp_hops; /* gateway hops */
+ u_int32_t bp_xid; /* transaction ID */
unsigned short bp_secs; /* seconds since boot began */
unsigned short bp_flags; /* RFC1532 broadcast, etc. */
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
struct in_addr bp_giaddr; /* gateway IP address */
- unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */
+ byte bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */
char bp_sname[BP_SNAME_LEN]; /* server host name */
char bp_file[BP_FILE_LEN]; /* boot file name */
- unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */
+ byte bp_vend[BP_VEND_LEN]; /* vendor-specific area */
/* note that bp_vend can be longer, extending to end of packet. */
};
@@ -95,43 +95,43 @@
* the vendor (options) data area of the packet.
*/
/* RFC 1048 */
-#define TAG_END ((unsigned char) 255)
-#define TAG_PAD ((unsigned char) 0)
-#define TAG_SUBNET_MASK ((unsigned char) 1)
-#define TAG_TIME_OFFSET ((unsigned char) 2)
-#define TAG_GATEWAY ((unsigned char) 3)
-#define TAG_TIME_SERVER ((unsigned char) 4)
-#define TAG_NAME_SERVER ((unsigned char) 5)
-#define TAG_DOMAIN_SERVER ((unsigned char) 6)
-#define TAG_LOG_SERVER ((unsigned char) 7)
-#define TAG_COOKIE_SERVER ((unsigned char) 8)
-#define TAG_LPR_SERVER ((unsigned char) 9)
-#define TAG_IMPRESS_SERVER ((unsigned char) 10)
-#define TAG_RLP_SERVER ((unsigned char) 11)
-#define TAG_HOST_NAME ((unsigned char) 12)
-#define TAG_BOOT_SIZE ((unsigned char) 13)
+#define TAG_END ((byte) 255)
+#define TAG_PAD ((byte) 0)
+#define TAG_SUBNET_MASK ((byte) 1)
+#define TAG_TIME_OFFSET ((byte) 2)
+#define TAG_GATEWAY ((byte) 3)
+#define TAG_TIME_SERVER ((byte) 4)
+#define TAG_NAME_SERVER ((byte) 5)
+#define TAG_DOMAIN_SERVER ((byte) 6)
+#define TAG_LOG_SERVER ((byte) 7)
+#define TAG_COOKIE_SERVER ((byte) 8)
+#define TAG_LPR_SERVER ((byte) 9)
+#define TAG_IMPRESS_SERVER ((byte) 10)
+#define TAG_RLP_SERVER ((byte) 11)
+#define TAG_HOST_NAME ((byte) 12)
+#define TAG_BOOT_SIZE ((byte) 13)
/* RFC 1395 */
-#define TAG_DUMP_FILE ((unsigned char) 14)
-#define TAG_DOMAIN_NAME ((unsigned char) 15)
-#define TAG_SWAP_SERVER ((unsigned char) 16)
-#define TAG_ROOT_PATH ((unsigned char) 17)
+#define TAG_DUMP_FILE ((byte) 14)
+#define TAG_DOMAIN_NAME ((byte) 15)
+#define TAG_SWAP_SERVER ((byte) 16)
+#define TAG_ROOT_PATH ((byte) 17)
/* RFC 1497 */
-#define TAG_EXTEN_FILE ((unsigned char) 18)
+#define TAG_EXTEN_FILE ((byte) 18)
/* RFC 1533 */
-#define TAG_NIS_DOMAIN ((unsigned char) 40)
-#define TAG_NIS_SERVER ((unsigned char) 41)
-#define TAG_NTP_SERVER ((unsigned char) 42)
+#define TAG_NIS_DOMAIN ((byte) 40)
+#define TAG_NIS_SERVER ((byte) 41)
+#define TAG_NTP_SERVER ((byte) 42)
/* Added for auto/dynamic IP addressing */
-#define TAG_DYNAMIC_OPTIONS ((unsigned char) 250)
-#define TAG_DYNAMIC_FORCE ((unsigned char) 253)
-#define TAG_DYNAMIC_SIZE ((unsigned char) 254)
+#define TAG_DYNAMIC_OPTIONS ((byte) 250)
+#define TAG_DYNAMIC_FORCE ((byte) 253)
+#define TAG_DYNAMIC_SIZE ((byte) 254)
/* DHCP maximum message size. */
-#define TAG_DHCP_IPLEASE ((unsigned char) 51)
-#define TAG_DHCP_MSG ((unsigned char) 53)
-#define TAG_DHCP_SERVERID ((unsigned char) 54)
-#define TAG_MAX_MSGSZ ((unsigned char) 57)
-#define TAG_DHCP_IPRENEW ((unsigned char) 58) /* PeP hic facet */
-#define TAG_DHCP_IPREBIND ((unsigned char) 59)
+#define TAG_DHCP_IPLEASE ((byte) 51)
+#define TAG_DHCP_MSG ((byte) 53)
+#define TAG_DHCP_SERVERID ((byte) 54)
+#define TAG_MAX_MSGSZ ((byte) 57)
+#define TAG_DHCP_IPRENEW ((byte) 58) /* PeP hic facet */
+#define TAG_DHCP_IPREBIND ((byte) 59)
/* XXX - Add new tags here */
@@ -141,13 +141,13 @@
struct cmu_vend {
char v_magic[4]; /* magic number */
- unsigned int32 v_flags; /* flags/opcodes, etc. */
+ u_int32_t v_flags; /* flags/opcodes, etc. */
struct in_addr v_smask; /* Subnet mask */
struct in_addr v_dgate; /* Default gateway */
struct in_addr v_dns1, v_dns2; /* Domain name servers */
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
struct in_addr v_ts1, v_ts2; /* Time servers */
- int32 v_unused[6]; /* currently unused */
+ int32_t v_unused[6]; /* currently unused */
};
--- bootpd.c
+++ bootpd.c
@@ -79,8 +79,10 @@
#ifdef __linux__
/* Use sigaction to make signal last... */
inline void (*signal(int sig,void (*handler)(int)))(int) {
- struct sigaction so,sa = {NULL,0,SA_NOMASK|SA_RESTART,NULL};
+ struct sigaction so,sa;
sa.sa_handler = handler;
+ sa.sa_flags = SA_NOMASK|SA_RESTART;
+ sigemptyset(&sa.sa_mask);
if (sigaction(sig,&sa,&so)<0) return NULL;
return so.sa_handler;
}
@@ -879,6 +881,8 @@
int i_got_dynamic=0;
#endif /* DYNAMIC */
+ bp->bp_file[127] = '\0';
+
/* XXX - SLIP init: Set bp_ciaddr = recv_addr here? */
/*
@@ -1010,11 +1014,12 @@
*/
/* Run a program, passing the client name as a parameter. */
if (hp->flags.exec_file) {
- char tst[100];
+ char tst[512];
+ memset(tst,0, sizeof(tst));
/* XXX - Check string lengths? -gwr */
- strcpy (tst, hp->exec_file->string);
+ strncpy (tst, hp->exec_file->string, sizeof(tst)-250);
strcat (tst, " ");
- strcat (tst, hp->hostname->string);
+ strncat (tst, hp->hostname->string, sizeof(tst)-strlen(tst)-5);
strcat (tst, " &");
if (debug)
report(LOG_INFO, "executing %s", tst);
@@ -1630,10 +1635,10 @@
return 0; /* Not mine, discard! */
switch (dhcp) {
- case 1 : len = dhcp_discover(bp,hp,vp,bytesleft-1); break;
- case 3 : len = dhcp_request(bp,hp,vp,bytesleft-1); break;
- case 4 : len = dhcp_decline(bp,hp,vp,bytesleft-1); break;
- case 7 : len = dhcp_release(bp,hp,vp,bytesleft-1); break;
+ case 1 : len = dhcp_discover(bp,hp,vp,bytesleft); break;
+ case 3 : len = dhcp_request(bp,hp,vp,bytesleft); break;
+ case 4 : len = dhcp_decline(bp,hp,vp,bytesleft); break;
+ case 7 : len = dhcp_release(bp,hp,vp,bytesleft); break;
default : report(LOG_NOTICE,"Unknown DHCP request (%d)",dhcp);
return 0;
}
@@ -1650,7 +1655,7 @@
* function (which is shared with bootpef.c).
* Keep back one byte for the TAG_END.
*/
- len = dovend_rfc1497(hp, vp, bytesleft - 1);
+ len = dovend_rfc1497(hp, vp, bytesleft);
vp += len;
bytesleft -= len;
#ifdef DHCP
@@ -1769,7 +1774,8 @@
*vp++ = 2; /* DHCPOFFER */
len += 3;
- len += dhcp_lease(bp,hp,&vp);
+ if (hp->dhcp_lease)
+ len += dhcp_lease(bp,hp,&vp);
*vp++ = TAG_DHCP_SERVERID;
*vp++ = 4;
@@ -1829,7 +1835,8 @@
*vp++ = 5;
len += 3;
- len += dhcp_lease(bp,hp,&vp);
+ if (hp->dhcp_lease)
+ len += dhcp_lease(bp,hp,&vp);
*vp++ = TAG_DHCP_SERVERID; /* Server id */
*vp++ = 4;
--- bootpd.h
+++ bootpd.h
@@ -183,12 +183,12 @@
htype, /* RFC826 says this should be 16-bits but
RFC951 only allocates 1 byte. . . */
haddr[MAXHADDRLEN];
- int32 time_offset;
- unsigned int32 bootsize,
+ int32_t time_offset;
+ u_int32_t bootsize,
msg_size,
min_wait;
#ifdef DHCP
- unsigned int32 dhcp_lease; /* PeP hic facet */
+ u_int32_t dhcp_lease; /* PeP hic facet */
#endif
struct in_addr bootserver,
iaddr,
@@ -214,4 +214,3 @@
extern hash_tbl *hwhashtable;
extern hash_tbl *iphashtable;
extern hash_tbl *nmhashtable;
-
--- bptypes.h
+++ bptypes.h
@@ -3,14 +3,14 @@
#ifndef BPTYPES_H
#define BPTYPES_H
+#include <stdint.h>
+
/*
* 32 bit integers are different types on various architectures
*/
-#ifndef int32
-#define int32 long
-#endif
-typedef unsigned int32 u_int32;
+typedef int32_t int32;
+typedef u_int32_t u_int32;
/*
* Nice typedefs. . .
--- dovend.c
+++ dovend.c
@@ -151,7 +151,7 @@
if (insert_ip(TAG_NIS_SERVER,
hp->nis_server,
&vp, &bytesleft))
- NEED(8, "ds");
+ NEED(8, "ys");
}
if (hp->flags.nis_domain) {
/*
@@ -159,7 +159,7 @@
* TAG_NIS_DOMAIN and length.
*/
len = strlen(hp->nis_domain->string);
- NEED((len + 2), "dn");
+ NEED((len + 2), "yd");
*vp++ = TAG_NIS_DOMAIN;
*vp++ = (byte) (len & 0xFF);
bcopy(hp->nis_domain->string, vp, len);
@@ -191,7 +191,7 @@
if (insert_ip(TAG_NTP_SERVER,
hp->ntp_server,
&vp, &bytesleft))
- NEED(8, "ts");
+ NEED(8, "nt");
}
/*
* I wonder: If the hostname were "promoted" into the BOOTP
--- dumptab.c
+++ dumptab.c
@@ -5,6 +5,10 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h> /* inet_ntoa */
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include <stdio.h>
#include <stdlib.h>
@@ -57,6 +61,7 @@
char *filename;
{
int n;
+ int fd;
struct host *hp;
FILE *fp;
long t;
@@ -103,7 +108,15 @@
/*
* Open bootpd.dump file.
*/
- if ((fp = fopen(filename, "w")) == NULL) {
+ unlink(filename);
+ if ((fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
+ report(LOG_ERR, "error opening \"%s\": %s",
+ filename, get_errmsg());
+ exit(1);
+
+ }
+
+ if ((fp = fdopen(fd, "w")) == NULL) {
report(LOG_ERR, "error opening \"%s\": %s",
filename, get_errmsg());
exit(1);
@@ -150,7 +163,7 @@
if (hp->flags.bootsize_auto) {
fprintf(fp, "auto:");
} else {
- fprintf(fp, "%d:", hp->bootsize);
+ fprintf(fp, "%ld:", hp->bootsize);
}
}
if (hp->flags.cookie_server) {
@@ -218,10 +231,10 @@
fprintf(fp, ":");
}
if (hp->flags.msg_size) {
- fprintf(fp, "\\\n\t:ms=%d:", hp->msg_size);
+ fprintf(fp, "\\\n\t:ms=%ld:", hp->msg_size);
}
if (hp->flags.min_wait) {
- fprintf(fp, "\\\n\t:mw=%d:", hp->min_wait);
+ fprintf(fp, "\\\n\t:mw=%ld:", hp->min_wait);
}
if (hp->flags.name_server) {
fprintf(fp, "\\\n\t:ns=");
--- getether.c
+++ getether.c
@@ -329,7 +329,9 @@
#include <memory.h>
#include <sys/ioctl.h>
#include <net/if.h> /* struct ifreq */
+#if !defined(__GLIBC__)
#include <sys/socketio.h> /* Needed for IOCTL defs */
+#endif
int
getether(ifname, eap)
--- hwaddr.c
+++ hwaddr.c
@@ -22,6 +22,11 @@
#include <net/if.h> /* for struct ifnet in net/if_arp.h */
#endif
+#if defined __GLIBC__ && __GLIBC__ >= 2
+#else
+#include <linux/netdevice.h>
+#endif
+
#include <net/if_arp.h>
#include <netinet/in.h>
@@ -117,7 +122,7 @@
char *p;
bzero((caddr_t) &arpreq, sizeof(arpreq));
- arpreq.arp_flags = ATF_INUSE | ATF_COM;
+ arpreq.arp_flags = ATF_COM;
/* Set up the protocol address. */
arpreq.arp_pa.sa_family = AF_INET;
--- print-bootp.c
+++ print-bootp.c
@@ -120,7 +120,7 @@
printf(" hops:%d", bp->bp_hops);
if (bp->bp_xid)
- printf(" xid:%d", ntohl(bp->bp_xid));
+ printf(" xid:%ld", ntohl(bp->bp_xid));
if (bp->bp_secs)
printf(" secs:%d", ntohs(bp->bp_secs));
@@ -341,7 +341,7 @@
case 'l': /* Long words */
while (len >= 4) {
bcopy((char *) bp, (char *) &ul, 4);
- printf("%d", ntohl(ul));
+ printf("%ld", ntohl(ul));
bp += 4;
len -= 4;
if (len) printf(",");
--- report.c
+++ report.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <syslog.h>
+#include <errno.h>
#include "report.h"
@@ -101,7 +102,7 @@
#endif
{
va_list ap;
- static char buf[128];
+ static char buf[256];
if ((priority < 0) || (priority >= numlevels)) {
priority = numlevels - 1;
@@ -111,7 +112,7 @@
#else
va_start(ap);
#endif
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof (buf), fmt, ap);
va_end(ap);
/*
--- tzone.c
+++ tzone.c
@@ -14,12 +14,12 @@
# include <syslog.h>
#endif /* SVR4 */
-#include "bptypes.h"
+#include <stdint.h>
#include "report.h"
#include "tzone.h"
/* This is what other modules use. */
-int32 secondswest;
+int32_t secondswest;
/*
* Get our timezone offset so we can give it to clients if the
--- tzone.h
+++ tzone.h
@@ -1,3 +1,3 @@
/* tzone.h */
-extern int32 secondswest;
+extern int32_t secondswest;
extern void tzone_init();