From patchwork Thu Jun 20 16:21:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3746 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:a501:b0:57d:b2cb:6cf with SMTP id hh1csp918021mab; Thu, 20 Jun 2024 09:22:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4K7E0ujTK2dp/0ojME9E3S8wbL5MG1MKb2Is/LlAKPbQ18ZEpRMRiXwXK9QPdR56dxfhDFP/oxVw6VVYO41sHLz/F1eE= X-Google-Smtp-Source: AGHT+IEv2b2a+dsLaTNsKstsAd5EQ1iJNVVYTZtPMbh1uKy3ukyR5XNfF6TFPQN1U3XWCwETiiP/ X-Received: by 2002:a05:6a20:729b:b0:1bc:bade:ea3 with SMTP id adf61e73a8af0-1bcbb732001mr6849230637.5.1718900533014; Thu, 20 Jun 2024 09:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718900533; cv=none; d=google.com; s=arc-20160816; b=eXpVk5MSO0ephpWMDeL6dihvKfmOeifcAr8BMd97gxYCbHk790UfG/XnIhItFc+wBQ WN0q5q+yYbF2C1QWdW98JtKtFuWAR2kllU0j37b71wqpGHiGiny0nrG+wPwVymkDvQEV dgkGxaa9/carNhgNx35lnPcTVKxJzF6zIELu/wL0M/6VaJIU/EdONLAIDrz68OKQgabG 8kMtwVWWGyMwsc5KhYNiVuXk4qBs3N2y1A4FL0cArDepV0gRJ8GkBFAVFAX3CceUR/1k yLvJSM8j6MAGVZhHN7fYxTlwZdjSAkK2xYo3MlyUn22qW/e/EgdqoW2yJtVoT0Z1BkrK RbQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=1bFwy9smBR1Ksd0OTwyQa3zqDyqsZ1C1BJViQoHPxyg=; fh=GFP4qDxgyJ2WEPo/oeLZg3Mj4NqvY1j2nTvTt7psNwg=; b=09kb59cFpevUs508iAp5E+XLxBfsvKKfsYSrjGVtEoKBcRlnIUwk8ycxzVJn9kWosH YLtNshA9CT4xZvPPlatzfEqzCG8LuPF1oEhvnbLziVr7NhVPgutmfMtQIpNeArGkf/9q o22FOVsm9fwMpDWpYdWwABPeXcUJz1KGVr2NjzbG/0G9oH96muhZz8JuASUjZm6Hu838 GQHDE2ZsptR3US0v1XBJxvdkJV90b3fd1sT+sR6CL3ihvr5k+x4X52tZ3PnTUiqZPuSS ljfNTkNg3d1CQLkZ0CK8im47iPsArc9YtbVRE7uoBm0/moR1jzQFWHoiEVwSAYcteTRQ 71oQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=kmGKzM74; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="HE/dM+za"; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=dEkPJrpP; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 41be03b00d2f7-705beb336d9si10731030a12.608.2024.06.20.09.22.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2024 09:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=kmGKzM74; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="HE/dM+za"; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=dEkPJrpP; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sKKXZ-0002EY-92; Thu, 20 Jun 2024 16:21:36 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sKKXX-0002ER-GG for openvpn-devel@lists.sourceforge.net; Thu, 20 Jun 2024 16:21:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NfLLJrPnSx78Zxg+HeUIUBm+rr1Dom75L9LyUou7744=; b=kmGKzM74WeWXLjrKLXAXCQ8sd0 yXLEBOv5T6hf2GLp3jLj3in7AWGJlATKiLr1GvQkecurhIbYgIQBr8ixm2nj+k1sSxjMP4u4A9rAo WTcb7OTuDMmGewHGknaN25+z35fDpZQA/TiWHQ6gpt/G5BsolZkzGTrTcOdQqVRZem0o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=NfLLJrPnSx78Zxg+HeUIUBm+rr1Dom75L9LyUou7744=; b=H E/dM+zanJyuoSM2GqbS0cViMG6slPM8xtqD0W0kPz8COXqkvhNDZM/AMqLxsGkCR5/igYSMFZDrpV 1gfpNeV0BuEU+n7SmsCejUD7YwZgKL9dOD/xLnsvdoZCTl4UFNgnDLGK0I/hUL+lXIM27DBfUL/3C F5B9PXks5rM5usjA=; Received: from mail-lf1-f53.google.com ([209.85.167.53]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1sKKXV-0007ZW-QX for openvpn-devel@lists.sourceforge.net; Thu, 20 Jun 2024 16:21:34 +0000 Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52b7ffd9f6eso1235858e87.3 for ; Thu, 20 Jun 2024 09:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1718900486; x=1719505286; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=NfLLJrPnSx78Zxg+HeUIUBm+rr1Dom75L9LyUou7744=; b=dEkPJrpP2WK1+R/vrWdg7l/23x5PKP17+fTQgbj/3Oh+XrGQyGARy3bJP2/5Vsac5S 0TkIDjXqGCGXNA7S17CsHX17DoFTWiGpM3wyOa6Tnv7fRnglXPiqCue8+PhxhBLzcwY1 Al6rEXMJUIqs+rCZ+yjfcW59CnvDLisOGWSkmzsR+3GHIcPLVjztpjLtLmNztVEXsZqN ue8sL5cdXPsr88wS2NG4WPr178ZUQ61NLxLIpdSwvqubAvlAcopzeVMJw95UdNtHnOXW cfQwNx4RmQk2Pjx4jE0rlxm73CsO6Qz5+JyNXxl8VUhHf7OOISXJP3hKVyPyyYYlftEn UFXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718900486; x=1719505286; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NfLLJrPnSx78Zxg+HeUIUBm+rr1Dom75L9LyUou7744=; b=QtnHIkglA5k1gvlT7ikiQ/BdU6wgJODBGDcREi0NPzNzIVzBJuIm+b5MeTkELFr7UB 0mKP495oue6o1d98nJmDOEzjJgD7tfeO88efF8HeqQs8ssEi2KLwb8OZ3X4yMMpss3oy dxTAQgoB/Z6hlsOKYmUfEKTuYyMh0a+0KeeEhRhA70GnYuHtRURlXI2LUVdpNUByZ+Y5 EQleKcsrMOIM61HzZN6lFC+tCAci45hSXrkGc65h2oCqVC9FxlDaU/avFqBhiP+M65A8 C+88rygx6aZfKC7zV7HJPTvXkkiUqnn2p5ZlpIf1jZnutYFPbW+cS/dT9j9bX/qpAh4r sB9A== X-Gm-Message-State: AOJu0YzO10d9Ox/j8l4npbQToi1WW/sZLbx9ADhDAJccvVygH9t/beEp YJys+ne3iJWd2yVe6MtgvKb6LxWX6kw1ca9Ij6bu7bivTzeZheplyhcoPc6Cq4PYWxM7dEj1Omn 7 X-Received: by 2002:a05:6512:3b29:b0:52c:9ab1:a312 with SMTP id 2adb3069b0e04-52ccaa5850bmr4771441e87.4.1718900485860; Thu, 20 Jun 2024 09:21:25 -0700 (PDT) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247fe1b5desm11115265e9.4.2024.06.20.09.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 09:21:25 -0700 (PDT) From: "flichtenheld (Code Review)" X-Google-Original-From: "flichtenheld (Code Review)" X-Gerrit-PatchSet: 1 Date: Thu, 20 Jun 2024 16:21:24 +0000 To: plaisthos Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I379e1eb6dc57b9fe4bbdaefbd947a14326e7117a X-Gerrit-Change-Number: 670 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 1b37f5ae21c6845d693cb942072bb6163b452009 References: Message-ID: <5ee31d0d7d35fcf39e67f633d5cbae59a1a6828b-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) 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: Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit 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.167.53 listed in list.dnswl.org] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.167.53 listed in sa-trusted.bondedsender.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.53 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.167.53 listed in bl.score.senderscore.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1sKKXV-0007ZW-QX Subject: [Openvpn-devel] [S] Change in openvpn[master]: console_systemd: rename query_user_exec to query_user_systemd 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: , Reply-To: frank@lichtenheld.com, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1802397845257270948?= X-GMAIL-MSGID: =?utf-8?q?1802397845257270948?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/670?usp=email to review the following change. Change subject: console_systemd: rename query_user_exec to query_user_systemd ...................................................................... console_systemd: rename query_user_exec to query_user_systemd This allows us to override query_user_exec for unit tests more consistently without having to jump through weird hoops. Fixes running test_pkcs11 with --enable-systemd. While here also fix documentation comments for query_user_exec*. Change-Id: I379e1eb6dc57b9fe4bbdaefbd947a14326e7117a Signed-off-by: Frank Lichtenheld --- M src/openvpn/console.h M src/openvpn/console_systemd.c M tests/unit_tests/openvpn/test_pkcs11.c M tests/unit_tests/openvpn/test_user_pass.c 4 files changed, 36 insertions(+), 13 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/670/1 diff --git a/src/openvpn/console.h b/src/openvpn/console.h index 7358299..b542099 100644 --- a/src/openvpn/console.h +++ b/src/openvpn/console.h @@ -65,11 +65,10 @@ /** - * Executes a configured setup, using the built-in method for querying the user. + * Loop through configured query_user slots, using the built-in method for + * querying the user. * This method uses the console/TTY directly. * - * @param setup Pointer to the setup defining what to ask the user - * * @return True if executing all the defined steps completed successfully */ bool query_user_exec_builtin(void); @@ -77,15 +76,28 @@ #if defined(ENABLE_SYSTEMD) /** - * Executes a configured setup, using the compiled method for querying the user - * - * @param setup Pointer to the setup defining what to ask the user + * Loop through configured query_user slots, using the systemd method for + * querying the user. + * If systemd is not running it will fall back to use + * query_user_exec_builtin() instead. * * @return True if executing all the defined steps completed successfully */ -bool query_user_exec(void); +bool query_user_exec_systemd(void); -#else /* ENABLE_SYSTEMD not defined*/ +/** + * Loop through configured query_user slots, using the compiled method for + * querying the user. + * + * @return True if executing all the defined steps completed successfully + */ +static bool +query_user_exec(void) +{ + return query_user_exec_systemd(); +} + +#else /* ENABLE_SYSTEMD not defined */ /** * Wrapper function enabling query_user_exec() if no alternative methods have * been enabled diff --git a/src/openvpn/console_systemd.c b/src/openvpn/console_systemd.c index c7cf1ad..cc91cd1 100644 --- a/src/openvpn/console_systemd.c +++ b/src/openvpn/console_systemd.c @@ -96,7 +96,7 @@ * */ bool -query_user_exec(void) +query_user_exec_systemd(void) { bool ret = true; /* Presume everything goes okay */ int i; diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/openvpn/test_pkcs11.c index 6d283a2..5518fa1 100644 --- a/tests/unit_tests/openvpn/test_pkcs11.c +++ b/tests/unit_tests/openvpn/test_pkcs11.c @@ -75,6 +75,14 @@ { assert_true(0); } +#if defined(ENABLE_SYSTEMD) +bool +query_user_exec_systemd(void) +{ + assert_true(0); + return false; +} +#endif bool query_user_exec_builtin(void) { diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/unit_tests/openvpn/test_user_pass.c index b43e655..de60291 100644 --- a/tests/unit_tests/openvpn/test_user_pass.c +++ b/tests/unit_tests/openvpn/test_user_pass.c @@ -26,10 +26,6 @@ #include "config.h" #endif -#undef ENABLE_SYSTEMD -/* avoid redefining ENABLE_SYSTEMD in misc.c */ -#undef HAVE_CONFIG_H - #include "syshead.h" #include "manage.h" @@ -44,6 +40,13 @@ struct management *management; /* global */ /* mocking */ +#if defined(ENABLE_SYSTEMD) +bool +query_user_exec_systemd(void) +{ + return query_user_exec_builtin(); +} +#endif bool query_user_exec_builtin(void) {