Skip to contentSkip to conversation

selinux_restorecon: Do not exit on directory cycles

PATCH In review Johannes Segitz 2 participants 3 messages Jul 21 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux_restorecon: Do not exit on directory cycles

All other failures are handled gracefully. Directory cycles can e.g. happen on BTRFS filesystems with subvolumes. Skip them and continue instead of exiting

---
 libselinux/src/selinux_restorecon.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
libselinux/src/selinux_restorecon.c +3 -4
index 7ef2d45d..33d315a2 100644
@@ -883,13 +883,12 @@ loop_body:
 
                switch (ftsent->fts_info) {
                case FTS_DC:
-                       selinux_log(SELINUX_ERROR,
+                       selinux_log(SELINUX_WARNING,
                                    "Directory cycle on %s.\n",
                                    ftsent->fts_path);
                        errno = ELOOP;
-                       state->error = -1;
-                       state->abort = true;
-                       goto finish;
+                       fts_set(fts, ftsent, FTS_SKIP);
+                       continue;
                case FTS_DP:
                        continue;
                case FTS_DNR:

--
2.55.0

maintainer
#1 lore raw
Quoted 6 lines · Johannes Segitz

All other failures are handled gracefully. Directory cycles can e.g. happen on BTRFS filesystems with subvolumes. Skip them and continue instead of exiting

This doesn't apply on selinux/main.

Quoted 27 lines
---
 libselinux/src/selinux_restorecon.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
libselinux/src/selinux_restorecon.c +3 -5
index 7ef2d45d..33d315a2 100644
@@ -883,13 +883,12 @@ loop_body:
 
                switch (ftsent->fts_info) {
                case FTS_DC:
-                       selinux_log(SELINUX_ERROR,
+                       selinux_log(SELINUX_WARNING,
                                    "Directory cycle on %s.\n",
                                    ftsent->fts_path);
                        errno = ELOOP;
-                       state->error = -1;
-                       state->abort = true;
-                       goto finish;
+                       fts_set(fts, ftsent, FTS_SKIP);
+                       continue;
                case FTS_DP:
                        continue;
                case FTS_DNR:
--

2.55.0

#2 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 6 lines · Johannes Segitz

All other failures are handled gracefully. Directory cycles can e.g. happen on BTRFS filesystems with subvolumes. Skip them and continue instead of exiting

This doesn't apply on selinux/main.

Sorry, had a repo still with branch "master", will send both again tomorrow

Johannes

Signature · 4 lines
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
www.suse.com, Geschäftsführer: Jochen Jaser, Andrew McDonald, Abhinav Puri, (HRB 36809, AG Nürnberg)