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