From: "cron2 (Code Review)" Date: Fri, 26 Jul 2024 11:57:32 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <4af52f39c1bf80ef0de993928a1113cfffedb44a-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="V68ICAWEzec="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: console_systemd: rename query_user_exec to query_user_systemd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --V68ICAWEzec= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#5) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/670?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: console_systemd: rename query_user_exec to query_user_syste= md ...................................................................... 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 Acked-by: Gert Doering Message-Id: <20240726104032.2112-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 983.html Signed-off-by: Gert Doering --- 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, 37 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/670/5 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 h= ave * 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 =3D true; /* Presume everything goes okay */ int i; diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/open= vpn/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/o= penvpn/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) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/670?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I379e1eb6dc57b9fe4bbdaefbd947a14326e7117a Gerrit-Change-Number: 670 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --V68ICAWEzec= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #5 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by cron2

console_systemd: rename query_user_exec to query_use=
r_systemd

This allows us to override query_user_exec for unit
tes= ts 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: I379e1eb= 6dc57b9fe4bbdaefbd947a14326e7117a
Signed-off-by: Frank Lichtenheld <f= rank@...2641...>
Acked-by: Gert Doering <gert@...1296...>
Me= ssage-Id: <20240726104032.2112-1-gert@...1296...>
URL: https://www= .mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28983.html
Sign= ed-off-by: Gert Doering <gert@...1296...>
---
M src/openvpn/con= sole.h
M src/openvpn/console_systemd.c
M tests/unit_tests/openvpn/tes= t_pkcs11.c
M tests/unit_tests/openvpn/test_user_pass.c
4 files change= d, 37 insertions(+), 14 deletions(-)

git pull ssh://gerrit.openvp=
n.net:29418/openvpn refs/changes/70/670/5
diff --git a/src/openvpn/=
console.h b/src/openvpn/console.h
index 7358299..72ae8e0 10= 0644
--- 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<= /span>
+ * querying the user= .
* This method uses the console/TTY directly.
= *
- * @param se= tup 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);
@@ -7= 7,21 +76,34 @@

#if defined(ENABLE_SYSTEM= D)
/**
- * Executes a configured setup, using the compiled method for querying th= e user
- *
- * @param setup Pointer to the = setup defining what to ask the user

+ * Loop through configured query_user slots, using the syst= emd method for
+ * qu= erying 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 d= efined steps completed successfully
+ */
+= static inline bool
+q= uery_user_exec(void)
= +{
+ return query_= user_exec_systemd();
= +}
+
+#else /* ENABLE_SYSTEMD not defined= */
/**
* Wrapper function enabling quer= y_user_exec() if no alternative methods have
* been enabl= ed
*
*/
-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/consol= e_systemd.c
index c7cf1ad..cc91cd1 100644
-= -- a/src/openvpn/console_systemd.c
+++ b/src/openvpn/consol= e_systemd.c
@@ -96,7 +96,7 @@
* */
bool
-query_user_exec(void)
+query_user_exec_systemd(void)
{
bool ret =3D true; /* Presume everything goes okay */

<= span> int i;

diff --git a/tests/unit_tests/openvpn/test= _pkcs11.c b/tests/unit_tests/openvpn/test_pkcs11.c
index 6d= 283a2..5518fa1 100644
--- a/tests/unit_tests/openvpn/test_p= kcs11.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)
+{
+ as= sert_true(0);
+ re= turn false;
+}=
+#endif
bo= ol
query_user_exec_builtin(void)
{=
diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/un= it_tests/openvpn/test_user_pass.c
index b43e655..de60291 10= 0644
--- 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 *manag= ement; /* global */

/* mocking */=
+#if defined(ENABLE_SYSTEMD= )
+bool
+query_user_exec_systemd(void)
+{
+ return query_user_exec_builtin();
+}
+#endif
bool
query_user_exec_builtin(void)

{

To view, visit change 670. To unsubscribe, or for help writing ma= il filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I379e1eb6dc57b9fe4bbdaefbd94= 7a14326e7117a
Gerrit-Change-Number: 670
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--V68ICAWEzec=--