]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: make CHASE_WARN effective with CHASE_NO_AUTOFS 10984/head
authorFranck Bui <fbui@suse.com>
Fri, 30 Nov 2018 14:43:13 +0000 (15:43 +0100)
committerFranck Bui <fbui@suse.com>
Mon, 10 Dec 2018 08:22:28 +0000 (09:22 +0100)
This has the side effect to upgrade the log level at which the log is emitted
from debug to warning.

This might be better since after all we didn't apply a tmpfiles.d/ rule and
that actually might end up being problematic eventually.

src/basic/fs-util.c
src/tmpfiles/tmpfiles.c

index 59383c52d2f09dd5994a25c2df6ba7b3bb8f1ea2..ac97c803d08ab2c8c8d9b79f737217c87a79bfb9 100644 (file)
@@ -659,6 +659,19 @@ static int log_unsafe_transition(int a, int b, const char *path, unsigned flags)
                                  n1, special_glyph(ARROW), n2, path);
 }
 
+static int log_autofs_mount_point(int fd, const char *path, unsigned flags) {
+        _cleanup_free_ char *n1 = NULL;
+
+        if (!FLAGS_SET(flags, CHASE_WARN))
+                return -EREMOTE;
+
+        (void) fd_get_path(fd, &n1);
+
+        return log_warning_errno(SYNTHETIC_ERRNO(EREMOTE),
+                                 "Detected autofs mount point %s during canonicalization of %s.",
+                                 n1, path);
+}
+
 int chase_symlinks(const char *path, const char *original_root, unsigned flags, char **ret) {
         _cleanup_free_ char *buffer = NULL, *done = NULL, *root = NULL;
         _cleanup_close_ int fd = -1;
@@ -723,6 +736,10 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
          *    unprivileged to privileged files or directories. In such cases the return value is -ENOLINK. If
          *    CHASE_WARN is also set a warning describing the unsafe transition is emitted.
          *
+         * 5. With CHASE_NO_AUTOFS: in this case if an autofs mount point is encountered, the path normalization is
+         *    aborted and -EREMOTE is returned. If CHASE_WARN is also set a warning showing the path of the mount point
+         *    is emitted.
+         *
          * */
 
         /* A root directory of "/" or "" is identical to none */
@@ -885,7 +902,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
 
                 if ((flags & CHASE_NO_AUTOFS) &&
                     fd_is_fs_type(child, AUTOFS_SUPER_MAGIC) > 0)
-                        return -EREMOTE;
+                        return log_autofs_mount_point(child, path, flags);
 
                 if (S_ISLNK(st.st_mode) && !((flags & CHASE_NOFOLLOW) && isempty(todo))) {
                         char *joined;
index d4e4f0c53565c40bd4b6bf9215c2c112d8d0e4d0..810b03567e61f78d9000cdbeb21fdb7e384dcd2d 100644 (file)
@@ -2261,11 +2261,12 @@ static int process_item(Item *i, OperationMask operation) {
 
         i->done |= operation;
 
-        r = chase_symlinks(i->path, NULL, CHASE_NO_AUTOFS, NULL);
+        r = chase_symlinks(i->path, NULL, CHASE_NO_AUTOFS|CHASE_WARN, NULL);
         if (r == -EREMOTE) {
-                log_debug_errno(r, "Item '%s' is below autofs, skipping.", i->path);
+                log_notice_errno(r, "Skipping %s", i->path);
                 return 0;
-        } else if (r < 0)
+        }
+        if (r < 0)
                 log_debug_errno(r, "Failed to determine whether '%s' is below autofs, ignoring: %m", i->path);
 
         r = FLAGS_SET(operation, OPERATION_CREATE) ? create_item(i) : 0;