diff options
author | Alberto Gonzalez Iniesta <agi@inittab.org> | 2014-10-29 17:43:51 +0100 |
---|---|---|
committer | Alberto Gonzalez Iniesta <agi@inittab.org> | 2014-10-29 17:43:51 +0100 |
commit | 63862ed15e1abb4b29c5a43b469321c928613c62 (patch) | |
tree | 9c21e69bf5a514459227f5e32f75b8e12916c03f /src/openvpn/console.c | |
parent | 809daf3b371e0c2457b5d4bd414382eb67bf8348 (diff) |
Imported Upstream version 2.3.5upstream/2.3.5
Diffstat (limited to 'src/openvpn/console.c')
-rw-r--r-- | src/openvpn/console.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/openvpn/console.c b/src/openvpn/console.c index afda8ca..d66d408 100644 --- a/src/openvpn/console.c +++ b/src/openvpn/console.c @@ -34,6 +34,10 @@ #include "buffer.h" #include "misc.h" +#ifdef ENABLE_SYSTEMD +#include <systemd/sd-daemon.h> +#endif + #ifdef WIN32 #include "win32.h" @@ -143,14 +147,14 @@ close_tty (FILE *fp) static bool check_systemd_running () { - struct stat a, b; + struct stat c; /* We simply test whether the systemd cgroup hierarchy is - * mounted */ + * mounted, as well as the systemd-ask-password executable + * being available */ - return (lstat("/sys/fs/cgroup", &a) == 0) - && (lstat("/sys/fs/cgroup/systemd", &b) == 0) - && (a.st_dev != b.st_dev); + return (sd_booted() > 0) + && (stat(SYSTEMD_ASK_PASSWORD_PATH, &c) == 0); } @@ -162,7 +166,7 @@ get_console_input_systemd (const char *prompt, const bool echo, char *input, con struct argv argv; argv_init (&argv); - argv_printf (&argv, "/bin/systemd-ask-password"); + argv_printf (&argv, SYSTEMD_ASK_PASSWORD_PATH); argv_printf_cat (&argv, "%s", prompt); if ((std_out = openvpn_popen (&argv, NULL)) < 0) { |