public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: selinux_set_callback: fix SETENFORCE callback test
Date: Fri, 11 Sep 2026 13:19:17 GMT [thread overview]
Message-ID: <178913275785.1.2677256206212109408.tests-selinux-5fe4b9e652ef@fedoraproject.org> (raw)
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;
}
reply other threads:[~2026-09-11 13:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly 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=178913275785.1.2677256206212109408.tests-selinux-5fe4b9e652ef@fedoraproject.org \
--to=plautrba@redhat.com \
--cc=git-commits@fedoraproject.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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox