Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.sbin/dhcp Pull up revision 1.7 (requested by mellon):



details:   https://anonhg.NetBSD.org/src/rev/ec8e0736dad3
branches:  netbsd-1-5
changeset: 491094:ec8e0736dad3
user:      he <he%NetBSD.org@localhost>
date:      Wed Apr 04 20:55:40 2001 +0000

description:
Pull up revision 1.7 (requested by mellon):
  Update DHCP software to ISC version 3, Beta 2, Patchlevel 23.

diffstat:

 usr.sbin/dhcp/client/scripts/freebsd |   58 +-
 usr.sbin/dhcp/includes/version.h     |    2 +-
 usr.sbin/dhcp/server/confpars.c      |  723 ++++++++++++++++++++++------------
 usr.sbin/dhcp/server/omapi.c         |   76 ++-
 4 files changed, 547 insertions(+), 312 deletions(-)

diffs (truncated from 1847 to 300 lines):

diff -r d91a2d6b0800 -r ec8e0736dad3 usr.sbin/dhcp/client/scripts/freebsd
--- a/usr.sbin/dhcp/client/scripts/freebsd      Wed Apr 04 20:55:37 2001 +0000
+++ b/usr.sbin/dhcp/client/scripts/freebsd      Wed Apr 04 20:55:40 2001 +0000
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+if [ -x /usr/bin/logger ]; then
+       LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
+else
+       LOGGER=echo
+fi
+
 make_resolv_conf() {
   echo search $new_domain_name >/etc/resolv.conf
   for nameserver in $new_domain_name_servers; do
@@ -29,11 +35,11 @@
 fi
 
 if [ x$new_network_number != x ]; then
-   echo New Network Number: $new_network_number
+   $LOGGER New Network Number: $new_network_number
 fi
 
 if [ x$new_broadcast_address != x ]; then
- echo New Broadcast Address: $new_broadcast_address
+ $LOGGER New Broadcast Address: $new_broadcast_address
   new_broadcast_arg="broadcast $new_broadcast_address"
 fi
 if [ x$old_broadcast_address != x ]; then
@@ -50,8 +56,8 @@
 fi
 
 if [ x$reason = xMEDIUM ]; then
-  ifconfig $interface $medium
-  ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1
+  eval "ifconfig $interface $medium"
+  eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
   sleep 1
   exit_with_hooks 0
 fi
@@ -77,6 +83,7 @@
      [ x$current_hostname = x$old_host_name ]; then
     if [ x$current_hostname = x ] || \
        [ x$new_host_name != x$old_host_name ]; then
+      $LOGGER "New Hostname: $new_host_name"
       hostname $new_host_name
     fi
   fi
@@ -87,30 +94,37 @@
   fi
   if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
    then
-    ifconfig $interface inet -alias $old_ip_address $medium
+    eval "ifconfig $interface inet -alias $old_ip_address $medium"
     route delete $old_ip_address 127.1 >/dev/null 2>&1
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
     if [ "$old_static_routes" != "" ]; then
-      set $old_static_routes
+      set -- $old_static_routes
       while [ $# -gt 1 ]; do
        route delete $1 $2
        shift; shift
       done
     fi
-    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
+    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' |sh
   fi
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
-    ifconfig $interface inet $new_ip_address $new_netmask_arg \
-                                       $new_broadcast_arg $medium
+    eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
+                                       $new_broadcast_arg $medium"
+    $LOGGER "New IP Address($interface): $new_ip_address"
+    $LOGGER "New Subnet Mask($interface): $new_subnet_mask"
+    $LOGGER "New Broadcast Address($interface): $new_broadcast_address"
+    if [ "$new_routers" != "" ]; then
+      $LOGGER "New Routers: $new_routers"
+    fi
     route add $new_ip_address 127.1 >/dev/null 2>&1
     for router in $new_routers; do
       route add default $router >/dev/null 2>&1
     done
     if [ "$new_static_routes" != "" ]; then
-      set $new_static_routes
+      $LOGGER "New Static Routes: $new_static_routes"
+      set -- $new_static_routes
       while [ $# -gt 1 ]; do
        route add $1 $2
        shift; shift
@@ -132,13 +146,13 @@
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
   if [ x$old_ip_address != x ]; then
-    ifconfig $interface inet -alias $old_ip_address $medium
+    eval "ifconfig $interface inet -alias $old_ip_address $medium"
     route delete $old_ip_address 127.1 >/dev/null 2>&1
     for router in $old_routers; do
       route delete default $router >/dev/null 2>&1
     done
     if [ "$old_static_routes" != "" ]; then
-      set $old_static_routes
+      set -- $old_static_routes
       while [ $# -gt 1 ]; do
        route delete $1 $2
        shift; shift
@@ -159,11 +173,15 @@
     ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
-  ifconfig $interface inet $new_ip_address $new_netmask_arg \
-                                       $new_broadcast_arg $medium
+  eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
+                                       $new_broadcast_arg $medium"
+  $LOGGER "New IP Address($interface): $new_ip_address"
+  $LOGGER "New Subnet Mask($interface): $new_subnet_mask"
+  $LOGGER "New Broadcast Address($interface): $new_broadcast_address"
   sleep 1
   if [ "$new_routers" != "" ]; then
-    set $new_routers
+    $LOGGER "New Routers: $new_routers"
+    set -- $new_routers
     if ping -q -c 1 $1; then
       if [ x$new_ip_address != x$alias_ip_address ] && \
                        [ x$alias_ip_address != x ]; then
@@ -174,27 +192,27 @@
       for router in $new_routers; do
        route add default $router >/dev/null 2>&1
       done
-      set $new_static_routes
+      set -- $new_static_routes
       while [ $# -gt 1 ]; do
-       route add $0 $1
+       route add $1 $2
        shift; shift
       done
       make_resolv_conf
       exit_with_hooks 0
     fi
   fi
-  ifconfig $interface inet -alias $new_ip_address $medium
+  eval "ifconfig $interface inet -alias $new_ip_address $medium"
   for router in $old_routers; do
     route delete default $router >/dev/null 2>&1
   done
   if [ "$old_static_routes" != "" ]; then
-    set $old_static_routes
+    set -- $old_static_routes
     while [ $# -gt 1 ]; do
       route delete $1 $2
       shift; shift
     done
   fi
-  arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
+  arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
                                                        |sh >/dev/null 2>&1
   exit_with_hooks 1
 fi
diff -r d91a2d6b0800 -r ec8e0736dad3 usr.sbin/dhcp/includes/version.h
--- a/usr.sbin/dhcp/includes/version.h  Wed Apr 04 20:55:37 2001 +0000
+++ b/usr.sbin/dhcp/includes/version.h  Wed Apr 04 20:55:40 2001 +0000
@@ -1,3 +1,3 @@
 /* Current version of ISC DHCP Distribution. */
 
-#define DHCP_VERSION   "V3.0b2pl9"
+#define DHCP_VERSION   "V3.0b2pl23"
diff -r d91a2d6b0800 -r ec8e0736dad3 usr.sbin/dhcp/server/confpars.c
--- a/usr.sbin/dhcp/server/confpars.c   Wed Apr 04 20:55:37 2001 +0000
+++ b/usr.sbin/dhcp/server/confpars.c   Wed Apr 04 20:55:40 2001 +0000
@@ -3,7 +3,7 @@
    Parser for dhcpd config file... */
 
 /*
- * Copyright (c) 1995-2000 Internet Software Consortium.
+ * Copyright (c) 1995-2001 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,95 +43,228 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: confpars.c,v 1.2.2.2 2000/10/18 04:11:40 tv Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: confpars.c,v 1.2.2.3 2001/04/04 20:55:40 he Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
 
 static TIME parsed_time;
 
-/* conf-file :== parameters declarations EOF
+#if defined (TRACING)
+trace_type_t *trace_readconf_type;
+trace_type_t *trace_readleases_type;
+
+void parse_trace_setup ()
+{
+       trace_readconf_type = trace_type_register ("readconf", (void *)0,
+                                                  trace_conf_input,
+                                                  trace_conf_stop, MDL);
+       trace_readleases_type = trace_type_register ("readleases", (void *)0,
+                                                    trace_conf_input,
+                                                    trace_conf_stop, MDL);
+}
+#endif
+
+/* conf-file :== parameters declarations END_OF_FILE
    parameters :== <nil> | parameter | parameters parameter
    declarations :== <nil> | declaration | declarations declaration */
 
 isc_result_t readconf ()
 {
-       return parse_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP);
+       return read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0);
 }
 
-/* conf-file :== parameters declarations EOF
+isc_result_t read_conf_file (const char *filename, struct group *group,
+                            int group_type, int leasep)
+{
+       int file;
+       struct parse *cfile;
+       isc_result_t status;
+#if defined (TRACING)
+       char *fbuf, *dbuf;
+       off_t flen;
+       int result;
+       unsigned tflen, ulen;
+       trace_type_t *ttype;
+
+       if (leasep)
+               ttype = trace_readleases_type;
+       else
+               ttype = trace_readconf_type;
+
+       /* If we're in playback, we need to snarf the contents of the
+          named file out of the playback file rather than trying to
+          open and read it. */
+       if (trace_playback ()) {
+               dbuf = (char *)0;
+               tflen = 0;
+               status = trace_get_file (ttype, filename, &tflen, &dbuf);
+               if (status != ISC_R_SUCCESS)
+                       return status;
+               ulen = tflen;
+
+               /* What we get back is filename\0contents, where contents is
+                  terminated just by the length.  So we figure out the length
+                  of the filename, and subtract that and the NUL from the
+                  total length to get the length of the contents of the file.
+                  We make fbuf a pointer to the contents of the file, and
+                  leave dbuf as it is so we can free it later. */
+               tflen = strlen (dbuf);
+               ulen = ulen - tflen - 1;
+               fbuf = dbuf + tflen + 1;
+               goto memfile;
+       }
+#endif
+
+       if ((file = open (filename, O_RDONLY)) < 0) {
+               if (leasep) {
+                       log_error ("Can't open lease database %s: %m --",
+                                  path_dhcpd_db);
+                       log_error ("  check for failed database %s!",
+                                  "rewrite attempt");
+                       log_error ("Please read the dhcpd.leases manual%s",
+                                  " page if you");
+                       log_fatal ("don't know what to do about this.");
+               } else {
+                       log_fatal ("Can't open %s: %m", filename);
+               }
+       }
+
+       cfile = (struct parse *)0;
+#if defined (TRACING)
+       flen = lseek (file, (off_t)0, SEEK_END);
+       if (flen < 0) {
+             boom:
+               log_fatal ("Can't lseek on %s: %m", filename);
+       }
+       if (lseek (file, (off_t)0, SEEK_SET) < 0)
+               goto boom;
+       /* Can't handle files greater than 2^31-1. */
+       if (flen > 0x7FFFFFFFUL)
+               log_fatal ("%s: file is too long to buffer.", filename);
+       ulen = flen;
+
+       /* Allocate a buffer that will be what's written to the tracefile,
+          and also will be what we parse from. */
+       tflen = strlen (filename);
+       dbuf = dmalloc (ulen + tflen + 1, MDL);
+       if (!dbuf)
+               log_fatal ("No memory for %s (%d bytes)",
+                          filename, ulen);
+
+       /* Copy the name into the beginning, nul-terminated. */
+       strcpy (dbuf, filename);
+



Home | Main Index | Thread Index | Old Index