From patchwork Fri Jul 10 23:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1235 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id 6Jq4LXqICV+eTAAAIUCqbw for ; Sat, 11 Jul 2020 05:38:02 -0400 Received: from proxy9.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net with LMTP id iC+OLXqICV/4JgAAfY0hYg ; Sat, 11 Jul 2020 05:38:02 -0400 Received: from smtp30.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy9.mail.ord1d.rsapps.net with LMTP id 8IVhLXqICV/OUQAA7h+8OQ ; Sat, 11 Jul 2020 05:38:02 -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: smtp30.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: 3684fdec-c35a-11ea-a08a-5254001e8e38-1-1 Received: from [216.105.38.7] ([216.105.38.7:47698] helo=lists.sourceforge.net) by smtp30.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 25/B0-25864-A78890F5; Sat, 11 Jul 2020 05:38:02 -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.90_1) (envelope-from ) id 1juBwX-0007sI-DJ; Sat, 11 Jul 2020 09:37:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juBwU-0007ra-Uo for openvpn-devel@lists.sourceforge.net; Sat, 11 Jul 2020 09:37:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=elsaMgvVmTWQjAFqbnV8kbmRmWfG9UY/KQ4k3xKGAMg=; b=A5R/3FTSP6lk3Kw+W0T2cSRK/8 p0dNqlWrz/H3Z4OM9Wl0tjCvtq7Ycz/VfL7IQytR3kAgxM0bVdSbc1iYuMii1jGfol5LsorfQibdx zm1MJ16zRaKxvhOSTh0Xq9uIKfYTm84AkEpf9gbgFu3KXNUhXxBEqLMOaNSN14qVbAR4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding: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=elsaMgvVmTWQjAFqbnV8kbmRmWfG9UY/KQ4k3xKGAMg=; b=Nll10q2uM/r83KbinmqYUgH/g2 9iGrVaKWgzESdTivfb/qCfJ2vDLnaz9hv0hTBp65EOPVUjAG8WUzDNgi229yU0YjVhD9aN2A1JeLB eJwJ41ZqsDJkOY/CnwC0so/12LRZzXq/Z0+3YwGjMR1XwyHjTraw/1dSMG9ojm5DWs1E=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1juBwT-00Dy2p-S8 for openvpn-devel@lists.sourceforge.net; Sat, 11 Jul 2020 09:37:10 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1juBwG-0002QM-4j for openvpn-devel@lists.sourceforge.net; Sat, 11 Jul 2020 11:36:56 +0200 Received: (nullmailer pid 23749 invoked by uid 10006); Sat, 11 Jul 2020 09:36:56 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Sat, 11 Jul 2020 11:36:48 +0200 Message-Id: <20200711093655.23686-7-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200711093655.23686-1-arne@rfc2549.org> References: <20200711093655.23686-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 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: 1juBwT-00Dy2p-S8 Subject: [Openvpn-devel] [PATCH v5 07/14] client-connect: Change cas_context from int to enum 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This deviates from Fabian's original patch that relied on the now removed connection_established bool as pointer being NULL or non NULL as implicit third state and makeing connection_established as a substate of (cas_context == CAS_PENDING) Signed-off-by: Arne Schwabe Patch V5: extend cas_context with two new states instead adding an extra mini state machine. Signed-off-by: Arne Schwabe Acked-by: Antonio Quartulli --- src/openvpn/multi.c | 2 +- src/openvpn/multi.h | 1 + src/openvpn/openvpn.h | 24 +++++++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 83848fdc..f9b8af80 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2163,7 +2163,7 @@ multi_client_connect_early_setup(struct multi_context *m, * Try to source a dynamic config file from the * --client-config-dir directory. */ -enum client_connect_return +static enum client_connect_return multi_client_connect_source_ccd(struct multi_context *m, struct multi_instance *mi, unsigned int *option_types_found) diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 4fb4d0b6..1d30dcc6 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -62,6 +62,7 @@ struct deferred_signal_schedule_entry struct timeval wakeup; }; + /** * Server-mode state structure for one single VPN tunnel. * diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h index a1308852..7c469b01 100644 --- a/src/openvpn/openvpn.h +++ b/src/openvpn/openvpn.h @@ -210,6 +210,21 @@ struct context_1 #endif }; + +/* client authentication state, CAS_SUCCEEDED must be 0 since + * non multi code path still checks this variable but does not initialise it + * so the code depends on zero initialisation */ +enum client_connect_status { + CAS_SUCCEEDED=0, + CAS_PENDING, + CAS_FAILED, + CAS_PARTIAL, /**< Variant of CAS_FAILED: at least one + * client-connect script/plugin succeeded + * while a later one in the chain failed + * (we still need cleanup compared to FAILED) + */ +}; + /** * Level 2 %context containing state that is reset on both \c SIGHUP and * \c SIGUSR1 restarts. @@ -444,13 +459,8 @@ struct context_2 int push_ifconfig_ipv6_netbits; struct in6_addr push_ifconfig_ipv6_remote; - /* client authentication state, CAS_SUCCEEDED must be 0 */ -#define CAS_SUCCEEDED 0 -#define CAS_PENDING 1 -#define CAS_FAILED 2 -#define CAS_PARTIAL 3 /* at least one client-connect script/plugin - * succeeded while a later one in the chain failed */ - int context_auth; + + enum client_connect_status context_auth; struct event_timeout push_request_interval; int n_sent_push_requests;