Blame SOURCES/0104-editenv-handle-relative-symlinks.patch
|
|
8631a2 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8631a2 |
From: Jonathan Lebon <jlebon@redhat.com>
|
|
|
8631a2 |
Date: Mon, 14 Aug 2017 14:37:20 -0400
|
|
|
8631a2 |
Subject: [PATCH] editenv: handle relative symlinks
|
|
|
8631a2 |
|
|
|
8631a2 |
Handle symlinks with targets relative to the containing dir. This
|
|
|
8631a2 |
ensures that the rename operation does not depend on the cwd.
|
|
|
8631a2 |
|
|
|
8631a2 |
Resolves: rhbz#1479960
|
|
|
8631a2 |
|
|
|
8631a2 |
Signed-off-by: Jonathan Lebon <jlebon@redhat.com>
|
|
|
8631a2 |
---
|
|
|
8631a2 |
util/editenv.c | 16 ++++++++++++++--
|
|
|
8631a2 |
1 file changed, 14 insertions(+), 2 deletions(-)
|
|
|
8631a2 |
|
|
|
8631a2 |
diff --git a/util/editenv.c b/util/editenv.c
|
|
|
09e3cc |
index d8d1dad6a..41bc7cb1c 100644
|
|
|
8631a2 |
--- a/util/editenv.c
|
|
|
8631a2 |
+++ b/util/editenv.c
|
|
|
8631a2 |
@@ -28,6 +28,7 @@
|
|
|
8631a2 |
|
|
|
8631a2 |
#include <errno.h>
|
|
|
8631a2 |
#include <string.h>
|
|
|
8631a2 |
+#include <libgen.h>
|
|
|
8631a2 |
|
|
|
8631a2 |
#define DEFAULT_ENVBLK_SIZE 1024
|
|
|
8631a2 |
|
|
|
8631a2 |
@@ -87,9 +88,20 @@ grub_util_create_envblk_file (const char *name)
|
|
|
8631a2 |
continue;
|
|
|
8631a2 |
}
|
|
|
8631a2 |
|
|
|
8631a2 |
- free (rename_target);
|
|
|
8631a2 |
linkbuf[retsize] = '\0';
|
|
|
8631a2 |
- rename_target = linkbuf;
|
|
|
8631a2 |
+ if (linkbuf[0] == '/')
|
|
|
8631a2 |
+ {
|
|
|
8631a2 |
+ free (rename_target);
|
|
|
8631a2 |
+ rename_target = linkbuf;
|
|
|
8631a2 |
+ }
|
|
|
8631a2 |
+ else
|
|
|
8631a2 |
+ {
|
|
|
8631a2 |
+ char *dbuf = xstrdup (rename_target);
|
|
|
8631a2 |
+ const char *dir = dirname (dbuf);
|
|
|
8631a2 |
+ free (rename_target);
|
|
|
8631a2 |
+ rename_target = xasprintf("%s/%s", dir, linkbuf);
|
|
|
8631a2 |
+ free (dbuf);
|
|
|
8631a2 |
+ }
|
|
|
8631a2 |
}
|
|
|
8631a2 |
|
|
|
8631a2 |
int rc = grub_util_rename (namenew, rename_target);
|