dhclient - Drop medium/alias useless utilization.
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Fri, 3 Aug 2012 22:26:45 +0000 (00:26 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sun, 19 Aug 2012 14:30:39 +0000 (16:30 +0200)
- Dump some useless calls to dhclient-script. i.e. MEDIUM, PREINIT,
  ARPSEND, ARPCHECK. Drop support for 'media', 'medium' and 'alias'
  specifications in dhclient.conf.
- Old leases still parse but these options now have no effect.
- Be more polite and decline all offers we don't accept.
- Fix a IMSG length check.
- Many expressions of support at various bars.

Taken-from: OpenBSD

sbin/dhclient/clparse.c
sbin/dhclient/dhclient-script
sbin/dhclient/dhclient.c
sbin/dhclient/dhclient.conf.5
sbin/dhclient/dhcpd.h
sbin/dhclient/privsep.c

index 74a657b..89c44bc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/clparse.c,v 1.36 2009/07/19 00:18:02 stevesk Exp $  */
+/*     $OpenBSD: src/sbin/dhclient/clparse.c,v 1.37 2011/04/04 11:14:52 krw Exp $      */
 
 /* Parser for dhclient config and lease files... */
 
 
 /* Parser for dhclient config and lease files... */
 
@@ -184,7 +184,7 @@ parse_client_statement(FILE *cfile)
                        config->default_actions[code] = ACTION_PREPEND;
                return;
        case TOK_MEDIA:
                        config->default_actions[code] = ACTION_PREPEND;
                return;
        case TOK_MEDIA:
-               parse_string_list(cfile, &config->media, 1);
+               skip_to_semi(cfile);
                return;
        case TOK_HARDWARE:
                parse_hardware_param(cfile, &ifi->hw_address);
                return;
        case TOK_HARDWARE:
                parse_hardware_param(cfile, &ifi->hw_address);
@@ -229,7 +229,7 @@ parse_client_statement(FILE *cfile)
                parse_client_lease_statement(cfile, 1);
                return;
        case TOK_ALIAS:
                parse_client_lease_statement(cfile, 1);
                return;
        case TOK_ALIAS:
-               parse_client_lease_statement(cfile, 2);
+               skip_to_semi(cfile);
                return;
        case TOK_REJECT:
                parse_reject_statement(cfile);
                return;
        case TOK_REJECT:
                parse_reject_statement(cfile);
@@ -426,12 +426,6 @@ parse_client_lease_statement(FILE *cfile, int is_static)
                return;
        }
 
                return;
        }
 
-       /* If this is an alias lease, it doesn't need to be sorted in. */
-       if (is_static == 2) {
-               client->alias = lease;
-               return;
-       }
-
        /*
         * The new lease may supersede a lease that's not the active
         * lease but is still on the lease list, so scan the lease list
        /*
         * The new lease may supersede a lease that's not the active
         * lease but is still on the lease list, so scan the lease list
@@ -531,7 +525,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease)
                        return;
                break;
        case TOK_MEDIUM:
                        return;
                break;
        case TOK_MEDIUM:
-               parse_string_list(cfile, &lease->medium, 0);
+               skip_to_semi(cfile);
                return;
        case TOK_FILENAME:
                lease->filename = parse_string(cfile);
                return;
        case TOK_FILENAME:
                lease->filename = parse_string(cfile);
@@ -720,50 +714,6 @@ bad_flag:
 }
 
 void
 }
 
 void
-parse_string_list(FILE *cfile, struct string_list **lp, int multiple)
-{
-       int                      token;
-       char                    *val;
-       struct string_list      *cur, *tmp;
-
-       /* Find the last medium in the media list. */
-       if (*lp)
-               for (cur = *lp; cur->next; cur = cur->next)
-                       ;       /* nothing */
-       else
-               cur = NULL;
-
-       do {
-               token = next_token(&val, cfile);
-               if (token != TOK_STRING) {
-                       parse_warn("Expecting media options.");
-                       skip_to_semi(cfile);
-                       return;
-               }
-
-               tmp = malloc(sizeof(struct string_list) + strlen(val));
-               if (tmp == NULL)
-                       error("no memory for string list entry.");
-               strlcpy(tmp->string, val, strlen(val) + 1);
-               tmp->next = NULL;
-
-               /* Store this medium at the end of the media list. */
-               if (cur)
-                       cur->next = tmp;
-               else
-                       *lp = tmp;
-               cur = tmp;
-
-               token = next_token(&val, cfile);
-       } while (multiple && token == ',');
-
-       if (token != ';') {
-               parse_warn("expecting semicolon.");
-               skip_to_semi(cfile);
-       }
-}
-
-void
 parse_reject_statement(FILE *cfile)
 {
        struct iaddrlist *list;
 parse_reject_statement(FILE *cfile)
 {
        struct iaddrlist *list;
index d97a1e8..26d7416 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
 #!/bin/sh
 #
-# $OpenBSD: src/sbin/dhclient/dhclient-script,v 1.18 2011/03/27 12:15:46 krw Exp $
+# $OpenBSD: src/sbin/dhclient/dhclient-script,v 1.19 2011/04/04 11:14:52 krw Exp $
 #
 # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org>
 #
 #
 # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org>
 #
@@ -24,7 +24,7 @@
 
 delete_old_address() {
        if [ -n "$old_ip_address" ]; then
 
 delete_old_address() {
        if [ -n "$old_ip_address" ]; then
-               ifconfig $interface inet $old_ip_address delete $medium
+               ifconfig $interface inet $old_ip_address delete
                #route delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1
        fi
 }
                #route delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1
        fi
 }
@@ -33,28 +33,12 @@ add_new_address() {
        ifconfig $interface \
                inet $new_ip_address \
                netmask $new_subnet_mask \
        ifconfig $interface \
                inet $new_ip_address \
                netmask $new_subnet_mask \
-               broadcast $new_broadcast_address \
-               $medium
+               broadcast $new_broadcast_address
 
        # XXX Original TIMEOUT code did not do this unless $new_routers was set?
        #route add $new_ip_address 127.0.0.1 >/dev/null 2>&1
 }
 
 
        # XXX Original TIMEOUT code did not do this unless $new_routers was set?
        #route add $new_ip_address 127.0.0.1 >/dev/null 2>&1
 }
 
-delete_old_alias() {
-       if [ -n "$alias_ip_address" ]; then
-               ifconfig $interface inet $alias_ip_address delete > /dev/null 2>&1
-#              #route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
-       fi
-}
-
-add_new_alias() {
-       if [ -n "$alias_ip_address" ]; then
-               ifconfig $interface inet $alias_ip_address alias netmask \
-                   $alias_subnet_mask
-               #route add $alias_ip_address 127.0.0.1
-       fi
-}
-
 delete_old_routes() {
        if [ -n "$old_static_routes" ]; then
                set $old_static_routes
 delete_old_routes() {
        if [ -n "$old_static_routes" ]; then
                set $old_static_routes
@@ -137,29 +121,25 @@ add_new_resolv_conf() {
 
 case $reason in
 MEDIUM)
 
 case $reason in
 MEDIUM)
-       ifconfig $interface $medium
-       sleep 1
+       # Not called by OpenBSD dhclient(8).
        ;;
 
 PREINIT)
        ;;
 
 PREINIT)
-       delete_old_alias
-       ifconfig $interface up
-       ;;
-
-ARPCHECK)
-       # Always succeed. i.e. accept lease.
+       # Not called by OpenBSD dhclient(8).
        ;;
 
 ARPSEND)
        ;;
 
 ARPSEND)
-       # Always fail. i.e. don't wait for ARP packet here.
+       # Not called by OpenBSD dhclient(8).
        exit 1
        ;;
 
        exit 1
        ;;
 
+ARPCHECK)
+       # Not called by OpenBSD dhclient(8).
+       # Always succeed. i.e. accept lease.
+       ;;
+
 BOUND|RENEW|REBIND|REBOOT)
        if [ -n "$old_ip_address" ]; then
 BOUND|RENEW|REBIND|REBOOT)
        if [ -n "$old_ip_address" ]; then
-               if [ "$old_ip_address" != "$alias_ip_address" ]; then
-                       delete_old_alias
-               fi
                if [ "$old_ip_address" != "$new_ip_address" ]; then
                        delete_old_address
                        delete_old_routes
                if [ "$old_ip_address" != "$new_ip_address" ]; then
                        delete_old_address
                        delete_old_routes
@@ -172,35 +152,25 @@ BOUND|RENEW|REBIND|REBOOT)
                add_new_address
                add_new_routes
        fi
                add_new_address
                add_new_routes
        fi
-       if [ "$new_ip_address" != "$alias_ip_address" ]; then
-               add_new_alias
-       fi
        add_new_resolv_conf
        ;;
 
 EXPIRE|FAIL)
        add_new_resolv_conf
        ;;
 
 EXPIRE|FAIL)
-       delete_old_alias
        if [ -n "$old_ip_address" ]; then
                delete_old_address
                delete_old_routes
        fi
        if [ -n "$old_ip_address" ]; then
                delete_old_address
                delete_old_routes
        fi
-       # XXX Why add alias we just deleted above?
-       add_new_alias
        if [ -f /etc/resolv.conf.save ]; then
                cat /etc/resolv.conf.save > /etc/resolv.conf
        fi
        ;;
 
 TIMEOUT)
        if [ -f /etc/resolv.conf.save ]; then
                cat /etc/resolv.conf.save > /etc/resolv.conf
        fi
        ;;
 
 TIMEOUT)
-       delete_old_alias
        add_new_address
        sleep 1
        if [ -n "$new_routers" ]; then
                set "$new_routers"
                if ping -q -c 1 -w 1 "$1"; then
        add_new_address
        sleep 1
        if [ -n "$new_routers" ]; then
                set "$new_routers"
                if ping -q -c 1 -w 1 "$1"; then
-                       if [ "$new_ip_address" != "$alias_ip_address" ]; then
-                               add_new_alias
-                       fi
                        add_new_routes
                        if add_new_resolv_conf; then
                                exit 0
                        add_new_routes
                        if add_new_resolv_conf; then
                                exit 0
index 09ee1ff..f4b7d48 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.138 2011/03/27 12:15:46 krw Exp $    */
+/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.139 2011/04/04 11:14:52 krw Exp $    */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -205,8 +205,7 @@ routehandler(void)
                        if (addr_eq(a, l->address))
                                break;
 
                        if (addr_eq(a, l->address))
                                break;
 
-               if (l != NULL || (client->alias &&
-                   addr_eq(a, client->alias->address)))
+               if (l != NULL)
                        /* new addr is the one we set */
                        break;
                snprintf(buf, sizeof(buf), "%s: %s",
                        /* new addr is the one we set */
                        break;
                snprintf(buf, sizeof(buf), "%s: %s",
@@ -262,9 +261,7 @@ routehandler(void)
        return;
 
 die:
        return;
 
 die:
-       script_init("FAIL", NULL);
-       if (client->alias)
-               script_write_params("alias_", client->alias);
+       script_init("FAIL");
        script_go();
        error("routehandler: %s", errmsg);
 }
        script_go();
        error("routehandler: %s", errmsg);
 }
@@ -381,11 +378,6 @@ main(int argc, char *argv[])
        rewrite_client_leases();
        close(fd);
 
        rewrite_client_leases();
        close(fd);
 
-       priv_script_init("PREINIT", NULL);
-       if (client->alias)
-               priv_script_write_params("alias_", client->alias);
-       priv_script_go();
-
        if ((routefd = socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
                error("socket(PF_ROUTE, SOCK_RAW): %m");
 
        if ((routefd = socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
                error("socket(PF_ROUTE, SOCK_RAW): %m");
 
@@ -481,9 +473,6 @@ state_reboot(void)
        client->first_sending = cur_time;
        client->interval = 0;
 
        client->first_sending = cur_time;
        client->interval = 0;
 
-       /* Zap the medium list... */
-       client->medium = NULL;
-
        /* Send out the first DHCPREQUEST packet. */
        send_request();
 }
        /* Send out the first DHCPREQUEST packet. */
        send_request();
 }
@@ -530,25 +519,11 @@ state_selecting(void)
        for (lp = client->offered_leases; lp; lp = next) {
                next = lp->next;
 
        for (lp = client->offered_leases; lp; lp = next) {
                next = lp->next;
 
-               /* Check to see if we got an ARPREPLY for the address
-                  in this particular lease. */
                if (!picked) {
                if (!picked) {
-                       script_init("ARPCHECK", lp->medium);
-                       script_write_params("check_", lp);
-
-                       /* If the ARPCHECK code detects another
-                          machine using the offered address, it exits
-                          nonzero.  We need to send a DHCPDECLINE and
-                          toss the lease. */
-                       if (script_go()) {
-                               make_decline(lp);
-                               send_decline();
-                               goto freeit;
-                       }
                        picked = lp;
                        picked = lp;
-                       picked->next = NULL;
                } else {
                } else {
-freeit:
+                       make_decline(lp);
+                       send_decline();
                        free_client_lease(lp);
                }
        }
                        free_client_lease(lp);
                }
        }
@@ -561,6 +536,7 @@ freeit:
                state_init();
                return;
        }
                state_init();
                return;
        }
+       picked->next = NULL;
 
        /* If it was a BOOTREPLY, we can just take the address right now. */
        if (!picked->options[DHO_DHCP_MESSAGE_TYPE].len) {
 
        /* If it was a BOOTREPLY, we can just take the address right now. */
        if (!picked->options[DHO_DHCP_MESSAGE_TYPE].len) {
@@ -667,22 +643,16 @@ dhcpack(struct iaddr client_addr, struct option_data *options)
 void
 bind_lease(void)
 {
 void
 bind_lease(void)
 {
-       /* Remember the medium. */
-       client->new->medium = client->medium;
-
        /* Write out the new lease. */
        write_client_lease(client->new, 0);
 
        /* Run the client script with the new parameters. */
        script_init((client->state == S_REQUESTING ? "BOUND" :
            (client->state == S_RENEWING ? "RENEW" :
        /* Write out the new lease. */
        write_client_lease(client->new, 0);
 
        /* Run the client script with the new parameters. */
        script_init((client->state == S_REQUESTING ? "BOUND" :
            (client->state == S_RENEWING ? "RENEW" :
-           (client->state == S_REBOOTING ? "REBOOT" : "REBIND"))),
-           client->new->medium);
+               (client->state == S_REBOOTING ? "REBOOT" : "REBIND"))));
        if (client->active && client->state != S_REBOOTING)
                script_write_params("old_", client->active);
        script_write_params("new_", client->new);
        if (client->active && client->state != S_REBOOTING)
                script_write_params("old_", client->active);
        script_write_params("new_", client->new);
-       if (client->alias)
-               script_write_params("alias_", client->alias);
        script_go();
 
        /* Replace the old active lease with the new one. */
        script_go();
 
        /* Replace the old active lease with the new one. */
@@ -736,7 +706,7 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options)
 {
        struct client_lease *lease, *lp;
        int i;
 {
        struct client_lease *lease, *lp;
        int i;
-       int arp_timeout_needed, stop_selecting;
+       int stop_selecting;
        char *name = options[DHO_DHCP_MESSAGE_TYPE].len ? "DHCPOFFER" :
            "BOOTREPLY";
 
        char *name = options[DHO_DHCP_MESSAGE_TYPE].len ? "DHCPOFFER" :
            "BOOTREPLY";
 
@@ -778,19 +748,6 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options)
        if (!options[DHO_DHCP_MESSAGE_TYPE].len)
                lease->is_bootp = 1;
 
        if (!options[DHO_DHCP_MESSAGE_TYPE].len)
                lease->is_bootp = 1;
 
-       /* Record the medium under which this lease was offered. */
-       lease->medium = client->medium;
-
-       /* Send out an ARP Request for the offered IP address. */
-       script_init("ARPSEND", lease->medium);
-       script_write_params("check_", lease);
-       /* If the script can't send an ARP request without waiting,
-          we'll be waiting when we do the ARPCHECK, so don't wait now. */
-       if (script_go())
-               arp_timeout_needed = 0;
-       else
-               arp_timeout_needed = 2;
-
        /* Figure out when we're supposed to stop selecting. */
        stop_selecting = client->first_sending + config->select_interval;
 
        /* Figure out when we're supposed to stop selecting. */
        stop_selecting = client->first_sending + config->select_interval;
 
@@ -800,14 +757,6 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options)
                lease->next = client->offered_leases;
                client->offered_leases = lease;
        } else {
                lease->next = client->offered_leases;
                client->offered_leases = lease;
        } else {
-               /* If we already have an offer, and arping for this
-                  offer would take us past the selection timeout,
-                  then don't extend the timeout - just hope for the
-                  best. */
-               if (client->offered_leases &&
-                   (cur_time + arp_timeout_needed) > stop_selecting)
-                       arp_timeout_needed = 0;
-
                /* Put the lease at the end of the list. */
                lease->next = NULL;
                if (!client->offered_leases)
                /* Put the lease at the end of the list. */
                lease->next = NULL;
                if (!client->offered_leases)
@@ -820,12 +769,6 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options)
                }
        }
 
                }
        }
 
-       /* If we're supposed to stop selecting before we've had time
-          to wait for the ARPREPLY, add some delay to wait for
-          the ARPREPLY. */
-       if (stop_selecting - cur_time < arp_timeout_needed)
-               stop_selecting = cur_time + arp_timeout_needed;
-
        /* If the selecting interval has expired, go immediately to
           state_selecting().  Otherwise, time out into
           state_selecting at the select interval. */
        /* If the selecting interval has expired, go immediately to
           state_selecting().  Otherwise, time out into
           state_selecting at the select interval. */
@@ -957,30 +900,6 @@ send_discover(void)
                return;
        }
 
                return;
        }
 
-       /* If we're selecting media, try the whole list before doing
-          the exponential backoff, but if we've already received an
-          offer, stop looping, because we obviously have it right. */
-       if (!client->offered_leases && config->media) {
-               int fail = 0;
-again:
-               if (client->medium) {
-                       client->medium = client->medium->next;
-                       increase = 0;
-               }
-               if (!client->medium) {
-                       if (fail)
-                               error("No valid media types for %s!", ifi->name);
-                       client->medium = config->media;
-                       increase = 1;
-               }
-
-               note("Trying medium \"%s\" %d", client->medium->string,
-                   increase);
-               script_init("MEDIUM", client->medium);
-               if (script_go())
-                       goto again;
-       }
-
        /*
         * If we're supposed to increase the interval, do so.  If it's
         * currently zero (i.e., we haven't sent any packets yet), set
        /*
         * If we're supposed to increase the interval, do so.  If it's
         * currently zero (i.e., we haven't sent any packets yet), set
@@ -1054,12 +973,8 @@ state_panic(void)
                            piaddr(client->active->address));
                        /* Run the client script with the existing
                           parameters. */
                            piaddr(client->active->address));
                        /* Run the client script with the existing
                           parameters. */
-                       script_init("TIMEOUT",
-                           client->active->medium);
+                       script_init("TIMEOUT");
                        script_write_params("new_", client->active);
                        script_write_params("new_", client->active);
-                       if (client->alias)
-                               script_write_params("alias_",
-                                   client->alias);
 
                        /* If the old lease is still good and doesn't
                           yet need renewal, go into BOUND state and
 
                        /* If the old lease is still good and doesn't
                           yet need renewal, go into BOUND state and
@@ -1115,9 +1030,7 @@ activate_next:
           tell the shell script that we failed to allocate an address,
           and try again later. */
        note("No working leases in persistent database - sleeping.");
           tell the shell script that we failed to allocate an address,
           and try again later. */
        note("No working leases in persistent database - sleeping.");
-       script_init("FAIL", NULL);
-       if (client->alias)
-               script_write_params("alias_", client->alias);
+       script_init("FAIL");
        script_go();
        client->state = S_INIT;
        add_timeout(cur_time + config->retry_interval, state_init);
        script_go();
        client->state = S_INIT;
        add_timeout(cur_time + config->retry_interval, state_init);
@@ -1147,44 +1060,19 @@ send_request(void)
        if ((client->state == S_REBOOTING ||
            client->state == S_REQUESTING) &&
            interval > config->reboot_timeout) {
        if ((client->state == S_REBOOTING ||
            client->state == S_REQUESTING) &&
            interval > config->reboot_timeout) {
-cancel:
                client->state = S_INIT;
                cancel_timeout(send_request);
                state_init();
                return;
        }
 
                client->state = S_INIT;
                cancel_timeout(send_request);
                state_init();
                return;
        }
 
-       /* If we're in the reboot state, make sure the media is set up
-          correctly. */
-       if (client->state == S_REBOOTING &&
-           !client->medium &&
-           client->active->medium) {
-               script_init("MEDIUM", client->active->medium);
-
-               /* If the medium we chose won't fly, go to INIT state. */
-               if (script_go())
-                       goto cancel;
-
-               /* Record the medium. */
-               client->medium = client->active->medium;
-       }
-
        /* If the lease has expired, relinquish the address and go back
           to the INIT state. */
        if (client->state != S_REQUESTING &&
            cur_time > client->active->expiry) {
                /* Run the client script with the new parameters. */
        /* If the lease has expired, relinquish the address and go back
           to the INIT state. */
        if (client->state != S_REQUESTING &&
            cur_time > client->active->expiry) {
                /* Run the client script with the new parameters. */
-               script_init("EXPIRE", NULL);
+               script_init("EXPIRE");
                script_write_params("old_", client->active);
                script_write_params("old_", client->active);
-               if (client->alias)
-                       script_write_params("alias_", client->alias);
-               script_go();
-
-               /* Now do a preinit on the interface so that we can
-                  discover a new address. */
-               script_init("PREINIT", NULL);
-               if (client->alias)
-                       script_write_params("alias_", client->alias);
                script_go();
 
                client->state = S_INIT;
                script_go();
 
                client->state = S_INIT;
@@ -1528,8 +1416,6 @@ write_client_lease(struct client_lease *lease, int rewrite)
        if (lease->server_name)
                fprintf(leaseFile, "  server-name \"%s\";\n",
                    lease->server_name);
        if (lease->server_name)
                fprintf(leaseFile, "  server-name \"%s\";\n",
                    lease->server_name);
-       if (lease->medium)
-               fprintf(leaseFile, "  medium \"%s\";\n", lease->medium->string);
        for (i = 0; i < 256; i++)
                if (lease->options[i].len)
                        fprintf(leaseFile, "  option %s %s;\n",
        for (i = 0; i < 256; i++)
                if (lease->options[i].len)
                        fprintf(leaseFile, "  option %s %s;\n",
@@ -1554,26 +1440,17 @@ write_client_lease(struct client_lease *lease, int rewrite)
 }
 
 void
 }
 
 void
-script_init(char *reason, struct string_list *medium)
+script_init(char *reason)
 {
 {
-       size_t           len, mediumlen = 0;
+       size_t           len;
        struct imsg_hdr  hdr;
        struct buf      *buf;
 
        struct imsg_hdr  hdr;
        struct buf      *buf;
 
-       if (medium != NULL && medium->string != NULL)
-               mediumlen = strlen(medium->string);
-
        hdr.code = IMSG_SCRIPT_INIT;
        hdr.code = IMSG_SCRIPT_INIT;
-       hdr.len = sizeof(struct imsg_hdr) +
-           sizeof(size_t) + mediumlen +
-           sizeof(size_t) + strlen(reason);
-
+       hdr.len = sizeof(struct imsg_hdr) + sizeof(size_t) + strlen(reason);
        buf = buf_open(hdr.len);
 
        buf_add(buf, &hdr, sizeof(hdr));
        buf = buf_open(hdr.len);
 
        buf_add(buf, &hdr, sizeof(hdr));
-       buf_add(buf, &mediumlen, sizeof(mediumlen));
-       if (mediumlen > 0)
-               buf_add(buf, medium->string, mediumlen);
        len = strlen(reason);
        buf_add(buf, &len, sizeof(len));
        buf_add(buf, reason, len);
        len = strlen(reason);
        buf_add(buf, &len, sizeof(len));
        buf_add(buf, reason, len);
@@ -1582,7 +1459,7 @@ script_init(char *reason, struct string_list *medium)
 }
 
 void
 }
 
 void
-priv_script_init(char *reason, char *medium)
+priv_script_init(char *reason)
 {
        client->scriptEnvsize = 100;
        if (client->scriptEnv == NULL)
 {
        client->scriptEnvsize = 100;
        if (client->scriptEnv == NULL)
@@ -1599,9 +1476,6 @@ priv_script_init(char *reason, char *medium)
 
        script_set_env("", "interface", ifi->name);
 
 
        script_set_env("", "interface", ifi->name);
 
-       if (medium)
-               script_set_env("", "medium", medium);
-
        script_set_env("", "reason", reason);
 }
 
        script_set_env("", "reason", reason);
 }
 
index 9567e0e..fe244a0 100644 (file)
@@ -1,4 +1,4 @@
-.\" $OpenBSD: src/sbin/dhclient/dhclient.conf.5,v 1.19 2011/03/27 06:50:48 jmc Exp $
+.\" $OpenBSD: src/sbin/dhclient/dhclient.conf.5,v 1.20 2011/04/04 11:14:52 krw Exp $
 .\"
 .\" Copyright (c) 1997 The Internet Software Consortium.
 .\" All rights reserved.
 .\"
 .\" Copyright (c) 1997 The Internet Software Consortium.
 .\" All rights reserved.
@@ -36,7 +36,7 @@
 .\" see ``http://www.isc.org/isc''.  To learn more about Vixie
 .\" Enterprises, see ``http://www.vix.com''.
 .\"
 .\" see ``http://www.isc.org/isc''.  To learn more about Vixie
 .\" Enterprises, see ``http://www.vix.com''.
 .\"
-.Dd August 2, 2012
+.Dd August 3, 2012
 .Dt DHCLIENT.CONF 5
 .Os
 .Sh NAME
 .Dt DHCLIENT.CONF 5
 .Os
 .Sh NAME
@@ -350,24 +350,6 @@ or, in the case of predefined leases declared in
 .Nm ,
 the value that the user wishes the client configuration script to use if the
 predefined lease is used.
 .Nm ,
 the value that the user wishes the client configuration script to use if the
 predefined lease is used.
-.It Ic medium Ar \&"media setup\&" ;
-The
-.Ic medium
-statement can be used on systems where network interfaces cannot
-automatically determine the type of network to which they are connected.
-The media setup string is a system-dependent parameter which is passed
-to the client configuration script when initializing the interface.
-On
-.Ux
-and UNIX-like systems, the argument is passed on the ifconfig command line
-when configuring the interface.
-.Pp
-The DHCP client automatically declares this parameter if it used a
-media type (see the
-.Ic media
-statement) when configuring the interface in order to obtain a lease.
-This statement should be used in predefined leases only if the network
-interface requires media type configuration.
 .It Ic renew Ar date ;
 .It Ic rebind Ar date ;
 .It Ic expire Ar date ;
 .It Ic renew Ar date ;
 .It Ic rebind Ar date ;
 .It Ic expire Ar date ;
@@ -412,27 +394,6 @@ The day of the month is likewise specified starting with 1.
 The hour is a number between 0 and 23,
 the minute a number between 0 and 59,
 and the second also a number between 0 and 59.
 The hour is a number between 0 and 23,
 the minute a number between 0 and 59,
 and the second also a number between 0 and 59.
-.Sh ALIAS DECLARATIONS
-.Ic alias No { Ar declarations ... No }
-.Pp
-Some DHCP clients running TCP/IP roaming protocols may require that in
-addition to the lease they may acquire via DHCP, their interface also
-be configured with a predefined IP alias so that they can have a
-permanent IP address even while roaming.
-The Internet Software Consortium DHCP client doesn't support roaming with
-fixed addresses directly, but in order to facilitate such experimentation,
-the DHCP client can be set up to configure an IP alias using the
-.Ic alias
-declaration.
-.Pp
-The
-.Ic alias
-declaration resembles a lease declaration, except that options other than
-the subnet-mask option are ignored by the standard client configuration
-script, and expiry times are ignored.
-A typical alias declaration includes an interface declaration, a fixed-address
-declaration for the IP alias address, and a subnet-mask option declaration.
-A medium statement should never be included in an alias declaration.
 .Sh OTHER DECLARATIONS
 .Bl -tag -width Ds
 .It Ic reject Ar ip-address ;
 .Sh OTHER DECLARATIONS
 .Bl -tag -width Ds
 .It Ic reject Ar ip-address ;
@@ -449,35 +410,13 @@ the bad DHCP server and fix it.
 .Xc
 A client with more than one network interface may require different
 behaviour depending on which interface is being configured.
 .Xc
 A client with more than one network interface may require different
 behaviour depending on which interface is being configured.
-All timing parameters and declarations other than lease and alias
+All timing parameters and declarations other than lease
 declarations can be enclosed in an interface declaration, and those
 parameters will then be used only for the interface that matches the
 specified name.
 Interfaces for which there is no interface declaration will use the
 parameters declared outside of any interface declaration,
 or the default settings.
 declarations can be enclosed in an interface declaration, and those
 parameters will then be used only for the interface that matches the
 specified name.
 Interfaces for which there is no interface declaration will use the
 parameters declared outside of any interface declaration,
 or the default settings.
-.It Xo
-.Ic media Ar \&"media setup\&"
-.Oo , Ar \&"media setup\&" , ... Oc ;
-.Xc
-The
-.Ic media
-statement defines one or more media configuration parameters which may
-be tried while attempting to acquire an IP address.
-The DHCP client will cycle through each media setup string on the list,
-configuring the interface using that setup and attempting to boot,
-and then trying the next one.
-This can be used for network interfaces which aren't capable of sensing
-the media type unaided \- whichever media type succeeds in getting a request
-to the server and hearing the reply is probably right (no guarantees).
-.Pp
-The media setup is only used for the initial phase of address
-acquisition (the DHCPDISCOVER and DHCPOFFER packets).
-Once an address has been acquired, the DHCP client will record it in its
-lease database and will record the media type used to acquire the address.
-Whenever the client tries to renew the lease, it will use that same media type.
-The lease must expire before the client will go back to cycling through media
-types.
 .It Ic script Ar \&"script-name\&" ;
 The
 .Ic script
 .It Ic script Ar \&"script-name\&" ;
 The
 .Ic script
@@ -494,8 +433,7 @@ For more information, see
 .El
 .Sh EXAMPLES
 The following configuration file is used on a laptop
 .El
 .Sh EXAMPLES
 The following configuration file is used on a laptop
-which has an IP alias of 192.5.5.213, and has one interface,
-ep0 (a 3Com 3C589C).
+which has one interface, ep0 (a 3Com 3C589C).
 Booting intervals have been shortened somewhat from the default, because
 the client is known to spend most of its time on networks with little DHCP
 activity.
 Booting intervals have been shortened somewhat from the default, because
 the client is known to spend most of its time on networks with little DHCP
 activity.
@@ -518,13 +456,6 @@ interface "ep0" {
            domain-name, domain-name-servers, host-name;
     require subnet-mask, domain-name-servers;
     script "/etc/dhclient-script";
            domain-name, domain-name-servers, host-name;
     require subnet-mask, domain-name-servers;
     script "/etc/dhclient-script";
-    media "media 10baseT/UTP", "media 10base2/BNC";
-}
-
-alias {
-  interface "ep0";
-  fixed-address 192.5.5.213;
-  option subnet-mask 255.255.255.255;
 }
 .Ed
 .Pp
 }
 .Ed
 .Pp
index e648cce..7d0d47b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/dhcpd.h,v 1.71 2010/07/02 22:03:27 deraadt Exp $    */
+/*     $OpenBSD: src/sbin/dhclient/dhcpd.h,v 1.72 2011/04/04 11:14:52 krw Exp $        */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -109,7 +109,6 @@ struct client_lease {
        struct iaddr             address;
        char                    *server_name;
        char                    *filename;
        struct iaddr             address;
        char                    *server_name;
        char                    *filename;
-       struct string_list      *medium;
        unsigned int             is_static : 1;
        unsigned int             is_bootp : 1;
        struct option_data       options[256];
        unsigned int             is_static : 1;
        unsigned int             is_bootp : 1;
        struct option_data       options[256];
@@ -146,11 +145,9 @@ struct client_config {
        time_t                   select_interval;
        time_t                   reboot_timeout;
        time_t                   backoff_cutoff;
        time_t                   select_interval;
        time_t                   reboot_timeout;
        time_t                   backoff_cutoff;
-       struct string_list      *media;
        char                    *script_name;
        enum { IGNORE, ACCEPT, PREFER }
                                 bootp_policy;
        char                    *script_name;
        enum { IGNORE, ACCEPT, PREFER }
                                 bootp_policy;
-       struct string_list      *medium;
        struct iaddrlist        *reject_list;
 };
 
        struct iaddrlist        *reject_list;
 };
 
@@ -159,14 +156,12 @@ struct client_state {
        struct client_lease      *new;
        struct client_lease      *offered_leases;
        struct client_lease      *leases;
        struct client_lease      *new;
        struct client_lease      *offered_leases;
        struct client_lease      *leases;
-       struct client_lease      *alias;
        enum dhcp_state           state;
        struct iaddr              destination;
        u_int32_t                 xid;
        u_int16_t                 secs;
        time_t                    first_sending;
        time_t                    interval;
        enum dhcp_state           state;
        struct iaddr              destination;
        u_int32_t                 xid;
        u_int16_t                 secs;
        time_t                    first_sending;
        time_t                    interval;
-       struct string_list       *medium;
        struct dhcp_packet        packet;
        int                       packet_length;
        struct iaddr              requested_address;
        struct dhcp_packet        packet;
        int                       packet_length;
        struct iaddr              requested_address;
@@ -310,11 +305,11 @@ void free_client_lease(struct client_lease *);
 void rewrite_client_leases(void);
 void write_client_lease(struct client_lease *, int);
 
 void rewrite_client_leases(void);
 void write_client_lease(struct client_lease *, int);
 
-void    priv_script_init(char *, char *);
+void    priv_script_init(char *);
 void    priv_script_write_params(char *, struct client_lease *);
 int     priv_script_go(void);
 
 void    priv_script_write_params(char *, struct client_lease *);
 int     priv_script_go(void);
 
-void script_init(char *, struct string_list *);
+void script_init(char *);
 void script_write_params(char *, struct client_lease *);
 int script_go(void);
 void script_set_env(const char *, const char *, const char *);
 void script_write_params(char *, struct client_lease *);
 int script_go(void);
 void script_set_env(const char *, const char *, const char *);
index bb2c241..4c626fa 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/privsep.c,v 1.15 2009/06/06 04:02:42 krw Exp $      */
+/*     $OpenBSD: src/sbin/dhclient/privsep.c,v 1.16 2011/04/04 11:14:52 krw Exp $      */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -94,9 +94,9 @@ void
 dispatch_imsg(int fd)
 {
        struct imsg_hdr          hdr;
 dispatch_imsg(int fd)
 {
        struct imsg_hdr          hdr;
-       char                    *medium, *reason, *filename,
+       char                    *reason, *filename,
                                *servername, *prefix;
                                *servername, *prefix;
-       size_t                   medium_len, reason_len, filename_len,
+       size_t                   reason_len, filename_len,
                                 servername_len, prefix_len, totlen;
        struct client_lease      lease;
        int                      ret, i, optlen;
                                 servername_len, prefix_len, totlen;
        struct client_lease      lease;
        int                      ret, i, optlen;
@@ -108,19 +108,8 @@ dispatch_imsg(int fd)
        case IMSG_SCRIPT_INIT:
                if (hdr.len < sizeof(hdr) + sizeof(size_t))
                        error("corrupted message received");
        case IMSG_SCRIPT_INIT:
                if (hdr.len < sizeof(hdr) + sizeof(size_t))
                        error("corrupted message received");
-               buf_read(fd, &medium_len, sizeof(medium_len));
-               if (hdr.len < medium_len + sizeof(size_t) + sizeof(hdr)
-                   + sizeof(size_t) || medium_len == SIZE_T_MAX)
-                       error("corrupted message received");
-               if (medium_len > 0) {
-                       if ((medium = calloc(1, medium_len + 1)) == NULL)
-                               error("%m");
-                       buf_read(fd, medium, medium_len);
-               } else
-                       medium = NULL;
-
                buf_read(fd, &reason_len, sizeof(reason_len));
                buf_read(fd, &reason_len, sizeof(reason_len));
-               if (hdr.len < medium_len + reason_len + sizeof(hdr) ||
+               if (hdr.len < reason_len + sizeof(hdr) + sizeof(size_t) ||
                    reason_len == SIZE_T_MAX)
                        error("corrupted message received");
                if (reason_len > 0) {
                    reason_len == SIZE_T_MAX)
                        error("corrupted message received");
                if (reason_len > 0) {
@@ -130,9 +119,8 @@ dispatch_imsg(int fd)
                } else
                        reason = NULL;
 
                } else
                        reason = NULL;
 
-               priv_script_init(reason, medium);
+               priv_script_init(reason);
                free(reason);
                free(reason);
-               free(medium);
                break;
        case IMSG_SCRIPT_WRITE_PARAMS:
                bzero(&lease, sizeof lease);
                break;
        case IMSG_SCRIPT_WRITE_PARAMS:
                bzero(&lease, sizeof lease);