]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: port code to chase_symlinks_and_open()
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Mar 2018 17:22:16 +0000 (19:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 29 Mar 2018 13:33:12 +0000 (15:33 +0200)
src/shared/dissect-image.c

index 7af59422b27eeccde01df11a2a6129b24a5a5d73..11c792f4a88d9cdecae6211c67d9f2af231ee216 100644 (file)
@@ -1286,18 +1286,14 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
                         fds[2*k] = safe_close(fds[2*k]);
 
                         NULSTR_FOREACH(p, paths[k]) {
-                                _cleanup_free_ char *q = NULL;
-
-                                r = chase_symlinks(p, t, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &q);
-                                if (r < 0)
-                                        continue;
-
-                                fd = open(q, O_RDONLY|O_CLOEXEC|O_NOCTTY);
+                                fd = chase_symlinks_and_open(p, t, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
                                 if (fd >= 0)
                                         break;
                         }
-                        if (fd < 0)
+                        if (fd < 0) {
+                                log_debug_errno(fd, "Failed to read %s file of image, ignoring: %m", paths[k]);
                                 continue;
+                        }
 
                         r = copy_bytes(fd, fds[2*k+1], (uint64_t) -1, 0);
                         if (r < 0)