From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1005390-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8922F1382C5 for <garchives@archives.gentoo.org>; Fri, 23 Feb 2018 21:53:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CB009E0830; Fri, 23 Feb 2018 21:53:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AB3F7E0830 for <gentoo-commits@lists.gentoo.org>; Fri, 23 Feb 2018 21:53:37 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9BE22335C06 for <gentoo-commits@lists.gentoo.org>; Fri, 23 Feb 2018 21:53:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E0C251A7 for <gentoo-commits@lists.gentoo.org>; Fri, 23 Feb 2018 21:53:34 +0000 (UTC) From: "William Hubbs" <williamh@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" <williamh@gentoo.org> Message-ID: <1519422672.16ff3cd8df6169f73e3d7cf00758a4703f62cbf0.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: sh/ X-VCS-Repository: proj/openrc X-VCS-Files: sh/openrc-run.sh.in X-VCS-Directories: sh/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 16ff3cd8df6169f73e3d7cf00758a4703f62cbf0 X-VCS-Branch: master Date: Fri, 23 Feb 2018 21:53:34 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: aa89b2ae-bde3-4f2e-9f5a-422fac9799e9 X-Archives-Hash: bc38f9114822c4f2152867a241647463 commit: 16ff3cd8df6169f73e3d7cf00758a4703f62cbf0 Author: Christian Brauner <christian.brauner <AT> ubuntu <DOT> com> AuthorDate: Mon Feb 12 12:32:01 2018 +0000 Commit: William Hubbs <williamh <AT> gentoo <DOT> org> CommitDate: Fri Feb 23 21:51:12 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=16ff3cd8 check whether /sys/fs/cgroup is a mountpoint The current check only tries to detect whether /sys/fs/cgroup exists and whether it is writable or not. But when the init system doesn't mount cgroups then /sys/fs/cgroup will just be an empty directory. When paired with unprivileged containers that mount sysfs this will cause misleading errors to be printed since /sys/fs/cgroup will be owned by user nobody:nogroup in this case. Independent of this specific problem this check will also be misleading when the /sys/fs/cgroup exists and is in fact writable by the init system but isn't actually a mountpoint. Note from William. "grep -qs" doesn't need to redirect output to /dev/null since it is completely silent. This fixes #209. sh/openrc-run.sh.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in index 95d0ecab..e3dff6ce 100644 --- a/sh/openrc-run.sh.in +++ b/sh/openrc-run.sh.in @@ -260,9 +260,12 @@ for _cmd; do # Apply cgroups settings if defined if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ] then - if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then - eerror "No permission to apply cgroup settings" - break + if grep -qs /sys/fs/cgroup /proc/1/mountinfo + then + if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then + eerror "No permission to apply cgroup settings" + break + fi fi cgroup_add_service fi