From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4 1/2] core: add tst_selinux_enabled() utility
Date: Tue, 22 Jul 2025 14:06:35 +0200 [thread overview]
Message-ID: <20250722120635.GB22975@pevik> (raw)
In-Reply-To: <20250722-xattr_bug_repr-v4-1-4be1e52e97c6@suse.com>
Hi Andrea, all,
[ Cc Stephen, the fix author in case I'm wrong with reproducing on enforcing=0 ]
> Add tst_selinux_enabled() utility in tst_security.h in order to verify
> if SELinux is currently up and running in the system.
...
> +int tst_selinux_enabled(void)
> +{
> + int res = 0;
> +
> + if (tst_is_mounted(SELINUX_PATH))
> + res = 1;
I was wondering if it the test require enforcing or not therefore I retested it
and it's really reproducible with permissive mode, i.e. with kernel command line
security=selinux selinux=1 enforcing=0
Because if enforcing was required, I would be for using tst_selinux_enforcing(),
which checks /sys/fs/selinux/enforce for 1 as Wei suggested in v3:
https://lore.kernel.org/ltp/aHf839WS0BPIa5Zq@MiWiFi-CR6608-srv/
@Cyril @Andrea, just checking if /sys/fs/selinux/enforce exists would be faster
than looping /proc/mounts (via tst_is_mounted(SELINUX_PATH)). Can we just modify
the patch?
Kind regards,
Petr
+++ lib/tst_security.c
@@ -107,7 +107,7 @@ int tst_selinux_enabled(void)
{
int res = 0;
- if (tst_is_mounted(SELINUX_PATH))
+ if (access(SELINUX_STATUS_PATH, F_OK) == 0)
res = 1;
tst_res(TINFO, "SELinux enabled: %s", res ? "yes" : "no");
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-07-22 12:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 6:55 [LTP] [PATCH v4 0/2] Add listxattr04 test reproducer Andrea Cervesato
2025-07-22 6:55 ` [LTP] [PATCH v4 1/2] core: add tst_selinux_enabled() utility Andrea Cervesato
2025-07-22 10:51 ` Petr Vorel
2025-07-22 12:06 ` Petr Vorel [this message]
2025-07-22 13:18 ` Stephen Smalley
2025-07-22 13:20 ` Stephen Smalley
2025-07-22 13:42 ` Petr Vorel
2025-07-22 13:48 ` Stephen Smalley
2025-07-23 11:17 ` Andrea Cervesato via ltp
2025-07-23 12:51 ` Petr Vorel
2025-07-23 11:19 ` Andrea Cervesato via ltp
2025-07-23 12:41 ` Petr Vorel
2025-07-23 12:43 ` Andrea Cervesato via ltp
2025-07-23 12:46 ` Stephen Smalley
2025-07-23 13:13 ` Stephen Smalley
2025-07-23 13:15 ` Andrea Cervesato via ltp
2025-07-23 19:50 ` Petr Vorel
2025-07-22 19:12 ` Wei Gao via ltp
2025-07-22 6:55 ` [LTP] [PATCH v4 2/2] Add listxattr04 reproducer Andrea Cervesato
2025-07-22 14:11 ` Petr Vorel
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=20250722120635.GB22975@pevik \
--to=pvorel@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
--cc=stephen.smalley.work@gmail.com \
/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