]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Use chase_symlinks() instead of path_join()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 3 Oct 2022 08:09:24 +0000 (10:09 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 3 Oct 2022 13:16:13 +0000 (14:16 +0100)
Let's properly resolve symlinks and check if the source actually
exists.

src/partition/repart.c

index cbda6e408bdedd19ba21d7126504eb466dc6ec21..29c9b579397a977a01b8e67253e59617d92332a9 100644 (file)
@@ -3361,9 +3361,9 @@ static int partition_populate_directory(Partition *p, char **ret_root, char **re
         if (strv_length(p->copy_files) == 2 && strv_length(p->make_directories) == 0 && streq(p->copy_files[1], "/")) {
                 _cleanup_free_ char *s = NULL;
 
-                s = path_join(arg_root, p->copy_files[0]);
-                if (!s)
-                        return log_oom();
+                r = chase_symlinks(p->copy_files[0], arg_root, CHASE_PREFIX_ROOT|CHASE_WARN, &s, NULL);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to resolve source '%s%s': %m", strempty(arg_root), p->copy_files[0]);
 
                 *ret_root = TAKE_PTR(s);
                 *ret_tmp_root = NULL;