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 <g...@greenie.muc.de>
---
 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
-- 
2.27.0



_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to