dhcpcd: send STOPPED reason to hooks if iface is not up and down.

- Process STOPPED reason in the wpa_supplicant hook to stop it when
the interface goes down.

This has been suggested by Roy Marples (dhcpcd author) in private email.
a final review this seems to DTRT.
This commit is contained in:
Juan RP 2014-11-28 12:41:11 +01:00
parent 615f325752
commit dcd645ef90
3 changed files with 47 additions and 22 deletions

View file

@ -1,21 +0,0 @@
--- dhcpcd-hooks/10-wpa_supplicant
+++ dhcpcd-hooks/10-wpa_supplicant
@@ -114,6 +114,6 @@ then
case "$reason" in
PREINIT) wpa_supplicant_start;;
RECONFIGURE) wpa_supplicant_reconfigure;;
- DEPARTED) wpa_supplicant_stop;;
+ DEPARTED|STOP) wpa_supplicant_stop;;
esac
fi
index 5293f9713cbe..8b19ffbcbb1b 100644
--- dhcpcd.c
+++ dhcpcd.c
@@ -1049,6 +1049,7 @@ handle_signal1(void *arg)
break;
case SIGTERM:
syslog(LOG_INFO, sigmsg, "TERM", (int)si->pid, "stopping");
+ do_release = 1;
break;
case SIGALRM:
syslog(LOG_INFO, sigmsg, "ALRM", (int)si->pid, "releasing");

View file

@ -0,0 +1,46 @@
--- dhcpcd-run-hooks.in.orig 2014-11-26 16:34:35.000000000 +0100
+++ dhcpcd-run-hooks.in 2014-11-28 11:53:13.712853795 +0100
@@ -2,13 +2,20 @@
# dhcpcd client configuration script
# Handy variables and functions for our hooks to use
+: ${if_up:=false}
+: ${if_down:=false}
+: ${syslog_debug:=false}
+
case "$reason" in
ROUTERADVERT)
ifsuffix=":ra";;
INFORM6|BOUND6|RENEW6|REBIND6|REBOOT6|EXPIRE6|RELEASE6|STOP6)
ifsuffix=":dhcp6";;
- STOPPED) # This reason should never be processed
- exit 0;;
+ STOPPED) # Only process this reason if iface is down.
+ if [ "$if_up" != "false" -o "$if_down" = "false" ]; then
+ exit 0
+ fi
+ ;;
*)
ifsuffix=;;
esac
@@ -22,10 +29,6 @@ signature_end="$signature_base_end $from
state_dir=@RUNDIR@/dhcpcd
_detected_init=false
-: ${if_up:=false}
-: ${if_down:=false}
-: ${syslog_debug:=false}
-
# Ensure that all arguments are unique
uniqify()
{
--- dhcpcd-hooks/10-wpa_supplicant.orig 2014-11-26 16:34:35.000000000 +0100
+++ dhcpcd-hooks/10-wpa_supplicant 2014-11-28 11:53:48.929217243 +0100
@@ -114,6 +114,6 @@ then
case "$reason" in
PREINIT) wpa_supplicant_start;;
RECONFIGURE) wpa_supplicant_reconfigure;;
- DEPARTED) wpa_supplicant_stop;;
+ DEPARTED|STOPPED) wpa_supplicant_stop;;
esac
fi

View file

@ -1,7 +1,7 @@
# Template file for 'dhcpcd'
pkgname=dhcpcd
version=6.6.4
revision=2
revision=3
lib32disabled=yes
build_options="systemd"
build_style=configure