Blame 0060-install-dracut-install.c-convert-destrootdir-to-real.patch

Harald Hoyer 12f6cc
From 78021eace175745792f04345efe2d42218f0bb59 Mon Sep 17 00:00:00 2001
Harald Hoyer 12f6cc
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 12f6cc
Date: Thu, 26 Jul 2012 19:21:06 +0200
Harald Hoyer 12f6cc
Subject: [PATCH] install/dracut-install.c: convert destrootdir to realpath
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
otherwise we get strange errors if it ends with a slash and does not
Harald Hoyer 12f6cc
exist.
Harald Hoyer 12f6cc
---
Harald Hoyer 12f6cc
 install/dracut-install.c | 9 +++++++++
Harald Hoyer 12f6cc
 1 file changed, 9 insertions(+)
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
diff --git a/install/dracut-install.c b/install/dracut-install.c
Harald Hoyer 12f6cc
index 9351472..e79065d 100644
Harald Hoyer 12f6cc
--- a/install/dracut-install.c
Harald Hoyer 12f6cc
+++ b/install/dracut-install.c
Harald Hoyer 12f6cc
@@ -517,6 +517,7 @@ Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n\
Harald Hoyer 12f6cc
   -h --help           Show this help\n\
Harald Hoyer 12f6cc
 \n\
Harald Hoyer 12f6cc
 Example:\n\
Harald Hoyer 12f6cc
+# mkdir -p /var/tmp/test-root\n\
Harald Hoyer 12f6cc
 # %s -D /var/tmp/test-root --ldd -a sh tr\n\
Harald Hoyer 12f6cc
 # tree /var/tmp/test-root\n\
Harald Hoyer 12f6cc
 /var/tmp/test-root\n\
Harald Hoyer 12f6cc
@@ -742,8 +743,16 @@ int main(int argc, char **argv)
Harald Hoyer 12f6cc
         if (strcmp(destrootdir, "/") == 0) {
Harald Hoyer 12f6cc
                 log_error("Environment DESTROOTDIR or argument -D is set to '/'!");
Harald Hoyer 12f6cc
                 usage(EXIT_FAILURE);
Harald Hoyer 12f6cc
+        }
Harald Hoyer 12f6cc
 
Harald Hoyer 12f6cc
+        i = destrootdir;
Harald Hoyer 12f6cc
+        destrootdir = realpath(destrootdir, NULL);
Harald Hoyer 12f6cc
+        if (!destrootdir) {
Harald Hoyer 12f6cc
+                log_error("Environment DESTROOTDIR or argument -D is set to '%s': %m", i);
Harald Hoyer 12f6cc
+                r = EXIT_FAILURE;
Harald Hoyer 12f6cc
+                goto finish;
Harald Hoyer 12f6cc
         }
Harald Hoyer 12f6cc
+        free(i);
Harald Hoyer 12f6cc
 
Harald Hoyer 12f6cc
         items = hashmap_new(string_hash_func, string_compare_func);
Harald Hoyer 12f6cc
         items_failed = hashmap_new(string_hash_func, string_compare_func);