Package: nbd-client
Version: 1:2.9.14-1
Severity: wishlist
Tags: patch

Hi again,

in a "live" busybox+klibc based initramfs the sed function to extract the port 
from the 3 argument form of nbdroot fails.   The parts of the regex work but 
the total regexp fails to do anything, I didn't really dig into the source of 
that issue as it seemed like it was likely to be a limitation of the particular 
sed.   I'm hoping you would consider rewriting this to make it less likely to 
break in less competent implementations of sed.

I have attached a patch which eliminates sed completely by using more shell 
substitutions, though just breaking down that one more complicated sed 
expression to two seperate calls to sed works equally well for me in my 
environment so tmtowtdi.

It's worth noting that a kernel root option will set the nbd device which is 
what is additionally set in the 3 argument form of nbdroot anyway, so again I 
might only have tripped this as I'm not using initramfs-tools local with a 
normal rootfs so I don't want to set root on the kernel command line.

As far as I know this is only an inconvience to me though as in my case I think 
I can safely set e.g. root=/dev/nbd0, I just don't want to and the existing 
code teased me into thinking I wouldn't need to.

Sincerest thanks again for your work on nbd in debian,

Niall

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Versions of packages nbd-client depends on:
ii  debconf [debconf-2.0]         1.5.28     Debian configuration management sy
ii  libc6                         2.10.1-2   GNU C Library: Shared libraries

nbd-client recommends no packages.

nbd-client suggests no packages.
diff -ur nbd-2.9.14.orig/debian/nbd-client.initrd nbd-2.9.14/debian/nbd-client.initrd
--- nbd-2.9.14.orig/debian/nbd-client.initrd	2009-10-28 15:22:33.000000000 +0000
+++ nbd-2.9.14/debian/nbd-client.initrd	2009-10-28 15:13:06.769421456 +0000
@@ -15,15 +15,16 @@
 	case $x in
 		nbdroot=*,*,*)
 			nbdroot="${x#nbdroot=}"
-			nbdsrv=$(echo "$nbdroot" | sed -e "s/,.*$//")
-			nbdport=$(echo "$nbdroot" | sed -e "s/,([^,]*),.*$/\1/")
-			nbdbasedev=$(echo "$nbdroot" | sed -e "s/^.*,//")
+			nbdsrv="${nbdroot%%,*}"
+			nbdport="${nbdroot%,*}"
+			nbdport="${nbdport##*,}"
+			nbdbasedev="${nbdroot##*,}"
 			nbdrootdev=/dev/$nbdbasedev
 			;;
 		nbdroot=*,*)
 			nbdroot="${x#nbdroot=}"
-			nbdsrv=$(echo "$nbdroot" | sed -e "s/,[^,]*$//")
-			nbdport=$(echo "$nbdroot" | sed -e "s/^[^,]*,//")
+			nbdsrv="${nbdroot%,*}"
+			nbdbasedev="${nbdport#*,}"
 			;;
 		ip=*)
 			IPOPTS="${x#ip=}"

Reply via email to