From patchwork Fri Sep 3 23:56:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1940 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 kLMKESBDM2ETLwAAIUCqbw (envelope-from ) for ; Sat, 04 Sep 2021 05:57:52 -0400 Received: from proxy20.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net with LMTP id oLS9ECBDM2GZXAAAfY0hYg (envelope-from ) for ; Sat, 04 Sep 2021 05:57:52 -0400 Received: from smtp1.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy20.mail.ord1d.rsapps.net with LMTPS id yId3ECBDM2EQOwAAsk8m8w (envelope-from ) for ; Sat, 04 Sep 2021 05:57:52 -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: smtp1.gate.ord1c.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 91276ff8-0d66-11ec-8481-842b2b47c027-1-1 Received: from [216.105.38.7] ([216.105.38.7:40808] helo=lists.sourceforge.net) by smtp1.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id C1/53-03284-F1343316; Sat, 04 Sep 2021 05:57:52 -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 1mMSQ1-0002I6-6x; Sat, 04 Sep 2021 09:57:01 +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 1mMSPr-0002Ey-6m for openvpn-devel@lists.sourceforge.net; Sat, 04 Sep 2021 09:56:51 +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:Cc:To:From:Sender:Reply-To: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=Qkf4I9hBucZbB4I/nTx9lPUsornsVv3/dmD/aTSiyI4=; b=hi3Qf30WsM+qUi+QrtlVc4S2Gj 7Tt1eF2M56PkLj+kiTKDFBt+dfKH2DSEzZ8JtCKrYKN+u1TZzmjNGjdtGl1ifDw7QB1uGnKQdFCAT 9OcpvAJ2F/3qfzFQk05UJNzadY6C519K9t4alEMFP1xcMQ/1IJU00oH++i/7suOZ1QPM=; 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:Cc:To:From:Sender:Reply-To: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=Qkf4I9hBucZbB4I/nTx9lPUsornsVv3/dmD/aTSiyI4=; b=MbEN7KI+xKPSdkKACR1D2hWFbB Kbm3BLYNaQncvcXxYCTOEsoXeQEqHm3RWYuqY4MsHMg4QVxE5x+nFnPk0dmWUM9xU44e5Bv/XCtUz aqegHzQ0NJDUf+6itFMF7/lRZhla6+VoSsT/SEqECWjn3zVhFx2k6VMSXR4BosKjH1Kk=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mMSPn-0006Hw-Ar for openvpn-devel@lists.sourceforge.net; Sat, 04 Sep 2021 09:56:51 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sat, 4 Sep 2021 11:56:24 +0200 Message-Id: <20210904095629.6273-3-a@unstable.cc> In-Reply-To: <20210904095629.6273-1-a@unstable.cc> References: <20210904095629.6273-1-a@unstable.cc> MIME-Version: 1.0 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.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1mMSPn-0006Hw-Ar Subject: [Openvpn-devel] [PATCH 2/7] compat-mode: allow user to specify version to be compatible with 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This changes introduces the basic inbfrastructure required to allow the user to specify a specific OpenVPN version to be compatible with. Following changes will modify defaults to more modern and safer values, while allowing backwards-compatible behaviour on demand. The backwards-compatible behaviour is intructed via the config knob '--compat-mode' implemented in this patch. Signed-off-by: Arne Schwabe Signed-off-by: Antonio Quartulli Acked-By: Arne Schwabe --- Changes.rst | 6 +++++ doc/man-sections/generic-options.rst | 9 +++++++ src/openvpn/options.c | 37 ++++++++++++++++++++++++++++ src/openvpn/options.h | 4 +++ 4 files changed, 56 insertions(+) diff --git a/Changes.rst b/Changes.rst index 0323a7f7..f55b0e3e 100644 --- a/Changes.rst +++ b/Changes.rst @@ -45,6 +45,12 @@ Pending auth support for plugins and scripts See ``sample/sample-scripts/totpauth.py`` for an example. +Compatibility mode (``--compat-mode``) + The modernisation of defaults can impact the compatibility of OpenVPN 2.6.0 + with older peers. The options ``--compat-mode`` allows UIs to provide users + with an easy way to still connect to older servers. + + Deprecated features ------------------- ``inetd`` has been removed diff --git a/doc/man-sections/generic-options.rst b/doc/man-sections/generic-options.rst index db39f6e2..63c6227c 100644 --- a/doc/man-sections/generic-options.rst +++ b/doc/man-sections/generic-options.rst @@ -52,6 +52,15 @@ which mode OpenVPN is configured as. BSDs implement a getrandom() or getentropy() syscall that removes the need for /dev/urandom to be available. +--compat-mode version + This option provides a way to alter the default of OpenVPN to be more + compatible with the version ``version`` specified. All of the changes + this option does can also be achieved using individual configuration + options. + + Note: Using this option reverts defaults to no longer recommended + values and should be avoided if possible. + --config file Load additional config options from ``file`` where each line corresponds to one command line option, but with the leading '--' removed. diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0d6b85cf..4d971a56 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3125,6 +3125,29 @@ options_postprocess_cipher(struct options *o) } } +/** + * Returns if we want 'backwards-compatibility' up to (but not included) a + * certain version + * + * @param version the oldest version that does not compatibility + * e.g. 20400 for all versions < 2.4.0 + * @return whether compatibility should be enabled + */ +static bool +need_compatibility_before(const struct options *o, int version) +{ + return o->backwards_compatible != 0 && o->backwards_compatible < version; +} + +/** + * Changes default values so that OpenVPN can be compatible with the user + * specified version + */ +static void +options_set_backwards_compatible_options(struct options *o) +{ +} + static void options_postprocess_mutate(struct options *o) { @@ -3137,6 +3160,8 @@ options_postprocess_mutate(struct options *o) helper_keepalive(o); helper_tcp_nodelay(o); + options_set_backwards_compatible_options(o); + options_postprocess_cipher(o); options_postprocess_mutate_invariant(o); @@ -6698,6 +6723,18 @@ add_option(struct options *options, setenv_str(es, p[1], p[2] ? p[2] : ""); } } + else if (streq(p[0], "compat-mode") && p[1] && !p[3]) + { + unsigned int major, minor, patch; + if (!(sscanf(p[1], "%u.%u.%u", &major, &minor, &patch) == 3)) + { + msg(msglevel, "cannot parse version number for --compat-mode: %s", + p[1]); + goto err; + } + + options->backwards_compatible = major * 10000 + minor * 100 + patch; + } else if (streq(p[0], "setenv-safe") && p[1] && !p[3]) { VERIFY_PERMISSION(OPT_P_SETENV); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index b0e40cb7..98c21a2a 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -225,6 +225,10 @@ struct options /* enable forward compatibility for post-2.1 features */ bool forward_compatible; + /** What version we should try to be compatible with as major * 10000 + + * minor * 100 + patch, e.g. 2.4.7 => 20407 */ + unsigned int backwards_compatible; + /* list of options that should be ignored even if unknown */ const char **ignore_unknown_option;