From patchwork Mon Jul 6 09:00:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1205 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director7.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id eOlnDhJ1A1+fEwAAIUCqbw for ; Mon, 06 Jul 2020 15:01:38 -0400 Received: from proxy1.mail.ord1d.rsapps.net ([172.30.191.6]) by director7.mail.ord1d.rsapps.net with LMTP id EK88DhJ1A1+QeAAAovjBpQ ; Mon, 06 Jul 2020 15:01:38 -0400 Received: from smtp21.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.ord1d.rsapps.net with LMTP id gJiXDhJ1A1+UUQAAasrz9Q ; Mon, 06 Jul 2020 15:01:38 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp21.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 1ddbdb5a-bfbb-11ea-a984-525400a98691-1-1 Received: from [216.105.38.7] ([216.105.38.7:60792] helo=lists.sourceforge.net) by smtp21.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 10/0E-15680-115730F5; Mon, 06 Jul 2020 15:01:37 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jsWMB-0005UG-Ia; Mon, 06 Jul 2020 19:00:47 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsWMA-0005U0-EG for openvpn-devel@lists.sourceforge.net; Mon, 06 Jul 2020 19:00:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6oTqsldSeP9oCi6ElwBj7oPlwG6qmwsHHSgvAnhKcYQ=; b=HTouLmHZD2GJ6YuoBJSAyEDnrP zP92ffNKZXVsapJLvNytQTBxpQTGYmnn2Ya/re+vHzfHK7zSTcDb14d3uJd6VJZa3I3/dhG14hWyn FxPUwkRdjbVAArxAu5WoYXnmA5YJ5ZA/DUGmEiNQdpU/1kk0hifRrWA+Ef6mqZ55DALk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=6oTqsldSeP9oCi6ElwBj7oPlwG6qmwsHHSgvAnhKcYQ=; b=W 2b5Nwr3Q6CY18TwbR9YXJDibgU/Wn/V4f3/Z2HPZgHXxDbgOmzaYDhpf50TM1k3fz5kN105uO/3R6 d98ZfG9386Pf4bKAmjtEcmF/dS98/SGOXHYbwIE8Ch0kMlQVj7XgJVeeS7KsbWml4MUEYunYFoukJ +2Q2KLXlOHj4YIyQ=; Received: from chekov.greenie.muc.de ([193.149.48.178]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jsWM8-00CXGr-Uh for openvpn-devel@lists.sourceforge.net; Mon, 06 Jul 2020 19:00:46 +0000 Received: from chekov.greenie.muc.de (localhost [127.0.0.1]) by chekov.greenie.muc.de (8.15.2/8.15.2) with ESMTPS id 066J0VJQ049343 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 6 Jul 2020 21:00:31 +0200 (CEST) (envelope-from gert@chekov.greenie.muc.de) Received: (from gert@localhost) by chekov.greenie.muc.de (8.15.2/8.15.2/Submit) id 066J0Vqt049342 for openvpn-devel@lists.sourceforge.net; Mon, 6 Jul 2020 21:00:31 +0200 (CEST) (envelope-from gert) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 6 Jul 2020 21:00:30 +0200 Message-Id: <20200706190030.49301-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1jsWM8-00CXGr-Uh Subject: [Openvpn-devel] [PATCH] Remove --writepid file on program exit. X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox For whatever reason, we never removed the pid file on program exit. Not only this is unclean, but it also makes testing for "I want this test case to FAIL" in t_client.sh more annoying to code for "is the OpenVPN process still around?"... Do not unlink the file if chroot() is active (might be outside the chroot arena - testing for realpath etc. is left for someone else). Signed-off-by: Gert Doering --- src/openvpn/openvpn.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index dc7001dc..65029e86 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -335,6 +335,12 @@ openvpn_main(int argc, char *argv[]) while (c.sig->signal_received == SIGHUP); } + /* if we opened a PID file and did not chroot(), unlink() it again */ + if (c.options.writepid && !c.options.chroot_dir) + { + platform_unlink(c.options.writepid); + } + context_gc_free(&c); #ifdef ENABLE_MANAGEMENT