~ubuntu-branches/ubuntu/oneiric/isc-dhcp/oneiric-security

« back to all changes in this revision

Viewing changes to debian/dhclient-script.udeb

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Pollock
  • Date: 2009-09-02 22:34:25 UTC
  • Revision ID: james.westby@ubuntu.com-20090902223425-e060dofnj2yf8zzf
Tags: 4.1.0-1
* The "throw everything out and start over" release
* New upstream release
* debian/control: drop 3 from the binary package names, adjust dependencies,
  maintainer scripts, accordingly
* use debhelper more extensively, de-cruft debian/rules
* remove dhcp-server preinst
* add debug packages
* add transitional packages
* add debian/README.source
* debian/control: bumped Standards-Version
* debian/isc-dhcp-server.postinst: transfer existing config and lease files
  when upgrading from dhcp3-server
* debian/isc-dhcp-client.postinst: transfer existing config file when
  upgrading from dhcp3-client
* debian/changelog: added marker for legacy malformed changelog entry to
  placate Lintian
* add a patch to correct groff warnings in man pages
* add a patch to ignore checksums on the loopback interface
* debian/control: make isc-dhcp-client depend on ifupdown that invokes
  /sbin/dhclient correctly

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
# reduced dhclient-script for the Debian installer
 
6
# changes by Joshua Kwan <joshk@triplehelix.org>,
 
7
# Bastian Blank <waldi@debian.org>
 
8
 
 
9
# dhclient-script for Linux. Dan Halbert, March, 1997.
 
10
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
 
11
# Modified for Debian.  Matt Zimmerman and Eloy Paris, December 2003
 
12
 
 
13
make_resolv_conf() {
 
14
    if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then
 
15
        local new_resolv_conf=/etc/resolv.conf.dhclient-new
 
16
        rm -f $new_resolv_conf
 
17
        if [ -n "$new_domain_name" ]; then
 
18
            echo "search $new_domain_name" >>$new_resolv_conf
 
19
        fi
 
20
        for nameserver in $new_domain_name_servers; do
 
21
            echo "nameserver $nameserver" >>$new_resolv_conf
 
22
        done
 
23
        mv $new_resolv_conf /etc/resolv.conf
 
24
    fi
 
25
}
 
26
 
 
27
set_hostname() {
 
28
    local current_hostname=$(cat /proc/sys/kernel/hostname)
 
29
    if [ -z "$current_hostname" ] || [ "$current_hostname" = "(none)" ]; then
 
30
        echo "$new_host_name" > /proc/sys/kernel/hostname
 
31
    fi
 
32
}
 
33
 
 
34
if [ -n "$new_subnet_mask" ]; then
 
35
    new_mask="/$(ptom $new_subnet_mask)"
 
36
fi
 
37
if [ -n "$old_subnet_mask" ]; then
 
38
    old_mask="/$(ptom $old_subnet_mask)"
 
39
fi
 
40
 
 
41
if [ -n "$new_broadcast_address" ]; then
 
42
    new_broadcast_arg="broadcast $new_broadcast_address"
 
43
fi
 
44
if [ -n "$old_broadcast_address" ]; then
 
45
    old_broadcast_arg="broadcast $old_broadcast_address"
 
46
fi
 
47
    
 
48
# Execute the operation
 
49
case "$reason" in
 
50
    MEDIUM|ARPCHECK|ARPSEND)
 
51
        # Do nothing
 
52
        ;;
 
53
    PREINIT)
 
54
        ip link set $interface up
 
55
 
 
56
        # We need to give the kernel some time to get the interface up.
 
57
        sleep 1
 
58
        ;;
 
59
    BOUND|RENEW|REBIND|REBOOT)
 
60
 
 
61
        set_hostname
 
62
        
 
63
        if [ -n "$old_ip_address" ] && \
 
64
             [ "$old_ip_address" != "$new_ip_address" ]; then
 
65
            # IP address changed. Bringing down the interface will delete all routes,
 
66
            # and clear the ARP cache.
 
67
            ip addr del $old_ip_address$old_mask $old_broadcast_arg dev $interface
 
68
            ip link set $interface down
 
69
        fi
 
70
 
 
71
        if [ -n "$new_interface_mtu" ]; then
 
72
            ip link set $interface mtu $new_interface_mtu || true
 
73
        fi
 
74
 
 
75
        if [ -z "$old_ip_address" ] || [ "$old_ip_address" != "$new_ip_address" ] || \
 
76
            [ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
 
77
 
 
78
            ip link set $interface up
 
79
            ip addr flush dev $interface
 
80
            ip addr add $new_ip_address$new_mask $new_broadcast_arg dev $interface
 
81
 
 
82
            for router in $new_routers; do
 
83
                ip route add default via $router
 
84
            done
 
85
        fi
 
86
 
 
87
        make_resolv_conf
 
88
 
 
89
        # Get the domain name into a file suitable for netcfg to read.
 
90
        printf "$new_domain_name" > /tmp/domain_name
 
91
 
 
92
        if [ -n "$new_ntp_servers" ]; then
 
93
            printf "$new_ntp_servers" > /tmp/dhcp-ntp-servers
 
94
        fi
 
95
 
 
96
        ;;
 
97
 
 
98
    EXPIRE|FAIL|RELEASE|STOP)
 
99
        if [ -n "$old_ip_address" ]; then
 
100
            # Shut down interface, which will delete routes and clear arp cache.
 
101
            ip addr flush dev $interface
 
102
            ip link set $interface down
 
103
        fi
 
104
 
 
105
        ;;
 
106
 
 
107
    TIMEOUT)
 
108
        ip link set $interface down
 
109
 
 
110
        ;;
 
111
esac
 
112
 
 
113
exit 0