From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 385C81382C5 for ; Sun, 31 May 2020 05:13:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 20375E0880; Sun, 31 May 2020 05:13:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 07451E0880 for ; Sun, 31 May 2020 05:13:29 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 48DAB34F014 for ; Sun, 31 May 2020 05:13:28 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B3F03270 for ; Sun, 31 May 2020 05:13:26 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1590901998.b3848b828d4f1cabe9bda54a0d9da473e5df3e9a.robbat2@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: net/ X-VCS-Repository: proj/netifrc X-VCS-Files: net/dhcpcd.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: b3848b828d4f1cabe9bda54a0d9da473e5df3e9a X-VCS-Branch: master Date: Sun, 31 May 2020 05:13:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c6f09e17-5d10-4948-a0bf-226c3130f40e X-Archives-Hash: a6607f16bcb15e0a334ea14c3ff5c84d commit: b3848b828d4f1cabe9bda54a0d9da473e5df3e9a Author: Lars Wendler gentoo org> AuthorDate: Fri May 22 08:09:22 2020 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Sun May 31 05:13:18 2020 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b3848b82 net/dhcpcd.sh: Put user args into a temp file So we still use the correct PID even if the user has changed his configuration between start and stop. Signed-off-by: Lars Wendler gentoo.org> Signed-off-by: Robin H. Johnson gentoo.org> net/dhcpcd.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh index c0639e0..dcc6817 100644 --- a/net/dhcpcd.sh +++ b/net/dhcpcd.sh @@ -16,11 +16,14 @@ _config_vars="$_config_vars dhcp dhcpcd" dhcpcd_start() { - # check for pidfile after we gathered the user's opts because they can + # check for pidfile after we gathered the user's args because they can # alter the pidfile's name (#718114) - local args= opt= pidfile= opts= new=true + # Save the args into a file so dhcpcd_stop can later re-use the very + # same args later. + local args= opt= pidfile= opts= new=true argsfile=/run/netifrc_dhcpcd_${IFACE}_args eval args=\$dhcpcd_${IFVAR} [ -z "${args}" ] && args=${dhcpcd} + echo "${args}" > ${argsfile} pidfile="$(dhcpcd -P ${args} ${IFACE})" # Get our options @@ -78,12 +81,16 @@ dhcpcd_start() dhcpcd_stop() { - local args= pidfile= opts= sig=SIGTERM + local args= pidfile= opts= sig=SIGTERM argsfile=/run/netifrc_dhcpcd_${IFACE}_args - # check for pidfile after we gathered the user's opts because they can + # check for pidfile after we gathered the user's args because they can # alter the pidfile's name (#718114) - eval args=\$dhcpcd_${IFVAR} - [ -z "${args}" ] && args=${dhcpcd} + if [ -f "${argsfile}" ] ; then + args="$(cat ${argsfile})" + else + eval args=\$dhcpcd_${IFVAR} + [ -z "${args}" ] && args=${dhcpcd} + fi pidfile="$(dhcpcd -P ${args} ${IFACE})" [ ! -f "${pidfile}" ] && return 0 @@ -94,5 +101,6 @@ dhcpcd_stop() *" release "*) dhcpcd -k "${IFACE}" ;; *) dhcpcd -x "${IFACE}" ;; esac + [ -f "${argsfile}" ] && rm -f "${argsfile}" eend $? }