From patchwork Tue Nov 9 08:47:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pete Nelson X-Patchwork-Id: 2067 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director15.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id DALDOaTQimFOUgAAIUCqbw (envelope-from ) for ; Tue, 09 Nov 2021 14:48:52 -0500 Received: from proxy14.mail.ord1d.rsapps.net ([172.30.191.6]) by director15.mail.ord1d.rsapps.net with LMTP id wCOEOKTQimGhMgAAIcMcQg (envelope-from ) for ; Tue, 09 Nov 2021 14:48:52 -0500 Received: from smtp14.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy14.mail.ord1d.rsapps.net with LMTPS id SGXdGqbQimHfGQAAtEH5vw (envelope-from ) for ; Tue, 09 Nov 2021 14:48:54 -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: smtp14.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; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: 108b8d20-4196-11ec-b1d1-525400504bae-1-1 Received: from [216.105.38.7] ([216.105.38.7:58104] helo=lists.sourceforge.net) by smtp14.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 1E/93-21562-4A0DA816; Tue, 09 Nov 2021 14:48:52 -0500 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.94.2) (envelope-from ) id 1mkX61-0002HH-Oc; Tue, 09 Nov 2021 19:47:54 +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.94.2) (envelope-from ) id 1mkX5t-0002H9-1g for openvpn-devel@lists.sourceforge.net; Tue, 09 Nov 2021 19:47:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:To:Subject:Message-ID:Date:From: MIME-Version:Sender:Reply-To:Cc: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=v6pnlA827EX7Y/34j2N4dJwZ/FGQ4TcypQ1ZZErUlec=; b=ZHUunM4DKZREveLeg9wGw/mTmd OPV6l4/RKWRVWztyRedb9HjeoiejAdNMI/V9eFHPSwQJJhB9BJMTYjGMOeLXoJ++iLlEv4xUWaa4D IZ1/V6KiyV0pYYWxUtjJLN4dXJJDDUKQyGsXUMTyoAj7hmN9s6qOan+RGNDNenRddz+k=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:To:Subject:Message-ID:Date:From:MIME-Version:Sender:Reply-To :Cc: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=v6pnlA827EX7Y/34j2N4dJwZ/FGQ4TcypQ1ZZErUlec=; b=J 6MG1iC7WKTniEDlrPYHPoJecWngjuZq1Kc7srIXxdlW5wctCdkZuSoLd0Zw/AYcwYIaAtTqmX7BE/ X6bYV7xsYT/BYw9mf523WNvtrHodL7jvZjsed8fKX3rt5yffJN0MDjanj8MPfFgrYI1fhXvOZFF0p QXElXJ9yvZ2UUHD4=; Received: from mail-pg1-f182.google.com ([209.85.215.182]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1mkX5p-0004uV-Jr for openvpn-devel@lists.sourceforge.net; Tue, 09 Nov 2021 19:47:46 +0000 Received: by mail-pg1-f182.google.com with SMTP id g28so80949pgg.3 for ; Tue, 09 Nov 2021 11:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=v6pnlA827EX7Y/34j2N4dJwZ/FGQ4TcypQ1ZZErUlec=; b=PDhmeNKiV5l5fhZ8bsQJKrTQx+/Q8Av9Xowd+U+Mw65P0P+/a3dPx4B6hVbPo8AP+8 nrWX6/VSDjuBhTSSnGfiLmhzYwNXLUpAVzvV3iER80dAcpmQlsozOv6RJw5gy8W9VZ/9 04zJRd48TzMh1zxoHYObDSX6Z7LJYiPLvd/u5LWzAnvlC9NrUvmfV5+IDI8StJENMaLF qxhiwVd/X+R9SycrYjYJiG6rM9puCwp0k0Cs3IgCNx7yvRGe2US22NJse8+kO8TuD67E ZuSlPnPBQNHJSzqg31wAvCqWlvY6/gSh4Dw6TWvFBcjvzKatC8Od80osaABZj47kTLt/ RoVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=v6pnlA827EX7Y/34j2N4dJwZ/FGQ4TcypQ1ZZErUlec=; b=BMQe4QMWOIeVaj/+artCWa2AYoKz9FX8uZFyQ0DLx1sKwWgabNnhHzo4QKVw1MxaRg JLIx0lfU//j09CszXLeA4tHrBrl6D9hSNrJDBGzqUkdtIfL/bpIjWEnguIhI3UmjJnp6 VH1Myrb7B25J+u4T/j0xQXOG4S1wmveE/qg9QRmMLWN5S6fw657hUeEQC+f3t4HJqMGm As0tzyxkKty5kZ5ubo83u0vGZb4TQ5TXdpAvEiHJXtzLb32TdqgEXMO2BWAlicVF0oxi 6a9iw7nPvNiXCf1fv/jfyNBbAr2vILjc4+L2YnwiumTQwuzICkugi1yFbOh0Wv02Tjjr tsCw== X-Gm-Message-State: AOAM531x7PmeGOuZjjcNhiX8Q4q41pOAWj2XsLyvcNiaA4K+UQmPGINU cLYlKrY/nfXPh9fTM0+PpAjeLdmNCTr8kVvRUYEFrrUucrI= X-Google-Smtp-Source: ABdhPJzTV6dSNF8szSOttd1+AAAl9OovM2QjyOhXWyV20oY1IZ2JOvOOmIza8OehQk35PFQ6jattsMhlTgxvU7GIuEk= X-Received: by 2002:a63:81c7:: with SMTP id t190mr8120599pgd.292.1636487255776; Tue, 09 Nov 2021 11:47:35 -0800 (PST) MIME-Version: 1.0 From: Pete Nelson Date: Tue, 9 Nov 2021 19:47:25 +0000 Message-ID: To: openvpn-devel@lists.sourceforge.net X-Spam-Report: Spam detection software, running on the system "util-spamd-1.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: When evaluating authentication plugins, stop further evaluation once the first failure is detected. Implementation notes: Refactoring from a switch-case to an if-else block allows the break statement to break out of the outer for loop without additional control variables. Also, moving the pr->n sett [...] Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.215.182 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [petiepooo[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.182 listed in wl.mailspike.net] 0.0 HTML_MESSAGE BODY: HTML included in message -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.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1mkX5p-0004uV-Jr Subject: [Openvpn-devel] [PATCH] boolean short-circuit auth upon 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 When evaluating authentication plugins, stop further evaluation once the first failure is detected. Implementation notes: Refactoring from a switch-case to an if-else block allows the break statement to break out of the outer for loop without additional control variables. Also, moving the pr->n setting to within the loop keeps the value correct if one does break out early. First email patch submission and first patch submitted to this list; be gentle please... -- Pete Signed-off-by: Peter Nelson --- src/openvpn/plugin.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index d5704e07..c6c9a63f 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -818,24 +818,19 @@ plugin_call_ssl(const struct plugin_list *pl, certdepth, current_cert ); - switch (status) + if (pr) { - case OPENVPN_PLUGIN_FUNC_SUCCESS: - break; - - case OPENVPN_PLUGIN_FUNC_DEFERRED: - deferred = true; - break; - - default: - error = true; - break; + pr->n = i + 1; + } + if (status == OPENVPN_PLUGIN_FUNC_DEFERRED) + { + deferred = true; + } + else if (status != OPENVPN_PLUGIN_FUNC_SUCCESS) + { + error = true; + break; } - } - - if (pr) - { - pr->n = i; } gc_free(&gc);