public inbox for selinux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Ignore files that vanish during relabeling if ignore_noent is set
@ 2026-01-14 15:32 Johannes Segitz
  2026-01-21 15:25 ` Vit Mojzis
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Segitz @ 2026-01-14 15:32 UTC (permalink / raw)
  To: selinux

[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]

This happens e.g. when temporary files vanish during labeling the file
system. I don't like it that this is now in the err: handler, but
otherwise it would need to be repeated above a couple of times

Signed-off-by: Johannes Segitz <jsegitz@suse.com>
---
 libselinux/src/selinux_restorecon.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 7ef2d45d..6c55125c 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -768,10 +768,15 @@ out1:
        freecon(newcon);
        return rc;
 err:
-       selinux_log(SELINUX_ERROR,
-                   "Could not set context for %s:  %m\n",
-                   pathname);
-       rc = -1;
+       if (flags->ignore_noent && errno == ENOENT) {
+    // Sometimes files gets deleted while the relabeling happens
+               goto out;
+       } else {
+               selinux_log(SELINUX_ERROR,
+                                       "Could not set context for %s:  %m\n",
+                                       pathname);
+               rc = -1;
+       }
        goto out1;
 }

--
2.52.0

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 870 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-24 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14 15:32 [PATCH] Ignore files that vanish during relabeling if ignore_noent is set Johannes Segitz
2026-01-21 15:25 ` Vit Mojzis
2026-02-24 14:59   ` Johannes Segitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox