summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2014-10-03 19:16:07 +0200
committerGert Doering <gert@greenie.muc.de>2014-10-07 14:26:00 +0200
commitf33ee6bcb12fdc3869b17b7c528a209f16581e2e (patch)
treee958140b2ceb7099b16e2106eb65f71a955aeacb /src
parent51390f4de4f02edf377d55a7ef108798d2d8dc88 (diff)
downloadopenvpn-f33ee6bcb12fdc3869b17b7c528a209f16581e2e.tar.gz
openvpn-f33ee6bcb12fdc3869b17b7c528a209f16581e2e.tar.xz
openvpn-f33ee6bcb12fdc3869b17b7c528a209f16581e2e.zip
systemd: Use systemd functions to consider systemd availability
This is another systemd implementation clean-up. It was found that SELinux will block OpenVPN from checking /sys/fs/cgroups. As OpenVPN only checked /sys/fs/cgroups and /sys/fs/cgroups/systemd to see if systemd was available or not, it was considered better to query systemd directly to see whether or not to query for usernames and passwords via systemd. This patch has been compile tested on Fedora 19 and Fedora 21 alpha and function tested on Fedora 19. v2 - Use PKG_CHECK_MODULES() + check for libsystemd before libystemd-daemon. systemd >= 209 use a unified library Signed-off-by: David Sommerseth <davids@redhat.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1412356567-27125-1-git-send-email-openvpn.list@topphemmelig.net> URL: http://article.gmane.org/gmane.network.openvpn.devel/9072 Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src')
-rw-r--r--src/openvpn/Makefile.am1
-rw-r--r--src/openvpn/console.c10
2 files changed, 7 insertions, 4 deletions
diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
index fd593c5..d089f50 100644
--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Makefile.am
@@ -126,6 +126,7 @@ openvpn_LDADD = \
$(OPTIONAL_PKCS11_HELPER_LIBS) \
$(OPTIONAL_CRYPTO_LIBS) \
$(OPTIONAL_SELINUX_LIBS) \
+ $(OPTIONAL_SYSTEMD_LIBS) \
$(OPTIONAL_DL_LIBS)
if WIN32
openvpn_SOURCES += openvpn_win32_resources.rc
diff --git a/src/openvpn/console.c b/src/openvpn/console.c
index 337b1bb..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,15 +147,13 @@ close_tty (FILE *fp)
static bool
check_systemd_running ()
{
- struct stat a, b, c;
+ struct stat c;
/* We simply test whether the systemd cgroup hierarchy is
* 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);
}