From bb7cfe65b619c18c40b69424eabcf1505d92dcbd9d543e60175ed8866d98a520 Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Mon, 28 Jan 2013 14:00:20 +0000 Subject: [PATCH] Accepting request 150170 from home:mtomaschewski:tests - Join openvpn.service systemd cgroup in start when needed, e.g. when starting with further parameters. (bnc#781106) OBS-URL: https://build.opensuse.org/request/show/150170 OBS-URL: https://build.opensuse.org/package/show/network:vpn/openvpn?expand=0&rev=50 --- openvpn.changes | 6 ++++++ openvpn.init | 31 +++++++++++++++++++++++++++++++ openvpn.spec | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/openvpn.changes b/openvpn.changes index 0bc6d03..3bdaa51 100644 --- a/openvpn.changes +++ b/openvpn.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Jan 28 13:59:07 UTC 2013 - mt@suse.com + +- Join openvpn.service systemd cgroup in start when needed, e.g. + when starting with further parameters. (bnc#781106) + ------------------------------------------------------------------- Thu Nov 29 18:19:40 CET 2012 - sbrabec@suse.cz diff --git a/openvpn.init b/openvpn.init index bb63df8..29e8a55 100644 --- a/openvpn.init +++ b/openvpn.init @@ -72,6 +72,35 @@ shopt -s nullglob action="$1" ; shift config="$1" ; shift +systemd_cgroup_dir="/sys/fs/cgroup/systemd" +openvpn_cgroup_dir="${systemd_cgroup_dir}/system/openvpn.service" + +join_openvpn_service_cgroup() +{ + local pid dummy + + # when the systemd cgroup mountpoint does not exists, + # assume we run unter systemv init -> nothing to do. + /bin/mountpoint -q "${systemd_cgroup_dir}" || return 0 + + # create the openvpn.service cgroup when needed + if test ! -d "${openvpn_cgroup_dir}" ; then + /bin/mkdir -p "${openvpn_cgroup_dir}" || return 1 + fi + + # check if the openvpn.service cgroup task list exists + if test -f "${openvpn_cgroup_dir}/tasks" ; then + # when we're already a member, all is done + while read pid dummy ; do + test "$pid" = "$$" && return 0 + done < "${openvpn_cgroup_dir}/tasks" + + # otherwise join the openvpn.service cgroup + echo "$$" > "${openvpn_cgroup_dir}/tasks" && return 0 + fi + return 1 +} + autostart_filter() { test "x$config" != "x" && return 0 @@ -84,6 +113,8 @@ autostart_filter() case "$action" in start) + join_openvpn_service_cgroup + /sbin/modprobe tun &>/dev/null name="" diff --git a/openvpn.spec b/openvpn.spec index 3ff5d8a..a584ac9 100644 --- a/openvpn.spec +++ b/openvpn.spec @@ -1,7 +1,7 @@ # # spec file for package openvpn # -# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed