Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: umockdev-record: t_system_single: handle missing SELinux context on /dev/null #256

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions tests/test-umockdev-record.vala
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,25 @@ t_system_single ()
assert_in("P: /devices/virtual/mem/null", sout);
assert_in("E: DEVNAME=/dev/zero", sout);
#if HAVE_SELINUX
// we may run on a system without SELinux
if (FileUtils.test("/sys/fs/selinux", FileTest.EXISTS)) {
string context;
assert_cmpint (Selinux.lgetfilecon ("/dev/null", out context), CompareOperator.GT, 0);
assert_in("E: __DEVCONTEXT=" + context + "\n", sout);
string context;
int res = Selinux.lgetfilecon ("/dev/null", out context);
if (res > 0) {
assert_in ("E: __DEVCONTEXT=" + context + "\n", sout);
} else if (res == -1 && (Posix.errno == Posix.ENODATA ||
Posix.errno == Posix.ENOTSUP ||
Posix.errno == Posix.ENOSYS)) {
// If SELinux is not available, or is available but
// there is no context defined for /dev/null,
// we should skip this check as there is
// no context recorded.
//
// ENODATA: context doesn't exist, or the process
// can't access it
// ENOTSUP: extended attributes not supported/disabled
// ENOSYS: lgetxattr syscall not available
assert (!sout.contains("E: __DEVCONTEXT"));
} else {
assert(!sout.contains("E: __DEVCONTEXT"));
assert_cmpint (res, CompareOperator.GT, 0);
}
#endif
}
Expand Down
Loading