From: Johannes Segitz <jsegitz@suse.de>
To: selinux@vger.kernel.org
Subject: [PATCH] Ignore files that vanish during relabeling if ignore_noent is set
Date: Wed, 14 Jan 2026 16:32:55 +0100 [thread overview]
Message-ID: <aWe3J9UVT9WIBiuF@suse.com> (raw)
[-- 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 --]
next reply other threads:[~2026-01-14 15:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 15:32 Johannes Segitz [this message]
2026-01-21 15:25 ` [PATCH] Ignore files that vanish during relabeling if ignore_noent is set Vit Mojzis
2026-02-24 14:59 ` Johannes Segitz
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=aWe3J9UVT9WIBiuF@suse.com \
--to=jsegitz@suse.de \
--cc=selinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.