changeset 10277:8c0d8d983f7d

6868481 p2v should handle absolute path archives
author <gerald.jelinek@sun.com>
date Fri, 07 Aug 2009 06:47:37 -0600
parents f3e12ac807fa
children 61e767547602
files usr/src/lib/brand/native/zone/common.ksh
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/brand/native/zone/common.ksh	Fri Aug 07 10:48:38 2009 +0100
+++ b/usr/src/lib/brand/native/zone/common.ksh	Fri Aug 07 06:47:37 2009 -0600
@@ -409,6 +409,15 @@
 	stage1=$1
 	archive=$2
 
+	# Check the first few members of the archive for an absolute path.
+	for i in `$stage1 "$archive" | cpio -it | head | cut -b1`
+	do
+		if [[ "$i" == "/" ]]; then
+			umnt_fs
+			fatal "$e_absolute_archive"
+		fi
+	done
+
 	cpioopts="-idmfE $ipdcpiofile"
 
 	vlog "cd \"$ZONEROOT\" && $stage1 \"$archive\" | cpio $cpioopts"
@@ -428,6 +437,15 @@
 {
 	archive=$1
 
+	# Check the first few members of the archive for an absolute path.
+	for i in `pax -f "$archive" | head | cut -b1`
+	do
+		if [[ "$i" == "/" ]]; then
+			umnt_fs
+			fatal "$e_absolute_archive"
+		fi
+	done
+
 	if [[ -s $ipdpaxfile ]]; then
 		filtopt="-c $(/usr/bin/cat $ipdpaxfile)"
 	fi
@@ -822,6 +840,7 @@
 e_not_readable=$(gettext "Cannot read directory '%s'")
 e_not_dir=$(gettext "Error: must be a directory")
 e_unknown_archive=$(gettext "Error: Unknown archive format. Must be a flash archive, a cpio archive (can also be gzipped or bzipped), a pax XUSTAR archive, or a level 0 ufsdump archive.")
+e_absolute_archive=$(gettext "Error: archive contains absolute paths instead of relative paths.")
 e_tmpfile=$(gettext "Unable to create temporary file")
 e_root_full=$(gettext "Zonepath root %s exists and contains data; remove or move aside prior to install.")