tags 570695 +patch
thanks

Hi,

The attached patch will fix the problem (I've already sent it to the
upstream).

Sent from Thailand Mini-DebCamp 2010 BSP:
http://wiki.debian.org/DebianThailand/MiniDebCamp2010/BSP

Attachment: pgp3XXa58iFPy.pgp
Description: PGP signature

diff -u makejail-0.0.5/makejail makejail-0.0.5/makejail
--- makejail-0.0.5/makejail
+++ makejail-0.0.5/makejail
@@ -353,7 +353,14 @@
 			moveIndent(1)
 			addFileToJail(checkDir)
 			moveIndent(-1)
-	fileInChroot="%s%s" % (config.chroot,fileName)
+	# The directory part of fileName may be a symlink to an
+	# absolute pathname.  For example, fileName is
+	# "lib64/ld-linux.so.2" where "lib64" is a symlink to "/lib".
+	# In that case it should be resolved before constructing
+	# fileInChroot.  See http://bugs.debian.org/570695.
+	fileDir, baseName = os.path.split(fileName)
+	fileInChroot=os.path.join(config.chroot,os.path.realpath(fileDir)[1:],
+				  baseName)
 	if os.path.exists(fileInChroot):
 		if fileIsNewer(fileName,fileInChroot):
 			debug("   File %s is newer than the %s, overwriting" % (fileName,fileInChroot))
@@ -373,7 +380,9 @@
 			absoluteLinkTarget="%s/%s" % (fileDir,linkTarget)
 		newFiles=addFileToJail(absoluteLinkTarget)
 		missingFiles=missingFiles+newFiles
-		newWorkingDir="%s/%s" % (config.chroot,fileDir[1:])
+		# newWorkingDir may be a symlink to an absolute
+		# pathname.  See the above comment.
+		newWorkingDir="%s/%s" % (config.chroot,os.path.realpath(fileDir)[1:])
 		os.chdir(newWorkingDir)
 		debug("   Creating '%s' as a symlink to '%s' (pwd=%s)" % (fileName[1:],linkTarget,newWorkingDir))
 		os.symlink(linkTarget,os.path.split(fileName)[1])
diff -u makejail-0.0.5/debian/changelog makejail-0.0.5/debian/changelog
--- makejail-0.0.5/debian/changelog
+++ makejail-0.0.5/debian/changelog
@@ -1,3 +1,11 @@
+makejail (0.0.5-8.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fix pathname handling when the directory components include absolute
+    symlink (Closes: #570695).
+
+ -- Daiki Ueno <u...@unixuser.org>  Sun, 14 Mar 2010 18:33:38 +0700
+
 makejail (0.0.5-8) unstable; urgency=low
 
   [ Changes by  Florian Grandel <jerico....@gmail.com ]
Regards,
-- 
Daiki Ueno

Reply via email to