Package: xvmount
Version: 3.7-14
Severity: normal
Tags: patch

[EMAIL PROTECTED]:~# xvmountconfig 

You may now select the user mountable devices from /etc/fstab
which are to be made available for mounting by xvmount.
uniq: invalid option -- W
Try `uniq --help' for more information.
[EMAIL PROTECTED]:~# grep uniq /usr/sbin/xvmountconfig 
sort -s |uniq -W 1 --separator='*'`"

Those Debian-specific options have _both_ been removed in Etch
coreutils.  And now that I look into it, I notice that
xvmountconfig's giant backtick process could be improved in several
ways. 

First, there's no need for an initial egrep when you could do all
the work in sed -r: 

 sed -r /etc/fstab -e '/^[[:space:]]*#/d' \
    -e '/([^[:space:]]+[[:space:]]+){3}.*\busers?\b/!d' \
    -e 's/[[:space:]][[:space:]]*/ /g' \
    -e 's/^ ?([^ ]*) ([^ ]*).*/\2*\1/'

(Note that fstab lines with leading whitespace are valid!)

Then the list is sorted, using asterisk as the field-separator
rather than, say, NUL; this means the mountpoint "/mnt" sorts
between "/mnt%99" and "/mnt/foo", which seems unfortunate.  And
shouldn't this be controlling for $LC_COLLATE?  But never mind all
this.  

Then you uniqify it, using uniq -W 1 --separator='*' to ensure that
in cases like this:

 /dev/floppy /mnt auto    rw,noauto,user
 /dev/cdrom  /mnt iso9660 ro,noauto,user

the /dev/floppy line (alphabetically later) is silently discarded.
I don't see any way of keeping this behaviour with Etch's uniq, but
is it really sensible to be uniqifying in the first place?  Wouldn't
it be more appropriate to bail out saying "I can't tell what you
want to have mounting on /mnt!"?  In other words:

LIST=$(sed blah blah blah | sort)

# do the check-for-valid-lines dance, then:

 DUPE=$(echo "$LIST" | sed 's/\*.*//' | uniq -d)

if [ -n "${DUPE}" ]
then
    do a similar complain/restoreconfig/die
fi

Patch to this effect attached.

-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i586)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18.hurakan
Locale: LANG=en_GB.iso8859-1, LC_CTYPE=en_GB.iso8859-1 (charmap=ISO-8859-1)

Versions of packages xvmount depends on:
ii  debconf [debconf-2.0]       1.5.11       Debian configuration management sy
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  xviewg                      3.2p1.4-21.1 XView shared libraries

xvmount recommends no packages.

-- debconf information:
* xvmount/generate_failed:
  xvmount/wrong_format:
  xvmount/convert_failed:
  xvmount/empty_fstab:
  xvmount/convert_old_config: true
--- /usr/sbin/xvmountconfig.old	2006-09-26 12:15:57.000000000 +0000
+++ /usr/sbin/xvmountconfig	2007-03-17 18:04:06.000000000 +0000
@@ -118,11 +118,10 @@
 fi
 
 # Treat all device types
-LIST="`egrep -e '([^[:space:]]+[[:space:]]+){3}.*,?user,?' /etc/fstab |\
-sed 	-e '/^[[:space:]]*#/d' \
-	-e 's/[[:space:]][[:space:]]*/ /g' \
-	-e 's/^\([^ ]*\) \([^ ]*\).*/\2*\1/' |\
-sort -s |uniq -W 1 --separator='*'`"
+LIST=$(sed -r /etc/fstab -e '/^[[:space:]]*#/d' \
+    -e '/([^[:space:]]+[[:space:]]+){3}.*\busers?\b/!d' \
+    -e 's/[[:space:]][[:space:]]*/ /g' \
+    -e 's/^ ?([^ ]*) ([^ ]*).*/\2*\1/')
 
 # Check for valid lines
 if [ -z "${LIST}" ]
@@ -136,6 +135,21 @@
   exit 8
 fi
 
+# Check for ambiguous mountpoints
+DUPE=$(echo "$LIST" | sed 's/\*.*//' | uniq -d)
+
+if [ -n "${DUPE}" ]
+then
+  echo "Ambiguous mountpoint found in /etc/fstab:"
+  echo "$DUPE"
+  if [ -r ${DIR}/${CONFIGFILE}.bak ]
+  then
+     echo "Your old configuration file is restored."
+     mv ${DIR}/${CONFIGFILE}.bak ${DIR}/${CONFIGFILE}
+  fi
+  exit 8
+fi
+
 # Get input - loop 
 DOUBLE=1
 while [ ${DOUBLE} = 1 ] ; do

Reply via email to