mirror of
https://github.com/OpenVPN/openvpn.git
synced 2025-05-09 13:41:06 +08:00
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 <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20240726104032.2112-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28983.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
8991f0d5c6
commit
418463ad27
@ -65,11 +65,10 @@ void query_user_add(char *prompt, size_t prompt_len,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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
|
* @return True if executing all the defined steps completed successfully
|
||||||
*/
|
*/
|
||||||
bool query_user_exec_builtin(void);
|
bool query_user_exec_builtin(void);
|
||||||
@ -77,21 +76,34 @@ bool query_user_exec_builtin(void);
|
|||||||
|
|
||||||
#if defined(ENABLE_SYSTEMD)
|
#if defined(ENABLE_SYSTEMD)
|
||||||
/**
|
/**
|
||||||
* Executes a configured setup, using the compiled method for querying the user
|
* Loop through configured query_user slots, using the systemd method for
|
||||||
*
|
* querying the user.
|
||||||
* @param setup Pointer to the setup defining what to ask 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
|
* @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
|
* Wrapper function enabling query_user_exec() if no alternative methods have
|
||||||
* been enabled
|
* been enabled
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static bool
|
static inline bool
|
||||||
query_user_exec(void)
|
query_user_exec(void)
|
||||||
{
|
{
|
||||||
return query_user_exec_builtin();
|
return query_user_exec_builtin();
|
||||||
|
@ -96,7 +96,7 @@ get_console_input_systemd(const char *prompt, const bool echo, char *input, cons
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
query_user_exec(void)
|
query_user_exec_systemd(void)
|
||||||
{
|
{
|
||||||
bool ret = true; /* Presume everything goes okay */
|
bool ret = true; /* Presume everything goes okay */
|
||||||
int i;
|
int i;
|
||||||
|
@ -75,6 +75,14 @@ query_user_clear(void)
|
|||||||
{
|
{
|
||||||
assert_true(0);
|
assert_true(0);
|
||||||
}
|
}
|
||||||
|
#if defined(ENABLE_SYSTEMD)
|
||||||
|
bool
|
||||||
|
query_user_exec_systemd(void)
|
||||||
|
{
|
||||||
|
assert_true(0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bool
|
bool
|
||||||
query_user_exec_builtin(void)
|
query_user_exec_builtin(void)
|
||||||
{
|
{
|
||||||
|
@ -26,10 +26,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef ENABLE_SYSTEMD
|
|
||||||
/* avoid redefining ENABLE_SYSTEMD in misc.c */
|
|
||||||
#undef HAVE_CONFIG_H
|
|
||||||
|
|
||||||
#include "syshead.h"
|
#include "syshead.h"
|
||||||
#include "manage.h"
|
#include "manage.h"
|
||||||
|
|
||||||
@ -44,6 +40,13 @@
|
|||||||
struct management *management; /* global */
|
struct management *management; /* global */
|
||||||
|
|
||||||
/* mocking */
|
/* mocking */
|
||||||
|
#if defined(ENABLE_SYSTEMD)
|
||||||
|
bool
|
||||||
|
query_user_exec_systemd(void)
|
||||||
|
{
|
||||||
|
return query_user_exec_builtin();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bool
|
bool
|
||||||
query_user_exec_builtin(void)
|
query_user_exec_builtin(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user