[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH initramfs-tools 3/5] init: Resolve both absolute and relative symlinks in validate_init



This is limited to a single level of symlinks, but that should be
good enough.

Remove the use of chroot - that makes no difference to reading a
symlink; it would only be useful if applied to the [ -x ].

Related-to: #763157
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 init | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/init b/init
index b47bf7a..670fabf 100755
--- a/init
+++ b/init
@@ -225,8 +225,12 @@ validate_init() {
 
 	# Work around absolute symlinks
 	if [ -d "${rootmnt}" ] && [ -h "${rootmnt}${checktarget}" ]; then
-		case $(readlink "${rootmnt}${checktarget}") in /*)
-			checktarget="$(chroot ${rootmnt} readlink ${checktarget})"
+		checktarget="$(readlink "${rootmnt}${checktarget}")"
+		case "$checktarget" in
+		/*)
+			;;
+		*)
+			checktarget="${1%/*}/$checktarget"
 			;;
 		esac
 	fi


-- 
Ben Hutchings
Logic doesn't apply to the real world. - Marvin Minsky

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: