From: "flichtenheld (Code Review)" Date: Thu, 20 Jun 2024 16:21:24 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <5ee31d0d7d35fcf39e67f633d5cbae59a1a6828b-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ELf3fDFs39A="; charset=UTF-8 Subject: [Openvpn-devel] [S] 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: plaisthos Cc: openvpn-devel --ELf3fDFs39A= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3Demail to review the following change. 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 --- 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 h= ave * 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 =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 */ =20 /* 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: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --ELf3fDFs39A= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

Vi= ew Change

console_systemd: rename query_user_exec to query_user_systemd=


This allows us to override query_user_exec for unit
tests more c= onsistently without having to jump through
weird hoops.

Fixes run= ning test_pkcs11 with --enable-systemd.

While here also fix document= ation comments for
query_user_exec*.

Change-Id: I379e1eb6dc57b9fe= 4bbdaefbd947a14326e7117a
Signed-off-by: Frank Lichtenheld <frank@...1665...= 641...>
---
M src/openvpn/console.h
M src/openvpn/console_syste= md.c
M tests/unit_tests/openvpn/test_pkcs11.c
M tests/unit_tests/open= vpn/test_user_pass.c
4 files changed, 36 insertions(+), 13 deletions(-)<= br>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/6=
70/1
diff --git a/src/openvpn/console.h b/src/openvpn/console.h
index 7358299..b542099 100644
--- a/src/openvp= n/console.h
+++ b/src/openvpn/console.h
@@ = -65,11 +65,10 @@


/**
- * Executes a configure= d 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 use= s the console/TTY directly.
*
- * @param setup Pointer to the setup defining = what to ask the user
- = *
* @return True if executing all the defined steps compl= eted successfully
*/
bool query_user_exe= c_builtin(void);
@@ -77,15 +76,28 @@

#if defined(ENABLE_SYSTEMD)
/**
- * Executes a configured setup, usi= ng the compiled method for querying the user

- *
- * @param setup Pointer to the setup defining what to ask the user
+ * Loop through confi= gured query_user slots, using the systemd method for
+ * querying the user.
+ * If systemd is not running it will fa= ll back to use
+ * qu= ery_user_exec_builtin() instead.
*
* @r= eturn True if executing all the defined steps completed successfully=
*/
-bool qu= ery_user_exec(void);
= +bool query_user_exec_systemd(void);

-#else /* ENABLE_SYSTEMD not defined*/
+/**
+ * Loop through configured query_user s= lots, using the compiled method for
+ * querying the user.
+ *
= + * @return True if executing all the defined steps completed successfully<= /span>
+ */
+static bool
+query_user_exec(void)
+{
+ return query_user_exec_systemd();
+}
+
+#el= se /* ENABLE_SYSTEMD not defined */
/**
= * Wrapper function enabling query_user_exec() if no alternative methods ha= ve
* been enabled
diff --git a/src/openvp= n/console_systemd.c b/src/openvpn/console_systemd.c
index c= 7cf1ad..cc91cd1 100644
--- a/src/openvpn/console_systemd.c<= /span>
+++ b/src/openvpn/console_systemd.c
@@ -96,= 7 +96,7 @@
*
*/
bool
-query_user_exec(void)
+query_user_exec_syste= md(void)
{
bool ret =3D true; /* Pre= sume everything goes okay */
int i;
di= ff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/openvp= n/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_ex= ec_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 ENA= BLE_SYSTEMD in misc.c */
-
#include "syshead.h"
#includ= e "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 change 670. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I379e1eb6dc57b9fe4bbdaefbd94= 7a14326e7117a
Gerrit-Change-Number: 670
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newchange
--ELf3fDFs39A=--