diff options
Diffstat (limited to 'main/multipath-tools')
7 files changed, 580 insertions, 0 deletions
diff --git a/main/multipath-tools/APKBUILD b/main/multipath-tools/APKBUILD new file mode 100644 index 0000000000..621351ca4e --- /dev/null +++ b/main/multipath-tools/APKBUILD @@ -0,0 +1,50 @@ +# Contributor: Leonardo Arena <rnalrd@gmail.com> +# Maintainer: Leonardo Arena <rnalrd@gmail.com> +pkgname="multipath-tools" +pkgver=0.4.8 +pkgrel=6 +pkgdesc="Device Mapper Multipathing Driver" +url="http://christophe.varoqui.free.fr/" +license="GPL" +depends= +makedepends="lvm2-dev libaio-dev readline-dev ncurses-dev udev-dev" +install= +subpackages="$pkgname-doc" +source="http://christophe.varoqui.free.fr/$pkgname/$pkgname-$pkgver.tar.bz2 + multipath-tools-0.4.8-udev-scsi_id-changes.patch + multipath-tools-0.4.8-socket-cve-2009-0115.patch + multipath-tools-0.4.8-r1-kpartx.patch + multipath-tools-0.4.8-kparted-ext-partitions.patch" + +_builddir="$srcdir/$pkgname-$pkgver" + +prepare() { + cd $_builddir + find . -name Makefile -exec sed -i -e 's/glibc/uclibc/g' {} \; + for i in ../*.patch + do + msg "Applying $i" + patch -p1 < $i || return 1 + done +} + +build() { + cd $_builddir + make -j1 prefix="/usr" \ + sysconfdir="/etc" \ + mandir="/usr/share/man" \ + infodir="/usr/share/info" || return 1 +} + +package() { + cd $_builddir + make DESTDIR="$pkgdir" install + install -D -m644 ../../$pkgname.conf $pkgdir/etc/multipath.conf + install -D -m755 ../../$pkgname.initd $pkgdir/etc/init.d/multipathd +} + +md5sums="3563b863b408d07c46929b6e8c2c248c multipath-tools-0.4.8.tar.bz2 +b39a63e65de16cf086618de6916bd98f multipath-tools-0.4.8-udev-scsi_id-changes.patch +2070c01a98d01833b9eee771fce3a22c multipath-tools-0.4.8-socket-cve-2009-0115.patch +0febb1f512681b8de8c2f0287e260efd multipath-tools-0.4.8-r1-kpartx.patch +68ea053e02e9f5c4883b24b3f9bb2bf1 multipath-tools-0.4.8-kparted-ext-partitions.patch" diff --git a/main/multipath-tools/multipath-tools-0.4.8-kparted-ext-partitions.patch b/main/multipath-tools/multipath-tools-0.4.8-kparted-ext-partitions.patch new file mode 100644 index 0000000000..3f70fd70e4 --- /dev/null +++ b/main/multipath-tools/multipath-tools-0.4.8-kparted-ext-partitions.patch @@ -0,0 +1,28 @@ +From c421c9282791696264d1333fb2552835140354c3 Mon Sep 17 00:00:00 2001 +From: Robin H. Johnson <robbat2@gentoo.org> +Date: Thu, 5 Nov 2009 03:44:12 +0000 +Subject: [PATCH] kpartx: Fix broken calculation of extended partitions that caused random devices to be used instead of the correct parent device. + +Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> +--- + kpartx/dos.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/kpartx/dos.c b/kpartx/dos.c +index 1691105..317fc56 100644 +--- a/kpartx/dos.c ++++ b/kpartx/dos.c +@@ -53,7 +53,9 @@ read_extended_partition(int fd, struct partition *ep, int en, + if (n < ns) { + sp[n].start = here + le32_to_cpu(p.start_sect); + sp[n].size = le32_to_cpu(p.nr_sects); +- sp[n].container = en + 1; ++ // This line seems to have no understandable ++ // purpose, and causes the wrong device to be used ++ //sp[n].container = en + 1; + n++; + } else { + fprintf(stderr, +-- +1.6.4 + diff --git a/main/multipath-tools/multipath-tools-0.4.8-r1-kpartx.patch b/main/multipath-tools/multipath-tools-0.4.8-r1-kpartx.patch new file mode 100644 index 0000000000..ae2a7fe1c6 --- /dev/null +++ b/main/multipath-tools/multipath-tools-0.4.8-r1-kpartx.patch @@ -0,0 +1,250 @@ +diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c +index 3e973aa..893d6dd 100644 +--- a/kpartx/devmapper.c ++++ b/kpartx/devmapper.c +@@ -4,10 +4,12 @@ + #include <stdio.h> + #include <stdlib.h> + #include <string.h> ++#include <stdint.h> + #include <libdevmapper.h> + #include <ctype.h> + #include <linux/kdev_t.h> + #include <errno.h> ++#include "devmapper.h" + + #define UUID_PREFIX "part%d-" + #define MAX_PREFIX_LEN 8 +@@ -72,7 +74,7 @@ dm_simplecmd (int task, const char *name) { + + extern int + dm_addmap (int task, const char *name, const char *target, +- const char *params, unsigned long size, const char *uuid, int part) { ++ const char *params, uint64_t size, const char *uuid, int part) { + int r = 0; + struct dm_task *dmt; + char *prefixed_uuid = NULL; +diff --git a/kpartx/devmapper.h b/kpartx/devmapper.h +index ccdbead..2bd27d2 100644 +--- a/kpartx/devmapper.h ++++ b/kpartx/devmapper.h +@@ -1,7 +1,7 @@ + int dm_prereq (char *, int, int, int); + int dm_simplecmd (int, const char *); +-int dm_addmap (int, const char *, const char *, const char *, unsigned long, +- char *, int); ++int dm_addmap (int, const char *, const char *, const char *, uint64_t, ++ const char *, int); + int dm_map_present (char *); + char * dm_mapname(int major, int minor); + dev_t dm_get_first_dep(char *devname); +diff --git a/kpartx/gpt.c b/kpartx/gpt.c +index dc846ca..047a829 100644 +--- a/kpartx/gpt.c ++++ b/kpartx/gpt.c +@@ -36,6 +36,7 @@ + #include <errno.h> + #include <endian.h> + #include <byteswap.h> ++#include <linux/fs.h> + #include "crc32.h" + + #if BYTE_ORDER == LITTLE_ENDIAN +@@ -50,10 +51,18 @@ + # define __cpu_to_le32(x) bswap_32(x) + #endif + ++#ifndef BLKGETLASTSECT + #define BLKGETLASTSECT _IO(0x12,108) /* get last sector of block device */ ++#endif ++#ifndef BLKGETSIZE + #define BLKGETSIZE _IO(0x12,96) /* return device size */ ++#endif ++#ifndef BLKSSZGET + #define BLKSSZGET _IO(0x12,104) /* get block device sector size */ ++#endif ++#ifndef BLKGETSIZE64 + #define BLKGETSIZE64 _IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */ ++#endif + + struct blkdev_ioctl_param { + unsigned int block; +@@ -143,20 +152,14 @@ get_sector_size(int filedes) + static uint64_t + _get_num_sectors(int filedes) + { +- unsigned long sectors=0; + int rc; +-#if 0 +- uint64_t bytes=0; ++ uint64_t bytes=0; + +- rc = ioctl(filedes, BLKGETSIZE64, &bytes); ++ rc = ioctl(filedes, BLKGETSIZE64, &bytes); + if (!rc) + return bytes / get_sector_size(filedes); +-#endif +- rc = ioctl(filedes, BLKGETSIZE, §ors); +- if (rc) +- return 0; +- +- return sectors; ++ ++ return 0; + } + + /************************************************************ +@@ -193,7 +196,7 @@ last_lba(int filedes) + sectors = 1; + } + +- return sectors - 1; ++ return sectors ? sectors - 1 : 0; + } + + +@@ -220,17 +223,22 @@ read_lba(int fd, uint64_t lba, void *buffer, size_t bytes) + { + int sector_size = get_sector_size(fd); + off_t offset = lba * sector_size; ++ uint64_t lastlba; + ssize_t bytesread; + + lseek(fd, offset, SEEK_SET); + bytesread = read(fd, buffer, bytes); + ++ lastlba = last_lba(fd); ++ if (!lastlba) ++ return bytesread; ++ + /* Kludge. This is necessary to read/write the last + block of an odd-sized disk, until Linux 2.5.x kernel fixes. + This is only used by gpt.c, and only to read + one sector, so we don't have to be fancy. + */ +- if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd)) { ++ if (!bytesread && !(lastlba & 1) && lba == lastlba) { + bytesread = read_lastoddsector(fd, lba, buffer, bytes); + } + return bytesread; +@@ -505,7 +513,8 @@ find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes) + if (!gpt || !ptes) + return 0; + +- lastlba = last_lba(fd); ++ if (!(lastlba = last_lba(fd))) ++ return 0; + good_pgpt = is_gpt_valid(fd, GPT_PRIMARY_PARTITION_TABLE_LBA, + &pgpt, &pptes); + if (good_pgpt) { +diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c +index dbe2ee2..72ca81d 100644 +--- a/kpartx/kpartx.c ++++ b/kpartx/kpartx.c +@@ -25,6 +25,7 @@ + #include <stdlib.h> + #include <string.h> + #include <unistd.h> ++#include <stdint.h> + #include <sys/stat.h> + #include <sys/types.h> + #include <ctype.h> +@@ -366,16 +367,16 @@ main(int argc, char **argv){ + + slices[j].minor = m++; + +- printf("%s%s%d : 0 %lu %s %lu\n", ++ printf("%s%s%d : 0 %" PRIu64 " %s %" PRIu64"\n", + mapname, delim, j+1, +- (unsigned long) slices[j].size, device, +- (unsigned long) slices[j].start); ++ slices[j].size, device, ++ slices[j].start); + } + /* Loop to resolve contained slices */ + d = c; + while (c) { + for (j = 0; j < n; j++) { +- unsigned long start; ++ uint64_t start; + int k = slices[j].container - 1; + + if (slices[j].size == 0) +@@ -387,9 +388,9 @@ main(int argc, char **argv){ + slices[j].minor = m++; + + start = slices[j].start - slices[k].start; +- printf("%s%s%d : 0 %lu /dev/dm-%d %lu\n", ++ printf("%s%s%d : 0 %" PRIu64 " /dev/dm-%d %" PRIu64 "\n", + mapname, delim, j+1, +- (unsigned long) slices[j].size, ++ slices[j].size, + slices[k].minor, start); + c--; + } +@@ -448,8 +449,8 @@ main(int argc, char **argv){ + } + strip_slash(partname); + +- if (safe_sprintf(params, "%s %lu", device, +- (unsigned long)slices[j].start)) { ++ if (safe_sprintf(params, "%s %" PRIu64 , ++ device, slices[j].start)) { + fprintf(stderr, "params too small\n"); + exit(1); + } +@@ -468,7 +469,7 @@ main(int argc, char **argv){ + &slices[j].minor); + + if (verbose) +- printf("add map %s (%d:%d): 0 %lu %s %s\n", ++ printf("add map %s (%d:%d): 0 %" PRIu64 " %s %s\n", + partname, slices[j].major, + slices[j].minor, slices[j].size, + DM_TARGET, params); +@@ -502,10 +503,10 @@ main(int argc, char **argv){ + } + strip_slash(partname); + +- if (safe_sprintf(params, "%d:%d %lu", ++ if (safe_sprintf(params, "%d:%d %" PRIu64, + slices[k].major, + slices[k].minor, +- (unsigned long)slices[j].start)) { ++ slices[j].start)) { + fprintf(stderr, "params too small\n"); + exit(1); + } +@@ -524,7 +525,7 @@ main(int argc, char **argv){ + &slices[j].minor); + + if (verbose) +- printf("add map %s : 0 %lu %s %s\n", ++ printf("add map %s : 0 %" PRIu64 " %s %s\n", + partname, slices[j].size, + DM_TARGET, params); + c--; +diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h +index 9b3aeca..43ae3f8 100644 +--- a/kpartx/kpartx.h ++++ b/kpartx/kpartx.h +@@ -1,6 +1,8 @@ + #ifndef _KPARTX_H + #define _KPARTX_H + ++#include <stdint.h> ++ + /* + * For each partition type there is a routine that takes + * a block device and a range, and returns the list of +@@ -20,8 +22,8 @@ + * units: 512 byte sectors + */ + struct slice { +- unsigned long start; +- unsigned long size; ++ uint64_t start; ++ uint64_t size; + int container; + int major; + int minor; diff --git a/main/multipath-tools/multipath-tools-0.4.8-socket-cve-2009-0115.patch b/main/multipath-tools/multipath-tools-0.4.8-socket-cve-2009-0115.patch new file mode 100644 index 0000000000..deab762065 --- /dev/null +++ b/main/multipath-tools/multipath-tools-0.4.8-socket-cve-2009-0115.patch @@ -0,0 +1,29 @@ +From: Hannes Reinecke <hare@suse.de> +Date: Wed, 1 Apr 2009 20:31:01 +0000 (+0200) +Subject: [multipathd] /var/run/multipathd.sock is world-writable +X-Git-Url: http://git.kernel.org/gitweb.cgi?p=linux%2Fstorage%2Fmultipath-tools%2F.git;a=commitdiff_plain;h=0a0319d381249760c71023edbe0ac9c093bb4a74;hp=15d4bdddcb9b71e0ec6fecc3c37a1b8cae8f51ff + +[multipathd] /var/run/multipathd.sock is world-writable + +Due to an stray 'umask()' the socket file is in fact world-writable, +allowing for an easy exploit. + +References: 458598 +--- + +diff --git a/multipathd/main.c b/multipathd/main.c +index 8a1a63d..9957f1f 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -1454,8 +1454,9 @@ daemonize(void) + + close(in_fd); + close(out_fd); +- chdir("/"); +- umask(0); ++ if (chdir("/") < 0) ++ fprintf(stderr, "cannot chdir to '/', continuing\n"); ++ + return 0; + } + diff --git a/main/multipath-tools/multipath-tools-0.4.8-udev-scsi_id-changes.patch b/main/multipath-tools/multipath-tools-0.4.8-udev-scsi_id-changes.patch new file mode 100644 index 0000000000..a770a05899 --- /dev/null +++ b/main/multipath-tools/multipath-tools-0.4.8-udev-scsi_id-changes.patch @@ -0,0 +1,90 @@ +diff -Nuar multipath-tools-0.4.8.orig/libmultipath/defaults.h multipath-tools-0.4.8/libmultipath/defaults.h +--- multipath-tools-0.4.8.orig/libmultipath/defaults.h 2007-08-02 21:05:37.000000000 +0000 ++++ multipath-tools-0.4.8/libmultipath/defaults.h 2009-10-30 06:00:21.432553430 +0000 +@@ -1,4 +1,4 @@ +-#define DEFAULT_GETUID "/lib/udev/scsi_id -g -u -s /block/%n" ++#define DEFAULT_GETUID "/lib/udev/scsi_id -g -u -d /dev/%n" + #define DEFAULT_UDEVDIR "/dev" + #define DEFAULT_SELECTOR "round-robin 0" + #define DEFAULT_FEATURES "0" +diff -Nuar multipath-tools-0.4.8.orig/libmultipath/hwtable.c multipath-tools-0.4.8/libmultipath/hwtable.c +--- multipath-tools-0.4.8.orig/libmultipath/hwtable.c 2007-08-02 21:05:37.000000000 +0000 ++++ multipath-tools-0.4.8/libmultipath/hwtable.c 2009-10-30 06:00:08.087158020 +0000 +@@ -157,7 +157,7 @@ + /* HP Smart Array */ + .vendor = "HP", + .product = "LOGICAL VOLUME.*", +- .getuid = "/lib/udev/scsi_id -n -g -u -s /block/%n", ++ .getuid = "/lib/udev/scsi_id -n -g -u -d /dev/%n", + .getprio = NULL, + .features = DEFAULT_FEATURES, + .hwhandler = DEFAULT_HWHANDLER, +@@ -199,7 +199,7 @@ + { + .vendor = "EMC", + .product = "SYMMETRIX", +- .getuid = "/lib/udev/scsi_id -g -u -ppre-spc3-83 -s /block/%n", ++ .getuid = "/lib/udev/scsi_id -g -u -ppre-spc3-83 -d /dev/%n", + .getprio = NULL, + .features = DEFAULT_FEATURES, + .hwhandler = DEFAULT_HWHANDLER, +diff -Nuar multipath-tools-0.4.8.orig/multipath/multipath.conf.5 multipath-tools-0.4.8/multipath/multipath.conf.5 +--- multipath-tools-0.4.8.orig/multipath/multipath.conf.5 2007-08-02 21:05:37.000000000 +0000 ++++ multipath-tools-0.4.8/multipath/multipath.conf.5 2009-10-30 05:59:19.272559733 +0000 +@@ -109,7 +109,7 @@ + The default program and args to callout to obtain a unique path + identifier. Should be specified with an absolute path. Default value + is +-.I /lib/udev/scsi_id -g -u -s ++.I /lib/udev/scsi_id -g -u -d + .TP + .B prio_callout + The default program and args to callout to obtain a path priority +diff -Nuar multipath-tools-0.4.8.orig/multipath.conf.annotated multipath-tools-0.4.8/multipath.conf.annotated +--- multipath-tools-0.4.8.orig/multipath.conf.annotated 2007-08-02 21:05:37.000000000 +0000 ++++ multipath-tools-0.4.8/multipath.conf.annotated 2009-10-30 05:59:53.002576683 +0000 +@@ -47,9 +47,9 @@ + # # scope : multipath + # # desc : the default program and args to callout to obtain a unique + # # path identifier. Absolute path required +-# # default : /lib/udev/scsi_id -g -u -s ++# # default : /lib/udev/scsi_id -g -u -d + # # +-# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" ++# getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n" + # + # # + # # name : prio_callout +@@ -291,9 +291,9 @@ + # # scope : multipath + # # desc : the program and args to callout to obtain a unique + # # path identifier. Absolute path required +-# # default : /lib/udev/scsi_id -g -u -s ++# # default : /lib/udev/scsi_id -g -u -d + # # +-# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" ++# getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n" + # + # # + # # name : prio_callout +diff -Nuar multipath-tools-0.4.8.orig/multipath.conf.synthetic multipath-tools-0.4.8/multipath.conf.synthetic +--- multipath-tools-0.4.8.orig/multipath.conf.synthetic 2007-08-02 21:05:37.000000000 +0000 ++++ multipath-tools-0.4.8/multipath.conf.synthetic 2009-10-30 05:59:38.569224508 +0000 +@@ -7,7 +7,7 @@ + # polling_interval 10 + # selector "round-robin 0" + # path_grouping_policy multibus +-# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" ++# getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n" + # prio_callout /bin/true + # path_checker directio + # rr_min_io 100 +@@ -52,7 +52,7 @@ + # vendor "COMPAQ " + # product "HSV110 (C)COMPAQ" + # path_grouping_policy multibus +-# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" ++# getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n" + # path_checker directio + # path_selector "round-robin 0" + # hardware_handler "0" diff --git a/main/multipath-tools/multipath-tools.conf b/main/multipath-tools/multipath-tools.conf new file mode 100644 index 0000000000..11194176df --- /dev/null +++ b/main/multipath-tools/multipath-tools.conf @@ -0,0 +1,113 @@ +## +## This is a template multipath-tools configuration file +## Uncomment the lines relevent to your environment +## +#defaults { +# udev_dir /dev +# polling_interval 10 +# selector "round-robin 0" +# path_grouping_policy multibus +# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" +# prio_callout /bin/true +# path_checker directio +# rr_min_io 100 +# rr_weight priorities +# failback immediate +# no_path_retry fail +# user_friendly_names no +#} +#blacklist { +# wwid 26353900f02796769 +# devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" +# devnode "^hd[a-z][[0-9]*]" +# devnode "^cciss!c[0-9]d[0-9]*[p[0-9]*]" +# device { +# vendor DEC.* +# product MSA[15]00 +# } +#} +#blacklist_exceptions { +# devnode "^dasd[c-d]+[0-9]*" +# wwid "IBM.75000000092461.4d00.34" +#} +#multipaths { +# multipath { +# wwid 3600508b4000156d700012000000b0000 +# alias yellow +# path_grouping_policy multibus +# path_checker directio +# path_selector "round-robin 0" +# failback manual +# rr_weight priorities +# no_path_retry 5 +# rr_min_io 100 +# } +# multipath { +# wwid 1DEC_____321816758474 +# alias red +# } +#} +#devices { +# device { +# vendor "COMPAQ " +# product "HSV110 (C)COMPAQ" +# path_grouping_policy multibus +# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" +# path_checker directio +# path_selector "round-robin 0" +# hardware_handler "0" +# failback 15 +# rr_weight priorities +# no_path_retry queue +# rr_min_io 100 +# product_blacklist LUN_Z +# } +# device { +# vendor "COMPAQ " +# product "MSA1000 " +# path_grouping_policy multibus +# } +#} + +#defaults { +# udev_dir /dev +# user_friendly_names yes +#} + +#blacklist { +# devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" +# devnode "^hd[a-z]" +# devnode "^sda" +# devnode "^sdb" +# devnode "^sdc" +# devnode "^sdd" +# devnode "^sda[0-9]" +# devnode "^sdb[0-9]" +# device { +# vendor DELL +# product "PERC|Universal" +# } +#} + +#devices { +# device { +# vendor DELL +# product MD3000i +# hardware_handler "1 rdac" +# path_checker rdac +# path_grouping_policy group_by_prio +# prio_callout "/sbin/mpath_prio_rdac /dev/%n" +# failback immediate +# getuid_callout "/lib/udev/scsi_id -g -u -s /block/%n" +# } +#} + +#multipaths { +# multipath { +# device { +# vendor DELL +# product MD3000i +# } +# } +#} + diff --git a/main/multipath-tools/multipath-tools.initd b/main/multipath-tools/multipath-tools.initd new file mode 100644 index 0000000000..931bc313d0 --- /dev/null +++ b/main/multipath-tools/multipath-tools.initd @@ -0,0 +1,20 @@ +#!/sbin/runscript +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/www/viewcvs.gentoo.org/raw_cvs/gentoo-x86/sys-fs/multipath-tools/files/rc-multipathd,v 1.5 2009/03/17 22:48:13 solar Exp $ + +depend() { + after firewall +} + +start() { + ebegin "Starting multipathd" + start-stop-daemon --start --quiet --exec /sbin/multipathd + eend $? +} + +stop() { + ebegin "Stopping multipathd" + start-stop-daemon --stop --quiet --pidfile /var/run/multipathd.pid + eend $? +} |