Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: sh/
Date: Fri, 23 Feb 2018 21:53:39
Message-Id: 1519422672.16ff3cd8df6169f73e3d7cf00758a4703f62cbf0.williamh@OpenRC
1 commit: 16ff3cd8df6169f73e3d7cf00758a4703f62cbf0
2 Author: Christian Brauner <christian.brauner <AT> ubuntu <DOT> com>
3 AuthorDate: Mon Feb 12 12:32:01 2018 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Fri Feb 23 21:51:12 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=16ff3cd8
7
8 check whether /sys/fs/cgroup is a mountpoint
9
10 The current check only tries to detect whether /sys/fs/cgroup exists and
11 whether it is writable or not. But when the init system doesn't mount
12 cgroups then /sys/fs/cgroup will just be an empty directory. When paired
13 with unprivileged containers that mount sysfs this will cause misleading
14 errors to be printed since /sys/fs/cgroup will be owned by user
15 nobody:nogroup in this case. Independent of this specific problem this
16 check will also be misleading when the /sys/fs/cgroup exists and is in
17 fact writable by the init system but isn't actually a mountpoint.
18
19 Note from William. "grep -qs" doesn't need to redirect output to
20 /dev/null since it is completely silent.
21
22 This fixes #209.
23
24 sh/openrc-run.sh.in | 9 ++++++---
25 1 file changed, 6 insertions(+), 3 deletions(-)
26
27 diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in
28 index 95d0ecab..e3dff6ce 100644
29 --- a/sh/openrc-run.sh.in
30 +++ b/sh/openrc-run.sh.in
31 @@ -260,9 +260,12 @@ for _cmd; do
32 # Apply cgroups settings if defined
33 if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ]
34 then
35 - if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then
36 - eerror "No permission to apply cgroup settings"
37 - break
38 + if grep -qs /sys/fs/cgroup /proc/1/mountinfo
39 + then
40 + if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then
41 + eerror "No permission to apply cgroup settings"
42 + break
43 + fi
44 fi
45 cgroup_add_service
46 fi