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