From: cvs2git Date: Sat, 6 Dec 1997 04:04:51 +0000 (+0000) Subject: This commit was manufactured by cvs2git to create branch 'RELEASE_2'. X-Git-Tag: V2-BETA-1~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b59ca1aa76d5eaae306c61330716757f453b524;p=thirdparty%2Fdhcp.git This commit was manufactured by cvs2git to create branch 'RELEASE_2'. --- diff --git a/common/dns.c b/common/dns.c deleted file mode 100644 index cc98e005a..000000000 --- a/common/dns.c +++ /dev/null @@ -1,403 +0,0 @@ -/* dns.c - - Domain Name Service subroutines. */ - -/* - * Copyright (C) 1992 by Ted Lemon. - * Copyright (c) 1997 The Internet Software Consortium. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of The Internet Software Consortium nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is based on software written in 1992 by Ted Lemon for - * a portable network boot loader. That original code base has been - * substantially modified for use in the Internet Software Consortium - * DHCP suite. - * - * These later modifications were done on behalf of the Internet - * Software Consortium by Ted Lemon in cooperation - * with Vixie Enterprises. To learn more about the Internet Software - * Consortium, see ``http://www.vix.com/isc''. To learn more about - * Vixie Enterprises, see ``http://www.vix.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: dns.c,v 1.5 1997/11/29 07:51:49 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include "arpa/nameser.h" - -int dns_protocol_initialized; -int dns_protocol_fd; - -static int addlabel PROTO ((u_int8_t *, char *)); -static int skipname PROTO ((u_int8_t *)); -static int copy_out_name PROTO ((u_int8_t *, u_int8_t *, char *)); -static int nslookup PROTO ((u_int8_t, char *, int, u_int16_t, u_int16_t)); -static int zonelookup PROTO ((u_int8_t, char *, int, u_int16_t)); -u_int16_t dns_port; - -/* Initialize the DNS protocol. */ - -void dns_startup () -{ - struct servent *srv; - struct sockaddr_in from; - - /* Only initialize icmp once. */ - if (dns_protocol_initialized) - error ("attempted to reinitialize dns protocol"); - dns_protocol_initialized = 1; - - /* Get the protocol number (should be 1). */ - srv = getservbyname ("domain", "tcp"); - if (srv) - dns_port = srv -> s_port; - else - dns_port = htons (53); - - /* Get a socket for the DNS protocol. */ - dns_protocol_fd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (dns_protocol_fd < 0) - error ("unable to create dns socket: %m"); - - pick_name_server (); - - add_protocol ("dns", dns_protocol_fd, dns_packet, 0); -} - -/* Label manipulation stuff; see RFC1035, page 28 section 4.1.2 and - page 30, section 4.1.4. */ - -/* addlabel copies a label into the specified buffer, putting the length of - the label in the first character, the contents of the label in subsequent - characters, and returning the length of the conglomeration. */ - -static int addlabel (buf, label) - u_int8_t *buf; - char *label; -{ - *buf = strlen (label); - memcpy (buf + 1, label, *buf); - return *buf + 1; -} - -/* skipname skips over all of the labels in a single domain name, - returning the length of the domain name. */ - -static int skipname (label) - u_int8_t *label; -{ - if (*label & INDIR_MASK) - return 2; - if (*label == 0) - return 1; - return *label + 1 + skipname (label + *label + 1); -} - -/* copy_out_name copies out the name appearing at the specified location - into a string, stored as fields seperated by dots rather than lengths - and labels. The length of the label-formatted name is returned. */ - -static int copy_out_name (base, name, buf) - u_int8_t *base; - u_int8_t *name; - char *buf; -{ - if (*name & INDIR_MASK) { - int offset = (*name & ~INDIR_MASK) + (*name + 1); - return copy_out_name (base, base + offset, buf); - } - if (!*name) { - *buf = 0; - return 1; - } - memcpy (buf, name + 1, *name); - *(buf + *name) = '.'; - return (*name + 1 - + copy_out_name (base, name + *name + 1, buf + *name + 1)); -} - -/* ns_inaddr_lookup constructs a PTR lookup query for an internet address - - e.g., 1.200.9.192.in-addr.arpa. If the specified timeout period passes - before the query is satisfied, or if the query fails, the callback is - called with a null pointer. Otherwise, the callback is called with the - address of the string returned by the name server. */ - -int ns_inaddr_lookup (id, inaddr) - u_int16_t id; - struct iaddr inaddr; -{ - unsigned char namebuf [512]; - unsigned char *s = namebuf; - unsigned char *label; - int i; - unsigned char c; - - for (i = 3; i >= 0; --i) { - label = s++; - *label = 1; - c = inaddr.iabuf [i]; - if (c > 100) { - ++*label; - *s++ = '0' + c / 100; - } - if (c > 10) { - ++*label; - *s++ = '0' + ((c / 10) % 10); - } - *s++ = '0' + (c % 10); - } - s += addlabel (s, "in-addr"); - s += addlabel (s, "arpa"); - *s++ = 0; -/* return nslookup (id, namebuf, s - namebuf, T_PTR, C_IN); */ - return zonelookup (id, namebuf, s - namebuf, C_IN); -} - -/* Construct and transmit a name server query. */ - -static int nslookup (id, qname, namelen, qtype, qclass) - u_int8_t id; - char *qname; - int namelen; - u_int16_t qtype; - u_int16_t qclass; -{ - HEADER *hdr; - unsigned char query [512]; - u_int8_t *s; - int len; - int i, status; - struct sockaddr_in *server = pick_name_server (); - - if (!server) - return 0; - - /* Construct a header... */ - hdr = (HEADER *)query; - memset (hdr, 0, sizeof *hdr); - hdr -> id = htons (id); - hdr -> rd = 1; - hdr -> opcode = QUERY; - hdr -> qdcount = htons (1); - - /* Copy in the name we're looking up. */ - s = (u_int8_t *)(hdr + 1); - memcpy (s, qname, namelen); - s += namelen; - - /* Set the query type. */ - putUShort (s, qtype); - s += sizeof (u_int16_t); - - /* Set the query class. */ - putUShort (s, qclass); - s += sizeof (u_int16_t); - - /* Send the query. */ - status = sendto (dns_protocol_fd, query, s - query, 0, - (struct sockaddr *)server, sizeof *server); - - /* If the send failed, report the failure. */ - if (status < 0) - return 0; - return 1; -} - -/* Construct a query for the SOA for a specified name. - Try every possible SOA name starting from the name specified and going - to the root name - e.g., for - - 215.5.5.192.in-addr.arpa, look for SOAs matching: - - 215.5.5.5.192.in-addr.arpa - 5.5.192.in-addr.arpa - 5.192.in-addr.arpa - 192.in-addr.arpa - in-addr.arpa - arpa */ - -static int zonelookup (id, qname, namelen, qclass) - u_int8_t id; - char *qname; - int namelen; - u_int16_t qclass; -{ - HEADER *hdr; - unsigned char query [512]; - u_int8_t *s, *nptr; - int len; - int i, status, count; - struct sockaddr_in *server = pick_name_server (); - - if (!server) - return 0; - - /* Construct a header... */ - hdr = (HEADER *)query; - memset (hdr, 0, sizeof *hdr); - hdr -> id = htons (id); - hdr -> rd = 1; - hdr -> opcode = QUERY; - - /* Copy in the name we're looking up. */ - s = (u_int8_t *)(hdr + 1); - memcpy (s, qname, namelen); - s += namelen; - - /* Set the query type. */ - putUShort (s, T_SOA); - s += sizeof (u_int16_t); - - /* Set the query class. */ - putUShort (s, qclass); - s += sizeof (u_int16_t); - count = 1; - - /* Now query up the hierarchy. */ - nptr = (u_int8_t *)(hdr + 1); - while (*(nptr += *nptr + 1)) { - /* Store a compressed reference from the full name. */ - putUShort (s, ntohs (htons (0xC000) | - htons (nptr - &query [0]))); - s += sizeof (u_int16_t); - - /* Store the query type. */ - putUShort (s, T_SOA); - s += sizeof (u_int16_t); - - putUShort (s, qclass); - s += sizeof (u_int16_t); - - /* Increment the query count... */ - ++count; -break; - } - hdr -> qdcount = htons (count); - -dump_raw (query, s - query); - /* Send the query. */ - status = sendto (dns_protocol_fd, query, s - query, 0, - (struct sockaddr *)server, sizeof *server); - - /* If the send failed, report the failure. */ - if (status < 0) - return 0; - return 1; -} - -/* Process a reply from a name server. */ - -void dns_packet (protocol) - struct protocol *protocol; -{ - HEADER *ns_header; - struct sockaddr_in from; - int fl; - unsigned char buf [4096]; - unsigned char nbuf [512]; - unsigned char *base; - unsigned char *dptr; - u_int16_t type; - u_int16_t class; - TIME ttl; - u_int16_t rdlength; - int len, status; - int i; - - len = sizeof from; - status = recvfrom (protocol -> fd, buf, sizeof buf, 0, - (struct sockaddr *)&from, &len); - if (status < 0) { - warn ("icmp_echoreply: %m"); - return; - } - - ns_header = (HEADER *)buf; - base = (unsigned char *)(ns_header + 1); - -#if 0 - /* Ignore invalid packets... */ - if (ntohs (ns_header -> id) > ns_query_max) { - printf ("Out-of-range NS message; id = %d\n", - ntohs (ns_header -> id)); - return; - } -#endif - - /* Parse the response... */ - dptr = base; - - /* Skip over the queries... */ - for (i = 0; i < ntohs (ns_header -> qdcount); i++) { - dptr += skipname (dptr); - /* Skip over the query type and query class. */ - dptr += 2 * sizeof (u_int16_t); - } - - /* Process the answers... */ - for (i = 0; i < ntohs (ns_header -> ancount); i++) { - /* Skip over the name we looked up. */ - dptr += skipname (dptr); - - /* Get the type. */ - type = getUShort (dptr); - dptr += sizeof type; - - /* Get the class. */ - class = getUShort (dptr); - dptr += sizeof class; - - /* Get the time-to-live. */ - ttl = getULong (dptr); - dptr += sizeof ttl; - - /* Get the length of the reply. */ - rdlength = getUShort (dptr); - dptr += sizeof rdlength; - - switch (type) { - case T_A: - note ("A record; value is %d.%d.%d.%d", - dptr [0], dptr [1], dptr [2], dptr [3]); - break; - - case T_CNAME: - case T_PTR: - copy_out_name (base, dptr, nbuf); - note ("Domain name; value is %s\n", nbuf); - return; - - default: - note ("unhandled type: %x", type); - } - } -} diff --git a/common/resolv.c b/common/resolv.c deleted file mode 100644 index d495e517d..000000000 --- a/common/resolv.c +++ /dev/null @@ -1,207 +0,0 @@ -/* resolv.c - - Parser for /etc/resolv.conf file. */ - -/* - * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of The Internet Software Consortium nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This software has been written for the Internet Software Consortium - * by Ted Lemon in cooperation with Vixie - * Enterprises. To learn more about the Internet Software Consortium, - * see ``http://www.vix.com/isc''. To learn more about Vixie - * Enterprises, see ``http://www.vix.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: resolv.c,v 1.5 1997/12/06 04:04:07 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" -#include "dhctoken.h" - -struct name_server *name_servers; -struct domain_search_list *domains; -char path_resolv_conf [] = _PATH_RESOLV_CONF; - -void read_resolv_conf (parse_time) - TIME parse_time; -{ - FILE *cfile; - char *val; - int token; - int declaration = 0; - struct name_server *sp, *sl, *ns; - struct domain_search_list *dp, *dl, *nd; - struct iaddr *iaddr; - - new_parse (path_resolv_conf); - - eol_token = 1; - if ((cfile = fopen (path_resolv_conf, "r")) == NULL) { - warn ("Can't open %s: %m", path_resolv_conf); - return; - } - - do { - token = next_token (&val, cfile); - if (token == EOF) - break; - else if (token == EOL) - continue; - else if (token == DOMAIN || token == SEARCH) { - do { - struct domain_search_list *nd, **dp; - char *dn; - - dn = parse_host_name (cfile); - if (!dn) - break; - - dp = &domains; - for (nd = domains; nd; nd = nd -> next) { - dp = &nd -> next; - if (!strcmp (nd -> domain, dn)) - break; - } - if (!nd) { - nd = new_domain_search_list - ("read_resolv_conf"); - if (!nd) - error ("No memory for %s", dn); - nd -> next = - (struct domain_search_list *)0; - *dp = nd; - nd -> domain = dn; - dn = (char *)0; - } - nd -> rcdate = parse_time; - token = peek_token (&val, cfile); - } while (token != EOL); - if (token != EOL) { - parse_warn ("junk after domain declaration"); - skip_to_semi (cfile); - } - token = next_token (&val, cfile); - } else if (token == NAMESERVER) { - struct name_server *ns, **sp; - struct iaddr iaddr; - - parse_ip_addr (cfile, &iaddr); - - sp = &name_servers; - for (ns = name_servers; ns; ns = ns -> next) { - sp = &ns -> next; - if (!memcmp (&ns -> addr.sin_addr, - iaddr.iabuf, iaddr.len)) - break; - } - if (!ns) { - ns = new_name_server ("read_resolv_conf"); - if (!ns) - error ("No memory for nameserver %s", - piaddr (iaddr)); - ns -> next = (struct name_server *)0; - *sp = ns; - memcpy (&ns -> addr.sin_addr, - iaddr.iabuf, iaddr.len); -#ifdef HAVE_SA_LEN - ns -> addr.sin_len = sizeof ns -> addr; -#endif - ns -> addr.sin_family = AF_INET; - ns -> addr.sin_port = htons (53); - memset (ns -> addr.sin_zero, 0, - sizeof ns -> addr.sin_zero); - } - ns -> rcdate = parse_time; - skip_to_semi (cfile); - } else - skip_to_semi (cfile); /* Ignore what we don't grok. */ - } while (1); - token = next_token (&val, cfile); /* Clear the peek buffer */ - - /* Lose servers that are no longer in /etc/resolv.conf. */ - sl = (struct name_server *)0; - for (sp = name_servers; sp; sp = ns) { - ns = sp -> next; - if (sp -> rcdate != parse_time) { - if (sl) - sl -> next = sp -> next; - else - name_servers = sp -> next; - free_name_server (sp, "pick_name_server"); - } else - sl = sp; - } - - /* Lose domains that are no longer in /etc/resolv.conf. */ - dl = (struct domain_search_list *)0; - for (dp = domains; dp; dp = nd) { - nd = dp -> next; - if (dp -> rcdate != parse_time) { - if (dl) - dl -> next = dp -> next; - else - domains = dp -> next; - free_domain_search_list (dp, "pick_name_server"); - } else - dl = dp; - } - eol_token = 0; -} - -/* Pick a name server from the /etc/resolv.conf file. */ - -struct sockaddr_in *pick_name_server () -{ - FILE *rc; - static TIME rcdate; - struct stat st; - - /* Check /etc/resolv.conf and reload it if it's changed. */ - if (cur_time > rcdate) { - if (stat (path_resolv_conf, &st) < 0) { - warn ("Can't stat %s", path_resolv_conf); - return (struct sockaddr_in *)0; - } - if (st.st_mtime > rcdate) { - char rcbuf [512]; - char *s, *t, *u; - rcdate = cur_time + 1; - - read_resolv_conf (rcdate); - } - } - - if (name_servers) - return &name_servers -> addr; - return (struct sockaddr_in *)0; -} diff --git a/common/sysconf.c b/common/sysconf.c deleted file mode 100644 index f2a800475..000000000 --- a/common/sysconf.c +++ /dev/null @@ -1,138 +0,0 @@ -/* sysconf.c - - System status watcher... - - !!!Boy, howdy, is this ever not guaranteed not to change!!! */ - -/* - * Copyright (c) 1997 The Internet Software Consortium. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of The Internet Software Consortium nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This software has been written for the Internet Software Consortium - * by Ted Lemon in cooperation with Vixie - * Enterprises. To learn more about the Internet Software Consortium, - * see ``http://www.vix.com/isc''. To learn more about Vixie - * Enterprises, see ``http://www.vix.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: sysconf.c,v 1.3 1997/11/29 07:52:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -int sysconf_initialized; -int sysconf_fd; - -void sysconf_startup (handler) - void (*handler) PROTO ((struct sysconf_header *, void *)); -{ - struct sockaddr_un name; - static int once; - int len; - - /* Only initialize sysconf once. */ - if (sysconf_initialized) - error ("attempted to reinitialize sysconf protocol"); - sysconf_initialized = 1; - - sysconf_fd = socket (AF_UNIX, SOCK_STREAM, 0); - if (sysconf_fd < 0) - error ("unable to create sysconf socket: %m"); - - /* XXX for now... */ - name.sun_family = PF_UNIX; - strcpy (name.sun_path, "/var/run/sysconf"); -#if defined (HAVE_SA_LEN) - name.sun_len = -#endif - len = ((sizeof name) - (sizeof name.sun_path) + - strlen (name.sun_path)); - - if (connect (sysconf_fd, (struct sockaddr *)&name, len) < 0) { - if (!once) - warn ("can't connect to sysconf socket: %m"); - once = 1; - close (sysconf_fd); - sysconf_initialized = 0; - add_timeout (cur_time + 60, sysconf_restart, handler); - } else - add_protocol ("sysconf", sysconf_fd, sysconf_message, handler); -} - -void sysconf_restart (v) - void *v; -{ - void (*handler) PROTO ((struct sysconf_header *, void *)) = v; - - sysconf_startup (handler); -} - -void sysconf_message (proto) - struct protocol *proto; -{ - struct sysconf_header hdr; - int status; - char *buf; - void (*handler) PROTO ((struct sysconf_header *, void *)); - - status = read (sysconf_fd, &hdr, sizeof hdr); - if (status < 0) { - warn ("sysconf_message: %m"); - lose: - add_timeout (cur_time + 60, sysconf_restart, proto -> local); - remove_protocol (proto); - return; - } - if (status < sizeof (hdr)) { - warn ("sysconf_message: short message"); - goto lose; - } - - if (hdr.length) { - buf = malloc (hdr.length); - if (!buf) - error ("sysconf_message: can't buffer payload"); - status = read (sysconf_fd, buf, hdr.length); - if (status < 0) - error ("sysconf_message payload read: %m"); - if (status != hdr.length) - error ("sysconf_message payload: short read"); - } else - buf = (char *)0; - - /* Call the handler... */ - if ((handler = proto -> local)) - (*handler) (&hdr, buf); - - if (buf) - free (buf); -} diff --git a/statmsg/Makefile.dist b/statmsg/Makefile.dist deleted file mode 100644 index 8a2498fa1..000000000 --- a/statmsg/Makefile.dist +++ /dev/null @@ -1,77 +0,0 @@ -# Makefile.dist -# -# Copyright (c) 1997 The Internet Software Consortium. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of The Internet Software Consortium nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND -# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# - -CATMANPAGES = -SRCS = main.c -OBJS = main.o -PROG = statmsg -MAN = - -DEBUG = -g -INCLUDES = -I.. -I../includes -DHCPLIB = ../common/libdhcp.a -CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) - -all: $(PROG) $(CATMANPAGES) - -install: $(PROG) $(CATMANPAGES) - $(INSTALL) statmsg $(BINDIR) - $(CHMOD) 755 $(BINDIR)/statmsg - if [ ! -d $(ADMMANDIR) ]; then \ - mkdir $(ADMMANDIR); \ - chmod 755 $(ADMMANDIR); \ - fi -# $(MANINSTALL) $(MANFROM) statmsg.cat8 $(MANTO) \ -# $(ADMMANDIR)/statmsg$(ADMMANEXT) - -clean: - -rm -f $(OBJS) - -realclean: clean - -rm -f $(PROG) $(CATMANPAGES) *~ #* - -distclean: realclean - -rm -f Makefile - -# These should only be done on 4.4 BSD-based systems, since the mandoc -# macros aren't available on older unices. Catted man pages are -# provided in the distribution so that this doesn't become a problem. - -statmsg.cat8: statmsg.8 - sed -e "s#ETCDIR#$(ETC)#" -e "s#DBDIR#$(VARDB)#" \ - -e "s#RUNDIR#$(VARRUN)#" < statmsg.8 \ - | nroff -man >statmsg.cat8 - -$(PROG): $(OBJS) $(DHCPLIB) - $(CC) $(LFLAGS) -o $(PROG) $(OBJS) $(DHCPLIB) $(LIBS) - -# Dependencies (semi-automatically-generated) diff --git a/statmsg/main.c b/statmsg/main.c deleted file mode 100644 index 924b9cea5..000000000 --- a/statmsg/main.c +++ /dev/null @@ -1,122 +0,0 @@ -/* main.c - - System status updater... - - !!!Boy, howdy, is this ever not guaranteed not to change!!! */ - -/* - * Copyright (c) 1997 The Internet Software Consortium. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of The Internet Software Consortium nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This software has been written for the Internet Software Consortium - * by Ted Lemon in cooperation with Vixie - * Enterprises. To learn more about the Internet Software Consortium, - * see ``http://www.vix.com/isc''. To learn more about Vixie - * Enterprises, see ``http://www.vix.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: main.c,v 1.3 1997/11/29 07:48:37 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -int log_priority; -int log_perror = 1; - -int main (argc, argv, envp) - int argc; - char **argv; - char **envp; -{ - struct sockaddr_un name; - int sysconf_fd; - struct sysconf_header hdr; - int status; - char *buf; - int len; - -#ifdef SYSLOG_4_2 - openlog ("statmsg", LOG_NDELAY); - log_priority = LOG_DAEMON; -#else - openlog ("statmsg", LOG_NDELAY, LOG_DAEMON); -#endif - -#if !(defined (DEBUG) || defined (SYSLOG_4_2) || defined (__CYGWIN32__)) - setlogmask (LOG_UPTO (LOG_INFO)); -#endif - - if (argc < 2) - error ("usage: statmsg type [data]"); - - hdr.length = 0; - if (!strcmp (argv [1], "network-location-changed")) - hdr.type = NETWORK_LOCATION_CHANGED; - else - error ("unknown status message type %s", argv [1]); - - sysconf_fd = socket (AF_UNIX, SOCK_STREAM, 0); - if (sysconf_fd < 0) - error ("unable to create sysconf socket: %m"); - - /* XXX for now... */ - name.sun_family = PF_UNIX; - strcpy (name.sun_path, "/var/run/sysconf"); -#if defined (HAVE_SA_LEN) - name.sun_len = -#endif - len = ((sizeof name) - (sizeof name.sun_path) + - strlen (name.sun_path)); - - if (connect (sysconf_fd, (struct sockaddr *)&name, len) < 0) - error ("can't connect to sysconf socket: %m"); - - status = write (sysconf_fd, &hdr, sizeof hdr); - if (status < 0) - error ("sysconf: %m"); - if (status < sizeof (hdr)) - error ("sysconf: short write"); - - if (hdr.length) { - status = write (sysconf_fd, buf, hdr.length); - if (status < 0) - error ("sysconf payload write: %m"); - if (status != hdr.length) - error ("sysconf payload: short write"); - } - - exit (0); -} - -void cleanup () -{ -} diff --git a/sysconfd/Makefile.dist b/sysconfd/Makefile.dist deleted file mode 100644 index 169e8ed9e..000000000 --- a/sysconfd/Makefile.dist +++ /dev/null @@ -1,77 +0,0 @@ -# Makefile.dist -# -# Copyright (c) 1997 The Internet Software Consortium. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of The Internet Software Consortium nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND -# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# - -CATMANPAGES = -SRCS = sysconfd.c -OBJS = sysconfd.o -PROG = sysconfd -MAN = - -DEBUG = -g -INCLUDES = -I.. -I../includes -DHCPLIB = ../common/libdhcp.a -CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) - -all: $(PROG) $(CATMANPAGES) - -install: $(PROG) $(CATMANPAGES) - $(INSTALL) sysconfd $(BINDIR) - $(CHMOD) 755 $(BINDIR)/sysconfd - if [ ! -d $(ADMMANDIR) ]; then \ - mkdir $(ADMMANDIR); \ - chmod 755 $(ADMMANDIR); \ - fi -# $(MANINSTALL) $(MANFROM) sysconfd.cat8 $(MANTO) \ -# $(ADMMANDIR)/sysconfd$(ADMMANEXT) - -clean: - -rm -f $(OBJS) - -realclean: clean - -rm -f $(PROG) $(CATMANPAGES) *~ #* - -distclean: realclean - -rm -f Makefile - -# These should only be done on 4.4 BSD-based systems, since the mandoc -# macros aren't available on older unices. Catted man pages are -# provided in the distribution so that this doesn't become a problem. - -sysconfd.cat8: sysconfd.8 - sed -e "s#ETCDIR#$(ETC)#" -e "s#DBDIR#$(VARDB)#" \ - -e "s#RUNDIR#$(VARRUN)#" < sysconfd.8 \ - | nroff -man >sysconfd.cat8 - -$(PROG): $(OBJS) $(DHCPLIB) - $(CC) $(LFLAGS) -o $(PROG) $(OBJS) $(DHCPLIB) $(LIBS) - -# Dependencies (semi-automatically-generated) diff --git a/sysconfd/sysconfd.c b/sysconfd/sysconfd.c deleted file mode 100644 index 399b2fe83..000000000 --- a/sysconfd/sysconfd.c +++ /dev/null @@ -1,262 +0,0 @@ -/* main.c - - System configuration status daemon... - - !!!Boy, howdy, is this ever not guaranteed not to change!!! */ - -/* - * Copyright (c) 1997 The Internet Software Consortium. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of The Internet Software Consortium nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This software has been written for the Internet Software Consortium - * by Ted Lemon in cooperation with Vixie - * Enterprises. To learn more about the Internet Software Consortium, - * see ``http://www.vix.com/isc''. To learn more about Vixie - * Enterprises, see ``http://www.vix.com''. - */ - -#ifndef lint -static char copyright[] = -"$Id: sysconfd.c,v 1.3 1997/11/29 07:49:06 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; -#endif /* not lint */ - -#include "dhcpd.h" - -int sysconf_fd; - -struct sysconf_client { - struct sysconf_client *next; - int fd; -} *clients; - -static void new_connection PROTO ((struct protocol *)); -static void client_input PROTO ((struct protocol *)); - -int log_priority; -int log_perror; - -struct interface_info fallback_interface; -TIME cur_time; -u_int16_t local_port; - - -int main (argc, argv, envp) - int argc; - char **argv; - char **envp; -{ - struct sockaddr_un name; - int sysconf_fd; - int pid; - int len; - -#ifdef SYSLOG_4_2 - openlog ("sysconfd", LOG_NDELAY); - log_priority = LOG_DAEMON; -#else - openlog ("sysconfd", LOG_NDELAY, LOG_DAEMON); -#endif - -#if !(defined (DEBUG) || defined (SYSLOG_4_2) || defined (__CYGWIN32__)) - setlogmask (LOG_UPTO (LOG_INFO)); -#endif - - /* Make a socket... */ - sysconf_fd = socket (AF_UNIX, SOCK_STREAM, 0); - if (sysconf_fd < 0) - error ("unable to create sysconf socket: %m"); - - /* XXX for now... */ - name.sun_family = PF_UNIX; - strcpy (name.sun_path, "/var/run/sysconf"); -#if defined (HAVE_SA_LEN) - name.sun_len = -#endif - len = ((sizeof name) - (sizeof name.sun_path) + - strlen (name.sun_path)); - unlink (name.sun_path); - - /* Bind to it... */ - if (bind (sysconf_fd, (struct sockaddr *)&name, len) < 0) - error ("can't bind to sysconf socket: %m"); - - /* Listen for connections... */ - if (listen (sysconf_fd, 1) < 0) - error ("can't listen on sysconf socket: %m"); - - /* Stop logging to stderr... */ - log_perror = 0; - - /* Become a daemon... */ - if ((pid = fork ()) < 0) - error ("Can't fork daemon: %m"); - else if (pid) - exit (0); - - /* Become session leader... */ - (void)setsid (); - - /* Set up a protocol structure for it... */ - add_protocol ("listener", sysconf_fd, new_connection, 0); - - /* Kernel status stuff goes here... */ - - /* Wait for something to happen... */ - dispatch (); - - exit (0); -} - -void new_connection (proto) - struct protocol *proto; -{ - struct sockaddr_un name; - int namelen; - struct sysconf_client *tmp; - int new_fd; - - tmp = (struct sysconf_client *)malloc (sizeof *tmp); - if (tmp < 0) - error ("Can't find memory for new client!"); - memset (tmp, 0, sizeof *tmp); - - namelen = sizeof name; - new_fd = accept (proto -> fd, (struct sockaddr *)&name, &namelen); - if (new_fd < 0) - warn ("accept: %m"); - - tmp -> next = clients; - tmp -> fd = new_fd; - clients = tmp; - - add_protocol ("aclient", new_fd, client_input, 0); -} - -void client_input (proto) - struct protocol *proto; -{ - struct sysconf_header hdr; - int status; - char *buf; - void (*handler) PROTO ((struct sysconf_header *, void *)); - struct sysconf_client *client; - - status = read (proto -> fd, &hdr, sizeof hdr); - if (status < 0) { - blow: - warn ("client_input: %m"); - close (proto -> fd); - remove_protocol (proto); - return; - } - if (status < sizeof (hdr)) { - warn ("client_input: short message"); - goto blow; - } - - if (hdr.length) { - buf = malloc (hdr.length); - if (!buf) { - warn ("client_input: can't buffer payload"); - goto blow; - } - status = read (proto -> fd, buf, hdr.length); - if (status < 0) { - warn ("client_input payload read: %m"); - goto blow; - } - if (status != hdr.length) { - warn ("client_input payload: short read"); - goto blow; - } - } else - buf = (char *)0; - - for (client = clients; client; client = client -> next) { - if (client -> fd == proto -> fd) - continue; - - status = write (client -> fd, &hdr, sizeof hdr); - if (status < 0) { - warn ("client_input: %m"); - continue; - } - if (status < sizeof (hdr)) { - warn ("client_input: short write"); - continue; - } - - if (hdr.length) { - status = write (client -> fd, buf, hdr.length); - if (status < 0) { - warn ("client_input payload write: %m"); - continue; - } - if (status != hdr.length) { - warn ("client_input payload: short write"); - continue; - } - } - } - - if (buf) - free (buf); -} - -void cleanup () -{ -} - -int commit_leases () -{ - return 0; -} - -int write_lease (lease) - struct lease *lease; -{ - return 0; -} - -void db_startup () -{ -} - -void bootp (packet) - struct packet *packet; -{ -} - -void dhcp (packet) - struct packet *packet; -{ -} - -