]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
install/dracut-install.c: convert destrootdir to realpath
authorHarald Hoyer <harald@redhat.com>
Thu, 26 Jul 2012 17:21:06 +0000 (19:21 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 26 Jul 2012 17:35:00 +0000 (19:35 +0200)
otherwise we get strange errors if it ends with a slash and does not
exist.

install/dracut-install.c

index 935147256a515d362c2148a6242baa7fc84cbaab..e79065dde83dca808f9b8e4ae27c6ab15a3c46a7 100644 (file)
@@ -517,6 +517,7 @@ Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n\
   -h --help           Show this help\n\
 \n\
 Example:\n\
+# mkdir -p /var/tmp/test-root\n\
 # %s -D /var/tmp/test-root --ldd -a sh tr\n\
 # tree /var/tmp/test-root\n\
 /var/tmp/test-root\n\
@@ -742,8 +743,16 @@ int main(int argc, char **argv)
         if (strcmp(destrootdir, "/") == 0) {
                 log_error("Environment DESTROOTDIR or argument -D is set to '/'!");
                 usage(EXIT_FAILURE);
+        }
 
+        i = destrootdir;
+        destrootdir = realpath(destrootdir, NULL);
+        if (!destrootdir) {
+                log_error("Environment DESTROOTDIR or argument -D is set to '%s': %m", i);
+                r = EXIT_FAILURE;
+                goto finish;
         }
+        free(i);
 
         items = hashmap_new(string_hash_func, string_compare_func);
         items_failed = hashmap_new(string_hash_func, string_compare_func);