]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
sync with branch
authorTed Lemon <source@isc.org>
Fri, 10 Aug 2001 10:50:50 +0000 (10:50 +0000)
committerTed Lemon <source@isc.org>
Fri, 10 Aug 2001 10:50:50 +0000 (10:50 +0000)
16 files changed:
client/dhclient.c
client/scripts/linux
common/dhcp-eval.5
common/execute.c
common/options.c
common/print.c
includes/dhcpd.h
includes/failover.h
includes/version.h
omapip/hash.c
omapip/protocol.c
server/confpars.c
server/dhcp.c
server/dhcpd.conf.5
server/failover.c
server/omapi.c

index e3667c74e52cf35e13450e068b1a54d083fc1d4c..26d84601145663c19d4aead569c874850f36038c 100644 (file)
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhclient.c,v 1.130 2001/06/27 00:29:29 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.131 2001/08/10 10:47:33 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -2654,6 +2654,7 @@ void go_daemon ()
 {
        static int state = 0;
        int pid;
+       int i;
 
        /* Don't become a daemon if the user requested otherwise. */
        if (no_daemon) {
@@ -2682,6 +2683,16 @@ void go_daemon ()
         close(1);
         close(2);
 
+       /* Reopen them on /dev/null. */
+       i = open ("/dev/null", O_RDWR);
+       if (i == 0)
+               i = open ("/dev/null", O_RDWR);
+       if (i == 1) {
+               i = open ("/dev/null", O_RDWR);
+               log_perror = 0; /* No sense logging to /dev/null. */
+       } else if (i != -1)
+               close (i);
+
        write_client_pid_file ();
 }
 
index 71d00ab38a6f145b356c441845afd87463f4d52c..6598b90e36dfb8a7cfd4efc7001048dc8dbc277d 100755 (executable)
@@ -90,7 +90,7 @@ if [ x$reason = xPREINIT ]; then
     # Add route to make broadcast work. Do not omit netmask.
     route add default dev $interface netmask 0.0.0.0
   else
-    ifconfig $interface up
+    ifconfig $interface up
   fi
 
   # We need to give the kernel some time to get the interface up.
@@ -122,7 +122,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
   if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
     # IP address changed. Bringing down the interface will delete all routes,
     # and clear the ARP cache.
-    ifconfig $interface inet down
+    ifconfig $interface inet down
 
   fi
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
@@ -157,7 +157,7 @@ if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
   fi
   if [ x$old_ip_address != x ]; then
     # Shut down interface, which will delete routes and clear arp cache.
-    ifconfig $interface inet down
+    ifconfig $interface inet down
   fi
   if [ x$alias_ip_address != x ]; then
     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
@@ -190,7 +190,7 @@ if [ x$reason = xTIMEOUT ]; then
     make_resolv_conf
     exit_with_hooks 0
   fi
-  ifconfig $interface inet down
+  ifconfig $interface inet down
   exit_with_hooks 1
 fi
 
index 1721c60817ce95db99af270a38c56cfd5cdc5ee6..3b80ad878809c9ba42f0ccddb85debe3ef2f201d 100644 (file)
@@ -409,33 +409,6 @@ Rebind - DHCP client is in the REBINDING state - it has an IP address,
 and is trying to contact any server to renew it.   The next message to
 be sent will be a DHCPREQUEST, which will be broadcast.
 .RE
-.SH
-FUNCTIONS
-Functions may be defined with the \fBdefine\fR statement.  A function
-definition may occur anywhere that regular statement may appear.
-Functions occupy the same namespace as variables, and obey the same
-scoping rules.
-.PP
-.nf
-define set-hostname(prefix) {
-  option host-name
-    concat (prefix, binary-to-ascii (16, 32, "", leased-address));
-}
-.fi
-.PP
-A function may return a value when used in an expression with the
-\fBreturn\fR statement.  A function with no return statement has a
-value of null.
-.PP
-.nf
-define make-hostname(prefix) {
-  return concat (prefix, binary-to-ascii (16, 32, "", leased-address));
-}
-
-option host-name make-hostname("dyn-");
-.fi
-.PP
-.RE
 .SH REFERENCE: LOGGING
 Logging statements may be used to send information to the standard logging
 channels.  A logging statement includes an optional priority (\fBfatal\fR,
index aeaac1b9814d80009bca613c0fab0853af86c065..1287e9e525676484830da2bbea7dbcb3b91c82df 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: execute.c,v 1.45 2001/06/27 00:29:48 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: execute.c,v 1.46 2001/08/10 10:48:58 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -999,10 +999,10 @@ int executable_statement_foreach (struct executable_statement *stmt,
              case null_statement:
                break;
              case if_statement:
-               if (executable_statement_foreach (stmt -> data.ie.tc,
+               if (executable_statement_foreach (foo -> data.ie.tc,
                                                  callback, vp, 1))
                        ok = 1;
-               if (executable_statement_foreach (stmt -> data.ie.fc,
+               if (executable_statement_foreach (foo -> data.ie.fc,
                                                  callback, vp, 1))
                        ok = 1;
                break;
@@ -1024,17 +1024,17 @@ int executable_statement_foreach (struct executable_statement *stmt,
                break;
              case statements_statement:
                if ((executable_statement_foreach
-                    (stmt -> data.statements, callback, vp, condp)))
+                    (foo -> data.statements, callback, vp, condp)))
                        ok = 1;
                break;
              case on_statement:
                if ((executable_statement_foreach
-                    (stmt -> data.on.statements, callback, vp, 1)))
+                    (foo -> data.on.statements, callback, vp, 1)))
                        ok = 1;
                break;
              case switch_statement:
                if ((executable_statement_foreach
-                    (stmt -> data.s_switch.statements, callback, vp, 1)))
+                    (foo -> data.s_switch.statements, callback, vp, 1)))
                        ok = 1;
                break;
              case case_statement:
@@ -1047,7 +1047,7 @@ int executable_statement_foreach (struct executable_statement *stmt,
                break;
              case let_statement:
                if ((executable_statement_foreach
-                    (stmt -> data.let.statements, callback, vp, 0)))
+                    (foo -> data.let.statements, callback, vp, 0)))
                        ok = 1;
                break;
              case define_statement:
index 25c624224bbf424416506756937ce7a228959c5f..0e7a0886ec57b37d5fb36ea17de09c2731fb0a4f 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: options.c,v 1.86 2001/06/27 00:29:54 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: options.c,v 1.87 2001/08/10 10:49:00 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -82,13 +82,34 @@ int parse_options (packet)
                                  &packet -> raw -> options [4],
                                  (packet -> packet_length -
                                   DHCP_FIXED_NON_UDP - 4),
-                                 &dhcp_universe))
-               return 0;
+                                 &dhcp_universe)) {
+
+               /* STSN servers have a bug where they send a mangled
+                  domain-name option, and whatever is beyond that in
+                  the packet is junk.   Microsoft clients accept this,
+                  which is probably why whoever implemented the STSN
+                  server isn't aware of the problem yet.   To work around
+                  this, we will accept corrupt packets from the server if
+                  they contain a valid DHCP_MESSAGE_TYPE option, but
+                  will not accept any corrupt client packets (the ISC DHCP
+                  server is sufficiently widely used that it is probably
+                  beneficial for it to be picky) and will not accept
+                  packets whose type can't be determined. */
+
+               if ((op = lookup_option (&dhcp_universe, packet -> options,
+                                        DHO_DHCP_MESSAGE_TYPE))) {
+                       if (!op -> data.data ||
+                           (op -> data.data [0] != DHCPOFFER &&
+                            op -> data.data [0] != DHCPACK &&
+                            op -> data.data [0] != DHCPNAK))
+                               return 0;
+               } else
+                       return 0;
+       }
 
        /* If we parsed a DHCP Option Overload option, parse more
           options out of the buffer(s) containing them. */
-       if (packet -> options_valid &&
-           (op = lookup_option (&dhcp_universe, packet -> options,
+       if ((op = lookup_option (&dhcp_universe, packet -> options,
                                 DHO_DHCP_OPTION_OVERLOAD))) {
                if (op -> data.data [0] & 1) {
                        if (!parse_option_buffer
index 807a53c7a033af569bb538cffb84d752b34f45a3..5f0c9f9d24e02f08536b0e2ee7d5d5908912614a 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: print.c,v 1.54 2001/06/27 00:29:57 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: print.c,v 1.55 2001/08/10 10:49:01 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1292,7 +1292,10 @@ void print_dns_status (int status, ns_updque *uq)
                strcpy (s, "empty update");
                s += strlen (s);
        }
-       errorp = 1;
+       if (status == NOERROR)
+               errorp = 0;
+       else
+               errorp = 1;
        en = isc_result_totext (status);
 #if 0
        switch (status) {
index acbe68aa64add1982a8d3f06f175a98af1d035b6..b4b8ac6905223884ed9cdadbd5cde869a177bab6 100644 (file)
@@ -592,9 +592,9 @@ struct collection {
 /* XXX classes must be reference-counted. */
 struct class {
        OMAPI_OBJECT_PREAMBLE;
-       struct class *nic;      /* Next in collection. */
+       struct class *nic;              /* Next in collection. */
        struct class *superclass;       /* Set for spawned classes only. */
-       char *name;             /* Not set for spawned classes. */
+       char *name;                     /* Not set for spawned classes. */
 
        /* A class may be configured to permit a limited number of leases. */
        int lease_limit;
index 2685447684fe34a61874ddf4b8aaa32f4848e3c4..e27a9115ceafe73e68af788537755f41088af8d6 100644 (file)
@@ -314,6 +314,8 @@ typedef struct _dhcp_failover_state {
        failover_message_t *toack_queue_tail;
        int pending_acks;               /* Number of messages in the toack
                                           queue. */
+       int pool_count;                 /* Number of pools referencing this
+                                          failover state object. */
 } dhcp_failover_state_t;
 
 #define DHCP_FAILOVER_VERSION          1
index 193122bc57b4206de453b50176780cc436c3a3ec..6bfb58308920548d6fecd64ced07963df93da6d5 100644 (file)
@@ -1,3 +1,3 @@
 /* Current version of ISC DHCP Distribution. */
 
-#define DHCP_VERSION   "V3.0rc8pl2"
+#define DHCP_VERSION   "V3.1-pre"
index 58aea60ee4f0a20ab26343014127b2379ebb0afe..da7b25e8cd502f8667c4c1890e6ba7fe8119c337 100644 (file)
@@ -3,7 +3,7 @@
    Routines for manipulating hash tables... */
 
 /*
- * Copyright (c) 1995-2001 Internet Software Consortium.
+ * Copyright (c) 1995-2000 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: hash.c,v 1.3 2001/06/27 00:30:48 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: hash.c,v 1.4 2001/08/10 10:50:22 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include <omapip/omapip_p.h>
index 8a5890a720c37b48ea5e413b79e47bee7984ae5a..6237f2a779d60221d06de3979d9b444fdefc8b58 100644 (file)
@@ -401,23 +401,27 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
        }
 
        /* If we get a disconnect, dump memory usage. */
-       if (!strcmp (name, "disconnect")
-#if defined (DEBUG_MEMORY_LEAKAGE)
-            && connect_outstanding != 0xBEADCAFE
-#endif
-               ) {
+       if (!strcmp (name, "disconnect")) {
 #if defined (DEBUG_MEMORY_LEAKAGE)
+           if (connect_outstanding != 0xBEADCAFE) {
                log_info ("generation %ld: %ld new, %ld outstanding, %ld%s",
                          dmalloc_generation,
                          dmalloc_outstanding - previous_outstanding,
                          dmalloc_outstanding, dmalloc_longterm, " long-term");
+           }
 #endif
 #if defined (DEBUG_MEMORY_LEAKAGE)
-               dmalloc_dump_outstanding ();
+           dmalloc_dump_outstanding ();
 #endif
 #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
-               dump_rc_history (0);
+           dump_rc_history ();
 #endif
+           for (m = omapi_registered_messages; m; m = m -> next) {
+               if (m -> protocol_object == p) {
+                   if (m -> object)
+                       omapi_signal (m -> object, "disconnect");
+               }
+           }
        }
 
        /* Not a signal we recognize? */
index 7c3d4512790ce40fc7149d788acb8d13b9a6315a..7521960748b509fbf48adab3e8a2ff99514fa755 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: confpars.c,v 1.146 2001/07/10 20:36:02 brister Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: confpars.c,v 1.147 2001/08/10 10:50:44 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1286,6 +1286,8 @@ void parse_pool_statement (cfile, group, type)
                                parse_warn (cfile,
                                            "failover peer %s: %s", val,
                                            isc_result_totext (status));
+                       else
+                               pool -> failover_peer -> pool_count++;
                        parse_semi (cfile);
                        break;
 #endif
@@ -1851,7 +1853,7 @@ int parse_class_declaration (cp, cfile, group, type)
                }
 
                /* Save the name, if there is one. */
-               class -> name = (char *)name;
+               class -> name = name;
        }
 
        if (type == 0 || type == 1 || type == 3)
@@ -2764,6 +2766,7 @@ int parse_lease_declaration (struct lease **lp, struct parse *cfile)
                        break;
                        
                      case OPTION:
+                     case SUPERSEDE:
                        noequal = 0;
                        seenbit = 0;
                        oc = (struct option_cache *)0;
index 095d78a730b61b11ca560cbe60f429458b97283f..9a3f0baf00a3e40e6f8ee5582e3a1a2df4520788 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.194 2001/06/27 00:31:07 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.195 2001/08/10 10:50:45 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -2919,6 +2919,7 @@ int find_lease (struct lease **lp,
                   be two "free" leases for the same uid, but only one of
                   them that's available for this failover peer to allocate. */
                if (uid_lease -> binding_state != FTS_ACTIVE &&
+                   uid_lease -> binding_state != FTS_BOOTP &&
                    !lease_mine_to_reallocate (uid_lease)) {
 #if defined (DEBUG_FIND_LEASE)
                        log_info ("not mine to allocate: %s",
@@ -2982,6 +2983,7 @@ int find_lease (struct lease **lp,
                   be two "free" leases for the same uid, but only one of
                   them that's available for this failover peer to allocate. */
                if (hw_lease -> binding_state != FTS_ACTIVE &&
+                   hw_lease -> binding_state != FTS_BOOTP &&
                    !lease_mine_to_reallocate (hw_lease)) {
 #if defined (DEBUG_FIND_LEASE)
                        log_info ("not mine to allocate: %s",
@@ -3114,6 +3116,7 @@ int find_lease (struct lease **lp,
           is not active, and is not ours to reallocate, forget about it. */
        if (ip_lease && (uid_lease || hw_lease) &&
            ip_lease -> binding_state != FTS_ACTIVE &&
+           ip_lease -> binding_state != FTS_BOOTP &&
            !lease_mine_to_reallocate (ip_lease) &&
            packet -> packet_type == DHCPDISCOVER) {
 #if defined (DEBUG_FIND_LEASE)
@@ -3126,14 +3129,16 @@ int find_lease (struct lease **lp,
           on the subnet that matches its uid, pick the one that
           it asked for and (if we can) free the other. */
        if (ip_lease &&
-           ip_lease -> binding_state == FTS_ACTIVE &&
+           (ip_lease -> binding_state == FTS_ACTIVE ||
+            ip_lease -> binding_state == FTS_BOOTP) &&
            ip_lease -> uid && ip_lease != uid_lease) {
                if (have_client_identifier &&
                    (ip_lease -> uid_len == client_identifier.len) &&
                    !memcmp (client_identifier.data,
                             ip_lease -> uid, ip_lease -> uid_len)) {
                        if (uid_lease) {
-                           if (uid_lease -> binding_state == FTS_ACTIVE) {
+                           if (uid_lease -> binding_state == FTS_ACTIVE ||
+                               uid_lease -> binding_state == FTS_BOOTP) {
                                log_error ("client %s has duplicate%s on %s",
                                           (print_hw_addr
                                            (packet -> raw -> htype,
@@ -3147,7 +3152,10 @@ int find_lease (struct lease **lp,
                                   it shouldn't still be using the old
                                   one, so we can free it for allocation. */
                                if (uid_lease &&
-                                   uid_lease -> binding_state == FTS_ACTIVE &&
+                                   (uid_lease -> binding_state == FTS_ACTIVE
+                                    ||
+                                    uid_lease -> binding_state == FTS_BOOTP)
+                                   &&
                                    !packet -> raw -> ciaddr.s_addr &&
                                    (share ==
                                     uid_lease -> subnet -> shared_network) &&
@@ -3302,7 +3310,8 @@ int find_lease (struct lease **lp,
                if (lease) {
                        if (!packet -> raw -> ciaddr.s_addr &&
                            packet -> packet_type == DHCPREQUEST &&
-                           uid_lease -> binding_state == FTS_ACTIVE)
+                           (uid_lease -> binding_state == FTS_ACTIVE ||
+                            uid_lease -> binding_state == FTS_BOOTP))
                                dissociate_lease (uid_lease);
 #if defined (DEBUG_FIND_LEASE)
                        log_info ("not choosing uid lease.");
index ebb57cfef9c9c08be5f3ac3f049c96cee651738a..f9b3463ded99ab1ab7212e5bc06f6daeb73c065f 100644 (file)
@@ -956,7 +956,7 @@ client sends a DHCPDISCOVER message, then the server sends a
 DHCPOFFER, then the client sends a DHCPREQUEST, then the server sends
 a DHCPACK.   In the current version of the server, the server will do
 a DNS update after it has received the DHCPREQUEST, and before it has
-sent the DHCPOFFER.   It only sends the DNS update if it has not sent
+sent the DHCPACK.   It only sends the DNS update if it has not sent
 one for the client's address before, in order to minimize the impact
 on the DHCP server.
 .PP
index 136176a59ca0af3672adb11d3a621b3e9dc95a49..6a094efebae137418ab46155866e1bddf080bc19 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: failover.c,v 1.56 2001/06/29 18:34:57 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: failover.c,v 1.57 2001/08/10 10:50:49 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -72,6 +72,15 @@ void dhcp_failover_startup ()
        for (state = failover_states; state; state = state -> next) {
                dhcp_failover_state_transition (state, "startup");
 
+               if (state -> pool_count == 0) {
+                       log_error ("failover peer declaration with no %s",
+                                  "referring pools.");
+                       log_error ("In order to use failover, you MUST %s",
+                                  "refer to your main failover declaration");
+                       log_error ("in each pool declaration.   You MUST %s",
+                                  "NOT use range declarations outside");
+                       log_fatal ("of pool declarations.");
+               }
                /* In case the peer is already running, immediately try
                   to establish a connection with it. */
                status = dhcp_failover_link_initiate ((omapi_object_t *)state);
@@ -243,7 +252,7 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h)
                local_addr.addrtype = AF_INET;
                local_addr.addrlen = sizeof (struct in_addr);
                if (!state -> server_identifier.len) {
-                       log_fatal ("failover peer %s: no identifier.",
+                       log_fatal ("failover peer %s: no local address.",
                                   state -> name);
                }
        } else {
@@ -4981,14 +4990,9 @@ normal_binding_state_transition_check (struct lease *lease,
                switch (binding_state) {
                      case FTS_FREE:
                      case FTS_BACKUP:
-                       /* Can't set a lease to free or backup until the
-                          peer agrees that it's expired. */
-                       if (tsfp > cur_time) {
-                               new_state = lease -> binding_state;
-                               goto out;
-                       }
-                       return binding_state;
 
+                       /* These are invalid state transitions - should we
+                          prevent them? */
                      case FTS_RESERVED:
                      case FTS_BOOTP:
                      case FTS_EXPIRED:
index 819d7f1df3eec5463fd9e76fde8de1b51ad9540b..b65eef17c91d4921715fbe9300075856e61e491c 100644 (file)
@@ -50,7 +50,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: omapi.c,v 1.50 2001/07/10 20:36:06 brister Exp $ Copyright (c) 1999-2001 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: omapi.c,v 1.51 2001/08/10 10:50:50 mellon Exp $ Copyright (c) 1999-2001 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -1868,7 +1868,7 @@ isc_result_t dhcp_class_destroy (omapi_object_t *h, const char *file, int line)
        isc_result_t status;
        int i;
 
-       if (h -> type != dhcp_type_class || h -> type != dhcp_type_subclass)
+       if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass)
                return ISC_R_INVALIDARG;
        class = (struct class *)h;