public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: selinux_set_callback: fix SETENFORCE callback test
@ 2026-09-11 13:19 Petr Lautrbach
0 siblings, 0 replies; only message in thread
From: Petr Lautrbach @ 2026-09-11 13:19 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/selinux
Branch : pr775-checkpolicy-revdeps
Commit : 5fe4b9e652ef51f34e20453f6c45907ca2c9b30c
Author : Petr Lautrbach <plautrba@redhat.com>
Date : 2021-07-29T12:25:33+02:00
Stats : +11/-4 in 1 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/5fe4b9e652ef51f34e20453f6c45907ca2c9b30c?branch=pr775-checkpolicy-revdeps
Log:
selinux_set_callback: fix SETENFORCE callback test
When enforcing is switched to permissive and back to enforcing before
the status is updated, the SETENFORCE callback is not called as the state is
same as before.
Also avc_init is deprecated:
test_callback.c:62:5: warning: ‘avc_init’ is deprecated: Use avc_open and selinux_set_callback [-Wdeprecated-declarations]
---
diff --git a/libselinux/selinux_set_callback/test_callback.c b/libselinux/selinux_set_callback/test_callback.c
index 240bd11..9a4cd62 100644
--- a/libselinux/selinux_set_callback/test_callback.c
+++ b/libselinux/selinux_set_callback/test_callback.c
@@ -58,8 +58,8 @@ int main (int argc, char **argv) {
}
printf("calling avc_audit to call audit and log functions\n");
-
- avc_init("", NULL, NULL, NULL, NULL);
+
+ avc_open(NULL, 0);
struct security_id ssid = { "asdf", 5 };
struct security_id tsid = { "asdf", 5 };
@@ -99,11 +99,9 @@ int main (int argc, char **argv) {
if (enforcing == 1) {
security_setenforce(0);
- security_setenforce(1);
}
else {
security_setenforce(1);
- security_setenforce(0);
}
// triggers callbacks
@@ -123,5 +121,14 @@ int main (int argc, char **argv) {
// triggers callbacks
avc_has_perm_noaudit(&ssid, &tsid, 0, 1, NULL, &avd);
+ printf("switch enforcing back to %d\n", enforcing);
+ enforcing = security_getenforce();
+ if (enforcing == 1) {
+ security_setenforce(0);
+ }
+ else {
+ security_setenforce(1);
+ }
+
return exit_code;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-11 13:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:19 [tests/selinux] pr775-checkpolicy-revdeps: selinux_set_callback: fix SETENFORCE callback test Petr Lautrbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox