Bug#569290: Acknowledgement (un-prefer /dev/block/* names more strongly than in lvm.conf)

2010-02-11 Thread Alasdair G Kergon
On Thu, Feb 11, 2010 at 01:17:06AM -0800, Kees Cook wrote:
> Attached patch fixes the issue.
 
> + m0 = strncmp(path0, "/dev/block/", 11);
> + m1 = strncmp(path1, "/dev/block/", 11);

/dev should not be hard-coded.  Use cmd->dev_dir so its location can
be changed through lvm.conf.

(The test suite makes use of that and it also makes it easy to 
control exactly what devices lvm sees when trying to reproduce
problems people report.)

Alasdair



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#569290: Acknowledgement (un-prefer /dev/block/* names more strongly than in lvm.conf)

2010-02-11 Thread Kees Cook
Attached patch fixes the issue.

Thanks,

-Kees

-- 
Kees Cook@debian.org
Description: Prefer any other device name over names in /dev/block/.
Author: Colin Watson 
Bug-Ubuntu: https://bugs.launchpad.net/bugs/341928
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=569290

Index: merged/lib/device/dev-cache.c
===
--- merged.orig/lib/device/dev-cache.c	2009-07-15 13:02:46.0 -0700
+++ merged/lib/device/dev-cache.c	2010-02-10 15:57:40.175269708 -0800
@@ -179,6 +179,21 @@
 	 * Built-in rules.
 	 */
 
+	/* Put /dev/block/ names last regardless of path shortness.
+	 * FIXME It would be better if we could do this in the configuration
+	 * file, but the only way to do so with preferred_names is to try to
+	 * enumerate all the possible names we might want to prefer over
+	 * /dev/block/. */
+	m0 = strncmp(path0, "/dev/block/", 11);
+	m1 = strncmp(path1, "/dev/block/", 11);
+
+	if (m0 != m1) {
+		if (m0 == 0)
+			return 1;
+		if (m1 == 0)
+			return 0;
+	}
+
 	/* Return the path with fewer slashes */
 	for (p = path0; p++; p = (const char *) strchr(p, '/'))
 		slash0++;