forked from SELinuxProject/selinux-testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selinux-testsuite: Add minimal test for cgroupfs labeling inheritance
This patch adds a tiny test that checks that labels of newly created cgroupfs files/directories are correctly inherited from the parent. Should start passing when the following issue is fixed: SELinuxProject/selinux-kernel#39 Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
- Loading branch information
Showing
5 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
################################# | ||
# | ||
# Policy for testing cgroupfs labeling | ||
# | ||
|
||
# Types for test file. | ||
type test_cgroup_t; | ||
files_type(test_cgroup_t) | ||
|
||
require { | ||
type cgroup_t; | ||
} | ||
allow test_cgroup_t cgroup_t:filesystem { associate }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
all: | ||
clean: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/perl | ||
|
||
use Test; | ||
BEGIN { plan tests => 2 } | ||
|
||
my $ret; | ||
|
||
# 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"); | ||
|
||
# Create a subdirectory in it. | ||
mkdir("/sys/fs/cgroup/unified/test/subdir"); | ||
|
||
$ret = system( | ||
"test `stat -c %C /sys/fs/cgroup/unified/test/subdir | cut -d : -f 3` = test_cgroup_t" | ||
); | ||
ok( $ret, 0 ); # Did the subdirectory inherit the parent's label? | ||
|
||
$ret = system( | ||
"test `stat -c %C /sys/fs/cgroup/unified/test/subdir/cgroup.type | cut -d : -f 3` = 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"); | ||
|
||
exit; |