From patchwork Wed Aug 12 21:29:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Thorpe X-Patchwork-Id: 1383 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id iJDiBKfwNF/SOgAAIUCqbw for ; Thu, 13 Aug 2020 03:49:59 -0400 Received: from proxy12.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net with LMTP id 0I6TA6fwNF8FXgAApN4f7A (envelope-from ) for ; Thu, 13 Aug 2020 03:49:59 -0400 Received: from smtp15.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3b.rsapps.net with LMTP id WBLqN6bwNF8ZOAAAEsW3lA ; Thu, 13 Aug 2020 03:49:58 -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: smtp15.gate.iad3b.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; dkim=fail (signature verification failed) header.d=sparklabs.com; dmarc=none (p=nil; dis=none) header.from=sparklabs.com X-Suspicious-Flag: YES X-Classification-ID: 958e1dca-dd39-11ea-844d-5254003d6d3a-1-1 Received: from [216.105.38.7] ([216.105.38.7:38764] helo=lists.sourceforge.net) by smtp15.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 90/5C-05486-6A0F43F5; Thu, 13 Aug 2020 03:49:58 -0400 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 1k67z6-0001uz-QU; Thu, 13 Aug 2020 07:49:12 +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 1k67z4-0001uq-SL for openvpn-devel@lists.sourceforge.net; Thu, 13 Aug 2020 07:49:10 +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=6wI+x0+entPrq0nsnwl2vIYgXWOTNjTr5HhICNWQOZM=; b=EW2AQuVRrQm50Wqw+QXHB58uVR cRJED/k8yIDjkbMaUo/mkWk2id3jk2AXS9eSe7jKLlW8+UnVOWALQRYGiS0GxVRp3lTpyVcnXcUny znesVh7EHPVWSHd28CqPEqjq8/7Mp2naXn/6STlZbwVw6IbAJFPKOv0Z2Rx/u4DG6I9Y=; 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=6wI+x0+entPrq0nsnwl2vIYgXWOTNjTr5HhICNWQOZM=; b=kkyvi0R1nZuvvA2NsrZkxs2zSq YEajNm6vINK2At6m7UlzsYIqv7jZ4b8egV323Y00cds4tk5qtS8EiUflWjv+1AgGFBnvXR6QKL6WX zQ8Rs6iOmKqzeK552WyNtU2VsdSnAaL9PMGGcFFBGBud3jx6phLydq27k3k6vRvUPAdU=; Received: from silicon.sparklabs.com ([66.185.22.121]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1k67z0-008v7P-SO for openvpn-devel@lists.sourceforge.net; Thu, 13 Aug 2020 07:49:10 +0000 Received: from silicon.sparklabs.com (localhost [127.0.0.1]) by silicon.sparklabs.com (Postfix) with ESMTP id 4BRyrG2GmhzPv6n for ; Thu, 13 Aug 2020 07:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sparklabs.com; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:to:from:from; s= dkim; t=1597303774; x=1599895775; bh=/+ud/qK4um3huYrkWGQwzQa3kCH er6vj8iw9vo3iTj8=; b=Jf635LtHk1PKJBlBVCLKJzGGlAOGqCU7Upd302U1i1U B2tFXJK8sx19npcMk52mG3PivdvVEjFVgSoPrdoSUcE9ftlQQxdCIVOlkR2MbHHb amiya03czM7SpOXwtAL4P3qtkjhtYy4ctTSPNZzBZtrXlLVGiaccc8VtWZLNrJqo = Received: from silicon.sparklabs.com ([127.0.0.1]) by silicon.sparklabs.com (silicon.sparklabs.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3u_VOkhZl8BL for ; Thu, 13 Aug 2020 07:29:34 +0000 (UTC) Received: from ubuntu20.localdomain (pa49-195-187-138.pa.nsw.optusnet.com.au [49.195.187.138]) by silicon.sparklabs.com (Postfix) with ESMTPSA id 4BRyrF0fydzPsgF; Thu, 13 Aug 2020 07:29:32 +0000 (UTC) From: Eric Thorpe To: openvpn-devel@lists.sourceforge.net Date: Thu, 13 Aug 2020 00:29:23 -0700 Message-Id: <20200813072923.24385-2-eric@sparklabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200813072923.24385-1-eric@sparklabs.com> References: <20200813072923.24385-1-eric@sparklabs.com> 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: sparklabs.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1k67z0-008v7P-SO Subject: [Openvpn-devel] [PATCH 2/2] Allows a plugin to provide a client_reason for authentication failure 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 Signed-off-by: Eric Thorpe --- src/openvpn/ssl_verify.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 8d8531c7..356b30fd 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -1157,6 +1157,9 @@ verify_user_pass_plugin(struct tls_session *session, struct tls_multi *multi, /* Is username defined? */ if ((session->opt->ssl_flags & SSLF_AUTH_USER_PASS_OPTIONAL) || strlen(up->username)) { + struct plugin_return pr, prfetch; + plugin_return_init(&pr); + /* set username/password in private env space */ setenv_str(session->opt->es, "username", up->username); setenv_str(session->opt->es, "password", up->password); @@ -1180,7 +1183,23 @@ verify_user_pass_plugin(struct tls_session *session, struct tls_multi *multi, #endif /* call command */ - retval = plugin_call(session->opt->plugins, OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY, NULL, NULL, session->opt->es); + retval = plugin_call(session->opt->plugins, OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY, NULL, &pr, session->opt->es); + + /* Fetch client reason */ + plugin_return_get_column(&pr, &prfetch, "client_reason"); + if (plugin_return_defined(&prfetch)) + { + int i; + for (i = 0; i < prfetch.n; ++i) + { + if (prfetch.list[i] && prfetch.list[i]->value) + { + auth_set_client_reason(multi, prfetch.list[i]->value); + } + } + } + + plugin_return_free(&pr); #ifdef PLUGIN_DEF_AUTH /* purge auth control filename (and file itself) for non-deferred returns */ @@ -1436,8 +1455,16 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi, if (multi->connection_established) { /* Notify the client */ - send_push_reply_auth_failed(multi, "SESSION:Auth failed"); - + const char *client_reason; + if (multi->client_reason != NULL) + { + client_reason = multi->client_reason; + } + else + { + client_reason = "SESSION:Auth failed"; + } + send_push_reply_auth_failed(multi, client_reason); } ks->authenticated = KS_AUTH_FALSE; msg(D_TLS_ERRORS, "TLS Auth Error: Auth Username/Password verification failed for peer");