SELinux Archive on lore.kernel.org
 help / color / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: selinux@vger.kernel.org
Subject: [PATCH] selinux-testsuite: fix the cgroups_label test
Date: Mon, 26 Aug 2019 11:11:30 -0400
Message-ID: <156683229042.27016.12674072161480134335.stgit@chester> (raw)

From: Paul Moore <paul@paul-moore.com>

We can't rely on /sys/fs/cgroups/unified anymore, use our own directory.

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 tests/cgroupfs_label/test |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/tests/cgroupfs_label/test b/tests/cgroupfs_label/test
index 127e802..385b953 100755
--- a/tests/cgroupfs_label/test
+++ b/tests/cgroupfs_label/test
@@ -5,24 +5,23 @@ BEGIN { plan tests => 2 }
 
 my $ret;
 
+my $dir = "/sys/fs/cgroup/selinuxtest";
+
 # Create a new cgroupfs directory and relabel it.
-mkdir("/sys/fs/cgroup/unified/test");
-system("chcon -R -t test_cgroup_t /sys/fs/cgroup/unified/test");
+mkdir("$dir");
+system("chcon -R -t test_cgroup_t $dir");
 
 # Create a subdirectory in it.
-mkdir("/sys/fs/cgroup/unified/test/subdir");
+mkdir("$dir/subdir");
 
-$ret =
-  system("test `secon -tf /sys/fs/cgroup/unified/test/subdir` = test_cgroup_t");
+$ret = system("secon -tf $dir/subdir | grep -q '^test_cgroup_t\$'");
 ok( $ret, 0 );    # Did the subdirectory inherit the parent's label?
 
-$ret = system(
-"test `secon -tf /sys/fs/cgroup/unified/test/subdir/cgroup.type` = test_cgroup_t"
-);
+$ret = system("secon -tf $dir/subdir/cgroup.type | grep -q '^test_cgroup_t\$'");
 ok( $ret, 0 );    # Did also files in the subdirectory inherit the label?
 
 # Cleanup.
-rmdir("/sys/fs/cgroup/unified/test/subdir");
-rmdir("/sys/fs/cgroup/unified/test");
+rmdir("$dir/subdir");
+rmdir("$dir");
 
 exit;


             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 15:11 Paul Moore [this message]
2019-08-26 15:19 ` Paul Moore

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156683229042.27016.12674072161480134335.stgit@chester \
    --to=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org
	public-inbox-index selinux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git