From patchwork Fri Jul 26 10:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3778 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:bb85:b0:5a1:d4fc:4ac6 with SMTP id gl5csp380912mab; Fri, 26 Jul 2024 03:41:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwP3B3hWr6BYIxgKmkAGns8mBVWqZRh2GAIRnaw5vz1ElsFAM/s7BwipSh4iSt57RIzL3A5/chq1Ox1M2MuF9iu8sUWWg= X-Google-Smtp-Source: AGHT+IF19bJINzzGz5jKfXBEhIZz5El5iwZlQHA6P0GIzwSAzmB+6fwX1dPvlaDEdm3AK+jP6tEM X-Received: by 2002:a17:902:8b82:b0:1fd:a54e:bc41 with SMTP id d9443c01a7336-1fed6cd3adcmr34566805ad.8.1721990481319; Fri, 26 Jul 2024 03:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721990481; cv=none; d=google.com; s=arc-20160816; b=CZgdwN2m+tob2bXc/16ZU0g60z6ZOjA//52NOSaHIjM5Q8h6t/twqFPbRK4r/vYk1x cOLxsTxDdblOttB3MCvMFTvB581Sh+LQFrjkT9IK4cCDrO2QgTCfOTd7snN8EFNmu48G +7lSr6rJtc6UsF92axC7JqPQfor74HbRQlal87PJw+R/c2b4jaATyGSbrcnhwvTCACXh 4O9vcP238bf8KOoHTUzT/4NK+JypWC+PluR4KVcvDYlikYeKhdRXjQ1gs5gpvo2ucuvQ UscjRgwlcnzV0FxtdjOkhgCtBQws/8NP2BAwblTcpEHronp3Xp/2iUfxd+WyrK1qsFsA kRhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=+Awie7mwAo8UVomZPZfAM+8WFqNL0KpJPha/mgm3S+Q=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=P4dTyis6YAMqIu+X4sbWLWAjeE9cQ4NDu3rujm+v3PkD5yjYvNt3EYCJupBJ/rnPj6 Osywa56oxISzXYzBH8DwOzwt2UFhz4ImB5Dw4WoP5fDpeb6pX4qyqHwuCw1w/w+AIrZt i0Elu+ox9RMvceLs60v3pVmYWhORJKVKOXutx1unvDuyJfj81V01mA96u0i9lZvOYbR2 NSw9Re0VJIcH7pn5Q55y1DuarXJ0GFKz7LzJ6z06gXFBgZX9+a1/QgMB7r98BhbBMsAW C3IwllXavyyWlniqsgJrpcKblEP7v3Wa0XnEFI/sYMDBHETin5yGqpfdSlXn6QfH2uAB Imtg==; 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=k6ImR7BH; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VZKj1xiL; 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=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id d9443c01a7336-1fed7ca2389si36694985ad.76.2024.07.26.03.41.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jul 2024 03:41:21 -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=k6ImR7BH; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VZKj1xiL; 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=muc.de 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 1sXINZ-0006vc-Hn; Fri, 26 Jul 2024 10:40:52 +0000 Received: from [172.30.29.67] (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 1sXINY-0006vE-Ed for openvpn-devel@lists.sourceforge.net; Fri, 26 Jul 2024 10:40: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:To:From:Sender:Reply-To:Cc: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=epgQ9wR4TXSHkpEpDY5/nGMC0AVBnLvsMQLCWUikcL0=; b=k6ImR7BHrd+/wqDqOrfRRHEnwI zHG7gCUN1PEnsYiYPuJI8hNzz68p1n1jbGJ6b0stx4K9FhYsptlzlqxXwFcYr7WwNsMZ2XrhTDjSZ fPxluHVVW6CAbtn8cVjoWAq5JtXOeh5MyUwdCm4hmZoFr5ANBeI17h2acf+aDWJyyqsI=; 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:To:From:Sender:Reply-To:Cc: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=epgQ9wR4TXSHkpEpDY5/nGMC0AVBnLvsMQLCWUikcL0=; b=VZKj1xiLXdtDwJomdVcCqzOngn 7T9PJ5DuljQ7kdYEbU9V62/JNF1/A6iCuVwv82d2EDGzLm3FcbOEARJgSGyS69dO5+UwwqUSv+JFa 0Lu+2C6PyrjYM7OOgOFP19uf/uDXogc4cYx1lpJsy/UuijJkWEkQPvTyptvSWzkPYzqw=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sXINQ-0002nx-Tm for openvpn-devel@lists.sourceforge.net; Fri, 26 Jul 2024 10:40:46 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 46QAeXw0002124 for ; Fri, 26 Jul 2024 12:40:33 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 46QAeX4d002123 for openvpn-devel@lists.sourceforge.net; Fri, 26 Jul 2024 12:40:33 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 26 Jul 2024 12:40:32 +0200 Message-ID: <20240726104032.2112-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.44.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.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: From: Frank Lichtenheld 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. Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 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: openvpn.net] 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. [193.149.48.174 listed in sa-trusted.bondedsender.org] 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. [193.149.48.174 listed in bl.score.senderscore.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1sXINQ-0002nx-Tm Subject: [Openvpn-devel] [PATCH v4] 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1805637890534664960?= X-GMAIL-MSGID: =?utf-8?q?1805637890534664960?= From: Frank Lichtenheld 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 Acked-by: Gert Doering --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/670 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/console.h b/src/openvpn/console.h index 7358299..72ae8e0 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,21 +76,34 @@ #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 inline 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 * */ -static bool +static inline bool query_user_exec(void) { return query_user_exec_builtin(); 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) {