summaryrefslogtreecommitdiff
path: root/sys-apps/openrc/files/0001-Filter-the-systemd-cgroup-from-the-current-process.patch
blob: ec925cc1415969aad30cbc2a2b17cef0a65d2a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 9f2ef0dabec9d7644f3f13e6d9e2037396493c6d Mon Sep 17 00:00:00 2001
From: Fabio Erculiani <lxnay@sabayon.org>
Date: Sat, 22 Jun 2013 11:05:11 +0200
Subject: [PATCH] Filter the systemd cgroup from the current process

logind relies on the name=systemd:/ cgroup path to determine the
session name and seat through pam_systemd. The problem arises when
the user log into a tty or via ssh and restart a service: the
name=systemd cgroup is not cleared and it gets inherited by all
the child processes spawned by the service.
---
 sh/runscript.sh.in | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 58e8eac..ba8eeb4 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -249,6 +249,12 @@ while [ -n "$1" ]; do
 		cd /
 		continue
 	fi
+	if [ "$1" = start ] && [ -d /sys/fs/cgroup/systemd ]; then
+		# reset the systemd cgroup so that it won't be
+		# propagated to children. This makes logind work,
+		# which otherwise gets confused.
+		echo $$ > /sys/fs/cgroup/systemd/tasks
+	fi
 	# See if we have the required function and run it
 	for _cmd in describe start stop status ${extra_commands:-$opts} \
 		$extra_started_commands $extra_stopped_commands
-- 
1.8.2.1