Re: Fix for password-protected .rar files



On Monday 24 July 2006 16:31, Pavel Tsekov wrote:
> On Mon, 24 Jul 2006, Denis Vlasenko wrote:
> 
> > https://savannah.gnu.org/bugs/?func=detailitem&item_id=16967
> 
> Is this option supported on earlier versions of rar which might be
> still used ?

Don't know. :)

> > unrar of password-protected archives hangs (unrar opens
> > /dev/tty and sits there, waiting for the password)
> > The patch adds -p- switch.
> > A few unsafe "$var" expansions are fixed in several etxfs scripts.
> 
> The patch includes random quoting of shell variables as well
> as formatting fixes  - please submit a proper patch which does
> only what it advertises.

Ok, the attached patch quotes some environment variables.

vfs/extfs/* scripts seem to presume that there are no spaces
in filenames. Yes, we typically do not expect $TMPDIR to contain spaces,
but if it will contain them on some strange system, then what?
Is cd $TMPDIR ok? No! cd "$TMPDIR"!

The attached patch fixes these.
--
vda
diff -urpN mc-4.6.1.org/vfs/extfs/audio.in mc-4.6.1.extfs/vfs/extfs/audio.in
--- mc-4.6.1.org/vfs/extfs/audio.in	2004-11-10 17:08:00.000000000 +0100
+++ mc-4.6.1.extfs/vfs/extfs/audio.in	2006-07-24 17:25:02.000000000 +0200
@@ -19,7 +19,7 @@ audiofs_list()
     cdparanoia -Q -d "$1" 2>&1 | grep '^[ 0-9][ 0-9][ 0-9]\.' | while read A B C
     do
 	A=`echo "$A" | sed -e 's/\.//' -e 's/^\(.\)$/0\1/'`
-	SIZE=`expr 44 + $B \* 2352`
+	SIZE=`expr 44 + "$B" \* 2352`
 	echo "-r--r--r-- 1 0 0 $SIZE $DATE track-${A}.wav"
     done
 }
@@ -35,7 +35,7 @@ audiofs_copyout()
 	wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+read+$RESPONSE&$CDDB_HANDSHAKE" | grep -v "^#" >> "$3"
     else
         TRACK=`echo "$2" | sed 's/track-0*//' | sed 's/\.wav//'`
-        cdparanoia -q -d "$1" $TRACK "$3" >/dev/null
+        cdparanoia -q -d "$1" "$TRACK" "$3" >/dev/null
     fi
 }
 
diff -urpN mc-4.6.1.org/vfs/extfs/bpp mc-4.6.1.extfs/vfs/extfs/bpp
--- mc-4.6.1.org/vfs/extfs/bpp	2002-12-09 06:01:04.000000000 +0100
+++ mc-4.6.1.extfs/vfs/extfs/bpp	2006-07-24 17:25:02.000000000 +0200
@@ -17,8 +17,8 @@ mcbppfs_list ()
     FILEPREF="-r--r--r--   1 root     root    "
     FIEXPREF="-r-xr-xr-x   1 root     root    "
     DATE=`date +"%b %d %H:%M"`
-    set x `ls -l $1`
-    size=$6
+    set x `ls -l "$1"`
+    size="$6"
     echo "$FILEPREF $size $DATE CONTENTS.tar.gz"
     echo "$FIEXPREF 35 $DATE INSTALL"
     echo "$FIEXPREF 35 $DATE UPGRADE"
diff -urpN mc-4.6.1.org/vfs/extfs/iso9660.in mc-4.6.1.extfs/vfs/extfs/iso9660.in
--- mc-4.6.1.org/vfs/extfs/iso9660.in	2004-10-29 11:14:38.000000000 +0200
+++ mc-4.6.1.extfs/vfs/extfs/iso9660.in	2006-07-24 17:25:02.000000000 +0200
@@ -11,7 +11,7 @@
 test_iso () {
     CHARSET=`echo "$save_ctype" | sed -n -e 's/.*\.\(.*\)"$/\1/p' | tr '[A-Z]' '[a-z]'`
     if test -n "$CHARSET"; then
-	isoinfo -j $CHARSET 2>&1 | grep "Unknown charset" >/dev/null && CHARSET=
+	isoinfo -j "$CHARSET" 2>&1 | grep "Unknown charset" >/dev/null && CHARSET=
     fi
     if test -n "$CHARSET"; then
 	JOLIET_OPT="-j $CHARSET -J"
@@ -62,7 +62,7 @@ BEGIN {
 }
 
 mcisofs_copyout () {
-	$ISOINFO -i "$1" -x "/$2" > "$3" 
+    $ISOINFO -i "$1" -x "/$2" > "$3" 
 }
 
 save_ctype=`locale | grep LC_CTYPE`
diff -urpN mc-4.6.1.org/vfs/extfs/rpm mc-4.6.1.extfs/vfs/extfs/rpm
--- mc-4.6.1.org/vfs/extfs/rpm	2004-09-03 23:23:05.000000000 +0200
+++ mc-4.6.1.extfs/vfs/extfs/rpm	2006-07-24 17:25:02.000000000 +0200
@@ -20,9 +20,9 @@ LC_TIME=C
 export LC_TIME
 
 if rpm --nosignature --version >/dev/null 2>&1; then
-  RPM="rpm --nosignature"
+    RPM="rpm --nosignature"
 else
-  RPM="rpm"
+    RPM="rpm"
 fi
 RPM2CPIO="rpm2cpio"
 SED="sed"
diff -urpN mc-4.6.1.org/vfs/extfs/trpm mc-4.6.1.extfs/vfs/extfs/trpm
--- mc-4.6.1.org/vfs/extfs/trpm	2004-10-27 16:44:31.000000000 +0200
+++ mc-4.6.1.extfs/vfs/extfs/trpm	2006-07-24 17:25:02.000000000 +0200
@@ -20,9 +20,9 @@ LC_TIME=C
 export LC_TIME
 
 if rpm --nosignature --version >/dev/null 2>&1; then
-  RPM="rpm --nosignature"
+    RPM="rpm --nosignature"
 else
-  RPM="rpm"
+    RPM="rpm"
 fi
 
 mcrpmfs_list ()
diff -urpN mc-4.6.1.org/vfs/extfs/uar.in mc-4.6.1.extfs/vfs/extfs/uar.in
--- mc-4.6.1.org/vfs/extfs/uar.in	2004-11-10 17:08:00.000000000 +0100
+++ mc-4.6.1.extfs/vfs/extfs/uar.in	2006-07-24 17:25:02.000000000 +0200
@@ -12,7 +12,7 @@ XAR=ar
 
 mcarfs_list ()
 {
-	$XAR tv "$1" | sed 's,^,-,;s, , 1 ,;s,/, ,'
+    $XAR tv "$1" | sed 's,^,-,;s, , 1 ,;s,/, ,'
 }
 
 mcarfs_copyout ()
diff -urpN mc-4.6.1.org/vfs/extfs/urar.in mc-4.6.1.extfs/vfs/extfs/urar.in
--- mc-4.6.1.org/vfs/extfs/urar.in	2005-02-08 08:44:38.000000000 +0100
+++ mc-4.6.1.extfs/vfs/extfs/urar.in	2006-07-24 17:25:18.000000000 +0200
@@ -9,11 +9,11 @@
 # rar and unrar can be found on http://www.rarlabs.com/
 
 RAR=rar
-UNRAR=$RAR
+UNRAR="$RAR"
 
 # Prefer unrar (freeware).  Try to find unrar in $PATH.
 save_IFS="$IFS"; IFS=:
-for dir in $PATH; do
+for dir in "$PATH"; do
     IFS="$save_IFS"
     test -z "$dir" && dir=.
     if test -x "$dir/unrar" -a -f "$dir/unrar"; then
diff -urpN mc-4.6.1.org/vfs/extfs/uzoo.in mc-4.6.1.extfs/vfs/extfs/uzoo.in
--- mc-4.6.1.org/vfs/extfs/uzoo.in	2004-08-17 10:24:59.000000000 +0200
+++ mc-4.6.1.extfs/vfs/extfs/uzoo.in	2006-07-24 17:25:02.000000000 +0200
@@ -14,10 +14,10 @@ ZOO=zoo
 mklink ()
 {
     TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uzoo.XXXXXX` || exit 1
-    trap 'cd /; rm -rf $TMPDIR' 0 1 2 3 5 13 15
-    ARCHIVE=$TMPDIR/tmp.zoo
+    trap 'cd /; rm -rf "$TMPDIR"' 0 1 2 3 5 13 15
+    ARCHIVE="$TMPDIR/tmp.zoo"
     ln -sf "$1" "$ARCHIVE"
-    cd $TMPDIR || exit 1
+    cd "$TMPDIR" || exit 1
 }
 
 mczoofs_list ()


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