[lxc-devel] [PATCH] unpriv tests: also move caller into unbound cgroups

Serge Hallyn serge.hallyn at ubuntu.com
Wed May 21 16:33:57 UTC 2014


Otherwise the name=systemd cgroup isn't changed to one which
the lxc-unpriv user can write to, causing the test to fail.

This allows lxc-test-unpriv and lxc-test-usernic to pass when run in an
unprivileged container with cgmanager.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/tests/lxc-test-unpriv     | 2 +-
 src/tests/lxc-test-usernic.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tests/lxc-test-unpriv b/src/tests/lxc-test-unpriv
index bbe1e08..139b080 100755
--- a/src/tests/lxc-test-unpriv
+++ b/src/tests/lxc-test-unpriv
@@ -92,7 +92,7 @@ chown -R $TUSER /run/user/$(id -u $TUSER)
 cd $HDIR
 
 if [ -e /sys/fs/cgroup/cgmanager/sock ]; then
-	for d in $(grep -v ^# /proc/cgroups | awk '{print $1}'); do
+	for d in $(cut -d : -f 2 /proc/self/cgroup); do
 		dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
 			--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
 			string:$d string:$TUSER >/dev/null
diff --git a/src/tests/lxc-test-usernic.in b/src/tests/lxc-test-usernic.in
index 93af623..ad11f0a 100755
--- a/src/tests/lxc-test-usernic.in
+++ b/src/tests/lxc-test-usernic.in
@@ -85,7 +85,7 @@ lxc.id_map = g 0 910000 10000
 EOF
 
 if [ -e /sys/fs/cgroup/cgmanager/sock ]; then
-	for d in $(grep -v ^# /proc/cgroups | awk '{print $1}'); do
+	for d in $(cut -d : -f 2 /proc/self/cgroup); do
 		dbus-send --print-reply --address=unix:path=/sys/fs/cgroup/cgmanager/sock \
 			--type=method_call /org/linuxcontainers/cgmanager org.linuxcontainers.cgmanager0_0.Create \
 			string:$d string:usernic-user >/dev/null
-- 
1.9.1



More information about the lxc-devel mailing list