Package: efax Version: 1:0.9a-19 Severity: important Tags: patch
The 'fax' frontend program can't handle filenames with spaces in them. The filename is split apart at whitespace, and the script dies shortly thereafter with a file not found error. I've attempted to fix the script to handle filenames properly; the patch is attached. Extremely rudimentary testing suggests it works. Thank you for your attention to this matter. Schwab -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.26 (SMP w/2 CPU cores; PREEMPT) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages efax depends on: ii debconf [debconf-2.0] 1.5.22 Debian configuration management sy ii libc6 2.7-12 GNU C Library: Shared libraries ii libpaper-utils 1.1.23 library for handling paper charact ii make 3.81-5 The GNU version of the "make" util efax recommends no packages. Versions of packages efax suggests: ii ghostscript-x [gs] 8.63.dfsg.1-2 The GPL Ghostscript PostScript/PDF ii imagemagick 7:6.3.7.9.dfsg1-3 image manipulation programs -- no debconf information
--- /usr/bin/fax 2006-01-23 12:59:30.000000000 +0000 +++ fax.new 2009-01-24 10:11:14.000000000 +0000 @@ -779,33 +779,43 @@ break ;; -# fax make : convert a text or Postscript file to fax format +# fax make : convert a text, Postscript, or PDF file to fax format m*) case $# in 0) echo "No files specified" ; ERR=2 ; break ;; esac - if [ ! -r $1 ] ; then echo "Can't read $1" ; ERR=2 ; break ; fi + if [ ! -r "$1" ] ; then echo "Can't read $1" ; ERR=2 ; break ; fi - read x <$1 + read x <"$1" case $x in %!*|?%!*) echo "$1 is postscript..." # GS can't deal with long paths so we 'cd' - DIRNAME=`dirname $1` ; BASENAME=`basename $1` - ( cd $DIRNAME ; \ - $GS -q -sDEVICE=tiffg3 -r$RES -dNOPAUSE -dSAFER \ - -sOutputFile=$BASENAME.%03d \ - -sPAPERSIZE=$PAGE \ - $BASENAME </dev/null >/dev/null ) + DIRNAME=`dirname "$1"` ; BASENAME=`basename "$1"` + ( cd "$DIRNAME" ; \ + $GS -q -sDEVICE=tiffg3 -r$RES -dNOPAUSE -dSAFER \ + -sOutputFile="$BASENAME.%03d" \ + -sPAPERSIZE=$PAGE \ + "$BASENAME" </dev/null >/dev/null ) + ;; + %PDF*) + echo "$1 is PDF..." + # GS can't deal with long paths (why?) so we 'cd' + DIRNAME=`dirname "$1"` ; BASENAME=`basename "$1"` + ( cd "$DIRNAME" ; \ + $GS -q -sDEVICE=tiffg3 -r$RES -dNOPAUSE -dSAFER \ + -sOutputFile="$BASENAME.%03d" \ + -sPAPERSIZE=$PAGE \ + "$BASENAME" </dev/null >/dev/null ) ;; II*|MM*|P4*) echo "$1 is an image file..." - $EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n $1.%03d $1 + $EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n "$1.%03d" "$1" ;; *) echo "$1 is text..." - $EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n $1.%03d $TEXTFONT $1 + $EFIX -ve -otiffg3 -p$PAGEDIM -r$RES -n "$1.%03d" $TEXTFONT "$1" ;; esac @@ -820,14 +830,14 @@ 0) echo "missing phone number to call" ; ERR=2 ; break ;; esac - case $# in - 1) echo "missing file to send" ; ERR=2 ; break ;; + case $# in + 1) echo "missing file to send" ; ERR=2 ; break ;; esac # look up names case $1 in - [A-Za-z]*) + [A-Za-z]*) for f in $DIRFILES ; do if [ -r $f ] ; then TELNO=`$LOOKUP` ; fi case "$TELNO" in '') continue ;; *) break ;; esac @@ -837,7 +847,7 @@ *) echo "Lookup: $1 = $TELNO" ;; esac ;; - *) TELNO="$1" ;; + *) TELNO="$1" ;; esac shift @@ -860,34 +870,51 @@ # use `fax make' to convert files if they need to be updated - FILES="" - for f in $* ; do - case $f in -) FILES="$FILES -" ; continue ;; esac - if [ ! -r $f ] ; then - echo "can't read file $f" ; ERR=2 ; break 2 + unset FILES + fidx=0 + for f in "$@" ; do + case "$f" in -) + # Standard input. + FILES[$fidx++]="-"; + continue ;; + esac + if [ ! -r "$f" ] ; then + echo "can't read file: $f" ; ERR=2 ; break 2 fi - case $f in - *.[0-9][0-9][0-9]) FILES="$FILES $f" ;; # skip image files - *) if echo ${f}.001: $f \; x | make -r -q -f - ; then + case "$f" in + *.[0-9][0-9][0-9]) + # Assume these are image files we've already pre-processed. + # Add them to the array of files to be delivered to the modem. + FILES[$fidx++]="$f" ;; + *) + # Compose a tiny Makefile, feed it to 'make' and check the + # the return code to see if the dependency is satisfied. + #if echo \"${f}.001\": \"$f\" \; x | make -r -q -f - ; then + # (Or we could use bash's -nt operator...) + if [ "${f}.001" -nt "$f" ] ; then echo ${f}.nnn is up-to-date else - $RM ${f}.[0-9][0-9][0-9] - $FAX make $OPT $f + $RM "${f}".[0-9][0-9][0-9] + $FAX make $OPT "$f" fi - if [ -r $f.001 ] ; then - FILES="$FILES $f.[0-9][0-9][0-9]" - else # something's wrong, catch it later - FILES="$FILES $f.001" + if [ -r "$f.001" ] ; then + # We got output; add the results to the FILES array. + for i in "$f".[0-9][0-9][0-9]; do + FILES[fidx++]="$i"; + done + else + # something's wrong, catch it later + FILES[fidx++]="$f.001" fi ;; esac done - # check that all files are OK + # check that all resulting files are readable. - for f in $FILES ; do - case $f in -) continue ;; esac - if [ ! -r $f ] ; then + for f in "${fil...@]}" ; do + case "$f" in -) continue ;; esac + if [ ! -r "$f" ] ; then echo "can't read file $f" ; ERR=2 ; break 2 fi done @@ -913,10 +940,10 @@ eval HDR=\"$HDR\" $NICE $EFAX -v "$VERB" -v "$VERBLOG" \ - -d/dev/$DEV $LOCK $INIT $SPKR \ - $CLASSINIT $FCINIT $TXINIT \ - $TXCAP -l "$FROM" $RESET $HDRFONT -h "$HDR" \ - $MANINIT -t "$TELNO" $FILES >$logfile + -d/dev/$DEV $LOCK $INIT $SPKR \ + $CLASSINIT $FCINIT $TXINIT \ + $TXCAP -l "$FROM" $RESET $HDRFONT -h "$HDR" \ + $MANINIT -t "$TELNO" "${fil...@]}" >$logfile ERR=$? @@ -926,7 +953,7 @@ *) echo "There were errors (see ${logfile})." ; break ;; esac - done + done # BUSYRETRIES SENT=` sed -n -e '/sent ->/s/^.*-> \([^ ]*\).*/\1/p' $logfile` FILES=`sed -n -e '/failed ->/s/^.*-> \([^ ]*\).*/\1/p' $logfile` @@ -934,7 +961,7 @@ case $FILES in '') break ;; esac echo Failed... - done + done # FAILRETRIES break ;;