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

* Re: [PATCH] Ignore files that vanish during relabeling if ignore_noent is set
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Vit Mojzis @ 2026-01-21 15:25 UTC (permalink / raw)
  To: Johannes Segitz, selinux

Hi,
does this still happen with 
https://github.com/SELinuxProject/selinux/commit/54c79a74f5b9154762abaadf8194665598b24115 
applied?

Vit

On 1/14/26 4:32 PM, Johannes Segitz wrote:
> 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


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

* Re: [PATCH] Ignore files that vanish during relabeling if ignore_noent is set
  2026-01-21 15:25 ` Vit Mojzis
@ 2026-02-24 14:59   ` Johannes Segitz
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Segitz @ 2026-02-24 14:59 UTC (permalink / raw)
  To: Vit Mojzis; +Cc: selinux

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

Sorry for the late reply, was on long term sick leave

On Wed, Jan 21, 2026 at 04:25:19PM +0100, Vit Mojzis wrote:
> does this still happen with https://github.com/SELinuxProject/selinux/commit/54c79a74f5b9154762abaadf8194665598b24115
> applied?

no, doesn't happen with that, thanks

Johannes
-- 
GPG Key                EE16 6BCE AD56 E034 BFB3  3ADD 7BF7 29D5 E7C8 1FA0
Subkey fingerprint:    250F 43F5 F7CE 6F1E 9C59  4F95 BC27 DD9D 2CC4 FD66
SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg, Germany
Geschäftsführer: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)

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

^ permalink raw reply	[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