summaryrefslogtreecommitdiff
path: root/src/openvpn/console_systemd.c
diff options
context:
space:
mode:
authorAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
committerAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
commit3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (patch)
treef29063da5bec4caf3853d49a22a09c8619eebd21 /src/openvpn/console_systemd.c
parentd53dba59e78da865c4fe820386ff2f4f76925f3b (diff)
New upstream version 2.4.0upstream/2.4.0
Diffstat (limited to 'src/openvpn/console_systemd.c')
-rw-r--r--src/openvpn/console_systemd.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/openvpn/console_systemd.c b/src/openvpn/console_systemd.c
index 8a953c9..1c0aa4c 100644
--- a/src/openvpn/console_systemd.c
+++ b/src/openvpn/console_systemd.c
@@ -42,7 +42,7 @@
*/
static bool
-check_systemd_running ()
+check_systemd_running()
{
struct stat c;
@@ -51,40 +51,41 @@ check_systemd_running ()
* being available */
return (sd_booted() > 0)
- && (stat(SYSTEMD_ASK_PASSWORD_PATH, &c) == 0);
+ && (stat(SYSTEMD_ASK_PASSWORD_PATH, &c) == 0);
}
static bool
-get_console_input_systemd (const char *prompt, const bool echo, char *input, const int capacity)
+get_console_input_systemd(const char *prompt, const bool echo, char *input, const int capacity)
{
int std_out;
bool ret = false;
- struct argv argv = argv_new ();
+ struct argv argv = argv_new();
- argv_printf (&argv, SYSTEMD_ASK_PASSWORD_PATH);
+ argv_printf(&argv, SYSTEMD_ASK_PASSWORD_PATH);
#ifdef SYSTEMD_NEWER_THAN_216
/* the --echo support arrived in upstream systemd 217 */
- if( echo )
+ if (echo)
{
- argv_printf_cat(&argv, "--echo");
+ argv_printf_cat(&argv, "--echo");
}
#endif
- argv_printf_cat (&argv, "--icon network-vpn");
- argv_printf_cat (&argv, "%s", prompt);
+ argv_printf_cat(&argv, "--icon network-vpn");
+ argv_printf_cat(&argv, "%s", prompt);
- if ((std_out = openvpn_popen (&argv, NULL)) < 0) {
- return false;
+ if ((std_out = openvpn_popen(&argv, NULL)) < 0)
+ {
+ return false;
}
- memset (input, 0, capacity);
- if (read (std_out, input, capacity-1) != 0)
+ memset(input, 0, capacity);
+ if (read(std_out, input, capacity-1) != 0)
{
- chomp (input);
- ret = true;
+ chomp(input);
+ ret = true;
}
- close (std_out);
+ close(std_out);
- argv_reset (&argv);
+ argv_reset(&argv);
return ret;
}
@@ -94,7 +95,8 @@ get_console_input_systemd (const char *prompt, const bool echo, char *input, con
* it will fall back to use query_user_exec_builtin() instead.
*
*/
-bool query_user_exec()
+bool
+query_user_exec()
{
bool ret = true; /* Presume everything goes okay */
int i;
@@ -108,12 +110,12 @@ bool query_user_exec()
/* Loop through the complete query setup and when needed, collect the information */
for (i = 0; i < QUERY_USER_NUMSLOTS && query_user[i].response != NULL; i++)
{
- if (!get_console_input_systemd(query_user[i].prompt, query_user[i].echo,
- query_user[i].response, query_user[i].response_len) )
- {
- /* Force the final result state to failed on failure */
- ret = false;
- }
+ if (!get_console_input_systemd(query_user[i].prompt, query_user[i].echo,
+ query_user[i].response, query_user[i].response_len) )
+ {
+ /* Force the final result state to failed on failure */
+ ret = false;
+ }
}
return ret;