From patchwork Tue Oct 11 00:49:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2813 X-Patchwork-Delegate: gert@greenie.muc.de 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 WKUXInpYRWNsCAAAIUCqbw (envelope-from ) for ; Tue, 11 Oct 2022 07:50:18 -0400 Received: from proxy3.mail.ord1d.rsapps.net ([172.30.191.6]) by director7.mail.ord1d.rsapps.net with LMTP id kGLwIXpYRWP0UQAAovjBpQ (envelope-from ) for ; Tue, 11 Oct 2022 07:50:18 -0400 Received: from smtp40.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.ord1d.rsapps.net with LMTPS id sDecIXpYRWO9VgAA7WKfLA (envelope-from ) for ; Tue, 11 Oct 2022 07:50:18 -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: smtp40.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=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: e00f173e-495a-11ed-95a9-525400f204c2-1-1 Received: from [216.105.38.7] ([216.105.38.7:40736] helo=lists.sourceforge.net) by smtp40.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id D1/76-22876-97855436; Tue, 11 Oct 2022 07:50:17 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1oiDlc-0006tN-97; Tue, 11 Oct 2022 11:49:48 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oiDlb-0006tD-Ki for openvpn-devel@lists.sourceforge.net; Tue, 11 Oct 2022 11:49:47 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9pOSqtJv8K4yOJ1DKrs4roZh1F7yg0olfCjvpKj76b8=; b=DxOOJ4V88ft4+5iX6E5PPi1Q2D OePD3C7323DsUPVsuGGKTK60EcILCpJ2N5KwZY8a0D8vnrj+zG+N3UB76WJ8Omy2aK505uOe3scfD EVqsv9nPc1NVoY7dAUqCRGV73ToO10jO53aQgN8Hf8pfXhLcR25BUa2k2cP6KRrJntH8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9pOSqtJv8K4yOJ1DKrs4roZh1F7yg0olfCjvpKj76b8=; b=LbeHLyH0otMs9FBrpkvtc6JPTH apL3omUEnx6767b3mqON4j6TBzYDGzDKUQ/RXJWLZfch5D1xzniPTJ9Fr/UQDN37WtPbAJ92ORd5I g/lZtHPOMCANvnXgbcXqWVCzZP61I8H5bfnb/q6y7DettAXvu86jzX77C7ciYRwTedYY=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1oiDlW-0023ki-V2 for openvpn-devel@lists.sourceforge.net; Tue, 11 Oct 2022 11:49:47 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1oiDlP-000KXk-KK for openvpn-devel@lists.sourceforge.net; Tue, 11 Oct 2022 13:49:35 +0200 Received: (nullmailer pid 1802248 invoked by uid 10006); Tue, 11 Oct 2022 11:49:35 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Tue, 11 Oct 2022 13:49:35 +0200 Message-Id: <20221011114935.1802202-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From the implemention and the fact that it is a an OCC message (basically the rudimentary predecessor to control channel), this message is very old. I think in the past this feature fit nicely to the weird inetd + openvpn mode that seems to have far to many hacks still left in our code. With inetd, it made sense that the server instance quits if y [...] Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-Headers-End: 1oiDlW-0023ki-V2 Subject: [Openvpn-devel] [PATCH v2] Change exit notification in P2P to be a SIGUSR1 instead of a SIGTERM signal 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 From the implemention and the fact that it is a an OCC message (basically the rudimentary predecessor to control channel), this message is very old. I think in the past this feature fit nicely to the weird inetd + openvpn mode that seems to have far to many hacks still left in our code. With inetd, it made sense that the server instance quits if you press C-c on the client. In our current state where inetd is no longer supported, this behaviour to exit makes little sense and this patch changes the behaviour to SIGUSR1. The P2MP mode nees to keep the SIGTERM behaviour to terminate that client session, so we use different signals based on the mode. Patch v2: use different signals for p2mp and p2p Signed-off-by: Arne Schwabe --- src/openvpn/occ.c | 12 ++++++++++-- src/openvpn/push.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/openvpn/occ.c b/src/openvpn/occ.c index 1ed0d3771..75703fc70 100644 --- a/src/openvpn/occ.c +++ b/src/openvpn/occ.c @@ -431,8 +431,16 @@ process_received_occ_msg(struct context *c) case OCC_EXIT: dmsg(D_PACKET_CONTENT, "RECEIVED OCC_EXIT"); - c->sig->signal_received = SIGTERM; - c->sig->signal_text = "remote-exit"; + /* in server mode we want the instance to be terminated. But for a + * standalone p2p, SIGTERM would terminate the program */ + if (c->options.mode == MODE_SERVER) + { + c->sig->signal_received = SIGTERM; + } + else + { + c->sig->signal_received = SIGUSR1; + } c->sig->signal_text = "remote-exit"; break; } c->c2.buf.len = 0; /* don't pass packet on */ diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 26259c6b8..ec909c630 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -193,7 +193,16 @@ void receive_exit_message(struct context *c) { dmsg(D_STREAM_ERRORS, "Exit message received by peer"); - c->sig->signal_received = SIGTERM; + /* in server mode we want the instance to be terminated. But for a + * standalone p2p, SIGTERM would terminate the program */ + if (c->options.mode == MODE_SERVER) + { + c->sig->signal_received = SIGTERM; + } + else + { + c->sig->signal_received = SIGUSR1; + } c->sig->signal_text = "remote-exit"; #ifdef ENABLE_MANAGEMENT if (management)