1 |
commit: b3848b828d4f1cabe9bda54a0d9da473e5df3e9a |
2 |
Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri May 22 08:09:22 2020 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun May 31 05:13:18 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b3848b82 |
7 |
|
8 |
net/dhcpcd.sh: Put user args into a temp file |
9 |
|
10 |
So we still use the correct PID even if the user has changed his |
11 |
configuration between start and stop. |
12 |
|
13 |
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org> |
14 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
15 |
|
16 |
net/dhcpcd.sh | 20 ++++++++++++++------ |
17 |
1 file changed, 14 insertions(+), 6 deletions(-) |
18 |
|
19 |
diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh |
20 |
index c0639e0..dcc6817 100644 |
21 |
--- a/net/dhcpcd.sh |
22 |
+++ b/net/dhcpcd.sh |
23 |
@@ -16,11 +16,14 @@ _config_vars="$_config_vars dhcp dhcpcd" |
24 |
|
25 |
dhcpcd_start() |
26 |
{ |
27 |
- # check for pidfile after we gathered the user's opts because they can |
28 |
+ # check for pidfile after we gathered the user's args because they can |
29 |
# alter the pidfile's name (#718114) |
30 |
- local args= opt= pidfile= opts= new=true |
31 |
+ # Save the args into a file so dhcpcd_stop can later re-use the very |
32 |
+ # same args later. |
33 |
+ local args= opt= pidfile= opts= new=true argsfile=/run/netifrc_dhcpcd_${IFACE}_args |
34 |
eval args=\$dhcpcd_${IFVAR} |
35 |
[ -z "${args}" ] && args=${dhcpcd} |
36 |
+ echo "${args}" > ${argsfile} |
37 |
pidfile="$(dhcpcd -P ${args} ${IFACE})" |
38 |
|
39 |
# Get our options |
40 |
@@ -78,12 +81,16 @@ dhcpcd_start() |
41 |
|
42 |
dhcpcd_stop() |
43 |
{ |
44 |
- local args= pidfile= opts= sig=SIGTERM |
45 |
+ local args= pidfile= opts= sig=SIGTERM argsfile=/run/netifrc_dhcpcd_${IFACE}_args |
46 |
|
47 |
- # check for pidfile after we gathered the user's opts because they can |
48 |
+ # check for pidfile after we gathered the user's args because they can |
49 |
# alter the pidfile's name (#718114) |
50 |
- eval args=\$dhcpcd_${IFVAR} |
51 |
- [ -z "${args}" ] && args=${dhcpcd} |
52 |
+ if [ -f "${argsfile}" ] ; then |
53 |
+ args="$(cat ${argsfile})" |
54 |
+ else |
55 |
+ eval args=\$dhcpcd_${IFVAR} |
56 |
+ [ -z "${args}" ] && args=${dhcpcd} |
57 |
+ fi |
58 |
pidfile="$(dhcpcd -P ${args} ${IFACE})" |
59 |
[ ! -f "${pidfile}" ] && return 0 |
60 |
|
61 |
@@ -94,5 +101,6 @@ dhcpcd_stop() |
62 |
*" release "*) dhcpcd -k "${IFACE}" ;; |
63 |
*) dhcpcd -x "${IFACE}" ;; |
64 |
esac |
65 |
+ [ -f "${argsfile}" ] && rm -f "${argsfile}" |
66 |
eend $? |
67 |
} |