Browse code

Bug 1720924: [CVE-2015-8605 CVE-2016-2774 ] dhcp Package

Change-Id: Ib808ff139a2b3ab16e6914b959c4918365b33de5
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1795
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George

harishspqr authored on 2016/12/01 07:07:24
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,645 @@
0
+Submitted By:            Armin K. <krejzi at email dot com>
1
+Date:                    2012-08-14
2
+Initial Package Version: 4.2.4-P1
3
+Upstream Status:         Rejected by upstream.
4
+Origin:                  Based on Debian's dhclient-script, but modified for BLFS
5
+Description:             This patch replaces original linux script for dhcp client with
6
+                         better one which is based on Debian's dhclient-script, but modified
7
+                         to be used on LFS/BLFS. It also removes net-tools dependency.
8
+
9
+--- a/client/scripts/linux	2014-07-09 20:26:40.000000000 +0200
10
+@@ -1,316 +1,346 @@
11
+ #!/bin/bash
12
++
13
+ # dhclient-script for Linux. Dan Halbert, March, 1997.
14
+ # Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
15
+-# No guarantees about this. I'm a novice at the details of Linux
16
+-# networking.
17
+-
18
+-# Notes:
19
+-
20
+-# 0. This script is based on the netbsd script supplied with dhcp-970306.
21
+-
22
+-# 1. ifconfig down apparently deletes all relevant routes and flushes
23
+-# the arp cache, so this doesn't need to be done explicitly.
24
+-
25
+-# 2. The alias address handling here has not been tested AT ALL.
26
+-# I'm just going by the doc of modern Linux ip aliasing, which uses
27
+-# notations like eth0:0, eth0:1, for each alias.
28
++# Modified for Debian.  Matt Zimmerman and Eloy Paris, December 2003
29
++# Modified to remove useless tests for antiquated kernel versions that
30
++# this doesn't even work with anyway, and introduces a dependency on /usr
31
++# being mounted, which causes cosmetic errors on hosts that NFS mount /usr
32
++# Andrew Pollock, February 2005
33
++# Modified to work on point-to-point links. Andrew Pollock, June 2005
34
++# Modified to support passing the parameters called with to the hooks. Andrew Pollock, November 2005
35
++# Modified to use the script with Linux From Scratch by Armin K., May 2012
36
+ 
37
+-# 3. I have to calculate the network address, and calculate the broadcast
38
+-# address if it is not supplied. This might be much more easily done
39
+-# by the dhclient C code, and passed on.
40
+-
41
+-# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
42
+-# of the $1 in its args.
43
+-
44
+-# 'ip' just looks too weird.  /sbin/ip looks less weird.
45
+-ip=/sbin/ip
46
++# The alias handling in here probably still sucks. -mdz
47
+ 
48
++# update /etc/resolv.conf based on received values
49
+ make_resolv_conf() {
50
+-  if [ x"$new_domain_name_servers" != x ]; then
51
+-    cat /dev/null > /etc/resolv.conf.dhclient
52
+-    chmod 644 /etc/resolv.conf.dhclient
53
+-    if [ x"$new_domain_search" != x ]; then
54
+-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
55
+-    elif [ x"$new_domain_name" != x ]; then
56
+-      # Note that the DHCP 'Domain Name Option' is really just a domain
57
+-      # name, and that this practice of using the domain name option as
58
+-      # a search path is both nonstandard and deprecated.
59
+-      echo search $new_domain_name >> /etc/resolv.conf.dhclient
60
+-    fi
61
+-    for nameserver in $new_domain_name_servers; do
62
+-      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
63
+-    done
64
+-
65
+-    mv /etc/resolv.conf.dhclient /etc/resolv.conf
66
+-  elif [ "x${new_dhcp6_name_servers}" != x ] ; then
67
+-    cat /dev/null > /etc/resolv.conf.dhclient6
68
+-    chmod 644 /etc/resolv.conf.dhclient6
69
++    local new_resolv_conf
70
+ 
71
+-    if [ "x${new_dhcp6_domain_search}" != x ] ; then
72
+-      echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
73
++    # DHCPv4
74
++    if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] ||
75
++       [ -n "$new_domain_name_servers" ]; then
76
++        new_resolv_conf=/etc/resolv.conf.dhclient-new
77
++        rm -f $new_resolv_conf
78
++
79
++        if [ -n "$new_domain_name" ]; then
80
++            echo domain ${new_domain_name%% *} >>$new_resolv_conf
81
++        fi
82
++
83
++        if [ -n "$new_domain_search" ]; then
84
++            if [ -n "$new_domain_name" ]; then
85
++                domain_in_search_list=""
86
++                for domain in $new_domain_search; do
87
++                    if [ "$domain" = "${new_domain_name}" ] ||
88
++                       [ "$domain" = "${new_domain_name}." ]; then
89
++                        domain_in_search_list="Yes"
90
++                    fi
91
++                done
92
++                if [ -z "$domain_in_search_list" ]; then
93
++                    new_domain_search="$new_domain_name $new_domain_search"
94
++                fi
95
++            fi
96
++            echo "search ${new_domain_search}" >> $new_resolv_conf
97
++        elif [ -n "$new_domain_name" ]; then
98
++            echo "search ${new_domain_name}" >> $new_resolv_conf
99
++        fi
100
++
101
++        if [ -n "$new_domain_name_servers" ]; then
102
++            for nameserver in $new_domain_name_servers; do
103
++                echo nameserver $nameserver >>$new_resolv_conf
104
++            done
105
++        else # keep 'old' nameservers
106
++            sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
107
++        fi
108
++
109
++        chown --reference=/etc/resolv.conf $new_resolv_conf
110
++        chmod --reference=/etc/resolv.conf $new_resolv_conf
111
++        mv -f $new_resolv_conf /etc/resolv.conf
112
++    # DHCPv6
113
++    elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then
114
++        new_resolv_conf=/etc/resolv.conf.dhclient-new
115
++        rm -f $new_resolv_conf
116
++
117
++        if [ -n "$new_dhcp6_domain_search" ]; then
118
++            echo "search ${new_dhcp6_domain_search}" >> $new_resolv_conf
119
++        fi
120
++
121
++        if [ -n "$new_dhcp6_name_servers" ]; then
122
++            for nameserver in $new_dhcp6_name_servers; do
123
++                # append %interface to link-local-address nameservers
124
++                if [ "${nameserver##fe80::}" != "$nameserver" ] ||
125
++                   [ "${nameserver##FE80::}" != "$nameserver" ]; then
126
++                    nameserver="${nameserver}%${interface}"
127
++                fi
128
++                echo nameserver $nameserver >>$new_resolv_conf
129
++            done
130
++        else # keep 'old' nameservers
131
++            sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
132
++        fi
133
++
134
++        chown --reference=/etc/resolv.conf $new_resolv_conf
135
++        chmod --reference=/etc/resolv.conf $new_resolv_conf
136
++        mv -f $new_resolv_conf /etc/resolv.conf
137
+     fi
138
+-    shopt -s nocasematch 
139
+-    for nameserver in ${new_dhcp6_name_servers} ; do
140
+-      # If the nameserver has a link-local address
141
+-      # add a <zone_id> (interface name) to it.
142
+-      if  [[ "$nameserver" =~ ^fe80:: ]]
143
+-      then
144
+-	zone_id="%$interface"
145
+-      else
146
+-	zone_id=
147
+-      fi
148
+-      echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
149
+-    done
150
+-    shopt -u nocasematch 
151
++}
152
+ 
153
+-    mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
154
+-  fi
155
++# set host name
156
++set_hostname() {
157
++    local current_hostname
158
++
159
++    if [ -n "$new_host_name" ]; then
160
++        current_hostname=$(hostname)
161
++
162
++        # current host name is empty, '(none)' or 'localhost' or differs from new one from DHCP
163
++        if [ -z "$current_hostname" ] ||
164
++           [ "$current_hostname" = '(none)' ] ||
165
++           [ "$current_hostname" = 'localhost' ] ||
166
++           [ "$current_hostname" = "$old_host_name" ]; then
167
++           if [ "$new_host_name" != "$old_host_name" ]; then
168
++               hostname "$new_host_name"
169
++           fi
170
++        fi
171
++    fi
172
+ }
173
+ 
174
+-# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
175
++# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
176
+ exit_with_hooks() {
177
+   exit_status=$1
178
+-  if [ -f /etc/dhclient-exit-hooks ]; then
179
+-    . /etc/dhclient-exit-hooks
180
++  if [ -f /etc/dhcp/dhclient-exit-hooks ]; then
181
++    . /etc/dhcp/dhclient-exit-hooks
182
+   fi
183
+-# probably should do something with exit status of the local script
184
+   exit $exit_status
185
+ }
186
+ 
187
++# The 576 MTU is only used for X.25 and dialup connections
188
++# where the admin wants low latency.  Such a low MTU can cause
189
++# problems with UDP traffic, among other things.  As such,
190
++# disallow MTUs from 576 and below by default, so that broken
191
++# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
192
++if [ -z "$new_interface_mtu" ] || [ "$new_interface_mtu" -le 576 ]; then
193
++    new_interface_mtu=''
194
++fi
195
++
196
++# The action starts here
197
++
198
+ # Invoke the local dhcp client enter hooks, if they exist.
199
+-if [ -f /etc/dhclient-enter-hooks ]; then
200
++if [ -f /etc/dhcp/dhclient-enter-hooks ]; then
201
+   exit_status=0
202
+-  . /etc/dhclient-enter-hooks
203
+-  # allow the local script to abort processing of this state
204
+-  # local script must set exit_status variable to nonzero.
205
++  . /etc/dhcp/dhclient-enter-hooks
206
+   if [ $exit_status -ne 0 ]; then
207
+     exit $exit_status
208
+   fi
209
+ fi
210
+ 
211
+-###
212
+-### DHCPv4 Handlers
213
+-###
214
+-
215
+-if [ x$new_broadcast_address != x ]; then
216
+-  new_broadcast_arg="broadcast $new_broadcast_address"
217
+-fi
218
+-if [ x$old_broadcast_address != x ]; then
219
+-  old_broadcast_arg="broadcast $old_broadcast_address"
220
+-fi
221
+-if [ x$new_subnet_mask != x ]; then
222
+-  new_subnet_arg="netmask $new_subnet_mask"
223
+-fi
224
+-if [ x$old_subnet_mask != x ]; then
225
+-  old_subnet_arg="netmask $old_subnet_mask"
226
+-fi
227
+-if [ x$alias_subnet_mask != x ]; then
228
+-  alias_subnet_arg="netmask $alias_subnet_mask"
229
+-fi
230
+-if [ x$new_interface_mtu != x ]; then
231
+-  mtu_arg="mtu $new_interface_mtu"
232
+-fi
233
+-if [ x$IF_METRIC != x ]; then
234
+-  metric_arg="metric $IF_METRIC"
235
+-fi
236
+-
237
+-if [ x$reason = xMEDIUM ]; then
238
+-  # Linux doesn't do mediums (ok, ok, media).
239
+-  exit_with_hooks 0
240
+-fi
241
+-
242
+-if [ x$reason = xPREINIT ]; then
243
+-  if [ x$alias_ip_address != x ]; then
244
+-    # Bring down alias interface. Its routes will disappear too.
245
+-    ifconfig $interface:0- inet 0
246
+-  fi
247
+-  ifconfig $interface 0 up
248
+-
249
+-  # We need to give the kernel some time to get the interface up.
250
+-  sleep 1
251
+-
252
+-  exit_with_hooks 0
253
+-fi
254
+-
255
+-if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
256
+-  exit_with_hooks 0
257
+-fi
258
+-  
259
+-if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
260
+-   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
261
+-  current_hostname=`hostname`
262
+-  if [ x$current_hostname = x ] || \
263
+-     [ x$current_hostname = "x(none)" ] || \
264
+-     [ x$current_hostname = xlocalhost ] || \
265
+-     [ x$current_hostname = x$old_host_name ]; then
266
+-    if [ x$new_host_name != x$old_host_name ]; then
267
+-      hostname "$new_host_name"
268
+-    fi
269
+-  fi
270
+-    
271
+-  if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
272
+-		[ x$alias_ip_address != x$old_ip_address ]; then
273
+-    # Possible new alias. Remove old alias.
274
+-    ifconfig $interface:0- inet 0
275
+-  fi
276
+-  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
277
+-    # IP address changed. Bringing down the interface will delete all routes,
278
+-    # and clear the ARP cache.
279
+-    ifconfig $interface inet 0 down
280
+-
281
+-  fi
282
+-  if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
283
+-     [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
284
+-
285
+-    ifconfig $interface inet $new_ip_address $new_subnet_arg \
286
+-					$new_broadcast_arg $mtu_arg
287
+-    # Add a network route to the computed network address.
288
+-    for router in $new_routers; do
289
+-      if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
290
+-	route add -host $router dev $interface
291
+-      fi
292
+-      route add default gw $router $metric_arg dev $interface
293
+-    done
294
+-  else
295
+-    # we haven't changed the address, have we changed other options           
296
+-    # that we wish to update?
297
+-    if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
298
+-      # if we've changed routers delete the old and add the new.
299
+-      for router in $old_routers; do
300
+-        route del default gw $router
301
+-      done
302
+-      for router in $new_routers; do
303
+-        if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
304
+-	  route add -host $router dev $interface
305
+-	fi
306
+-	route add default gw $router $metric_arg dev $interface
307
+-      done
308
+-    fi
309
+-  fi
310
+-  if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
311
+-   then
312
+-    ifconfig $interface:0- inet 0
313
+-    ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
314
+-    route add -host $alias_ip_address $interface:0
315
+-  fi
316
+-  make_resolv_conf
317
+-  exit_with_hooks 0
318
+-fi
319
+-
320
+-if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
321
+-   || [ x$reason = xSTOP ]; then
322
+-  if [ x$alias_ip_address != x ]; then
323
+-    # Turn off alias interface.
324
+-    ifconfig $interface:0- inet 0
325
+-  fi
326
+-  if [ x$old_ip_address != x ]; then
327
+-    # Shut down interface, which will delete routes and clear arp cache.
328
+-    ifconfig $interface inet 0 down
329
+-  fi
330
+-  if [ x$alias_ip_address != x ]; then
331
+-    ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
332
+-    route add -host $alias_ip_address $interface:0
333
+-  fi
334
+-  exit_with_hooks 0
335
+-fi
336
+-
337
+-if [ x$reason = xTIMEOUT ]; then
338
+-  if [ x$alias_ip_address != x ]; then
339
+-    ifconfig $interface:0- inet 0
340
+-  fi
341
+-  ifconfig $interface inet $new_ip_address $new_subnet_arg \
342
+-					$new_broadcast_arg $mtu_arg
343
+-  set $new_routers
344
+-  if ping -q -c 1 $1; then
345
+-    if [ x$new_ip_address != x$alias_ip_address ] && \
346
+-			[ x$alias_ip_address != x ]; then
347
+-      ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
348
+-      route add -host $alias_ip_address dev $interface:0
349
+-    fi
350
+-    for router in $new_routers; do
351
+-      if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
352
+-	route add -host $router dev $interface
353
+-      fi
354
+-      route add default gw $router $metric_arg dev $interface
355
+-    done
356
+-    make_resolv_conf
357
+-    exit_with_hooks 0
358
+-  fi
359
+-  ifconfig $interface inet 0 down
360
+-  exit_with_hooks 1
361
+-fi
362
+-
363
+-###
364
+-### DHCPv6 Handlers
365
+-###
366
+-
367
+-if [ x$reason = xPREINIT6 ] ; then
368
+-  # Ensure interface is up.
369
+-  ${ip} link set ${interface} up
370
+-
371
+-  # Remove any stale addresses from aborted clients.
372
+-  ${ip} -f inet6 addr flush dev ${interface} scope global permanent
373
+-
374
+-  exit_with_hooks 0
375
+-fi
376
+-
377
+-if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
378
+-    echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
379
++# Execute the operation
380
++case "$reason" in
381
+ 
382
+-    exit_with_hooks 0
383
+-fi
384
+-
385
+-if [ x$reason = xBOUND6 ] ; then
386
+-  if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
387
+-    exit_with_hooks 2;
388
+-  fi
389
++    ### DHCPv4 Handlers
390
+ 
391
+-  ${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
392
+-	dev ${interface} scope global
393
++    MEDIUM|ARPCHECK|ARPSEND)
394
++        # Do nothing
395
++        ;;
396
++    PREINIT)
397
++        # The DHCP client is requesting that an interface be
398
++        # configured as required in order to send packets prior to
399
++        # receiving an actual address. - dhclient-script(8)
400
++
401
++        # ensure interface is up
402
++        ip link set dev ${interface} up
403
++
404
++        if [ -n "$alias_ip_address" ]; then
405
++            # flush alias IP from interface
406
++            ip -4 addr flush dev ${interface} label ${interface}:0
407
++        fi
408
++
409
++        ;;
410
++
411
++    BOUND|RENEW|REBIND|REBOOT)
412
++        set_hostname
413
++
414
++        if [ -n "$old_ip_address" ] && [ -n "$alias_ip_address" ] &&
415
++           [ "$alias_ip_address" != "$old_ip_address" ]; then
416
++            # alias IP may have changed => flush it
417
++            ip -4 addr flush dev ${interface} label ${interface}:0
418
++        fi
419
++
420
++        if [ -n "$old_ip_address" ] &&
421
++           [ "$old_ip_address" != "$new_ip_address" ]; then
422
++            # leased IP has changed => flush it
423
++            ip -4 addr flush dev ${interface} label ${interface}
424
++        fi
425
++
426
++        if [ -z "$old_ip_address" ] ||
427
++           [ "$old_ip_address" != "$new_ip_address" ] ||
428
++           [ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
429
++            # new IP has been leased or leased IP changed => set it
430
++            ip -4 addr add ${new_ip_address}${new_subnet_mask:+/$new_subnet_mask} \
431
++                ${new_broadcast_address:+broadcast $new_broadcast_address} \
432
++                dev ${interface} label ${interface}
433
++
434
++            if [ -n "$new_interface_mtu" ]; then
435
++                # set MTU
436
++                ip link set dev ${interface} mtu ${new_interface_mtu}
437
++            fi
438
++
439
++            # set if_metric if IF_METRIC is set or there's more than one router
440
++            if_metric="$IF_METRIC"
441
++            if [ "${new_routers%% *}" != "${new_routers}" ]; then
442
++                if_metric=${if_metric:-1}
443
++            fi
444
++
445
++            for router in $new_routers; do
446
++                if [ "$new_subnet_mask" = "255.255.255.255" ]; then
447
++                    # point-to-point connection => set explicit route
448
++                    ip -4 route add ${router} dev $interface >/dev/null 2>&1
449
++                fi
450
++
451
++                # set default route
452
++                ip -4 route add default via ${router} dev ${interface} \
453
++                    ${if_metric:+metric $if_metric} >/dev/null 2>&1
454
++
455
++                if [ -n "$if_metric" ]; then
456
++                    if_metric=$((if_metric+1))
457
++                fi
458
++            done
459
++        fi
460
++
461
++        if [ -n "$alias_ip_address" ] &&
462
++           [ "$new_ip_address" != "$alias_ip_address" ]; then
463
++            # separate alias IP given, which may have changed
464
++            # => flush it, set it & add host route to it
465
++            ip -4 addr flush dev ${interface} label ${interface}:0
466
++            ip -4 addr add ${alias_ip_address}${alias_subnet_mask:+/$alias_subnet_mask} \
467
++                dev ${interface} label ${interface}:0
468
++            ip -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
469
++        fi
470
++
471
++        # update /etc/resolv.conf
472
++        make_resolv_conf
473
++
474
++        ;;
475
++
476
++    EXPIRE|FAIL|RELEASE|STOP)
477
++        if [ -n "$alias_ip_address" ]; then
478
++            # flush alias IP
479
++            ip -4 addr flush dev ${interface} label ${interface}:0
480
++        fi
481
++
482
++        if [ -n "$old_ip_address" ]; then
483
++            # flush leased IP
484
++            ip -4 addr flush dev ${interface} label ${interface}
485
++        fi
486
++
487
++        if [ -n "$alias_ip_address" ]; then
488
++            # alias IP given => set it & add host route to it
489
++            ip -4 addr add ${alias_ip_address}${alias_network_arg} \
490
++                dev ${interface} label ${interface}:0
491
++            ip -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
492
++        fi
493
++
494
++        ;;
495
++
496
++    TIMEOUT)
497
++        if [ -n "$alias_ip_address" ]; then
498
++            # flush alias IP
499
++            ip -4 addr flush dev ${interface} label ${interface}:0
500
++        fi
501
++
502
++        # set IP from recorded lease
503
++        ip -4 addr add ${new_ip_address}${new_subnet_mask:+/$new_subnet_mask} \
504
++            ${new_broadcast_address:+broadcast $new_broadcast_address} \
505
++            dev ${interface} label ${interface}
506
++
507
++        if [ -n "$new_interface_mtu" ]; then
508
++            # set MTU
509
++            ip link set dev ${interface} mtu ${new_interface_mtu}
510
++        fi
511
++
512
++        # if there is no router recorded in the lease or the 1st router answers pings
513
++        if [ -z "$new_routers" ] || ping -q -c 1 "${new_routers%% *}"; then
514
++            if [ -n "$alias_ip_address" ] &&
515
++               [ "$new_ip_address" != "$alias_ip_address" ]; then
516
++                # separate alias IP given => set up the alias IP & add host route to it
517
++                ip -4 addr add ${alias_ip_address}${alias_subnet_mask:+/$alias_subnet_mask} \
518
++                    dev ${interface} label ${interface}:0
519
++                ip -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
520
++            fi
521
++
522
++            # set if_metric if IF_METRIC is set or there's more than one router
523
++            if_metric="$IF_METRIC"
524
++            if [ "${new_routers%% *}" != "${new_routers}" ]; then
525
++                if_metric=${if_metric:-1}
526
++            fi
527
++
528
++            # set default route
529
++            for router in $new_routers; do
530
++                ip -4 route add default via ${router} dev ${interface} \
531
++                    ${if_metric:+metric $if_metric} >/dev/null 2>&1
532
++
533
++                if [ -n "$if_metric" ]; then
534
++                    if_metric=$((if_metric+1))
535
++                fi
536
++            done
537
++
538
++            # update /etc/resolv.conf
539
++            make_resolv_conf
540
++        else
541
++            # flush all IPs from interface
542
++            ip -4 addr flush dev ${interface}
543
++            exit_with_hooks 1
544
++        fi
545
++
546
++        ;;
547
++
548
++    ### DHCPv6 Handlers
549
++    # TODO handle prefix change: ?based on ${old_ip6_prefix} and ${new_ip6_prefix}?
550
++
551
++    PREINIT6)
552
++        # ensure interface is up
553
++        ip link set ${interface} up
554
++
555
++        # flush any stale global permanent IPs from interface
556
++        ip -6 addr flush dev ${interface} scope global permanent
557
++
558
++        ;;
559
++
560
++    BOUND6|RENEW6|REBIND6)
561
++        if [ "${new_ip6_address}" ] && [ "${new_ip6_prefixlen}" ]; then
562
++            # set leased IP
563
++            ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
564
++                dev ${interface} scope global
565
++        fi
566
++
567
++        # update /etc/resolv.conf
568
++        if [ "${reason}" = BOUND6 ] ||
569
++           [ "${new_dhcp6_name_servers}" != "${old_dhcp6_name_servers}" ] ||
570
++           [ "${new_dhcp6_domain_search}" != "${old_dhcp6_domain_search}" ]; then
571
++            make_resolv_conf
572
++        fi
573
++
574
++        ;;
575
++
576
++    DEPREF6)
577
++        if [ -z "${cur_ip6_prefixlen}" ]; then
578
++            exit_with_hooks 1
579
++        fi
580
++
581
++        # set preferred lifetime of leased IP to 0
582
++        ip -6 addr change ${cur_ip6_address}/${cur_ip6_prefixlen} \
583
++            dev ${interface} scope global preferred_lft 0
584
++
585
++        ;;
586
++
587
++    EXPIRE6|RELEASE6|STOP6)
588
++        if [ -z "${old_ip6_address}" ] || [ -z "${old_ip6_prefixlen}" ]; then
589
++            exit_with_hooks 1
590
++        fi
591
++
592
++        # delete leased IP
593
++        ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
594
++            dev ${interface}
595
+ 
596
+-  # Check for nameserver options.
597
+-  make_resolv_conf
598
+-
599
+-  exit_with_hooks 0
600
+-fi
601
+-
602
+-if [ x$reason = xRENEW6 ] || [ x$reason = xREBIND6 ] ; then
603
+-  if [ x${new_ip6_address} != x ] && [ x${new_ip6_prefixlen} != x ] ; then
604
+-    ${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
605
+-	dev ${interface} scope global
606
+-  fi
607
+-
608
+-  # Make sure nothing has moved around on us.
609
+-
610
+-  # Nameservers/domains/etc.
611
+-  if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
612
+-     [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
613
+-    make_resolv_conf
614
+-  fi
615
+-
616
+-  exit_with_hooks 0
617
+-fi
618
+-
619
+-if [ x$reason = xDEPREF6 ] ; then
620
+-  if [ x${new_ip6_prefixlen} = x ] ; then
621
+-    exit_with_hooks 2;
622
+-  fi
623
+-
624
+-  ${ip} -f inet6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
625
+-       dev ${interface} scope global preferred_lft 0
626
+-
627
+-  exit_with_hooks 0
628
+-fi
629
+-
630
+-if [ x$reason = xEXPIRE6 -o x$reason = xRELEASE6 -o x$reason = xSTOP6 ] ; then
631
+-  if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
632
+-    exit_with_hooks 2;
633
+-  fi
634
+-
635
+-  ${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
636
+-	dev ${interface}
637
+-
638
+-  exit_with_hooks 0
639
+-fi
640
++        ;;
641
++esac
642
+ 
643
+ exit_with_hooks 0
0 644
new file mode 100644
... ...
@@ -0,0 +1,48 @@
0
+Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
1
+Date: 2011-11-23
2
+Initial Package Version: 4.2.2
3
+Upstream Status: unknown
4
+Origin: found at fedora
5
+Description: Allow dhcp4 to work even if the kernel doesn't support ipv6.
6
+Fixed up by hand to apply to 4.2.2 (to me, it looks identical to the 4.2.0
7
+version, but patch failed in one hunk when I tried to apply that one).
8
+
9
+--- dhcp-4.2.2/common/discover.c.orig	2011-07-19 23:22:48.000000000 +0100
10
+@@ -455,7 +455,7 @@
11
+ 	}
12
+ 
13
+ #ifdef DHCPv6
14
+-	if (local_family == AF_INET6) {
15
++	if ((local_family == AF_INET6) && !access("/proc/net/if_inet6", R_OK)) {
16
+ 		ifaces->fp6 = fopen("/proc/net/if_inet6", "r");
17
+ 		if (ifaces->fp6 == NULL) {
18
+ 			log_error("Error opening '/proc/net/if_inet6' to "
19
+@@ -466,6 +466,8 @@
20
+ 			ifaces->fp = NULL;
21
+ 			return 0;
22
+ 		}
23
++	} else {
24
++		ifaces->fp6 = NULL;
25
+ 	}
26
+ #endif
27
+ 
28
+@@ -733,7 +735,7 @@
29
+ 		return 1;
30
+ 	}
31
+ #ifdef DHCPv6
32
+-	if (!(*err)) {
33
++	if (!(*err) && ifaces->fp6) {
34
+ 		if (local_family == AF_INET6)
35
+ 			return next_iface6(info, err, ifaces);
36
+ 	}
37
+@@ -752,7 +754,8 @@
38
+ 	ifaces->sock = -1;
39
+ #ifdef DHCPv6
40
+ 	if (local_family == AF_INET6) {
41
+-		fclose(ifaces->fp6);
42
++		if (ifaces->fp6)
43
++			fclose(ifaces->fp6);
44
+ 		ifaces->fp6 = NULL;
45
+ 	}
46
+ #endif
... ...
@@ -1,16 +1,16 @@
1 1
 Summary:	Dynamic host configuration protocol
2 2
 Name:		dhcp
3
-Version:	4.3.3
4
-Release:	3%{?dist}
3
+Version:	4.3.5
4
+Release:	1%{?dist}
5 5
 License:	ISC
6 6
 Url:      	http://isc.org/products/DHCP/
7
-Source0:  	ftp://ftp.isc.org/isc/%{name}/%{version}/%{name}-%{version}-P1.tar.gz
8
-%define sha1 dhcp=4e76757a0aebcb9200c1d2ca0f28ff41a5c56586
7
+Source0:  	ftp://ftp.isc.org/isc/%{name}/%{version}/%{name}-%{version}.tar.gz
8
+%define sha1 dhcp=6140a0cf6b3385057d76c14278294284ba19e5a5
9 9
 Group:		System Environment/Base
10 10
 Vendor:		VMware, Inc.
11 11
 Distribution:	Photon
12
-Patch0:		http://www.linuxfromscratch.org/patches/blfs/svn/dhcp-4.3.3-P1-client_script-1.patch
13
-Patch1:         dhcp-4.3.3-CVE-2016-2774.patch
12
+Patch0:		dhcp-4.3.5-client_script-1.patch
13
+Patch1:		dhcp-4.3.5-missing_ipv6-1.patch
14 14
 BuildRequires:	systemd
15 15
 %description
16 16
 The ISC DHCP package contains both the client and server programs for DHCP. dhclient (the client) is used for connecting to a network which uses DHCP to assign network addresses. dhcpd (the server) is used for assigning network addresses on private networks
... ...
@@ -40,7 +40,7 @@ The ISC DHCP Client, dhclient, provides a means for configuring one or more netw
40 40
 
41 41
 
42 42
 %prep
43
-%setup -qn %{name}-%{version}-P1
43
+%setup -qn %{name}-%{version}
44 44
 %patch0 -p1
45 45
 %patch1 -p1
46 46
 %build
... ...
@@ -147,6 +147,8 @@ install -v -dm 755 %{buildroot}/var/lib/dhclient
147 147
 %{_mandir}/man8/dhclient.8.gz
148 148
 
149 149
 %changelog
150
+*	Mon Nov 14 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 4.3.5-1
151
+-	Upgraded to version 4.3.5.
150 152
 *	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 4.3.3-3
151 153
 -	GA - Bump release of all rpms
152 154
 * 	Wed Mar 30 2016 Anish Swaminathan <anishs@vmware.com>  4.3.3-2