From patchwork Wed Dec 2 00:59:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1535 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.30.191.6]) by backend41.mail.ord1d.rsapps.net with LMTP id UK/XN/CBx19HBAAAqwncew (envelope-from ) for ; Wed, 02 Dec 2020 07:00:48 -0500 Received: from proxy17.mail.ord1d.rsapps.net ([172.30.191.6]) by director13.mail.ord1d.rsapps.net with LMTP id 0HisN/CBx190XQAA91zNiA (envelope-from ) for ; Wed, 02 Dec 2020 07:00:48 -0500 Received: from smtp1.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy17.mail.ord1d.rsapps.net with LMTPS id uK56N/CBx1/TVAAAWC7mWg (envelope-from ) for ; Wed, 02 Dec 2020 07:00:48 -0500 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.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: 03a7769a-3496-11eb-8051-5254002d775b-1-1 Received: from [216.105.38.7] ([216.105.38.7:35864] helo=lists.sourceforge.net) by smtp1.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 8A/08-12965-FE187CF5; Wed, 02 Dec 2020 07:00:48 -0500 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 1kkQnb-0000MA-AI; Wed, 02 Dec 2020 11:59:55 +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 1kkQnZ-0000Lx-57 for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2020 11:59:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2vMk0IMnsqfaHmpk1hEXcR0jtz5ejtzVM+SI8XPPDbo=; b=Mu615pIDslQ9B06p6FTQcJm8JC bqfOxhdrLSk9Eo+VAJMGYZf8asulQbbG1Rcp2x7YNZMi1H0RUOIxt1O3yoFooxg4u/WFgTudKttEA QPoP5vITsKAklpCV+ebE2feX49Ue5PrXRvzPyOkyjwcK7fW2QgHgDLaZZlX6PbdXP+sA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=2vMk0IMnsqfaHmpk1hEXcR0jtz5ejtzVM+SI8XPPDbo=; b=aczPWvGf4RY0MzeL3QoGgQfcKi Hah6ZDk4VVT61pD0MIQ70foqHsnjxFpn+5XLTBWPGEl3vQ0P93xjwuNZwl3HTHMonQ8W1XAqt/J3I 7B0mDmrv3LmawQgn+lHBsvMgCWit+D2PwjneNrM8yJJh91zQUYTz41ZUsRcme7ZdJyp0=; 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 1kkQnQ-00Ft9y-5Z for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2020 11:59:53 +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 1kkQnA-000NIl-Rw for openvpn-devel@lists.sourceforge.net; Wed, 02 Dec 2020 12:59:28 +0100 Received: (nullmailer pid 16660 invoked by uid 10006); Wed, 02 Dec 2020 11:59:28 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Wed, 2 Dec 2020 12:59:28 +0100 Message-Id: <20201202115928.16615-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 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: 1kkQnQ-00Ft9y-5Z Subject: [Openvpn-devel] [PATCH v2] Remove auth_user_pass.wait_for_push variable 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 variable was first introduce in earlier attempt to fix the auth-token problems with auth-nocache before user_password and auth_token were split into two variables. The idea of the variable it is being set if --pull is in use. However the variable was not always set correctly, especially if username/password are queried after an expired auth-token. Instead using that variable use session->opt->pull directly. Patch V2: rename delayed_auth_pass_purge to ssl_clean_user_pass to give a more fitting name since this function is not only used in the dealyed code path and also the new name aligns with ssl_clean_auth_token. Also fix a leftover wait_for_push in that function Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/init.c | 2 +- src/openvpn/manage.c | 1 - src/openvpn/misc.h | 1 - src/openvpn/ssl.c | 10 ++++------ src/openvpn/ssl.h | 5 ++++- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 2291a89a..27a4170d 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1615,7 +1615,7 @@ initialization_sequence_completed(struct context *c, const unsigned int flags) */ if (c->options.mode == MODE_POINT_TO_POINT) { - delayed_auth_pass_purge(); + ssl_clean_user_pass(); } /* Test if errors */ diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 68b136fb..446b82f4 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -3579,7 +3579,6 @@ management_query_user_pass(struct management *man, { /* preserve caller's settings */ man->connection.up_query.nocache = up->nocache; - man->connection.up_query.wait_for_push = up->wait_for_push; *up = man->connection.up_query; } secure_memzero(&man->connection.up_query, sizeof(man->connection.up_query)); diff --git a/src/openvpn/misc.h b/src/openvpn/misc.h index 8c3a1227..e4342b0d 100644 --- a/src/openvpn/misc.h +++ b/src/openvpn/misc.h @@ -64,7 +64,6 @@ struct user_pass { bool defined; bool nocache; - bool wait_for_push; /* true if this object is waiting for a push-reply */ /* max length of username/password */ #ifdef ENABLE_PKCS11 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 950bf421..efbf688f 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -434,8 +434,6 @@ ssl_set_auth_nocache(void) { passbuf.nocache = true; auth_user_pass.nocache = true; - /* wait for push-reply, because auth-token may still need the username */ - auth_user_pass.wait_for_push = true; } /* @@ -2414,14 +2412,15 @@ key_method_2_write(struct buffer *buf, struct tls_session *session) } /* if auth-nocache was specified, the auth_user_pass object reaches * a "complete" state only after having received the push-reply - * message. + * message. The push message might contain an auth-token that needs + * the username of auth_user_pass. * * For this reason, skip the purge operation here if no push-reply * message has been received yet. * * This normally happens upon first negotiation only. */ - if (!auth_user_pass.wait_for_push) + if (!session->opt->pull) { purge_user_pass(&auth_user_pass, false); } @@ -4195,8 +4194,7 @@ done: } void -delayed_auth_pass_purge(void) +ssl_clean_user_pass(void) { - auth_user_pass.wait_for_push = false; purge_user_pass(&auth_user_pass, false); } diff --git a/src/openvpn/ssl.h b/src/openvpn/ssl.h index f3032dab..56034540 100644 --- a/src/openvpn/ssl.h +++ b/src/openvpn/ssl.h @@ -592,7 +592,10 @@ void extract_x509_field_test(void); */ bool is_hard_reset_method2(int op); -void delayed_auth_pass_purge(void); +/** + * Cleans the saved user/password unless auth-nocache is in use. + */ +void ssl_clean_user_pass(void); /*