Skip to contentSkip to conversation

libselinux: Ignore directories removed during relabeling

PATCH In review Vit Mojzis 2 participants 2 messages Jan 30 – Mar 18 SELinux security module

lore
Share & tools
lore

Vit Mojzis

author
#0 lore raw

PATCH 1/1 libselinux: Ignore directories removed during relabeling

Extend 54c79a74f5b9154762abaadf8194665598b24115 to directories, since users will expect them to be ignored as well.

In case ignore_noent is specified, ignore directories removed during relabeling (race condition between directory read and removal after parent directory read).

---
 libselinux/src/selinux_restorecon.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
libselinux/src/selinux_restorecon.c +4 -3
index 681c69db..2e605b5a 100644
@@ -932,9 +932,10 @@ loop_body:
 		case FTS_DNR:
 			error = errno;
 			errno = ftsent->fts_errno;
-			selinux_log(SELINUX_ERROR,
-				    "Could not read %s: %m.\n",
-				    ftsent->fts_path);
+			if (!state->flags.ignore_noent || errno != ENOENT)
+				selinux_log(SELINUX_ERROR,
+					    "Could not read %s: %m.\n",
+					    ftsent->fts_path);
 			errno = error;
 			fts_set(fts, ftsent, FTS_SKIP);
 			continue;
Signature · 1 line
2.52.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Vit Mojzis

Extend 54c79a74f5b9154762abaadf8194665598b24115 to directories, since users will expect them to be ignored as well.

For future reference, please include the one-line summary of the commit along with the hash, and feel free to shorten the hash, ala:
commit 54c79a74f5b91547 ("libselinux: Ignore files removed during relabeling")

Quoted 6 lines

In case ignore_noent is specified, ignore directories removed during relabeling (race condition between directory read and removal after parent directory read).

Quoted 26 lines
---
 libselinux/src/selinux_restorecon.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
libselinux/src/selinux_restorecon.c +4 -4
index 681c69db..2e605b5a 100644
@@ -932,9 +932,10 @@ loop_body:
                case FTS_DNR:
                        error = errno;
                        errno = ftsent->fts_errno;
-                       selinux_log(SELINUX_ERROR,
-                                   "Could not read %s: %m.\n",
-                                   ftsent->fts_path);
+                       if (!state->flags.ignore_noent || errno != ENOENT)
+                               selinux_log(SELINUX_ERROR,
+                                           "Could not read %s: %m.\n",
+                                           ftsent->fts_path);
                        errno = error;
                        fts_set(fts, ftsent, FTS_SKIP);
                        continue;
--

2.52.0