Révision ff3da5db
Ajouté par Renato Botelho il y a presque 10 ans
sbin/dhclient-script | ||
---|---|---|
27 | 27 |
SED=/usr/bin/sed |
28 | 28 |
ARP=/usr/sbin/arp |
29 | 29 |
IFCONFIG=/sbin/ifconfig |
30 |
PFCTL=/sbin/pfctl |
|
30 | 31 |
|
31 | 32 |
LOCALHOST=127.0.0.1 |
32 | 33 |
|
33 | 34 |
if [ -x /usr/bin/logger ]; then |
34 | 35 |
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient" |
35 | 36 |
else |
36 |
LOGGER=echo
|
|
37 |
LOGGER="echo"
|
|
37 | 38 |
fi |
38 | 39 |
|
39 | 40 |
# |
... | ... | |
42 | 43 |
|
43 | 44 |
check_hostname() { |
44 | 45 |
current_hostname=`$HOSTNAME` |
45 |
if [ -z "$current_hostname" ]; then |
|
46 |
$LOGGER "New Hostname ($interface): $new_host_name" |
|
47 |
$HOSTNAME $new_host_name |
|
48 |
elif [ "$current_hostname" = "$old_host_name" -a \ |
|
49 |
"$new_host_name" != "$old_host_name" ]; then |
|
46 |
if [ -z "$current_hostname" -o \ |
|
47 |
"$current_hostname" != "$new_host_name" ]; then |
|
50 | 48 |
$LOGGER "New Hostname ($interface): $new_host_name" |
51 | 49 |
$HOSTNAME $new_host_name |
52 | 50 |
fi |
... | ... | |
60 | 58 |
|
61 | 59 |
delete_old_states() { |
62 | 60 |
$LOGGER "Starting delete_old_states()" |
61 |
_FLUSHED=0 |
|
63 | 62 |
# If the IP changed, remove states from the old one |
64 | 63 |
if [ -f /var/db/${interface}_ip ]; then |
65 |
OLD_IP = `cat /var/db/${interface}_ip`
|
|
64 |
OLD_IP=`cat /var/db/${interface}_ip`
|
|
66 | 65 |
$LOGGER "Comparing IPs: Old: ${OLD_IP} New: ${new_ip_address}" |
67 | 66 |
if [ -n "${OLD_IP}" ] && [ "${OLD_IP}" != "${new_ip_address}" ]; then |
68 | 67 |
$LOGGER "Removing states from old IP '${OLD_IP}' (new IP '${new_ip_address}')" |
69 |
/sbin/pfctl -i $interface -Fs |
|
70 |
pfctl -K ${OLD_IP}/32 |
|
68 |
${PFCTL} -i $interface -Fs |
|
69 |
${PFCTL} -K ${OLD_IP}/32 |
|
70 |
_FLUSHED=1 |
|
71 | 71 |
fi |
72 | 72 |
fi |
73 | 73 |
# Delete states through old gateway if it's not the same |
74 |
OLD_ROUTER="" |
|
74 | 75 |
if [ -n "${old_routers}" ]; then |
75 |
OLD_ROUTER = $old_routers |
|
76 |
fi |
|
77 |
if [ -z "${OLD_ROUTER}" ] && [ -f /tmp/${interface}_router ]; then |
|
78 |
OLD_ROUTER = `cat /tmp/${interface}_router` |
|
76 |
OLD_ROUTER=$old_routers |
|
77 |
elif [ -f /tmp/${interface}_router ]; then |
|
78 |
OLD_ROUTER=`cat /tmp/${interface}_router` |
|
79 | 79 |
fi |
80 |
if [ -n "${OLD_ROUTER}" ]; then |
|
80 |
if [ ${_FLUSHED} -eq 0 -a -n "${OLD_ROUTER}" ]; then
|
|
81 | 81 |
$LOGGER "Comparing Routers: Old: ${OLD_ROUTER} New: ${new_routers}" |
82 | 82 |
if [ "${OLD_ROUTER}" != "${new_routers}" ]; then |
83 | 83 |
$LOGGER "Removing states through old gateway '${OLD_ROUTER}' (new gateway '${new_routers}')" |
84 |
/sbin/pfctl -i $interface -Fs -G ${OLD_ROUTER}
|
|
84 |
${PFCTL} -i $interface -Fs
|
|
85 | 85 |
fi |
86 | 86 |
fi |
87 | 87 |
} |
Formats disponibles : Unified diff
Fix #3700 and other syntax issues:
- Remove
G parameter from pfctl since it doesn't exist anymore
Initialize $old_router- Fix sh syntax on variable assign, it couldn't have space before =
- Simplify logic
- Avoid flush states twice, if it was done on IP change, don't do it
again if router also has changed