Skip to content

Commit a69e30e

Browse files
stephensmalleyWOnder93
authored andcommitted
tests/mac_admin: skip all tests on NFS
NFS does not truly support setting / getting of undefined contexts. While some of the tests currently pass, they trigger kernel error messages like the ones below: nfs_setsecurity() system_u:object_r:UNDEFINED:s0 31 security_inode_notifysecctx() -22 nfs_setsecurity() system_u:object_r:UNDEFINED:s0 31 security_inode_notifysecctx() -22 nfs_setsecurity() unconfined_u:object_r:UNDEFINED:s0 35 security_inode_notifysecctx() -22 If we wanted this to work over NFS, we would need further changes to the kernel. For now, skip all the mac_admin tests to avoid log spam. This is similar to handling in other test scripts like tests/capable_file/test. Signed-off-by: Stephen Smalley <[email protected]> Signed-off-by: Ondrej Mosnacek <[email protected]>
1 parent 95bc3ca commit a69e30e

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

tests/mac_admin/test

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
#!/usr/bin/perl
22

3-
use Test;
3+
use Test::More;
44

55
BEGIN {
66
$basedir = $0;
77
$basedir =~ s|(.*)/[^/]*|$1|;
88

99
$isnfs = `stat -f --print %T $basedir`;
10-
if ( $isnfs ne "nfs" ) {
11-
plan tests => 8;
10+
11+
if ( $isnfs eq "nfs" ) {
12+
plan skip_all => "undefined contexts not supported over NFS";
1213
}
1314
else {
14-
plan tests => 6;
15+
plan tests => 8;
1516
}
1617
}
1718

1819
# Verify that test_mac_admin_t can relabel a file to an undefined context.
1920
system("rm -f $basedir/test_file; touch $basedir/test_file");
2021
$result = system(
2122
"runcon -t test_mac_admin_t -- chcon -t UNDEFINED $basedir/test_file 2>&1");
22-
ok( $result, 0 ); # we expect this to succeed.
23+
ok( $result eq 0 ); # we expect this to succeed.
2324

2425
# Verify that test_mac_admin_t sees the undefined context.
2526
$result = `runcon -t test_mac_admin_t -- secon -t -f $basedir/test_file 2>&1`;
2627
chomp($result);
27-
ok( $result, "UNDEFINED" );
28+
ok( $result eq "UNDEFINED" );
2829

2930
# Verify that test_no_mac_admin_t sees the unlabeled context
3031
$result =
3132
`runcon -t test_no_mac_admin_t -- secon -t -f $basedir/test_file 2>&1`;
3233
chomp($result);
33-
ok( $result, "unlabeled_t" );
34+
ok( $result eq "unlabeled_t" );
3435

3536
# Delete the test file.
3637
system("rm -f $basedir/test_file");
@@ -40,22 +41,17 @@ system("rm -rf $basedir/test_dir");
4041
$result = system(
4142
"runcon -t test_mac_admin_t -- mkdir --context=system_u:object_r:UNDEFINED:s0 $basedir/test_dir 2>&1"
4243
);
43-
ok( $result, 0 ); # we expect this to succeed.
44-
45-
if ( $isnfs ne "nfs" ) {
44+
ok( $result eq 0 ); # we expect this to succeed.
4645

47-
# Verify that test_mac_admin_t sees the undefined label value.
48-
$result =
49-
`runcon -t test_mac_admin_t -- secon -t -f $basedir/test_dir 2>&1`;
50-
chomp($result);
51-
ok( $result, "UNDEFINED" );
46+
# Verify that test_mac_admin_t sees the undefined label value.
47+
$result = `runcon -t test_mac_admin_t -- secon -t -f $basedir/test_dir 2>&1`;
48+
chomp($result);
49+
ok( $result eq "UNDEFINED" );
5250

53-
# Verify that test_no_mac_admin_t sees the unlabeled context.
54-
$result =
55-
`runcon -t test_no_mac_admin_t -- secon -t -f $basedir/test_dir 2>&1`;
56-
chomp($result);
57-
ok( $result, "unlabeled_t" );
58-
}
51+
# Verify that test_no_mac_admin_t sees the unlabeled context.
52+
$result = `runcon -t test_no_mac_admin_t -- secon -t -f $basedir/test_dir 2>&1`;
53+
chomp($result);
54+
ok( $result eq "unlabeled_t" );
5955

6056
# Delete the test directory
6157
system("rm -rf $basedir/test_dir");

0 commit comments

Comments
 (0)