[Pkg-sysvinit-devel] Bug#697002: [PATCH initramfs-tools 3/5] init: Resolve both absolute and relative symlinks in validate_init

Ben Hutchings ben at decadent.org.uk
Mon Sep 29 00:46:38 UTC 2014


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20140929/748da003/attachment-0001.sig>


More information about the Pkg-sysvinit-devel mailing list