From eb0a721f28d4e8128959bb7441566c73bfbadc47a29f6561c5b2ab205a48e08d Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Mon, 29 Aug 2011 15:49:55 +0000 Subject: [PATCH] - Add openvpn-2.1-systemd-passwd.patch / modify openvpn.init to support systemd password query (bnc#675406) OBS-URL: https://build.opensuse.org/package/show/network:vpn/openvpn?expand=0&rev=28 --- openvpn-2.1-systemd-passwd.patch | 61 ++++++++++++++++++++++++++++++++ openvpn.changes | 6 ++++ openvpn.spec | 4 ++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 openvpn-2.1-systemd-passwd.patch diff --git a/openvpn-2.1-systemd-passwd.patch b/openvpn-2.1-systemd-passwd.patch new file mode 100644 index 0000000..cca599a --- /dev/null +++ b/openvpn-2.1-systemd-passwd.patch @@ -0,0 +1,61 @@ +Index: openvpn-2.2.1/misc.c +=================================================================== +--- openvpn-2.2.1.orig/misc.c ++++ openvpn-2.2.1/misc.c +@@ -1333,26 +1333,49 @@ get_console_input (const char *prompt, c + ASSERT (input); + ASSERT (capacity > 0); + input[0] = '\0'; ++ bool is_systemd_running; ++ struct stat a, b; ++ ++ /* We simply test whether the systemd cgroup hierarchy is ++ * mounted */ ++ ++ is_systemd_running = (lstat("/sys/fs/cgroup", &a) == 0) ++ && (lstat("/sys/fs/cgroup/systemd", &b) == 0) ++ && (a.st_dev != b.st_dev); + + #if defined(WIN32) + return get_console_input_win32 (prompt, echo, input, capacity); + #elif defined(HAVE_GETPASS) +- if (echo) ++ if (echo || is_systemd_running) + { + FILE *fp; + +- fp = open_tty (true); +- fprintf (fp, "%s", prompt); +- fflush (fp); +- close_tty (fp); ++ if (is_systemd_running) ++ { ++ char *cmd; ++ ++ asprintf(&cmd, "/bin/systemd-ask-password \"%s\"", prompt); ++ fp = popen (cmd, "re"); ++ free (cmd); ++ } ++ else ++ { ++ fp = open_tty (true); ++ fprintf (fp, "%s", prompt); ++ fflush (fp); ++ close_tty (fp); + +- fp = open_tty (false); ++ fp = open_tty (false); ++ } + if (fgets (input, capacity, fp) != NULL) + { + chomp (input); + ret = true; + } +- close_tty (fp); ++ if (is_systemd_running) ++ fclose (fp); ++ else ++ close_tty (fp); + } + else + { diff --git a/openvpn.changes b/openvpn.changes index 07213ad..5ed9d56 100644 --- a/openvpn.changes +++ b/openvpn.changes @@ -5,6 +5,12 @@ Tue Aug 23 15:41:00 UTC 2011 - crrodriguez@opensuse.org - Use SSL_MODE_RELEASE_BUFFERS to keep memory usage low, sent upstream as https://community.openvpn.net/openvpn/ticket/157 +------------------------------------------------------------------- +Mon Aug 22 09:55:44 UTC 2011 - fcrozat@novell.com + +- Add openvpn-2.1-systemd-passwd.patch / modify openvpn.init to + support systemd password query (bnc#675406) + ------------------------------------------------------------------- Mon Jul 11 14:38:45 UTC 2011 - mt@suse.de diff --git a/openvpn.spec b/openvpn.spec index e850aef..9bcadd2 100644 --- a/openvpn.spec +++ b/openvpn.spec @@ -38,7 +38,8 @@ Source4: client-netconfig.up Source5: client-netconfig.down Patch1: %{name}-2.1-plugin-man.dif Patch2: %{name}-2.1-plugin-build.dif -Patch3: 0001-Use-SSL_MODE_RELEASE_BUFFERS-if-available.patch +Patch3: openvpn-2.1-systemd-passwd.patch +Patch4: 0001-Use-SSL_MODE_RELEASE_BUFFERS-if-available.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: lzo-devel openssl-devel BuildRequires: iproute2 pam-devel @@ -132,6 +133,7 @@ Authors: %patch1 -p0 %patch2 -p0 %patch3 -p1 +%patch4 -p1 sed -e "s|@PLUGIN_DIR@|%{plugin_dir}|g" \ -e "s|@PLUGIN_LIBDIR@|%{plugin_libdir}|g" \ -e "s|@PLUGIN_DOCDIR@|%{_defaultdocdir}/%{name}|g" \