--- dhcpcd-3.2.3.orig/dhcp.c +++ dhcpcd-3.2.3/dhcp.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include "config.h" @@ -327,6 +329,34 @@ #endif message_length = p - m; + +#if __linux__ + /* send_packet() always sends to the hardware broadcast address, which is + broken when the client and server are in different broadcast domains + and using a dhcp-helper and a renewal is in progress, since the client + sends direct to the server and the intermediate router will likely drop + broadcast addresses. + + This fix only works under Linux, where we have a UDP socket suitabley + set up which we can use to send in that case. */ + + if (to.s_addr != 0 && iface->listen_fd != -1) + { + struct sockaddr_in dest; + dest.sin_family = AF_INET; + dest.sin_port = htons (DHCP_SERVER_PORT); + dest.sin_addr = to; + + logger (LOG_DEBUG, "sending %s with xid 0x%x over UDP socket", + dhcp_message (type), xid); + + retval = sendto(iface->listen_fd, message, message_length, 0 , + (struct sockaddr *)&dest, sizeof(dest)); + free(message); + + return retval; + } +#endif packet = xzalloc (sizeof (*packet)); make_dhcp_packet (packet, (unsigned char *) message, message_length, @@ -599,6 +629,98 @@ return (head); } +int check_domain_name(const char *ptr, size_t len, int dots) +{ + const char *p; + + /* not empty or complete length not over 255 characters */ + if (len == 0 || len >= 256) + return -1; + + /* consists of [[:alnum:]-]+ labels separated by [.] */ + /* a [_] is against RFC but seems to be "widely used"... */ + for (p=ptr; *p && len-- > 0; p++) { + if ( *p == '-' || *p == '_') { + /* not allowed at begin or end of a label */ + if ((p - ptr) == 0 || len == 0 || p[1] == '.') + return -1; + } else + if ( *p == '.') { + /* each label has to be 1-63 characters; + we allow [.] at the end ('foo.bar.') */ + ptrdiff_t d = p - ptr; + if( d <= 0 || d >= 64) + return -1; + ptr = p + 1; /* jump to the next label */ + if(dots > 0 && len > 0) + dots--; + } else + if ( !isalnum((unsigned char)*p)) { + /* also numbers at the begin are fine */ + return -1; + } + } + return dots ? -1 : 0; +} + +int check_domain_name_list(const char *ptr, size_t len, int dots) +{ + const char *p; + int ret = -1; /* at least one needed */ + + if (!ptr || !len) + return -1; + + for (p=ptr; *p && len > 0; p++, len--) { + if (*p != ' ') + continue; + if (p > ptr) { + if (check_domain_name(ptr, p - ptr, dots) != 0) + return -1; + ret = 0; + } + ptr = p + 1; + } + if (p > ptr) + return check_domain_name(ptr, p - ptr, dots); + else + return ret; +} + +int check_dhcp_option(unsigned char option, const char *ptr, size_t len) +{ + if( !ptr) + return -1; + + switch (option) { + case DHCP_HOSTNAME: + case DHCP_NISDOMAIN: + case DHCP_SIPSERVER: + case DHCP_DNSDOMAIN: /* accept a list for compatibiliy */ + case DHCP_DNSSEARCH: + return check_domain_name_list(ptr, len, 0); + break; + case DHCP_ROOTPATH: + if( len == 0) + return -1; + for (; *ptr && len-- > 0; ptr++) { + if( !(isalnum((unsigned char)*ptr) || + *ptr == '#' || *ptr == '%' || + *ptr == '+' || *ptr == '-' || + *ptr == '_' || *ptr == ':' || + *ptr == '.' || *ptr == ',' || + *ptr == '@' || *ptr == '~' || + *ptr == '\\' || *ptr == '/' || + *ptr == '[' || *ptr == ']' || + *ptr == '=' || *ptr == ' ')) + return -1; + } + return 0; + break; + } + return 0; +} + static struct route_head *decode_routers (const unsigned char *data, int length) { int i; @@ -646,8 +768,16 @@ dhcp->leasedfrom = tv.tv_sec; dhcp->frominfo = false; dhcp->address.s_addr = message->yiaddr; - strlcpy (dhcp->servername, (char *) message->servername, - sizeof (dhcp->servername)); + if (message->servername[0] != '\0' && + check_domain_name((const char *)message->servername, + strlen((const char *)message->servername), 0) != 0) + { + logger (LOG_ERR, "suspect value in SERVERNAME - discarded"); + dhcp->servername[0] = '\0'; + } else { + strlcpy (dhcp->servername, (char *) message->servername, + sizeof (dhcp->servername)); + } #define LEN_ERR \ { \ @@ -761,6 +891,13 @@ #undef GET_UINT16 #undef GET_UINT8 +#define CHECKOPT(_opt,_var) \ + if(check_dhcp_option(_opt, (const char *)p, length) != 0) { \ + logger (LOG_ERR, "suspect value in option %s - discarded", #_opt); \ + if (_var) free (_var); \ + _var = NULL; \ + } + #define GETSTR(_var) { \ MIN_LENGTH (sizeof (char)); \ if (_var) free (_var); \ @@ -769,9 +906,13 @@ memset (_var + length, 0, 1); \ } case DHCP_HOSTNAME: + CHECKOPT (DHCP_HOSTNAME, dhcp->hostname) + else GETSTR (dhcp->hostname); break; case DHCP_DNSDOMAIN: + CHECKOPT (DHCP_DNSDOMAIN, dhcp->dnsdomain) + else GETSTR (dhcp->dnsdomain); break; case DHCP_MESSAGE: @@ -779,11 +920,15 @@ break; #ifdef ENABLE_INFO case DHCP_ROOTPATH: + CHECKOPT (DHCP_ROOTPATH, dhcp->rootpath) + else GETSTR (dhcp->rootpath); break; #endif #ifdef ENABLE_NIS case DHCP_NISDOMAIN: + CHECKOPT (DHCP_NISDOMAIN, dhcp->nisdomain) + else GETSTR (dhcp->nisdomain); break; #endif @@ -814,11 +959,21 @@ case DHCP_DNSSEARCH: MIN_LENGTH (1); free (dhcp->dnssearch); + dhcp->dnssearch = NULL; len = decode_search (p, length, NULL); if (len > 0) { - dhcp->dnssearch = xmalloc (len); - decode_search (p, length, - dhcp->dnssearch); + char *str = xmalloc (len); + decode_search (p, length, str); + if (check_dhcp_option(DHCP_DNSSEARCH, + str, len - 1) != 0) { + logger (LOG_ERR, + "suspect value in " + "option %s - discarded", + "DHCP_DNSSEARCH"); + free(str); + } else { + dhcp->dnssearch = str; + } } break; @@ -836,8 +991,22 @@ #ifdef ENABLE_INFO case DHCP_SIPSERVER: - free (dhcp->sipservers); - dhcp->sipservers = decode_sipservers (p,length); + if(dhcp->sipservers) + free (dhcp->sipservers); + dhcp->sipservers = NULL; + { + char *str = decode_sipservers (p,length); + if(str && check_dhcp_option(DHCP_SIPSERVER, + str, strlen(str)) != 0) { + logger (LOG_ERR, + "suspect value in " + "option %s - discarded", + "DHCP_SIPSERVER"); + free(str); + } else { + dhcp->sipservers = str; + } + } break; #endif @@ -873,6 +1042,7 @@ #undef LENGTH #undef MIN_LENGTH #undef MULT_LENGTH +#undef CHECKOPT default: logger (LOG_DEBUG, --- dhcpcd-3.2.3.orig/dhcpcd.c +++ dhcpcd-3.2.3/dhcpcd.c @@ -178,8 +178,10 @@ options->doduid = true; options->timeout = DEFAULT_TIMEOUT; - gethostname (options->hostname, sizeof (options->hostname)); - if (strcmp (options->hostname, "(none)") == 0 || + memset (options->hostname, 0, sizeof (options->hostname)); + gethostname (options->hostname, sizeof (options->hostname) - 1); + options->hostname[sizeof (options->hostname) - 1] = '\0'; + if (check_domain_name(options->hostname, strlen(options->hostname), 0) != 0 || strcmp (options->hostname, "localhost") == 0) memset (options->hostname, 0, sizeof (options->hostname)); @@ -228,6 +230,9 @@ "`%s' too long for HostName string, max is %d", optarg, MAXHOSTNAMELEN); goto abort; + } else if(check_domain_name(optarg, strlen(optarg), 0) != 0) { + logger (LOG_ERR, "suspect string in hostname argument"); + goto abort; } else strlcpy (options->hostname, optarg, sizeof (options->hostname)); --- dhcpcd-3.2.3.orig/Makefile +++ dhcpcd-3.2.3/Makefile @@ -24,6 +24,7 @@ LDADD+= ${LIBRESOLV} ${LIBRT} CFLAGS+= -DINFODIR=\"${INFOD}\" ${FORK} ${RC} +CFLAGS+= ${COPTS} # As version.h is generated by us, hardcode the depend correctly. ${SRCS}: version.h --- dhcpcd-3.2.3.orig/version.h +++ dhcpcd-3.2.3/version.h @@ -0,0 +1 @@ +#define VERSION "3.2.3" --- dhcpcd-3.2.3.orig/dhcpcd.8 +++ dhcpcd-3.2.3/dhcpcd.8 @@ -0,0 +1,365 @@ +.\" Copyright 2006-2008 Roy Marples +.\" All rights reserved +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd Feb 20, 2008 +.Dt DHCPCD 8 SMM +.Sh NAME +.Nm dhcpcd +.Nd an RFC 2131 compliant DHCP client +.Sh SYNOPSIS +.Nm +.Op Fl dknpAEGHMLNRSTY +.Op Fl c , -script Ar script +.Op Fl h , -hostname Ar hostname +.Op Fl i , -classid Ar classid +.Op Fl l , -leasetime Ar seconds +.Op Fl m , -metric Ar metric +.Op Fl r , -request Ar address +.Op Fl t , -timeout Ar seconds +.Op Fl u , -userclass Ar class +.Op Fl F , -fqdn Ar FQDN +.Op Fl I , -clientid Ar clientid +.Ar interface +.Nm +.Fl k , -release +.Ar interface +.Nm +.Fl x , -exit +.Ar interface +.Sh DESCRIPTION +.Nm +is an implementation of the DHCP client specified in +.Rs +.%T "RFC 2131" +.Re +.Nm +gets the host information +.Po +IP address, routes, etc +.Pc +from a DHCP server and configures the network +.Ar interface +of the +machine on which it is running. +.Nm +will then write DNS information to +.Xr resolvconf 8 , +if available, otherwise directly to +.Pa /etc/resolv.conf . +.Nm +will also configure +.Pa /etc/yp.conf +and +.Pa /etc/ntpd.conf +with NIS and NTP information if the DHCP server provided them. +If those file contents changed, then +.Nm +will also attempt to restart the respective services to notify them of the +change. +If the hostname is currenly blank, (null) or localhost then +.Nm +will set the hostname to the one supplied by the DHCP server, or look it up +in DNS if none supplied. +.Nm +then daemonises and waits for the lease renewal time to lapse. +Then it attempts to renew its lease and reconfigure if the new lease changes. +.Ss Local Link configuration +If +.Nm +failed to obtain a lease, it will probe for a valid IPv4LL address +.Po +aka Zeroconf, aka APIPA +.Pc . +Once obtained it will probe every 10 seconds for a DHCP server to get a +proper address. +.Pp +Even when +.Nm +obtains a proper lease, it will still add a Local Link route +.Po +165.254.0.0/16 +.Pc +so that the host can communicate with clients using these addresses. +.Pp +When using IPv4LL, +.Nm +will always succeed and return a 0 exit code. To disable this behaviour, you +can use the +.Fl L , -noipv4ll +option. +.Ss Hooking into DHCP events +.Nm +will run /etc/dhcpcd.sh, or the script specified by the +.Fl c , -script +option. It will set $1 to a shell compatible file that holds various +configuration settings obtained from the DHCP server and $2 to either +up, down or new depending on the state of +.Nm . +.Nm +ignores the exist code of the script. +.Ss Fine tuning +You can fine tune the behaviour of +.Nm +with the following options :- +.Bl -tag -width indent +.It Fl d , -debug +Echo debug and informational messages to the console. +Subsequent debug options stop +.Nm +from daemonising. +.It Fl h , -hostname Ar hostname +By default, +.Nm +will send the current hostname to the DHCP server so it can register in DNS. +You can use this option to specify the +.Ar hostname +sent, or an empty string to +stop any +.Ar hostname +from being sent. +.It Fl i , -classid Ar classid +Override the DHCP vendor +.Ar classid +field we send. The default is +dhcpcd-. +.It Fl k , -release +This causes an existing +.Nm +process running on the +.Ar interface +to release it's lease, deconfigure the +.Ar interface +and then exit. +.It Fl l , -leasetime Ar seconds +Request a specific lease time in +.Ar seconds . +By default +.Nm +does not request any lease time and leaves the it in the hands of the +DHCP server. +.It Fl m , -metric Ar metric +Added routes will use the +.Ar metric +on systems where this is supported +.Po +presently only Linux +.Pc . +Route metrics allow the addition of routes to the same destination across +different interfaces, the lower the metric the more it is preferred. +.It Fl n , -renew +Notifies an existing +.Nm +process running on the +.Ar interface +to renew it's lease. If +.Nm +is not running, then it starts up as normal. +.It Fl p , -persistent +.Nm +normally deconfigures the +.Ar interface +and configuration when it exits. +Sometimes, this isn't desirable if for example you have root mounted over NFS. +You can use this option to stop this from happening. +.It Fl r , -request Op Ar address +.Nm +normally sends a DHCP Broadcast to find servers to offer an address. +.Nm +will then request the address used. You can use this option to skip the +broadcast step and just request an +.Ar address . +The downside is if you request +an +.Ar address +the DHCP server does not know about or the DHCP server is not +authorative, it will remain silent. In this situation, we go back to the init +state and broadcast again. +If no +.Ar address +is given then we use the first address currently assigned to the +.Ar interface . +.It Fl s , -inform Op Ar address Op / Ar cidr +Behaves exactly like +.Fl r , -request +as above, but sends a DHCP inform instead of a request. This requires the +interface to be configured first. This does not get a lease as such, just +notifies the DHCP server of the +.Ar address +we are using. +.It Fl t , -timeout Ar seconds +Timeout after +.Ar seconds , +instead of the default 20. +A setting of 0 +.Ar seconds +causes +.Nm +to wait forever to get a lease. +.It Fl u , -userclass Ar class +Tags the DHCP message with the userclass +.Ar class . +DHCP servers use this give memebers of the class DHCP options other than the +default, without having to know things like hardware address or hostname. +.If Fl F , -fqdn Ar fqdn +Requests that the DHCP server updates DNS using FQDN instead of just a +hostname. Valid values for +.Ar fqdn +are none, ptr and both. +.Nm +dhcpcd itself never does any DNS updates. +.It Fl H , --sethostname +Forces +.Nm +to set the hostname as supplied by the DHCP server. Because some OS's and users +prefer to have just the hostname, or the full FQDN more +.Fl H , --sethostname +options change the behaviour. Below is the list of possible combinations:- +.Bl -tag -width indent +.It Fl H +set the hostname to the full FQDN. +.It Fl HH +strip the domain if it matches the dns domain. +.It Fl HHH +strip the domain regardless. +.It Fl HHHH +same as +.Fl H +but force hostname lookup via DNS. +.It Fl HHHHH +same as above, but strip the domain if it matches the dns domain. +.It Fl HHHHHH +same as above, but strip the domain regardless. +.El +.It Fl I , -clientid Ar clientid +Send +.Ar clientid +as a client identifier string. If +.Ar clientid +matches a hardware address format, such as 01:00:01:02:03:04:05 then we encode +it as that, otherwise as a string. You need to specify the hardware type in +the first byte. Ethernet is 01, and the hardware address in the example is +00:01:02:03:04:05. If the +.Ar clientid +is a blank string, then we disable DUID support and use a +.Ar clientid +as shown above. +.It Fl S, -mscsr +Microsoft have their own code for Classless Static Routes +.Po +RFC 3442 +.Pc . +You can use this option to request this as well as the normal CSR. Another +instace of this option only requests the Microsoft CSR to prevent DHCP message +over-running its maximum size. DHCP server administrators should update their +CSR code from the Microsoft specific one to the RFC compliant one as the +content is fully compatible. +.El +.Ss Restriciting behaviour +.Nm +will try to do as much as it can by default. However, there are sometimes +situations where you don't want the things to be configured exactly how the +the DHCP server wants. Here are some option that deal with turning these bits +off. +.Bl -tag -width indent +.It Fl A , -noarp +Don't request or claim the address by ARP. +.It Fl G , -nogateway +Don't set any default routes. +.It Fl L , -noipv4ll +Don't use IPv4LL at all. +.It Fl M , -nomtu +Don't set the MTU of the +.Ar interface . +.It Fl N , -nontp +Don't touch +.Pa /etc/ntpd.conf +or restart the ntp service. +.It Fl R , -nodns +Don't send DNS information to resolvconf or touch +.Pa /etc/resolv.conf . +.It Fl T , -test +On receipt of discover messages, simply print the contents of the DHCP +message to the console. +.Nm +will not configure the +.Ar interface , +touch any files or restart any services. +.It Fl Y , -nonis +Don't touch +.Pa /etc/yp.conf +or restart the ypbind service. +.El +.Sh NOTES +Because +.Nm +supports InfiniBand, we put a Node-specific Client Identifier in the +ClientID field. This is required by RFC 4390. It's also required for DHCP IPv6 +which +.Nm +should support one day. However, some DHCP servers have no idea what this is +and reject the message as they do not understand type 255. This is not +conformant with RFC 2132 and the server should be fixed. Also, some DHCP +server configurations require an ethernet hardware address of 6 hexacdecimal +numbers in the ClientID which is the default behaviour of most other DHCP +clients. If your DHCP server is as desribed above, you should fix the server, +or if that is not an option you can compile DUID support out of +.Nm +or use the +.Fl I , -clientid Ar clientid +option and set +.Ar clientid +to ''. +.Pp +ISC dhcpd, dnsmasq, udhcpd and Microsoft DHCP server 2003 default configurations +work just fine with the default +.Nm +configuration. +.Pp +.Nm +requires a Berkley Packet Filter, or BPF device on BSD based systems and a +Linux Socket Filter, or LPF device on Linux based systems. +.Sh FILES +.Bl -ohang +.It Pa /etc/dhcpcd.sh +Bourne shell script that is run when we configure or deconfigure an interface. +.It Pa /var/lib/dhcpcd/dhcpcd.duid +Text file that holds the DUID used to identify the host. +.It Pa /var/lib/dhcpcd/dhcpcd- Ns Ar interface Ns .info +Bourne shell file that holds the DHCP values used in configuring the interface. +This path is passed as the first argument to +.Pa /etc/dhcpcd.sh . +.El +.Sh SEE ALSO +.Xr ntp 1 , +.Xr resolv.conf 5 , +.Xr resolvconf 8 , +.Xr yp.conf 5 , +.Xr ypbind 8 +.Sh STANDARDS +RFC 2131, RFC 2132, RFC 2855, RFC 3004, RFC 3361, RFC 3397, RFC 3442, RFC 3927, +RFC 4361, RFC 4390, RFC 4702. +.Sh AUTHORS +.An "Roy Marples" Aq roy@marples.name +.Sh BUGS +Please report them to http://bugs.marples.name --- dhcpcd-3.2.3.orig/interface.c +++ dhcpcd-3.2.3/interface.c @@ -35,6 +35,7 @@ /* Netlink suff */ #ifdef __linux__ +/* typedef unsigned long long __u64; */ /* broken in later headers */ #include /* Needed for 2.4 kernels */ #include #include --- dhcpcd-3.2.3.orig/configure.c +++ dhcpcd-3.2.3/configure.c @@ -453,7 +453,7 @@ char *addr; struct addrinfo hints; struct addrinfo *res = NULL; - int result; + int result, check; char *p; logger (LOG_DEBUG, "Looking up hostname via DNS"); @@ -479,9 +479,10 @@ result = getaddrinfo (addr, "0", &hints, &res); if (res) freeaddrinfo (res); - if (result == 0) + check = check_domain_name(addr, strlen(addr), 0); + if (result == 0 || check != 0) logger (LOG_ERR, "malicious PTR record detected"); - if (result == 0 || ! *addr) { + if (result == 0 || ! *addr || check != 0) { free (addr); return (NULL); } @@ -758,12 +759,12 @@ #endif curhostname = xmalloc (sizeof (char) * MAXHOSTNAMELEN); - *curhostname = '\0'; + memset(curhostname, 0, MAXHOSTNAMELEN); - gethostname (curhostname, MAXHOSTNAMELEN); + gethostname (curhostname, MAXHOSTNAMELEN - 1); + curhostname[MAXHOSTNAMELEN - 1] = '\0'; if (options->dohostname || - strlen (curhostname) == 0 || - strcmp (curhostname, "(none)") == 0 || + check_domain_name(curhostname, strlen (curhostname), 0) != 0 || strcmp (curhostname, "localhost") == 0) { newhostname = xmalloc (sizeof (char) * MAXHOSTNAMELEN); --- dhcpcd-3.2.3.orig/dhcp.h +++ dhcpcd-3.2.3/dhcp.h @@ -212,5 +212,9 @@ uint32_t xid, char type, const options_t *options); void free_dhcp (dhcp_t *dhcp); int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message); +int check_dhcp_option(unsigned char option, const char *ptr, size_t len); +int check_domain_name(const char *ptr, size_t len, int dots); +int check_domain_name_list(const char *ptr, size_t len, int dots); + #endif --- dhcpcd-3.2.3.orig/debian/dhcpcd +++ dhcpcd-3.2.3/debian/dhcpcd @@ -0,0 +1,105 @@ +#!/bin/bash + +# dhcpcd doesn't support a config file, just command line options. +# ifup can set some options (-h -i -I -l) but no others. +# This wrapper adds any other options set in /etc/default/dhcpcd +# (and the hostname if not set by ifup or /etc/default/dhcpcd) +# and then calls the dhcpcd binary, named dhcpcd-bin. +# +# Note that this wrapper _requires_ the interface name: it doesn't support +# the eth0 default that dhcpcd proper does. + +if [ "$1" = "--version" ]; then echo "3.2.3"; exit 0; fi + +# get interface +eval INTERFACE=\${$#} +if [ $# = 0 ] || + [ ${INTERFACE:0:1} = '-' ] +then + echo "Usage: dhcpcd [options] " + exit 1 +fi + + +# determine if we will add the option to send the current hostname +sendhost=yes +sethost=no +setclid=yes + +for o +do + if [ x"$o" = x"-h" ]; then + sendhost=no + fi + if [ x"$o" = x"-H" ]; then + sethost=yes + fi + if [ x"$o" = x"-I" ]; then + setclid=no + fi +done + +# load configuration file +if [ -f /etc/default/dhcpcd ] ; then + . /etc/default/dhcpcd +fi + +for o in ${OPTIONS[@]} +do + if [ "$o" = "-h" ]; then + sendhost=no + fi + if [ "$o" = "-H" ]; then + sethost=yes + fi + if [ x"$o" = x"-I" ]; then + setclid=no + fi +done + +# Note that in the absence of /etc/default/dhcpcd we play safe and disallow +# changes to /etc/resolv.conf and friends. + +if [ "$SET_DNS" != "yes" ]; then + OPTIONS=("-R" "${OPTIONS[@]}") +fi + +#if [ "$SET_DOMAIN" = "yes" ]; then +# OPTIONS="-D $OPTIONS" +#fi + +if [ "$SET_HOSTNAME" = "yes" ]; then + OPTIONS=("-H" "${OPTIONS[@]}") + sethost=yes +fi + +if [ "$SET_NTP" != "yes" ]; then + OPTIONS=("-N" "${OPTIONS[@]}") +fi + +if [ "$SET_YP" != "yes" ]; then + OPTIONS=("-Y" "${OPTIONS[@]}") +fi + +# We tell dhcpcd to send the hostname iff the option is not +# already set by our caller, and the hostname will not be changed +# by dhcpcd + +if [ $sendhost = yes ] && + [ $sethost = no ] && + [ -x /bin/hostname ] +then + name=`/bin/hostname` + if [ ${#name} != 0 ]; then + OPTIONS=("-h" "$name" "${OPTIONS[@]}") + fi +fi + +# if we have been upgraded, /etc/dhcpc/inhibit-duid will exist, +# so for the client-id to be backwards compatible unless explicitly set +if [ $setclid = yes ] && + [ -f /etc/dhcpc/inhibit-duid ]; then + exec /sbin/dhcpcd-bin -I '' "${OPTIONS[@]}" "$@" +else + exec /sbin/dhcpcd-bin "${OPTIONS[@]}" "$@" +fi --- dhcpcd-3.2.3.orig/debian/copyright +++ dhcpcd-3.2.3/debian/copyright @@ -0,0 +1,40 @@ + +Version 1.3.x was originally downloaded from: + + ftp://phystech.com/pub/ + +Version 2.x.x was downloaded from + + http://developer.berlios.de/projects/dhcpcd/ + +Version 3.x.x was downloaded from + + http://roy.marples.name/dhcpcd + +Copyright: + + * dhcpcd - DHCP client daemon + * Copyright 2006-2008 Roy Marples + * All rights reserved + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + --- dhcpcd-3.2.3.orig/debian/postinst +++ dhcpcd-3.2.3/debian/postinst @@ -0,0 +1,23 @@ +#!/bin/sh -e + +# /etc/dhcpc/resolv.conf is now a link to /var/lib/dhcpcd/resolv.conf +rm -f /etc/dhcpc/resolv.conf +ln -s /var/lib/dhcpcd/resolv.conf /etc/dhcpc/resolv.conf + +# remove older-version state dir. +rm -rf /var/lib/dhcpc + +# share binary and man page with dhcpcd5 +update-alternatives --quiet --install /sbin/dhcpcd dhcpcd /sbin/dhcpcd3 100 \ + --slave /usr/share/man/man8/dhcpcd.8.gz dhcpcd.8.gz \ + /usr/share/man/man8/dhcpcd3.8.gz + +update-alternatives --auto dhcpcd + +#DEBHELPER# + + + + + + --- dhcpcd-3.2.3.orig/debian/control +++ dhcpcd-3.2.3/debian/control @@ -0,0 +1,18 @@ +Source: dhcpcd +Section: net +Priority: optional +Build-Depends: debhelper (>>2.0.0) +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Simon Kelley +Standards-Version: 3.7.3 + +Package: dhcpcd +Architecture: any +Depends: ${shlibs:Depends}, bsdutils (>=2.11n), procps +Replaces: dhcpcd-sv +Conflicts: dhcpcd-sv, ifupdown (<< 0.6.4-4) +Description: DHCP client for automatically configuring IPv4 networking + Simple configuration: supports executions of a script when the + IP address changes. + + --- dhcpcd-3.2.3.orig/debian/rules +++ dhcpcd-3.2.3/debian/rules @@ -0,0 +1,77 @@ +#!/usr/bin/make -f +# -*-makefile-*- +# Made with the aid of dh_make, by Craig Small +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. +# Some lines taken from debmake, by Cristoph Lameter. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# policy manual, section 10.1 +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + COPTS = -g -O0 -Wall -W -DENABLE_INFO_COMPAT +else + COPTS = -g -O2 -Wall -W -DENABLE_INFO_COMPAT +endif + + +configure-stamp: + dh_testdir + touch configure-stamp + +build: configure-stamp + dh_testdir + $(MAKE) COPTS="$(COPTS)" + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f *.o core *.core *~ dhcpcd + dh_clean -Pdebian/tmp + +# Build architecture-independent files here. +binary-indep: build +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build +# dh_testversion + dh_testdir + dh_testroot + dh_clean -k -Pdebian/tmp + dh_installdirs -Pdebian/tmp + + install dhcpcd debian/tmp/sbin/dhcpcd-bin + install debian/dhcpcd debian/tmp/sbin/dhcpcd3 + install -m 644 debian/config debian/tmp/etc/default/dhcpcd + install debian/dhcpcd.sh debian/tmp/etc + install -d debian/tmp/var/lib/dhcpc + + dh_installdocs -Pdebian/tmp README + dh_installchangelogs -Pdebian/tmp + + install dhcpcd.8 debian/tmp/usr/share/man/man8/dhcpcd-bin.8 + install debian/dhcpcd.8 debian/tmp/usr/share/man/man8/dhcpcd3.8 + gzip -9 debian/tmp/usr/share/man/man8/dhcpcd-bin.8 + gzip -9 debian/tmp/usr/share/man/man8/dhcpcd3.8 + + dh_strip -Pdebian/tmp + dh_compress -Pdebian/tmp + dh_fixperms -Pdebian/tmp + dh_installdeb -Pdebian/tmp + dh_shlibdeps -Pdebian/tmp + dh_gencontrol -Pdebian/tmp + dh_md5sums -Pdebian/tmp + dh_builddeb -Pdebian/tmp + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary + + + + --- dhcpcd-3.2.3.orig/debian/preinst +++ dhcpcd-3.2.3/debian/preinst @@ -0,0 +1,25 @@ +#!/bin/sh -e + +# The name of the lease-change script changed. +# Move it here, but leave a link from the old name. + +if [ -f /etc/dhcpc/dhcpcd.exe ] && [ ! -f /etc/dhcpcd.sh ]; then + mv /etc/dhcpc/dhcpcd.exe /etc/dhcpcd.sh + ln -s /etc/dhcpcd.sh /etc/dhcpc/dhcpcd.exe +fi + +if [ -f /etc/dhcpc/config ] && [ ! -f /etc/default/dhcpcd ]; then + mv /etc/dhcpc/config /etc/default/dhcpcd + ln -s /etc/default/dhcpcd /etc/dhcpc/config +fi + +# If upgrading from a version prior to 3.2.1, we create the +# file /etc/dhcpc/inhibit-duid so that hosts don't suddenly change +# their client-id and move IP addresses. New installations can use DUID +# from the start with no problems. + +if [ $1 = upgrade ]; then + if [ -n $2 ] && dpkg --compare-versions $2 lt 3.2.1-1; then + echo "Remove this file to make dhcpcd use DUID-based client-ids" >/etc/dhcpc/inhibit-duid + fi +fi --- dhcpcd-3.2.3.orig/debian/dhcpcd.dirs +++ dhcpcd-3.2.3/debian/dhcpcd.dirs @@ -0,0 +1,4 @@ +sbin +usr/share/man/man8 +etc/default +etc/dhcpc --- dhcpcd-3.2.3.orig/debian/prerm +++ dhcpcd-3.2.3/debian/prerm @@ -0,0 +1,15 @@ +#!/bin/sh -e + +rm -f /etc/dhcpc/duid-inhibit + +if [ "$1" != "upgrade" ]; then + update-alternatives --remove dhcpcd /sbin/dhcpcd3 +fi + +#DEBHELPER# + + + + + + --- dhcpcd-3.2.3.orig/debian/README.debian +++ dhcpcd-3.2.3/debian/README.debian @@ -0,0 +1,51 @@ +dhcpcd for Debian +----------------- + +Startup +------- +If you would like an interface to be configured using dhcpcd at +boot time then add lines like + +auto eth1 +iface eth1 inet dhcp + +to /etc/network/interfaces. This will cause ifup to bring up +interface eth1 at boot time. + +Ifup will use dhcpcd to configure a particular interface if it +is set up to configure that interface according to an "iface" +description in /etc/network/interfaces of type "inet dhcp". +See the ifup(8) and interfaces(5) manual pages for more +information on how to write the /etc/network/interfaces file. + +Resolv.conf +----------- +Dhcpcd will no longer update /etc/resolv.conf and /etc/ntp.conf +directly unless this is enabled in /etc/dhcpc/config by setting +the SET_DNS environment variable to "yes". If the resolvconf +package is installed then the resolv.conf information will be +sent to resolvconf; otherwise the information will be written +to /etc/dhcpc/resolv.conf . Note that if you are using +resolvconf then you must _not_ set SET_DNS to "yes" since this +will interfere with resolvconf's operation. + +DUID-based client-ids +--------------------- +Dhcpcd version 3 constructs client-ids using the a DUID, as specified +by RFC 4361. previous versions used a client-id based on the interface +MAC address, as specified in RFC 2131. If a host which already has a +DHCP lease changes its client-id, it is probable that it will be +allocated a new IP address by the DHCP server, which may cause +problems. To avoid this, if the Debian package of dhcpcd is upgraded, +the file /etc/dhcpc/duid-inhibit will be created, which forces dhcpcd +to use the old client-id. New installations use DUID-based client-ids +from scratch and existing ones can be upgraded in a controlled manner +by deleting /etc/dhcpc/duid-inhibit and taking interfaces down and +then back up. + + + + -- Simon Kelley , Tues, 12 Feb 2008 12:22:01 +0000 + + + --- dhcpcd-3.2.3.orig/debian/dhcpcd.8 +++ dhcpcd-3.2.3/debian/dhcpcd.8 @@ -0,0 +1,30 @@ +.\" $Id$ +.\" +.TH dhcpcd 8 "13 May 2004" "dhcpcd" "Debian GNU/Linux" + +.SH NAME +dhcpcd \- a wrapper for the DHCP client daemon. +.SH SYNOPSIS +.B dhcpcd