diff options
-rw-r--r-- | etc/dhclient.conf | 3 | ||||
-rw-r--r-- | sbin/dhclient/clparse.c | 58 | ||||
-rw-r--r-- | sbin/dhclient/dhclient-script | 59 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 157 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.conf.5 | 77 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 11 | ||||
-rw-r--r-- | sbin/dhclient/privsep.c | 22 |
7 files changed, 47 insertions, 340 deletions
diff --git a/etc/dhclient.conf b/etc/dhclient.conf index bab65904083..b6c156b41de 100644 --- a/etc/dhclient.conf +++ b/etc/dhclient.conf @@ -1,4 +1,4 @@ -# $OpenBSD: dhclient.conf,v 1.1 1998/09/08 20:26:41 marc Exp $ +# $OpenBSD: dhclient.conf,v 1.2 2011/04/04 11:14:52 krw Exp $ # # DHCP Client Configuration # @@ -14,4 +14,3 @@ # request subnet-mask, broadcast-address, time-offset, routers, # domain-name, domain-name-servers, host-name, lpr-servers, ntp-servers; # require subnet-mask, domain-name-servers, routers; -# media "link0 link1", "link0 link1", "link0 link1", "-link0 link1"; diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 1bd7583502c..da7ed762dab 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.36 2009/07/19 00:18:02 stevesk Exp $ */ +/* $OpenBSD: clparse.c,v 1.37 2011/04/04 11:14:52 krw Exp $ */ /* 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: - parse_string_list(cfile, &config->media, 1); + skip_to_semi(cfile); 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, 2); + skip_to_semi(cfile); return; case TOK_REJECT: parse_reject_statement(cfile); @@ -426,12 +426,6 @@ parse_client_lease_statement(FILE *cfile, int is_static) 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 @@ -531,7 +525,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease) 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); @@ -720,50 +714,6 @@ bad_flag: } 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; diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script index 289320b4f03..0dd9e8c7e72 100644 --- a/sbin/dhclient/dhclient-script +++ b/sbin/dhclient/dhclient-script @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: dhclient-script,v 1.18 2011/03/27 12:15:46 krw Exp $ +# $OpenBSD: dhclient-script,v 1.19 2011/04/04 11:14:52 krw Exp $ # # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org> # @@ -23,14 +23,14 @@ 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 $rdomain delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1 fi } ip6_delete_old_address() { if [ -n "$old_ip6_address" ]; then - ifconfig $interface inet6 $old_ip6_address delete $medium + ifconfig $interface inet6 $old_ip6_address delete fi } @@ -38,8 +38,7 @@ add_new_address() { 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 $rdomain add $new_ip_address 127.0.0.1 >/dev/null 2>&1 @@ -48,24 +47,7 @@ add_new_address() { ip6_add_new_address() { ifconfig $interface \ inet6 $new_ip6_address \ - prefixlen $new_ip6_prefixlen \ - $medium -} - -delete_old_alias() { - if [ -n "$alias_ip_address" ]; then - ifconfig $interface \ - inet $alias_ip_address delete > /dev/null 2>&1 - route $rdomain 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 $rdomain add $alias_ip_address 127.0.0.1 - fi + prefixlen $new_ip6_prefixlen } delete_old_routes() { @@ -195,33 +177,30 @@ ip6_add_new_resolv_conf() { case $reason in MEDIUM) - ifconfig $interface $medium - sleep 1 + # Not called by OpenBSD dhclient(8). ;; PREINIT) - delete_old_alias - ifconfig $interface up + # Not called by OpenBSD dhclient(8). ;; PREINIT6) - ifconfig $interface up - ;; - -ARPCHECK) - # Always succeed. i.e. accept lease. + # Not called by OpenBSD dhclient(8). ;; ARPSEND) + # Not called by OpenBSD dhclient(8). # Always fail. i.e. don't wait for ARP packet here. 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 - 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 @@ -234,9 +213,6 @@ BOUND|RENEW|REBIND|REBOOT) add_new_address add_new_routes fi - if [ "$new_ip_address" != "$alias_ip_address" ]; then - add_new_alias - fi add_new_resolv_conf ;; @@ -255,13 +231,10 @@ BOUND6|RENEW6|REBIND6) ;; EXPIRE|FAIL) - delete_old_alias 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 @@ -274,15 +247,11 @@ EXPIRE6|RELEASE6|STOP6) ;; 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 - if [ "$new_ip_address" != "$alias_ip_address" ]; then - add_new_alias - fi add_new_routes if add_new_resolv_conf; then exit 0 diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index f900ef5baf4..377ef16d7f5 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.138 2011/03/27 12:15:46 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.139 2011/04/04 11:14:52 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -205,8 +205,7 @@ routehandler(void) for (l = client->leases; l != NULL; l = l->next) 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; @@ -264,9 +263,7 @@ routehandler(void) return; die: - script_init("FAIL", NULL); - if (client->alias) - script_write_params("alias_", client->alias); + script_init("FAIL"); script_go(); error("routehandler: %s", errmsg); } @@ -388,11 +385,6 @@ main(int argc, char *argv[]) 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"); @@ -497,9 +489,6 @@ state_reboot(void) client->first_sending = cur_time; client->interval = 0; - /* Zap the medium list... */ - client->medium = NULL; - /* Send out the first DHCPREQUEST packet. */ send_request(); } @@ -545,26 +534,11 @@ state_selecting(void) picked = NULL; 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) { - 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->next = NULL; } else { -freeit: + make_decline(lp); + send_decline(); free_client_lease(lp); } } @@ -578,6 +552,8 @@ freeit: 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) { client->new = picked; @@ -681,22 +657,16 @@ dhcpack(struct iaddr client_addr, struct option_data *options) 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" : - (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->alias) - script_write_params("alias_", client->alias); script_go(); /* Replace the old active lease with the new one. */ @@ -750,7 +720,7 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options) { 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"; @@ -790,19 +760,6 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options) 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; @@ -812,14 +769,6 @@ dhcpoffer(struct iaddr client_addr, struct option_data *options) 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) @@ -832,12 +781,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. */ @@ -967,30 +910,6 @@ send_discover(void) 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 @@ -1064,12 +983,8 @@ state_panic(void) 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); - 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 @@ -1125,9 +1040,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."); - 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); @@ -1157,44 +1070,19 @@ send_request(void) 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; } - /* 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. */ - script_init("EXPIRE", NULL); + script_init("EXPIRE"); 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; @@ -1538,8 +1426,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->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", @@ -1564,26 +1450,18 @@ write_client_lease(struct client_lease *lease, int rewrite) } 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; - if (medium != NULL && medium->string != NULL) - mediumlen = strlen(medium->string); - 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_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); @@ -1592,7 +1470,7 @@ script_init(char *reason, struct string_list *medium) } void -priv_script_init(char *reason, char *medium) +priv_script_init(char *reason) { char *rdomain; @@ -1617,9 +1495,6 @@ priv_script_init(char *reason, char *medium) script_set_env("", "rdomain", rdomain); free(rdomain); - if (medium) - script_set_env("", "medium", medium); - script_set_env("", "reason", reason); } diff --git a/sbin/dhclient/dhclient.conf.5 b/sbin/dhclient/dhclient.conf.5 index e4b92620384..c4754c29e43 100644 --- a/sbin/dhclient/dhclient.conf.5 +++ b/sbin/dhclient/dhclient.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.conf.5,v 1.19 2011/03/27 06:50:48 jmc Exp $ +.\" $OpenBSD: dhclient.conf.5,v 1.20 2011/04/04 11:14:52 krw Exp $ .\" .\" 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''. .\" -.Dd $Mdocdate: March 27 2011 $ +.Dd $Mdocdate: April 4 2011 $ .Dt DHCLIENT.CONF 5 .Os .Sh NAME @@ -352,24 +352,6 @@ or, in the case of predefined leases declared in .Nm dhclient.conf , 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 ; @@ -413,27 +395,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. -.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 ; @@ -450,35 +411,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. -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. -.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 @@ -495,8 +434,7 @@ For more information, see .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. @@ -519,13 +457,6 @@ interface "ep0" { 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 diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index c7bb9eca06c..1c686ade33b 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.71 2010/07/02 22:03:27 deraadt Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.72 2011/04/04 11:14:52 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -110,7 +110,6 @@ struct client_lease { 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]; @@ -147,11 +146,9 @@ struct client_config { 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; - struct string_list *medium; struct iaddrlist *reject_list; }; @@ -160,14 +157,12 @@ struct client_state { 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; - struct string_list *medium; struct dhcp_packet packet; int packet_length; struct iaddr requested_address; @@ -313,11 +308,11 @@ void free_client_lease(struct client_lease *); 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 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 *); diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c index c5feb4f26d1..9f755b6ee73 100644 --- a/sbin/dhclient/privsep.c +++ b/sbin/dhclient/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.15 2009/06/06 04:02:42 krw Exp $ */ +/* $OpenBSD: privsep.c,v 1.16 2011/04/04 11:14:52 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -94,9 +94,9 @@ void dispatch_imsg(int fd) { struct imsg_hdr hdr; - char *medium, *reason, *filename, + char *reason, *filename, *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; @@ -108,19 +108,8 @@ dispatch_imsg(int fd) 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)); - 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) { @@ -130,9 +119,8 @@ dispatch_imsg(int fd) } else reason = NULL; - priv_script_init(reason, medium); + priv_script_init(reason); free(reason); - free(medium); break; case IMSG_SCRIPT_WRITE_PARAMS: bzero(&lease, sizeof lease); |