Skip to content

Commit

Permalink
remount: ignore ENOENT error during SELinux relabeling
Browse files Browse the repository at this point in the history
Ignore ENOENT error in selinux_restorecon to avoid failures when
temporary files created by systemd-sysusers in /etc are missing during
relabeling. This prevents errors such as:

  "Failed to relabel /etc/.#gshadowJzu4Rx: No such file or directory"

and allows the process to continue.

Co-Authored-By: Alexander Larsson <[email protected]>
Signed-off-by: Eric Curtin <[email protected]>
  • Loading branch information
ericcurtin and alexlarsson committed Jun 18, 2024
1 parent 8f559e9 commit f68cf8d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/switchroot/ostree-remount.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,18 @@ static void
relabel_dir_for_upper (const char *upper_path, const char *real_path, gboolean is_dir)
{
#ifdef HAVE_SELINUX
/* Ignore ENOENT, because if there is no file to relabel we can continue,
* systemd-sysusers runs in parallel and can create temporary files in /etc
* causing failures like:
* "Failed to relabel /etc/.#gshadowJzu4Rx: No such file or directory"
*/
if (selinux_restorecon (real_path, 0))
err (EXIT_FAILURE, "Failed to relabel %s", real_path);
{
if (errno == ENOENT)
return;

err (EXIT_FAILURE, "Failed to relabel %s", real_path);
}

if (!is_dir)
return;
Expand Down

0 comments on commit f68cf8d

Please sign in to comment.