debian/0000775000000000000000000000000012303401511007156 5ustar debian/open-iscsi-udeb.dirs0000664000000000000000000000005412150615442013040 0ustar bin usr/lib/finish-install.d sbin etc/iscsi debian/patches/0000775000000000000000000000000012150615740010620 5ustar debian/patches/03_hardened-build-flags.patch0000664000000000000000000000372112150615442016106 0ustar hardened build flags - wheezy release goal Index: open-iscsi/usr/Makefile =================================================================== --- open-iscsi.orig/usr/Makefile 2012-04-07 19:58:23.341694200 +0530 +++ open-iscsi/usr/Makefile 2012-04-07 20:00:41.622379886 +0530 @@ -28,7 +28,7 @@ endif endif -OPTFLAGS ?= -O2 -g +OPTFLAGS ?= `dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS` WARNFLAGS ?= -Wall -Wstrict-prototypes CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../include -I. -I../utils/open-isns \ -D$(OSNAME) $(IPC_CFLAGS) @@ -54,14 +54,14 @@ iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \ iscsid.o session_mgmt.o discoveryd.o - $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns + $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns `dpkg-buildflags --get LDFLAGS` iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o - $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns + $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns `dpkg-buildflags --get LDFLAGS` iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \ iscsistart.o statics.o - $(CC) $(CFLAGS) $^ -o $@ + $(CC) $(CFLAGS) $^ -o $@ `dpkg-buildflags --get LDFLAGS` clean: rm -f *.o $(PROGRAMS) .depend $(LIBSYS) Index: open-iscsi/utils/Makefile =================================================================== --- open-iscsi.orig/utils/Makefile 2012-04-07 19:54:51.056641535 +0530 +++ open-iscsi/utils/Makefile 2012-04-07 20:01:57.138754352 +0530 @@ -1,12 +1,12 @@ # This Makefile will work only with GNU make. -CFLAGS += $(OPTFLAGS) -O2 -fno-inline -Wall -Wstrict-prototypes -g +CFLAGS += $(OPTFLAGS) -fno-inline -Wall -Wstrict-prototypes `dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS` PROGRAMS = iscsi-iname all: $(PROGRAMS) iscsi-iname: md5.o iscsi-iname.o - $(CC) $(CFLAGS) $^ $(DBM_LIB) -o $@ + $(CC) $(CFLAGS) $^ $(DBM_LIB) -o $@ `dpkg-buildflags --get LDFLAGS` clean: rm -f *.o $(PROGRAMS) .depend debian/patches/series0000664000000000000000000000026112150615442012033 0ustar 01_spelling-errors-and-manpage-hyphen-fixes.patch 02_make-iscsistart-a-dynamic-binary.patch 03_hardened-build-flags.patch 04_fix_iscsi_path.patch 05_var-lock_var-run_transition debian/patches/01_spelling-errors-and-manpage-hyphen-fixes.patch0000664000000000000000000000777512150615442022062 0ustar spelling error fixes Index: open-iscsi/doc/iscsiadm.8 =================================================================== --- open-iscsi.orig/doc/iscsiadm.8 2012-04-07 20:49:15.044826780 +0530 +++ open-iscsi/doc/iscsiadm.8 2012-04-07 20:52:31.133799130 +0530 @@ -2,10 +2,10 @@ .SH NAME iscsiadm \- open-iscsi administration utility .SH SYNOPSIS -\fBiscsiadm\fR \-m discoverydb [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-lD ] ] | [ [ -p ip:port -t type ] \ +\fBiscsiadm\fR \-m discoverydb [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-lD ] ] | [ [ \-p ip:port \-t type ] \ [ \-o operation ] [ \-n name ] [ \-v value ] [ \-lD ] ] -\fBiscsiadm\fR \-m discovery [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-l ] ] | [ [ -p ip:port ] [ \-l | \-D ] ] +\fBiscsiadm\fR \-m discovery [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-l ] ] | [ [ \-p ip:port ] [ \-l | \-D ] ] \fBiscsiadm\fR \-m node [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-L all,manual,automatic ] [ \-U all,manual,automatic ] [ \-S ] [ [ \-T targetname \-p ip:port \-I iface ] [ \-l | \-u | \-R | \-s] ] [ [ \-o operation ] [ \-n name ] [ \-v value ] [ \-p ip:port ] ] @@ -16,7 +16,7 @@ \fBiscsiadm\fR \-m fw [\-l] -\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ -C chap [ -o operation ] [ -v chap_tbl_idx ] ] +\fBiscsiadm\fR \-m host [ \-P printlevel ] [ \-H hostno|MAC ] [ \-C chap [ \-o operation ] [ \-v chap_tbl_idx ] ] \fBiscsiadm\fR \-k priority @@ -64,7 +64,7 @@ Currently iscsiadm support ping as submode for iface. For example, -iscsiadm -m iface -I ifacename -C ping -a ipaddr -b packetsize -c count -i interval +iscsiadm \-m iface \-I ifacename \-C ping \-a ipaddr \-b packetsize \-c count \-i interval .TP \fB\-d\fR, \fB\-\-debug=\fIdebug_level\fP @@ -113,7 +113,7 @@ In discovery mode multiple interfaces can be specified by passing in multiple \-I/\-\-interface instances. For example, -"iscsiadm \-m discoverydb \-t st \-p ip:port \-I iface0 \-I iface2 --discover" +"iscsiadm \-m discoverydb \-t st \-p ip:port \-I iface0 \-I iface2 \-\-discover" Will direct iscsiadm to setup the node db to create records which will create sessions though the two intefaces passed in. Index: open-iscsi/usr/auth.c =================================================================== --- open-iscsi.orig/usr/auth.c 2012-04-07 20:49:15.044826780 +0530 +++ open-iscsi/usr/auth.c 2012-04-07 20:49:21.232857456 +0530 @@ -2002,7 +2002,7 @@ "AuthMethod negotiation failed", "AuthMethod negotiated to none", "CHAP algorithm negotiation failed", - "CHAP challange reflected", + "CHAP challenge reflected", "Local password same as remote", "Local password not set", "CHAP identifier bad", Index: open-iscsi/usr/initiator_common.c =================================================================== --- open-iscsi.orig/usr/initiator_common.c 2012-04-07 19:36:03.303049315 +0530 +++ open-iscsi/usr/initiator_common.c 2012-04-07 20:49:51.281006449 +0530 @@ -77,7 +77,7 @@ if (auth_cfg->username_in[0] || auth_cfg->password_in_length) { /* sanity check the config */ if (auth_cfg->password_length == 0) { - log_warning("CHAP configuratoin has incoming " + log_warning("CHAP configuration has incoming " "authentication credentials but has no " "outgoing credentials configured."); return EINVAL; Index: open-iscsi/usr/netlink.c =================================================================== --- open-iscsi.orig/usr/netlink.c 2012-04-07 19:36:31.791190562 +0530 +++ open-iscsi/usr/netlink.c 2012-04-07 20:50:28.697191996 +0530 @@ -935,7 +935,7 @@ iov[1].iov_len = sizeof(ev); rc = __kipc_call(iov, 2); if (rc < 0) { - log_error("connnection %d:%d transport disconnect failed for " + log_error("connection %d:%d transport disconnect failed for " "ep %" PRIu64 " with error %d.", conn->session->id, conn->id, conn->transport_ep_handle, rc); } else debian/patches/04_fix_iscsi_path.patch0000664000000000000000000000102712150615442015137 0ustar Fix path for iscsid as we ship it in /usr/sbin Index: open-iscsi/etc/iscsid.conf =================================================================== --- open-iscsi.orig/etc/iscsid.conf 2012-04-07 20:18:02.891543275 +0530 +++ open-iscsi/etc/iscsid.conf 2012-04-24 09:36:41.058624577 +0530 @@ -20,7 +20,7 @@ # iscsid.startup = /etc/rc.d/init.d/iscsid force-start # # Default for upstream open-iscsi scripts (uncomment to activate). -iscsid.startup = /sbin/iscsid +iscsid.startup = /usr/sbin/iscsid ############################# debian/patches/02_make-iscsistart-a-dynamic-binary.patch0000664000000000000000000000135412150615442020371 0ustar From 40ef398290064e0c52be9e0d2127901b0f91f20d Mon Sep 17 00:00:00 2001 From: Ritesh Raj Sarraf Date: Tue, 2 Feb 2010 11:43:29 +0530 Subject: [PATCH 32/43] make iscsistart a dynamic binary --- usr/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Index: open-iscsi/usr/Makefile =================================================================== --- open-iscsi.orig/usr/Makefile 2012-04-07 19:36:03.299049291 +0530 +++ open-iscsi/usr/Makefile 2012-04-07 19:39:32.276085546 +0530 @@ -61,7 +61,7 @@ iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \ iscsistart.o statics.o - $(CC) $(CFLAGS) -static $^ -o $@ + $(CC) $(CFLAGS) $^ -o $@ clean: rm -f *.o $(PROGRAMS) .depend $(LIBSYS) debian/patches/05_var-lock_var-run_transition0000664000000000000000000000531712150615442016516 0ustar Description: Move from /var/lock and /var/run to /run/lock and /run Author: Stéphane Graber --- open-iscsi-2.0.873.orig/doc/iscsid.8 +++ open-iscsi-2.0.873/doc/iscsid.8 @@ -40,7 +40,7 @@ do not write a process ID file. .TP .BI [-p|--pid=]\fIpid\-file\fP write process ID to \fIpid\-file\fR rather than the default -\fI/var/run/iscsid.pid\fR +\fI/run/iscsid.pid\fR .TP .BI [-h|--help] display this help and exit --- open-iscsi-2.0.873.orig/usr/initiator.h +++ open-iscsi-2.0.873/usr/initiator.h @@ -38,9 +38,9 @@ #define CONFIG_FILE ISCSI_CONFIG_ROOT"iscsid.conf" #define INITIATOR_NAME_FILE ISCSI_CONFIG_ROOT"initiatorname.iscsi" -#define PID_FILE "/var/run/iscsid.pid" +#define PID_FILE "//run/iscsid.pid" #ifndef LOCK_DIR -#define LOCK_DIR "/var/lock/iscsi" +#define LOCK_DIR "/run/lock/iscsi" #endif #define LOCK_FILE LOCK_DIR"/lock" #define LOCK_WRITE_FILE LOCK_DIR"/lock.write" --- open-iscsi-2.0.873.orig/utils/open-isns/paths.h +++ open-iscsi-2.0.873/utils/open-isns/paths.h @@ -13,7 +13,7 @@ #define OPENISNS_VERSION_STRING "0.90" #define ISNS_ETCDIR "/etc/isns" -#define ISNS_RUNDIR "/var/run" +#define ISNS_RUNDIR "/run" #define ISNS_DEFAULT_ISNSD_CONFIG ISNS_ETCDIR "/isnsd.conf" #define ISNS_DEFAULT_ISNSDD_CONFIG ISNS_ETCDIR "/isnsdd.conf" #define ISNS_DEFAULT_ISNSADM_CONFIG ISNS_ETCDIR "/isnsadm.conf" --- open-iscsi-2.0.873.orig/utils/open-isns/doc/isns_config.5 +++ open-iscsi-2.0.873/utils/open-isns/doc/isns_config.5 @@ -94,7 +94,7 @@ statically. .TP .BR PIDFile " (server): This specifies the name of the server's PID file, which is -.B /var/run/isnsd.pid +.B /run/isnsd.pid by default. .\" ------------------------------------------------------------------ .SS Database Related Options --- open-iscsi-2.0.873.orig/utils/open-isns/etc/openisns.init +++ open-iscsi-2.0.873/utils/open-isns/etc/openisns.init @@ -8,7 +8,7 @@ # description: Starts and stops the iSCSI isns server # # processname: isnsd -# pidfile: /var/run/isnsd.pid +# pidfile: /run/isnsd.pid # config: /etc/isns/isnsd.conf # Source function library. @@ -27,14 +27,14 @@ start() success echo [ $RETVAL -eq 0 ] || return - touch /var/lock/subsys/open-isns + touch /run/lock/subsys/open-isns } stop() { echo -n "Stopping iSCSI isns service: " killproc isnsd - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/open-isns + [ $RETVAL -eq 0 ] && rm -f /run/lock/subsys/open-isns success echo @@ -61,7 +61,7 @@ status) RETVAL=$? ;; condrestart) - [ -f /var/lock/subsys/open-isns ] && restart + [ -f /run/lock/subsys/open-isns ] && restart ;; *) echo $"Usage: $0 {start|stop|restart|status|condrestart}" debian/docs0000664000000000000000000000000712150615442010040 0ustar README debian/README.Debian0000664000000000000000000001033412150615442011232 0ustar open-iscsi for Debian ----------------------------------- The open-iscsi package contains the userspace portion the Open iSCSI project. It depends on iSCSI modules which are already present in current (>= 2.6.18) kernels. WARNING! Please unmount iSCSI-backed filesystems before upgrading the open-iscsi package, as they are not automatically unmounted and the restart of iscsid will break the iscsi block devices and prevent any outstanding I/O from completing (and require a remount before the filesystems will work again). 64 bit kernel with 32 bit userspace ----------------------------------- open-iscsi running with a 64 bit kernel and 32 bit userspace can run into a hang during the iSCSI login phase. This is a known issue upstream. For details, please see Debian BTS #502845 Automatic login and mount ----------------------------------- If you want to automatically connect to all discovered targets, change the following line: node.startup = manual to: node.startup = automatic If you want to automatically mount filesystems on iSCSI volumes, change node.startup to automatic as above, and also add _netdev to the mount options (in /etc/fstab) for the filesystems you would like to mount automatically when open-iscsi is started. iSCSI Qualified Names (IQN) and initiatorname.iscsi ----------------------------------- The initiatorname.iscsi file defines the iSCSI Qualified Name (IQN) of the iSCSI initiator. This IQN is used by the initiator to identify itself to the target. Example: InitiatorName=iqn.1993-08.org.debian:01:lnx-debian While this name can be adjusted to suit your needs, once set, it should not be changed. If you later change the InitiatorName, existing access control lists on the target may reject the initiator to log in. In case a name change is required, the access control lists on the target will need to be updated. Root on iSCSI ----------------------------------- The Debian open-iscsi package now supports root filesystem on iSCSI. Support for this is controlled by the existence of the /etc/iscsi/iscsi.initramfs file. If you are booting from an iSCSI accelerator or NIC that supports iSCSI boot natively, you can likely have your iSCSI target mounted without any manual configuration. Either place the single line "ISCSI_AUTO=true" into /etc/iscsi/iscsi.initramfs, or touch /etc/iscsi/iscsi.initramfs and use the kernel boot line option "iscsi_auto". If manual configuration is necessary, there are two ways to include iSCSI boot options in your initramfs: 1) Touch /etc/iscsi/iscsi.initramfs and provide options on the command line. This provides flexibility, but if passwords are used, is not very secure. Available boot line options: iscsi_initiator, iscsi_target_name, iscsi_target_ip, iscsi_target_port, iscsi_target_group, iscsi_username, iscsi_password, iscsi_in_username, iscsi_in_password See iscsistart --help for a description of each option 2) Provide iSCSI option in /etc/iscsi/iscsi.initramfs. Available options: ISCSI_INITIATOR, ISCSI_TARGET_NAME, ISCSI_TARGET_IP, ISCSI_TARGET_PORT, ISCSI_TARGET_GROUP, ISCSI_USERNAME ISCSI_PASSWORD, ISCSI_IN_USERNAME, ISCSI_IN_PASSWORD Example Syntax: ISCSI_INITIATOR="iqn.1993-08.org.debian:01:9b3e5634fdb9" ISCSI_TARGET_NAME=iqn.2008-01.com.example:storage.foo ISCSI_TARGET_IP=192.168.1.1 ISCSI_TARGET_PORT=3160 ISCSI_USERNAME="username" ISCSI_PASSWORD="password" ISCSI_IN_USERNAME="in_username" ISCSI_IN_PASSWORD="in_password" ISCSI_TARGET_GROUP=1 Remember to set proper permissions if username/passwords are used. If both facilities are used, command line options overwrite iscsi.initramfs options. Also remember that iSCSI requires a working network device, so you'll need to get networking started via an ip= boot option (ex. ip=dhcp). You also won't want to restart the device during boot, so set it to manual mode in /etc/networking/interfaces. Leave BOOT=local set in /etc/initramfs-tools/initramfs.conf and provide a root=/dev/sd* device as the iSCSI disk will look like a local disk. Note: If you need multiple sessions in the initramfs, you can provide multiple IPs to the ISCSI_TARGET_IP variable. Eg: ISCSI_TARGET_IP="192.168.1.1 192.168.2.1 192.168.3.1" This will allow login into all the Target IPs in the initrafs. debian/watch0000664000000000000000000000010712150615442010217 0ustar version=3 http://www.open-iscsi.org/bits/open-iscsi-(.*)-(.*)\.tar\.gz debian/open-iscsi-udeb.finish-install0000664000000000000000000000032312150615442015022 0ustar #! /bin/sh set -e got_iscsi= for f in /etc/iscsi/*; do [ -e "$f" ] || continue got_iscsi=1 break done if [ "$got_iscsi" ]; then # Copy the configuration to the target... cp -a /etc/iscsi /target/etc/ fi debian/manpages0000664000000000000000000000012512150615442010704 0ustar doc/iscsi_discovery.8 doc/iscsid.8 doc/iscsiadm.8 doc/iscsistart.8 doc/iscsi-iname.8 debian/README.source0000664000000000000000000000053712150615442011354 0ustar debian/rules has a get-orig-source target. This makefile target will be able to fetch the upstream tarball This package uses quilt to manage all modifications to the upstream source. Changes are stored in the source package as diffs in debian/patches and applied during the build. See /usr/share/doc/quilt/README.source for a detailed explanation. debian/control0000664000000000000000000000602112272262302010570 0ustar Source: open-iscsi Section: net Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Debian iSCSI Maintainers Uploaders: Andrew Moise , Philipp Hug , Guido Günther , Ritesh Raj Sarraf Build-Depends: debhelper (>= 7.0.0), bzip2, bison, flex, autotools-dev Standards-Version: 3.9.2 Vcs-Git: git://git.debian.org/git/pkg-iscsi/open-iscsi.git Vcs-Browser: http://git.debian.org/?p=pkg-iscsi/open-iscsi.git Homepage: http://www.open-iscsi.org/ XS-Testsuite: autopkgtest Package: open-iscsi Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, udev Replaces: open-iscsi-utils Conflicts: open-iscsi-utils (<< 2.0.873-3ubuntu1~) Description: High performance, transport independent iSCSI implementation Open-iSCSI is a high-performance, transport independent, multi-platform implementation of RFC3720 iSCSI . Open-iSCSI is partitioned into user and kernel parts where the kernel portion implements iSCSI data path (i.e. iSCSI Read and iSCSI Write) The userspace contains the entire control plane consisting of: * Configuration Manager * iSCSI Discovery, Login and Logout processing * Connection level error processing * Nop-In and Nop-Out handling * Text processing, iSNS, SLP, Radius et cetera (future) . The userspace component consists of a daemon, iscsid and a management utility, iscsiadm Package: open-iscsi-utils Priority: extra Section: oldlibs Architecture: all Depends: ${misc:Depends}, open-iscsi Description: transitional dummy package Open-iSCSI is a high-performance, transport independent, multi-platform implementation of RFC3720 iSCSI . Open-iSCSI is partitioned into user and kernel parts where the kernel portion implements iSCSI data path (i.e. iSCSI Read and iSCSI Write) The userspace contains the entire control plane consisting of: * Configuration Manager * iSCSI Discovery, Login and Logout processing * Connection level error processing * Nop-In and Nop-Out handling * Text processing, iSNS, SLP, Radius et cetera (future) . The userspace component consists of a daemon, iscsid and a management utility, iscsiadm . This is an empty transitional package, it can be safely removed. Package: open-iscsi-udeb Architecture: amd64 arm64 armhf i386 ia64 mips mipsel powerpc ppc64el x32 Section: debian-installer Package-Type: udeb Depends: ${shlibs:Depends}, ${misc:Depends}, scsi-modules, libnss-files-udeb Description: Configure iSCSI Open-iSCSI is a high-performance, transport independent, multi-platform implementation of RFC3720 iSCSI. . This is the minimal package (udeb) used by debian-installer. #Package: linux-iscsi-modules-source #Architecture: all #Depends: ${shlibs:Depends}, ${misc:Depends}, module-assistant, debhelper (>= 4.0.0), bzip2 #Description: Source Code for the Linux iSCSI Kernel Modules # Along with make-kpkg, this package maybe used to build a linux-iscsi-modules # package for a kernel-image package. debian/open-iscsi.iscsi-network-interface.upstart0000664000000000000000000000374712150615442017436 0ustar # iscsi-network-interface - suppress configuration of network interface used # by iSCSI root device # # If the root filesystem is on iSCSI, then we must take care to avoid # changing the state of its network interface. To this end, the initramfs # leaves a note for us which interface was used, and we mangle # /run/network/ifstate manually to stop it being brought up or down # automatically. This is a slight layering violation, but, unfortunately, # ifupdown appears to have no way to do this without also running # /etc/network/*.d/ scripts. description "configure network device used by iSCSI root" start on starting network-interface stop on stopping network-interface pre-start script CR=" " ifile=/run/initramfs/open-iscsi.interface if [ -f "$ifile" ] && read iface < "$ifile" && ! grep -qs "^$iface=" /run/network/ifstate; then mkdir -p /run/network echo "$iface=$iface" >>/run/network/ifstate if [ -x /etc/network/if-up.d/upstart ]; then IFACE=$iface LOGICAL=$iface ADDRFAM=inet METHOD=manual /etc/network/if-up.d/upstart fi if command -v resolvconf >/dev/null && [ -f /run/net-$iface.conf ]; then . "/run/net-$iface.conf" R="" [ -n "$DOMAINSEARCH" ] && R="$R${CR}domainsearch $DOMAINSEARCH" for ns in "$IPV4DNS0" "$IPV4DNS1"; do [ -n "$ns" -a "$ns" != "0.0.0.0" ] && R="$R${CR}nameserver $ns" done [ -z "${R}" ] || resolvconf -a $iface.iscsi-network < $NAMEFILE echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE echo "## If you change the InitiatorName, existing access control lists" >> $NAMEFILE echo "## may reject this initiator. The InitiatorName must be unique">> $NAMEFILE echo "## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames." >> $NAMEFILE printf "InitiatorName=$INAME\n" >> $NAMEFILE chmod 600 $NAMEFILE else echo "Error: failed to generate an iSCSI InitiatorName, driver cannot start." echo exit 1; fi fi if [ -d /var/lib/open-iscsi ]; then chmod 700 /var/lib/open-iscsi else mkdir /var/lib/open-iscsi chmod 700 /var/lib/open-iscsi fi update_initramfs ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac #DEBHELPER# exit 0 debian/dirs0000664000000000000000000000025312150615442010054 0ustar usr/bin usr/sbin var/lib/open-iscsi etc/init.d etc/default etc etc/iscsi etc/network/if-up.d usr/share/initramfs-tools/hooks/ usr/share/initramfs-tools/scripts/local-top/ debian/rules0000775000000000000000000001061412272262302010250 0ustar #!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # This has to be exported to make some magic below work. export DH_OPTIONS # get-orig-source target DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p') DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH) SUPPORTED_ARCH_UDEB = amd64 arm64 armhf i386 ia64 mips mipsel powerpc ppc64el x32 get-orig-source: [ ! -f $(ORIG_FILE).gz ] || rm -f $(ORIG_FILE).gz uscan --force-download --rename --repack --download-version=$(DEB_UPSTREAM_VERSION) --destdir=. CFLAGS = -Wall -g export OPTFLAGS =-DDISCOVERY_FILE=\"/var/lib/open-iscsi/discovery\" -DNODE_FILE=\"/var/lib/open-iscsi/node\" ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. dh_autotools-dev_updateconfig touch configure-stamp #Architecture build: build-arch build-arch: build-arch-stamp build-arch-stamp: configure-stamp # Add here commands to compile the arch part of the package. $(MAKE) -C utils/fwparam_ibft $(MAKE) user $(MAKE) -C utils touch build-arch-stamp build-indep: build-indep-stamp build-indep-stamp: configure-stamp # Add here commands to compile the indep part of the package. #$(MAKE) doc touch build-indep-stamp clean: dh_testdir dh_testroot rm -f build-arch-stamp build-indep-stamp configure-stamp # Add here commands to clean up after the build process. $(MAKE) -C utils/fwparam_ibft clean $(MAKE) -C usr clean $(MAKE) -C utils clean rm -rf modules dh_autotools-dev_restoreconfig dh_clean install: install-arch # disabled kernel module package for now because source is already in debian stock kernelsy install-indep: install-arch: dh_testdir dh_testroot dh_prep dh_installdirs -s # Add here commands to install the arch part of the package into # debian/open-iscsi. install -m 755 usr/iscsiadm $(CURDIR)/debian/open-iscsi/usr/bin install -m 755 usr/iscsid $(CURDIR)/debian/open-iscsi/usr/sbin install -m 755 usr/iscsistart $(CURDIR)/debian/open-iscsi/usr/sbin install -m 755 utils/iscsi_discovery $(CURDIR)/debian/open-iscsi/usr/sbin install -m 755 utils/iscsi-iname $(CURDIR)/debian/open-iscsi/usr/sbin install -m 600 etc/iscsid.conf $(CURDIR)/debian/open-iscsi/etc/iscsi install -m 644 debian/open-iscsi.default $(CURDIR)/debian/open-iscsi/etc/default/open-iscsi ifneq (,$(findstring $(DEB_HOST_ARCH),$(SUPPORTED_ARCH_UDEB))) # udeb stuff install -m 755 usr/iscsiadm $(CURDIR)/debian/open-iscsi-udeb/bin install -m 755 utils/iscsi-iname $(CURDIR)/debian/open-iscsi-udeb/sbin install -m 755 utils/iscsi_discovery $(CURDIR)/debian/open-iscsi-udeb/sbin install -m 755 usr/iscsid $(CURDIR)/debian/open-iscsi-udeb/sbin install -m 755 usr/iscsistart $(CURDIR)/debian/open-iscsi-udeb/sbin install -m 644 etc/iscsid.conf $(CURDIR)/debian/open-iscsi-udeb/etc/iscsi install -m 644 debian/open-iscsi-udeb.start $(CURDIR)/debian/open-iscsi-udeb/sbin/iscsi-start install -m 755 debian/open-iscsi-udeb.finish-install $(CURDIR)/debian/open-iscsi-udeb/usr/lib/finish-install.d/10open-iscsi endif # initramfs stuff install -m 755 debian/extra/initramfs.hook \ $(CURDIR)/debian/open-iscsi/usr/share/initramfs-tools/hooks/iscsi install -m 755 debian/extra/initramfs.local-top \ $(CURDIR)/debian/open-iscsi/usr/share/initramfs-tools/scripts/local-top/iscsi dh_install -s # Must not depend on anything. This is to be called by # binary-arch/binary-indep # in another 'make' thread. binary-common: dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_installexamples dh_installinit -u 'start 45 S . stop 81 0 1 6 .' --no-start dh_installinit -u 'stop 80 0 1 6 .' --no-start --name=umountiscsi.sh dh_installinit --name=iscsi-network-interface -n --upstart-only dh_installman dh_link dh_strip dh_compress dh_fixperms dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture independant packages using the common target. binary-indep: build-indep install-indep $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common # Build architecture dependant packages using the common target. binary-arch: build-arch install-arch $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common binary: binary-arch binary-indep .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure get-orig-source debian/compat0000664000000000000000000000000212150615442010366 0ustar 7 debian/changelog0000664000000000000000000006242512303401502011041 0ustar open-iscsi (2.0.873-3ubuntu9) trusty; urgency=medium * Add missing python test dependency. -- Martin Pitt Wed, 26 Feb 2014 16:07:37 +0100 open-iscsi (2.0.873-3ubuntu8) trusty; urgency=medium * open-iscsi-udeb: Enable builds on armhf, arm64, ppc64el, x32 (LP: #1274203) -- dann frazier Wed, 29 Jan 2014 12:34:45 -0700 open-iscsi (2.0.873-3ubuntu7) saucy; urgency=low * Use dh_autotools-dev to update config.sub|guess. -- Dmitrijs Ledkovs Fri, 11 Oct 2013 17:03:37 +0100 open-iscsi (2.0.873-3ubuntu6) saucy; urgency=low * debian/tests: Add autopkgtest. -- Yolanda Mon, 27 May 2013 10:39:35 +0200 open-iscsi (2.0.873-3ubuntu5) quantal-proposed; urgency=low * Ensure all udev events have been processed before trying to configure iscsi networking in the initramfs (LP: #1066945): - debian/extra/initramfs.local-top: Restore wait_for_udev call before configure_networking to ensure network devices are present. -- James Page Wed, 17 Oct 2012 12:37:43 +0100 open-iscsi (2.0.873-3ubuntu4) quantal-proposed; urgency=low * Generate initiator name on install, not first boot, ensuring that the initramfs built during install contains a valid iSCSI initiator name resulting in a iSCSI based root volume that will actually boot (LP: #1057635): - debian/{rules,initiatorname.iscsi}: Don't install a default initiatorname.iscsi. - debian/open-iscsi.postinst: Generate initiatorname.iscsi on install. -- James Page Mon, 15 Oct 2012 12:42:53 +0100 open-iscsi (2.0.873-3ubuntu3) quantal; urgency=low * debian/open-iscsi.iscsi-network-interface.upstart: fix bad syntax in 'post-stop' -- Scott Moser Mon, 17 Sep 2012 16:50:22 -0400 open-iscsi (2.0.873-3ubuntu2) quantal; urgency=low * debian/extra/initramfs.local-top: start writing /run/initramfs/open-iscsi.interface file again (LP: #1050480) * debian/open-iscsi.iscsi-network-interface.upstart: integrate with resolvconf (LP: #1050487) -- Scott Moser Mon, 17 Sep 2012 15:46:26 -0400 open-iscsi (2.0.873-3ubuntu1) quantal; urgency=low * Merge from Debian. Remaining changes: (LP: #961114, LP: #677333) - Add upstart job iscsi-network-interface - Migrate from /var/run and /lib/init/rw to /run, from /var/lock to /run/lock. * Turn open-iscsi-utils into a transitional package -- Stéphane Graber Tue, 10 Jul 2012 13:53:52 -0400 open-iscsi (2.0.873-3) unstable; urgency=low * [4939401] Fix build to install udeb stuff only on supported architectures -- Ritesh Raj Sarraf Wed, 27 Jun 2012 22:36:05 +0530 open-iscsi (2.0.873-2) unstable; urgency=low * [0019fa9] Restrict architecture for the udeb package as its dependency, scsi-modules, is not available on all the architecture paltforms -- Ritesh Raj Sarraf Tue, 26 Jun 2012 18:54:17 +0530 open-iscsi (2.0.873-1) unstable; urgency=low * [53943f2] Load iscsi_ibft module to allow target session over iBFT. Thanks to JOORIS Emmanuel (Closes: #672122) * [ca41744] Delete old obsolete patches * [01a54bf] Drop old manpages already available upstream * [caf884c] ship upstream manpages for iscsi-iname and iscsistart * [a983848] Imported Upstream version 2.0.873 -- Ritesh Raj Sarraf Mon, 21 May 2012 23:54:53 +0530 open-iscsi (2.0.872+git0.6676a1cf-2) unstable; urgency=low * Upload to unstable * [cb80472] Fix default iscsid path in config file. Thanks to Michal Suchanek (Closes: #650221) -- Ritesh Raj Sarraf Tue, 24 Apr 2012 09:41:08 +0530 open-iscsi (2.0.872+git0.6676a1cf-1) experimental; urgency=low [ Ritesh Raj Sarraf ] * New Upstream git snapshot (Closes: #645752) * [ce26f7c] Imported Upstream version 2.0.872+git0.6676a1cf * [9ad08d7] also include iscsitart in the udeb * [bc79ad2] refresh patch debian/patches/spelling-error-fixes.patch * [0286328] refresh patch 004_make-iscsistart-a-dynamic-binary.patch * [360a509] Drop patches: + iscsi-dont-build-with-ssl.patch and + disable-isns-security.patch * [350db4d] rename and reorder patches * [794fa4f] Package-Type is now an understood feild by dpkg * [593f187] Add hardened build flags. Thanks to Moritz Muehlenhoff (Closes: #659662) * [cf4c6c3] Kill iscsid processes properly, on stop. Thanks to Gwendal Grignou (Closes: #665966) * [f1a9d2f] linitan fixes for spelling errors and manpage hyphen errors * [a8560c8] add and fix lsb headers for init files [ Colin Watson ] * [156b745] open-iscsi: add a udeb (Closes: #635161) -- Ritesh Raj Sarraf Sat, 07 Apr 2012 21:02:37 +0530 open-iscsi (2.0.872-2) unstable; urgency=low * Upload to unstable -- Ritesh Raj Sarraf Wed, 14 Sep 2011 14:26:00 +0530 open-iscsi (2.0.872-1) experimental; urgency=low * New Upstream Release * [cccd5a9] Use udevadm to check for existense of udev. Thanks to Marco d'Itri (Closes: #622209) * [ddb81e4] Drop patches, merged upstream * [25aa1d9] disable security and slp support * [89b2a6a] Add patch to disable ssl. Thanks to Mike Christie * [d70e88a] Refresh patch * [b501aec] delete debian/patches/disable-isns.patch * [2cc67f7] spelling-error and hyphentation fixes * [b886116] Bump Standards Version to 3.9.2 * [405ecfd] add autotools-dev to build-dep to ensure we have no stale configure scripts -- Ritesh Raj Sarraf Fri, 26 Aug 2011 16:21:38 +0530 open-iscsi (2.0.871.3-6) unstable; urgency=low * [87c440c] fix gcc 4.6 build failure (Closes: #625152) -- Ritesh Raj Sarraf Tue, 03 May 2011 00:22:07 +0530 open-iscsi (2.0.871.3-5) unstable; urgency=low * Last upload was incorrect. Really upload to unstable -- Ritesh Raj Sarraf Sat, 12 Feb 2011 02:00:34 +0530 open-iscsi (2.0.871.3-4) unstable; urgency=low * Reupload to unstable -- Ritesh Raj Sarraf Thu, 10 Feb 2011 20:17:07 +0530 open-iscsi (2.0.871.3-3) experimental; urgency=low * Install iscsid.conf with 0600 permission as it can contain passwords (Closes: #472965) * Provide an example for iSCSI root installation (Closes: #492358) * Add support to enable multiple session to the iSCSI Target in the initramfs. Thanks to Norbert Tretkowski for the patch. (Closes: #598773) * Add patch to support NICs that have native iSCSI support. Thanks to Bjoern Metzdorf for the patch. (Closes: #514924) * cherry pick commit f0b670c0 from upstrem (Closes: #603990) * Bump Standards Version (No changes required) -- Ritesh Raj Sarraf Wed, 05 Jan 2011 13:43:42 +0545 open-iscsi (2.0.871.3-2) unstable; urgency=low * Break down and add quilt patches + 003_Fix-CVE-2009-1297.patch + 004_make-iscsistart-a-dynamic-binary.patch * Add some explanation about initiatorname.iscsi into README.Debian (Closes: #507003) * Fix double variable assignment in initramfs.local-top. Thanks to Aurelien Jarno (Closes: #576786) * Document the odd hang behavior during iSCSI login phase when using 32 bit open-iscsi with 64 bit kernel * Change address to my official Debian address and remove the DMUA flag * Handle iSCSI LVM devices and devices marked _netdev (Closes: #498616) * Switch to 3.0 (quilt) source format -- Ritesh Raj Sarraf Fri, 11 Jun 2010 12:33:02 +0530 open-iscsi (2.0.871.3-1) unstable; urgency=low * New upstream release (Closes: #564012, #566511) * When open-iscsi service is asked to stop, attempt to umount all iSCSI devices. On failure, bail out (Closes: #501580, #499126) * Add debian/source/format specifying the current source format -- Ritesh Raj Sarraf Wed, 24 Mar 2010 21:44:38 +0530 open-iscsi (2.0.871-1) unstable; urgency=low [ Guido Günther ] * Imported Upstream version 2.0.871 [ Ritesh Raj Sarraf ] * New Upstream Release - 2.0.871 (Closes: #424642) * Fix credential passing in local-top/initramfs.local-top (Closes: #550012, #525053) * Fix settling of devices in initramfs (Closes: #501582, #488999) * Update Standards-Version to 3.8.4 * Change to team maintenance * Add git-orig-source target * Add debian/watch file * Add README.source file * Add quilt patches * Add Vcs headers * Update debhelper to v7 * Update copyright information * Improve description (Closes: #504707) * Stop umountiscsi and open-iscsi in runlevel 1 * Remove already obsolete disabled-install-indep target * Replace deprecated dh_clean -k with dh_prep * Refresh 001_manpages_fixes.patch * Fix copyright and explain packaging licensing * Fix "undefined reference to strl* when building iscsid" * Proper sanity check in the init script for empty strings (Closes: #501319) * Provide init script service with the same name * Build iscsistart as a dynamic binary -- Ritesh Raj Sarraf Sat, 06 Feb 2010 20:28:23 +0530 open-iscsi (2.0.871-0ubuntu9) oneiric-proposed; urgency=low * Make sure the upstart job triggers ifupdown's upstart script to avoid waiting 2 minutes at boot time for network to come up. (LP: #870214) -- Stéphane Graber Tue, 11 Oct 2011 22:31:39 +0100 open-iscsi (2.0.871-0ubuntu8) oneiric; urgency=low * Disable open-iscsi init script when root is on iscsi (LP: #838809) -- Stéphane Graber Thu, 15 Sep 2011 10:01:12 -0400 open-iscsi (2.0.871-0ubuntu7) oneiric; urgency=low * Migrate from /var/run and /lib/init/rw to /run, from /var/lock to /run/lock, and from /dev/.initramfs to /run/initramfs. -- Colin Watson Thu, 14 Jul 2011 17:01:42 +0100 open-iscsi (2.0.871-0ubuntu6) oneiric; urgency=low * Fix initramfs iSCSI login (many thanks to Amos Hayes for lending me a test system; LP: #728088): - Write out /dev/.initramfs/open-iscsi.interface in the same subshell as configure_networking, so that we can get at the value of DEVICE. - Wait for udev to settle before attempting to configure networking. -- Colin Watson Fri, 27 May 2011 23:27:31 +0100 open-iscsi (2.0.871-0ubuntu5) maverick; urgency=low * Include and in usr/iscsi_sysfs.c for S_* macros (LP: #600953). -- Colin Watson Fri, 02 Jul 2010 17:08:14 +0100 open-iscsi (2.0.871-0ubuntu4) lucid; urgency=low * Revert ISCSI_NETDEVICE change; it's normally better to select the interface by MAC address (LP: #473036). -- Colin Watson Fri, 05 Feb 2010 12:06:06 -0800 open-iscsi (2.0.871-0ubuntu3) lucid; urgency=low * If ISCSI_NETDEVICE is set, configure that interface in the initramfs (LP: #473036). -- Colin Watson Fri, 22 Jan 2010 17:01:17 +0000 open-iscsi (2.0.871-0ubuntu2) lucid; urgency=low * Fix handling of ISCSI_USERNAME, ISCSI_PASSWORD, ISCSI_IN_USERNAME, and ISCSI_IN_PASSWORD in iscsi.initramfs (closes: #525053). -- Colin Watson Mon, 14 Dec 2009 12:24:42 +0000 open-iscsi (2.0.871-0ubuntu1) lucid; urgency=low * New upstream release. * If the root filesystem is on iSCSI, prevent the network interface used for it from being brought up or down automatically (LP: #457767). * Backport from upstream: - Allow updating of discovery records (Hannes Reinecke). - Fix discovery record use, rather than always using iscsid.conf settings (Mike Christie). -- Colin Watson Thu, 10 Dec 2009 18:19:20 +0000 open-iscsi (2.0.870.1-0ubuntu12) karmic; urgency=low * debian/open-iscsi-udeb.finish-install: Stop checking disk-detect/iscsi/enable, as that template doesn't exist any more. -- Colin Watson Fri, 02 Oct 2009 18:49:18 +0100 open-iscsi (2.0.870.1-0ubuntu11) karmic; urgency=low * open-iscsi-utils Replaces: old versions of open-iscsi. * SECURITY UPDATE: temporary file vulnerability (LP: #408915) - utils/iscsi_discovery: store iscsiadm -m discovery result in a variable rather than writing it to an insecurely-created temporary file - CVE-2009-1297 -- Colin Watson Mon, 24 Aug 2009 23:42:10 +0100 open-iscsi (2.0.870.1-0ubuntu10) karmic; urgency=low * debian/control, debian/open-iscsi-utils.install, open-iscsi-utils.manpages : create a new binary package which contains /sbin/iscsiadm, needed for some packages to build against (eg, libvirt), but not containing the init script, LP: #414986 -- Dustin Kirkland Tue, 18 Aug 2009 08:11:34 -0500 open-iscsi (2.0.870.1-0ubuntu9) karmic; urgency=low * debian/open-iscsi.init: don't exit with error if /lib/init/rw/sendsigs.omit.d/ doesn't exist (LP: #414986) -- Jamie Strandboge Mon, 17 Aug 2009 14:12:01 -0500 open-iscsi (2.0.870.1-0ubuntu8) karmic; urgency=low * Make sure network devices are always included in the initramfs if booting with / on iSCSI. * Retry initramfs network configuration for a while until it works (LP: #237460). -- Colin Watson Tue, 11 Aug 2009 13:05:43 +0100 open-iscsi (2.0.870.1-0ubuntu7) karmic; urgency=low [ Colin Watson ] * debian/open-iscsi-udeb.postinst, debian/open-iscsi-udeb.templates: Remove; this is being taken over by disk-detect and partman-iscsi. * debian/control: Remove XB-Installer-Menu-Item. [ Mathias Gug ] * debian/open-iscsi.postinst: Fix backwards use of update-rc.d (LP: #306678). * debian/open-iscsi.init: Overwrite existing pid file symlinks in /lib/init/rw/sendsigs.omit.d/. -- Colin Watson Mon, 10 Aug 2009 13:28:41 +0100 open-iscsi (2.0.870.1-0ubuntu6) karmic; urgency=low * utils/iscsi_discovery: Fix several bashisms (test ==, &> redirection, trap with numeric signals). -- Colin Watson Tue, 04 Aug 2009 12:30:44 +0100 open-iscsi (2.0.870.1-0ubuntu5) karmic; urgency=low * utils/iscsi_discovery: replace uses of awk with other shell voodoo, so that this works in the installer. LP: #236640. * debian/rules, debian/open-iscsi-udeb.dirs: install the open-isci-udeb finish script to /usr/lib/finish-install.d, not to /lib/finish-install.d. * debian/open-iscsi-udeb.finish-install: copy the config from the root to the correct directory in the target. -- Steve Langasek Tue, 07 Jul 2009 22:10:17 -0700 open-iscsi (2.0.870.1-0ubuntu4) karmic; urgency=low * debian/extra/initramfs.hook: iscsistart is in /sbin, not /usr/sbin (LP: #364616). -- Colin Watson Thu, 02 Jul 2009 14:12:25 +0100 open-iscsi (2.0.870.1-0ubuntu3) jaunty; urgency=low * Invoke iscsi-iname using normal $PATH lookup rather than using an incorrect explicit path (see LP #236640). -- Colin Watson Thu, 09 Apr 2009 16:49:08 +0100 open-iscsi (2.0.870.1-0ubuntu2) jaunty; urgency=low * debian/control: Drop udeb dependency on crypto-modules; as best as I can tell, this is required for crc32c support, which is now built-in to the Ubuntu kernels. -- Dustin Kirkland Tue, 03 Feb 2009 11:20:35 +0100 open-iscsi (2.0.870.1-0ubuntu1) jaunty; urgency=low * New upstream release: - Support 2.6.26/27 kernels (LP: #289470). - Fix iscsid shutdown (LP: #181188). * Merge from Debian. Remaining Ubuntu changes: - Note: Debian version isn't 870~rc3 but 869.2 which leads to a big .diff.gz file. Only files in debian/ have been considered for this merge since debian hasn't patched the source. - debian/control, debian/rules, debian/open-iscsi-udeb*: + Add open-iscsi-udeb. - debian/open-iscsi.dirs: + rename dirs to open-iscsi.dirs because of open-iscsi-udeb addition. + drop network/if-up.d/ directory since we're using symlinks instead. + utilities installed in /bin,/sbin rather than /usr/bin,/usr/sbin. - debian/open-iscsi.init: + utilities installed in /bin,/sbin rather than /usr/bin,/usr/sbin. + lsb log messages. + Don't generate initiatorname name (moved to postinst). + Support for being called from ifup/ifdown scripts. + Refactor start functions: - move daemon start to startdaemon function. - call udevadm settle rather then udevsettle (which doesn't do anything useful). - don't exit if the daemon is already running during sanitychecks. Instead check in startdaemon if the daemon needs to be started. - only start automatic targets if necessary. - add waitfordevices function: called during rcS, waits for all automatic targets to be ready. Iscsi targets are considered as local block devices - they don't need to be marked with _netdev in fstab. (LP: #227848) - start targets if not run from rcS. + Check status of iscsid daemon in addition to listing the iscsi sessions when status action is called. + Add iscsid to the list of processes that should not be killed by sendsigs during shutdown (LP: #192080). + Add starttargets, stoptargets and restarttargets to usage message. - debian/rules: + Install utilities /bin,/sbin rather than /usr/bin,/usr/sbin. + Start open-iscsi at S25 (waiting for devices created by ifupdown calls and before local filesystems are checked and mounted) + stop at S41 (after local filesystems are unmounted). Don't use umountiscsi.sh script from debian. (LP: #192080). - debian/initiatorname.iscsi, debian/open-iscsi.postinst: + Generate the random initiatorname during postinstall rather than in the init script. + Don't ship a default initiatorname.iscsi file. - debian/open-iscsi.postinst: + fix init script ordering on upgrades. - debian/open-iscsi.links: + symlink open-iscsi init script in if-up.d and if-down.d directory so that the iscsi subsystem is started/stopped when network interfaces are configured. - debian/open-iscsi.postrm: + delete iscsi configuration when the package is purged. - utils/iscsi_discovery: De-bashify iscsi_discovery. - usr/idbm.c: Fix build failure with new glibc. LP: #299843. * Dropped: - Exit without error if /sys is not available. Otherwise, it's not possible to use this package as a build-dependency (in Debian). - Drop upstream url in long description now that it's in the Homepage field (in Debian). -- Mathias Gug Mon, 01 Dec 2008 10:45:03 -0500 open-iscsi (2.0.870~rc3-0.6) unstable; urgency=low * Non-maintainer upload. * [4bfddee] Fix CVE-2009-1297 (Closes: #547011) - thanks to Colin Watson for the patch -- Guido Günther Sat, 23 Jan 2010 17:56:18 +0100 open-iscsi (2.0.870~rc3-0.5) unstable; urgency=low * Non-maintainer upload to fix release goal. * Fix incorrect provides and dependencies in init.d script (Closes: #541390). * Add missing package dependency on udev. Rewrite init.d script to use 'udevadm settle' instead of obsolete 'udevsettle' (Closes: #517225). * No longer ignore errors in the postinst. Tip from lintian. * Do not start open-iscsi init.d script during package installation, to avoid installation problem (Closes: #529280). -- Petter Reinholdtsen Sun, 13 Sep 2009 20:25:49 +0200 open-iscsi (2.0.870~rc3-0.4) unstable; urgency=medium * Clean up diff.gz, it downgraded the package to 2.0.869.2. (closes: #507496) -- Norbert Tretkowski Thu, 8 Jan 2009 11:19:23 +0100 open-iscsi (2.0.870~rc3-0.3) unstable; urgency=low * Non-maintainer upload. * Do not exit with return code 1 in init script, because it breaks upgrades and is a policy violation (Closes: #503070) -- Patrick Schoenfeld Mon, 27 Oct 2008 10:21:17 +0100 open-iscsi (2.0.870~rc3-0.2) unstable; urgency=low * Non-maintainer upload. * Drop patch from iscsistart.c which breaks booting from iscsi. (closes: #499508) * Drop patch from version.h which adds an outdated upstream version number. -- Norbert Tretkowski Fri, 10 Oct 2008 10:46:56 +0200 open-iscsi (2.0.870~rc3-0.1) unstable; urgency=low * Non-maintainer upload. * New upstream release - Adds support for Linux 2.6.26 (Closes: #499508) * Fix ">&" redirection bashism in open-iscsi initscript. -- Chris Lamb Tue, 30 Sep 2008 21:40:27 +0100 open-iscsi (2.0.869.2-2.1) unstable; urgency=medium * Non-maintainer upload. * Fix bashism in debian/rules (Closes: #484427) - Move upstream URL to Homepage field. - Bump Standards-Version to 3.8.0. -- Chris Lamb Fri, 11 Jul 2008 23:20:18 +0100 open-iscsi (2.0.869.2-2) unstable; urgency=low * Revert if-up.d approach for logging into automatic targets; just start open-iscsi at rcS.d/S45, and mount _netdev filesystems when open-iscsi is started. * Call udevsettle before mounting -- Philipp Hug Mon, 12 May 2008 12:48:49 +0200 open-iscsi (2.0.869.2-1) unstable; urgency=low * New upstream release -- Philipp Hug Mon, 12 May 2008 11:56:30 +0200 open-iscsi (2.0.869~rc4-1) experimental; urgency=low * init script: If /sys is not mounted return without error (Closes: #470434, #423368) * Merged changes by Andrew Moise * Adding Andrew as Co-Maintainer * New upstream release (Closes: #474167) * Added flex and bison build-depends * Fixed up init scripts to attempt to handle automatic mounting and unmounting properly (Closes: #423851, #438542) * Added /etc/network/if-up.d/000open-iscsi to start automatic targets * Parameterized /etc/iscsi/initiatorname.iscsi in init script, correcting one place where it still said /etc/initiatorname.iscsi * Updated README.Debian * Include iscsistart for use in initramfs (Closes: #419408) * Add initramfs scripts to make iSCSI root easy * Based on patch by Guido Guenther -- Philipp Hug Sat, 12 Apr 2008 15:53:12 +0200 open-iscsi (2.0.865-1ubuntu5) jaunty; urgency=low * Fix build failure with new glibc. LP: #299843. -- Matthias Klose Thu, 27 Nov 2008 15:58:15 +0100 open-iscsi (2.0.865-1ubuntu4) intrepid; urgency=low * Exit without error if /sys is not available. Otherwise, it's not possible to use this package as a build-dependency. -- Soren Hansen Fri, 02 May 2008 00:57:02 +0200 open-iscsi (2.0.865-1ubuntu3) hardy; urgency=low * Migration of /usr/{bin,sbin,lib} -> to /{bin,sbin,lib}. (LP: #208441) * Push the shutdown scripts back. (LP: #196748) * Update control to 3.7.3. * Updated the maintainer according to spec. -- Chuck Short Wed, 09 Apr 2008 18:09:28 -0400 open-iscsi (2.0.865-1ubuntu2) hardy; urgency=low * Fixed init script to point to the right iscsiadm. (LP: #206520) -- Chuck Short Tue, 25 Mar 2008 09:53:08 -0400 open-iscsi (2.0.865-1ubuntu1) hardy; urgency=low * Add open-iscsi-udeb. * Include iscsi_discovery. * De-bashify iscsi_discovery. * Start open-iscsi in single user mode. * Properly lsb-ify init script. * Modify Maintainer value to match the DebianMaintainerField specification. -- Soren Hansen Fri, 08 Feb 2008 11:56:11 +0100 open-iscsi (2.0.865-1) unstable; urgency=low * New upstream release * Removed iscsi-iname patch as it's now included in upstream * Moved initiatorname.iscsi to /etc/iscsi/initiatorname.iscsi -- Philipp Hug Sat, 16 Jun 2007 12:31:05 +0200 open-iscsi (2.0.730-1) unstable; urgency=low * Reverted to upstream init script + patches (Closes: #397363 #401579) * Removed libdb dependency * Create /etc/iscsi * Integrated NMU changes from Martin Zobel-Helas + New Upstream Release (Closes: #397636) + Made /var/lib/open-iscsi 0700 (Closes: #398733) + change #define INITIATOR_NAME_FILE to /etc/initiatorname.iscsi in usr/initiator.h + Fix package description (Closes: #380162) -- Philipp Hug Wed, 6 Dec 2006 20:22:30 +0100 open-iscsi (1.0.485-4) unstable; urgency=low * Removed bash-ism from init script * Added hint about autostart to README.Debian * Improved description a bit (Closes: #380162) -- Philipp Hug Mon, 21 Aug 2006 19:55:40 +0200 open-iscsi (1.0.485-3) unstable; urgency=low * Added description to man page -- Philipp Hug Sun, 23 Jul 2006 19:08:48 +0200 open-iscsi (1.0.485-2) unstable; urgency=low * Moved package to unstable * Removed unused section in control * Updated Standards-Version to 3.7.2.1 * Added INIT INFO section to init script to make it lsb compliant * Removed unusued lines in rules * Added man page for iscsi-iname -- Philipp Hug Sat, 22 Jul 2006 19:45:35 +0200 open-iscsi (1.0.485-1) experimental; urgency=low * Install iscsid.conf in /etc/iscsid.conf instead of /etc/iscsid.conf-example -- Philipp Hug Tue, 27 Jun 2006 14:42:20 +0200 open-iscsi (1.0.485-0unreleased) dapper; urgency=low * Initial Release (closes: Bug#333695) * Updated init script * Automatically generate iscsi initiator name * Use Debian specific initator name prefix * Put database into /var/lib/open-iscsi -- Philipp Hug Mon, 6 Mar 2006 19:20:17 +0000 debian/source/0000775000000000000000000000000012150615740010471 5ustar debian/source/format0000664000000000000000000000001412150615442011676 0ustar 3.0 (quilt) debian/postinst.modules.in0000664000000000000000000000021612150615442013051 0ustar #!/bin/sh set -e if [ "`uname -r`" = "_KVERS_" ]; then /sbin/depmod -a & fi #DEBHELPER# exit 0 debian/open-iscsi-udeb.start0000664000000000000000000000166712150615442013247 0ustar #! /bin/sh # This is basically a version of the init script without dependencies on lsb # and without all the sanity checks. The installer is a clean environment, so # we don't need all of that. # Generate a unique InitiatorName and save it INAME=`iscsi-iname -p iqn.1993-08.org.debian:01` echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/iscsi/initiatorname.iscsi echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/iscsi/initiatorname.iscsi echo "## If you change the InitiatorName, existing access control lists" >> /etc/iscsi/initiatorname.iscsi echo "## may reject this initiator. The InitiatorName must be unique">> /etc/iscsi/initiatorname.iscsi echo "## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames." >> /etc/iscsi/initiatorname.iscsi printf "InitiatorName=$INAME\n" >> /etc/iscsi/initiatorname.iscsi chmod 600 /etc/iscsi/initiatorname.iscsi modprobe -q iscsi_tcp 2>/dev/null >&2 /sbin/iscsid debian/copyright0000664000000000000000000000144512150615442011127 0ustar This package was debianized by Philipp Hug on Tue, 07 Mar 2005 01:22:53 +0100. Based on linux-iscsi debianization from Chad Tindel It was downloaded from http://www.open-iscsi.org/ Upstream Authors: Open-iSCSI Developers Copyright: (C) Dmitry Yusupov and others. License: You are free to distribute this software under the terms of the GNU General Public License v2 (or at your option) any later version. On Debian systems, the complete text of the GNU General Public License can be found in the file `/usr/share/common-licenses/GPL-2'. The Debian packaging is copyright 2009, Ritesh Raj Sarraf and is licensed under the GPL 2 license, see `/usr/share/common-licenses/GPL-2'. debian/control.modules.in0000664000000000000000000000135612150615442012654 0ustar Source: linux-iscsi-modules Section: net Priority: optional Maintainer: Philipp Hug Build-Depends: debhelper (>> 4.1.0), bzip2 Standards-Version: 3.6.1 Package: linux-iscsi-modules-_KVERS_ Architecture: any Depends: modutils, open-iscsi Provides: linux-iscsi-modules Description: Linux Kernel Driver Modules for Linux iSCSI (kernel _KVERS_) This is a Linux driver for iSCSI initiator functionality. . This package contains the compiled kernel modules for _KVERS_ . If you have compiled your own kernel, you will most likely need to build your own linux-iscsi-modules. The linux-iscsi-source package has been provided for use with the Debian kernel-package utility to produce a version of linux-iscsi-module for your kernel. debian/rules.modules0000664000000000000000000000167512150615442011725 0ustar #!/usr/bin/make -f # module-assistant stuff PACKAGE = linux-iscsi-modules MA_DIR ?= /usr/share/modass -include $(MA_DIR)/include/generic.make -include $(MA_DIR)/include/common-rules.make kdist_clean: prep-deb-files dh_clean #$(MAKE) clean KERNEL_PATH=$(KSRC) make clean kdist_config: prep-deb-files TARGET = $(CURDIR)/debian/linux-iscsi-modules-$(KVERS) MODULES_TARGET = $(TARGET)/lib/modules/$(KVERS)/kernel/net/iscsi binary-modules: kdist_config dh_testdir dh_testroot dh_clean -k dh_installdirs lib/modules/$(KVERS) # build and install the module patch -d kernel < kernel/backward-compile-2.6.11.patch make -C kernel KSRC=$(KSRC) mkdir -p $(MODULES_TARGET) install -m 755 kernel/iscsi_tcp.ko $(MODULES_TARGET) install -m 755 kernel/scsi_transport_iscsi.ko $(MODULES_TARGET) dh_installdocs dh_installchangelogs dh_compress dh_fixperms dh_installdeb dh_gencontrol -- -v$(VERSION) dh_md5sums dh_builddeb --destdir=$(DEB_DESTDIR) debian/open-iscsi.init0000664000000000000000000001305212150615442012127 0ustar #! /bin/sh ### BEGIN INIT INFO # Provides: open-iscsi iscsi # Required-Start: $network $remote_fs # Required-Stop: $network $remote_fs sendsigs # Default-Start: S # Default-Stop: 0 1 6 # Short-Description: Starts and stops the iSCSI initiator services and logs in to default targets # Description: Starts and stops the iSCSI initiator services and logs in to default targets ### END INIT INFO PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/iscsid ADM=/usr/bin/iscsiadm PIDFILE=/run/iscsid.pid NAMEFILE=/etc/iscsi/initiatorname.iscsi CONFIGFILE=/etc/iscsi/iscsid.conf [ -x "$DAEMON" ] || exit 0 . /lib/lsb/init-functions # Include defaults if available if [ -f /etc/default/open-iscsi ]; then . /etc/default/open-iscsi fi if [ ! -d /sys/class/ ]; then log_failure_msg "iSCSI requires a mounted sysfs, not started." exit 0 fi nodestartup_re='s/^node\.conn\[0]\.startup[ ]*=[ ]*//p' RETVAL=0 sanitychecks() { # Do sanity checks before we start.. if [ ! -e "$CONFIGFILE" ]; then echo echo "Error: configuration file $CONFIGFILE is missing!" echo "The iSCSI driver has not been correctly installed and cannot start." echo exit 1 elif [ -s $PIDFILE ] && kill -0 `head -1 $PIDFILE` >/dev/null ; then echo echo "iSCSI daemon already running" echo exit 0 fi if [ ! -f $NAMEFILE ] ; then echo echo "Error: InitiatorName file $NAMEFILE is missing!" echo "The iSCSI driver has not been correctly installed and cannot start." echo exit 1 fi # see if we need to generate a unique iSCSI InitiatorName # this should only happen if the if grep -q "^GenerateName=yes" $NAMEFILE ; then if [ ! -x /usr/sbin/iscsi-iname ] ; then echo "Error: /usr/sbin/iscsi-iname does not exist, driver was not successfully installed" exit 1; fi # Generate a unique InitiatorName and save it INAME=`/usr/sbin/iscsi-iname -p iqn.1993-08.org.debian:01` if [ "$INAME" != "" ] ; then echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE echo "## If you change the InitiatorName, existing access control lists" >> $NAMEFILE echo "## may reject this initiator. The InitiatorName must be unique">> $NAMEFILE echo "## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames." >> $NAMEFILE printf "InitiatorName=$INAME\n" >> $NAMEFILE chmod 600 $NAMEFILE else echo "Error: failed to generate an iSCSI InitiatorName, driver cannot start." echo exit 1; fi fi # make sure there is a valid InitiatorName for the driver if ! grep -q "^InitiatorName=[^ \t\n]" $NAMEFILE ; then echo echo "Error: $NAMEFILE does not contain a valid InitiatorName." echo "The iSCSI driver has not been correctly installed and cannot start." echo exit 1 fi } start() { log_daemon_msg "Starting iSCSI initiator service" "iscsid" sanitychecks modprobe -q iscsi_tcp 2>/dev/null || : modprobe -q ib_iser 2>/dev/null || : start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON RETVAL=$? log_end_msg $RETVAL starttargets udevadm settle || true; # Handle iSCSI LVM devices if [ ! -x "/sbin/vgchange" -a -n "$LVMGROUPS" ]; then log_warning_msg "LVM2 tools are not installed, not honouring LVMGROUPS." LMVGROUPS="" fi if [ -n "$LVMGROUPS" ]; then log_daemon_msg "Activating iSCSI volume groups" for vg in "$LVMGROUPS"; do log_progress_msg $vg vgchange --available=y $vg done log_end_msg 0 fi # Now let's mount log_daemon_msg "Mounting network filesystems" MOUNT_RESULT=1 if mount -a -O _netdev >/dev/null 2>&1; then MOUNT_RESULT=0 break fi log_end_msg $MOUNT_RESULT } starttargets() { log_daemon_msg "Setting up iSCSI targets" echo $ADM -m node --loginall=automatic log_end_msg 0 } stoptargets() { log_daemon_msg "Disconnecting iSCSI targets" sync # only logout if daemon is running, iscsiadm hangs otherwise if [ -s $PIDFILE ] && kill -0 `head -1 $PIDFILE` >/dev/null ; then $ADM -m node --logoutall=all fi log_end_msg 0 } stop() { if [ -f /etc/iscsi/iscsi.initramfs ]; then log_warning_msg "/etc/iscsi/iscsi.initramfs present, not stopping iscsid yet" return 0 fi # Call umountiscsi.sh to unmount iSCSI devices first invoke-rc.d umountiscsi.sh stop exit_status=$? if [ $exit_status -ne 0 ]; then log_failure_msg "Couldn't unmount all iSCSI devices. Cannot stop iSCSI service" exit 1 fi stoptargets log_daemon_msg "Stopping iSCSI initiator service" start-stop-daemon --stop --quiet --pidfile $PIDFILE --signal TERM --exec $DAEMON rm -f $PIDFILE modprobe -r ib_iser 2>/dev/null modprobe -r iscsi_tcp 2>/dev/null log_end_msg 0 } restart() { stop start } restarttargets() { stoptargets starttargets } status() { #XXX FIXME: what to do here? #status iscsid # list active sessions echo Current active iSCSI sessions: $ADM -m session } case "$1" in start|starttargets|stop|stoptargets|restart|restarttargets|status) $1 ;; force-reload) restart ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" exit 1 ;; esac exit $RETVAL debian/tests/0000775000000000000000000000000012303401507010325 5ustar debian/tests/daemon0000775000000000000000000000042412150615460011523 0ustar #!/bin/bash #-------------------------- # Testing open-iscsi daemon #-------------------------- set -e /etc/init.d/open-iscsi start > /dev/null 2>&1 if pidof -x iscsid > /dev/null; then echo "OK" exit 0 else echo "ERROR: OPEN-ISCSI IS NOT RUNNING" exit 1 fi debian/tests/testlib.py0000664000000000000000000011534212150615460012360 0ustar # # testlib.py quality assurance test script # Copyright (C) 2008-2011 Canonical Ltd. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this program. If not, see # . # '''Common classes and functions for package tests.''' import string, random, crypt, subprocess, pwd, grp, signal, time, unittest, tempfile, shutil, os, os.path, re, glob import sys, socket, gzip from stat import * from encodings import string_escape import warnings warnings.filterwarnings('ignore', message=r'.*apt_pkg\.TagFile.*', category=DeprecationWarning) try: import apt_pkg apt_pkg.InitSystem(); except: # On non-Debian system, fall back to simple comparison without debianisms class apt_pkg(object): def VersionCompare(one, two): list_one = one.split('.') list_two = two.split('.') while len(list_one)>0 and len(list_two)>0: if list_one[0] > list_two[0]: return 1 if list_one[0] < list_two[0]: return -1 list_one.pop(0) list_two.pop(0) return 0 bogus_nxdomain = "208.69.32.132" # http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html # This is needed so that the subprocesses that produce endless output # actually quit when the reader goes away. import signal def subprocess_setup(): # Python installs a SIGPIPE handler by default. This is usually not what # non-Python subprocesses expect. signal.signal(signal.SIGPIPE, signal.SIG_DFL) class TimedOutException(Exception): def __init__(self, value = "Timed Out"): self.value = value def __str__(self): return repr(self.value) def _restore_backup(path): pathbackup = path + '.autotest' if os.path.exists(pathbackup): shutil.move(pathbackup, path) def _save_backup(path): pathbackup = path + '.autotest' if os.path.exists(path) and not os.path.exists(pathbackup): shutil.copy2(path, pathbackup) # copy2 does not copy ownership, so do it here. # Reference: http://docs.python.org/library/shutil.html a = os.stat(path) os.chown(pathbackup, a[4], a[5]) def config_copydir(path): if os.path.exists(path) and not os.path.isdir(path): raise OSError, "'%s' is not a directory" % (path) _restore_backup(path) pathbackup = path + '.autotest' if os.path.exists(path): shutil.copytree(path, pathbackup, symlinks=True) def config_replace(path,contents,append=False): '''Replace (or append) to a config file''' _restore_backup(path) if os.path.exists(path): _save_backup(path) if append: contents = file(path).read() + contents open(path, 'w').write(contents) def config_comment(path, field): _save_backup(path) contents = "" for line in file(path): if re.search("^\s*%s\s*=" % (field), line): line = "#" + line contents += line open(path+'.new', 'w').write(contents) os.rename(path+'.new', path) def config_set(path, field, value, spaces=True): _save_backup(path) contents = "" if spaces==True: setting = '%s = %s\n' % (field, value) else: setting = '%s=%s\n' % (field, value) found = False for line in file(path): if re.search("^\s*%s\s*=" % (field), line): found = True line = setting contents += line if not found: contents += setting open(path+'.new', 'w').write(contents) os.rename(path+'.new', path) def config_patch(path, patch, depth=1): '''Patch a config file''' _restore_backup(path) _save_backup(path) handle, name = mkstemp_fill(patch) rc = subprocess.call(['/usr/bin/patch', '-p%s' %(depth), path], stdin=handle, stdout=subprocess.PIPE) os.unlink(name) if rc != 0: raise Exception("Patch failed") def config_restore(path): '''Rename a replaced config file back to its initial state''' _restore_backup(path) def timeout(secs, f, *args): def handler(signum, frame): raise TimedOutException() old = signal.signal(signal.SIGALRM, handler) result = None signal.alarm(secs) try: result = f(*args) finally: signal.alarm(0) signal.signal(signal.SIGALRM, old) return result def require_nonroot(): if os.geteuid() == 0: print >>sys.stderr, "This series of tests should be run as a regular user with sudo access, not as root." sys.exit(1) def require_root(): if os.geteuid() != 0: print >>sys.stderr, "This series of tests should be run with root privileges (e.g. via sudo)." sys.exit(1) def require_sudo(): if os.geteuid() != 0 or os.environ.get('SUDO_USER', None) == None: print >>sys.stderr, "This series of tests must be run under sudo." sys.exit(1) if os.environ['SUDO_USER'] == 'root': print >>sys.stderr, 'Please run this test using sudo from a regular user. (You ran sudo from root.)' sys.exit(1) def random_string(length,lower=False): '''Return a random string, consisting of ASCII letters, with given length.''' s = '' selection = string.letters if lower: selection = string.lowercase maxind = len(selection)-1 for l in range(length): s += selection[random.randint(0, maxind)] return s def mkstemp_fill(contents,suffix='',prefix='testlib-',dir=None): '''As tempfile.mkstemp does, return a (file, name) pair, but with prefilled contents.''' handle, name = tempfile.mkstemp(suffix=suffix,prefix=prefix,dir=dir) os.close(handle) handle = file(name,"w+") handle.write(contents) handle.flush() handle.seek(0) return handle, name def create_fill(path, contents, mode=0644): '''Safely create a page''' # make the temp file in the same dir as the destination file so we # don't get invalid cross-device link errors when we rename handle, name = mkstemp_fill(contents, dir=os.path.dirname(path)) handle.close() os.rename(name, path) os.chmod(path, mode) def login_exists(login): '''Checks whether the given login exists on the system.''' try: pwd.getpwnam(login) return True except KeyError: return False def group_exists(group): '''Checks whether the given login exists on the system.''' try: grp.getgrnam(group) return True except KeyError: return False def recursive_rm(dirPath, contents_only=False): '''recursively remove directory''' names = os.listdir(dirPath) for name in names: path = os.path.join(dirPath, name) if os.path.islink(path) or not os.path.isdir(path): os.unlink(path) else: recursive_rm(path) if contents_only == False: os.rmdir(dirPath) def check_pidfile(exe, pidfile): '''Checks if pid in pidfile is running''' if not os.path.exists(pidfile): return False # get the pid try: fd = open(pidfile, 'r') pid = fd.readline().rstrip('\n') fd.close() except: return False return check_pid(exe, pid) def check_pid(exe, pid): '''Checks if pid is running''' cmdline = "/proc/%s/cmdline" % (str(pid)) if not os.path.exists(cmdline): return False # get the command line try: fd = open(cmdline, 'r') tmp = fd.readline().split('\0') fd.close() except: return False # this allows us to match absolute paths or just the executable name if re.match('^' + exe + '$', tmp[0]) or \ re.match('.*/' + exe + '$', tmp[0]) or \ re.match('^' + exe + ': ', tmp[0]) or \ re.match('^\(' + exe + '\)', tmp[0]): return True return False def check_port(port, proto, ver=4): '''Check if something is listening on the specified port. WARNING: for some reason this does not work with a bind mounted /proc ''' assert (port >= 1) assert (port <= 65535) assert (proto.lower() == "tcp" or proto.lower() == "udp") assert (ver == 4 or ver == 6) fn = "/proc/net/%s" % (proto) if ver == 6: fn += str(ver) rc, report = cmd(['cat', fn]) assert (rc == 0) hport = "%0.4x" % port if re.search(': [0-9a-f]{8}:%s [0-9a-f]' % str(hport).lower(), report.lower()): return True return False def get_arch(): '''Get the current architecture''' rc, report = cmd(['uname', '-m']) assert (rc == 0) return report.strip() def get_memory(): '''Gets total ram and swap''' meminfo = "/proc/meminfo" memtotal = 0 swaptotal = 0 if not os.path.exists(meminfo): return (False, False) try: fd = open(meminfo, 'r') for line in fd.readlines(): splitline = line.split() if splitline[0] == 'MemTotal:': memtotal = int(splitline[1]) elif splitline[0] == 'SwapTotal:': swaptotal = int(splitline[1]) fd.close() except: return (False, False) return (memtotal,swaptotal) def is_running_in_vm(): '''Check if running under a VM''' # add other virtualization environments here for search in ['QEMU Virtual CPU']: rc, report = cmd_pipe(['dmesg'], ['grep', search]) if rc == 0: return True return False def ubuntu_release(): '''Get the Ubuntu release''' f = "/etc/lsb-release" try: size = os.stat(f)[ST_SIZE] except: return "UNKNOWN" if size > 1024*1024: raise IOError, 'Could not open "%s" (too big)' % f try: fh = open("/etc/lsb-release", 'r') except: raise lines = fh.readlines() fh.close() pat = re.compile(r'DISTRIB_CODENAME') for line in lines: if pat.search(line): return line.split('=')[1].rstrip('\n').rstrip('\r') return "UNKNOWN" def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.PIPE, stdin = None, timeout = None): '''Try to execute given command (array) and return its stdout, or return a textual error if it failed.''' try: sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, preexec_fn=subprocess_setup) except OSError, e: return [127, str(e)] out, outerr = sp.communicate(input) # Handle redirection of stdout if out == None: out = '' # Handle redirection of stderr if outerr == None: outerr = '' return [sp.returncode,out+outerr] def cmd_pipe(command1, command2, input = None, stderr = subprocess.STDOUT, stdin = None): '''Try to pipe command1 into command2.''' try: sp1 = subprocess.Popen(command1, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, close_fds=True) sp2 = subprocess.Popen(command2, stdin=sp1.stdout, stdout=subprocess.PIPE, stderr=stderr, close_fds=True) except OSError, e: return [127, str(e)] out = sp2.communicate(input)[0] return [sp2.returncode,out] def cwd_has_enough_space(cdir, total_bytes): '''Determine if the partition of the current working directory has 'bytes' free.''' rc, df_output = cmd(['df']) result = 'Got exit code %d, expected %d\n' % (rc, 0) if rc != 0: return False kb = total_bytes / 1024 mounts = dict() for line in df_output.splitlines(): if '/' not in line: continue tmp = line.split() mounts[tmp[5]] = int(tmp[3]) cdir = os.getcwd() while cdir != '/': if not mounts.has_key(cdir): cdir = os.path.dirname(cdir) continue if kb < mounts[cdir]: return True else: return False if kb < mounts['/']: return True return False def get_md5(filename): '''Gets the md5sum of the file specified''' (rc, report) = cmd(["/usr/bin/md5sum", "-b", filename]) expected = 0 assert (expected == rc) return report.split(' ')[0] def dpkg_compare_installed_version(pkg, check, version): '''Gets the version for the installed package, and compares it to the specified version. ''' (rc, report) = cmd(["/usr/bin/dpkg", "-s", pkg]) assert (rc == 0) assert ("Status: install ok installed" in report) installed_version = "" for line in report.splitlines(): if line.startswith("Version: "): installed_version = line.split()[1] assert (installed_version != "") (rc, report) = cmd(["/usr/bin/dpkg", "--compare-versions", installed_version, check, version]) assert (rc == 0 or rc == 1) if rc == 0: return True return False def prepare_source(source, builder, cached_src, build_src, patch_system): '''Download and unpack source package, installing necessary build depends, adjusting the permissions for the 'builder' user, and returning the directory of the unpacked source. Patch system can be one of: - cdbs - dpatch - quilt - quiltv3 - None (not the string) This is normally used like this: def setUp(self): ... self.topdir = os.getcwd() self.cached_src = os.path.join(os.getcwd(), "source") self.tmpdir = tempfile.mkdtemp(prefix='testlib', dir='/tmp') self.builder = testlib.TestUser() testlib.cmd(['chgrp', self.builder.login, self.tmpdir]) os.chmod(self.tmpdir, 0775) def tearDown(self): ... self.builder = None self.topdir = os.getcwd() if os.path.exists(self.tmpdir): testlib.recursive_rm(self.tmpdir) def test_suite_build(self): ... build_dir = testlib.prepare_source('foo', \ self.builder, \ self.cached_src, \ os.path.join(self.tmpdir, \ os.path.basename(self.cached_src)), "quilt") os.chdir(build_dir) # Example for typical build, adjust as necessary print "" print " make clean" rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'clean']) print " configure" rc, report = testlib.cmd(['sudo', '-u', self.builder.login, './configure', '--prefix=%s' % self.tmpdir, '--enable-debug']) print " make (will take a while)" rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make']) print " make check (will take a while)", rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'check']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) self.assertEquals(expected, rc, result + report) def test_suite_cleanup(self): ... if os.path.exists(self.cached_src): testlib.recursive_rm(self.cached_src) It is up to the caller to clean up cached_src and build_src (as in the above example, often the build_src is in a tmpdir that is cleaned in tearDown() and the cached_src is cleaned in a one time clean-up operation (eg 'test_suite_cleanup()) which must be run after the build suite test (obviously). ''' # Make sure we have a clean slate assert (os.path.exists(os.path.dirname(build_src))) assert (not os.path.exists(build_src)) cdir = os.getcwd() if os.path.exists(cached_src): shutil.copytree(cached_src, build_src) os.chdir(build_src) else: # Only install the build dependencies on the initial setup rc, report = cmd(['apt-get','-y','--force-yes','build-dep',source]) assert (rc == 0) os.makedirs(build_src) os.chdir(build_src) # These are always needed pkgs = ['build-essential', 'dpkg-dev', 'fakeroot'] rc, report = cmd(['apt-get','-y','--force-yes','install'] + pkgs) assert (rc == 0) rc, report = cmd(['apt-get','source',source]) assert (rc == 0) shutil.copytree(build_src, cached_src) unpacked_dir = os.path.join(build_src, glob.glob('%s-*' % source)[0]) # Now apply the patches. Do it here so that we don't mess up our cached # sources. os.chdir(unpacked_dir) assert (patch_system in ['cdbs', 'dpatch', 'quilt', 'quiltv3', None]) if patch_system != None and patch_system != "quiltv3": if patch_system == "quilt": os.environ.setdefault('QUILT_PATCHES','debian/patches') rc, report = cmd(['quilt', 'push', '-a']) assert (rc == 0) elif patch_system == "cdbs": rc, report = cmd(['./debian/rules', 'apply-patches']) assert (rc == 0) elif patch_system == "dpatch": rc, report = cmd(['dpatch', 'apply-all']) assert (rc == 0) cmd(['chown', '-R', '%s:%s' % (builder.uid, builder.gid), build_src]) os.chdir(cdir) return unpacked_dir def _aa_status(): '''Get aa-status output''' exe = "/usr/sbin/aa-status" assert (os.path.exists(exe)) if os.geteuid() == 0: return cmd([exe]) return cmd(['sudo', exe]) def is_apparmor_loaded(path): '''Check if profile is loaded''' rc, report = _aa_status() if rc != 0: return False for line in report.splitlines(): if line.endswith(path): return True return False def is_apparmor_confined(path): '''Check if application is confined''' rc, report = _aa_status() if rc != 0: return False for line in report.splitlines(): if re.search('%s \(' % path, line): return True return False def check_apparmor(path, first_ubuntu_release, is_running=True): '''Check if path is loaded and confined for everything higher than the first Ubuntu release specified. Usage: rc, report = testlib.check_apparmor('/usr/sbin/foo', 8.04, is_running=True) if rc < 0: return self._skipped(report) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) self.assertEquals(expected, rc, result + report) ''' global manager rc = -1 if manager.lsb_release["Release"] < first_ubuntu_release: return (rc, "Skipped apparmor check") if not os.path.exists('/sbin/apparmor_parser'): return (rc, "Skipped (couldn't find apparmor_parser)") rc = 0 msg = "" if not is_apparmor_loaded(path): rc = 1 msg = "Profile not loaded for '%s'" % path # this check only makes sense it the 'path' is currently executing if is_running and rc == 0 and not is_apparmor_confined(path): rc = 1 msg = "'%s' is not running in enforce mode" % path return (rc, msg) def get_gcc_version(gcc, full=True): gcc_version = 'none' if not gcc.startswith('/'): gcc = '/usr/bin/%s' % (gcc) if os.path.exists(gcc): gcc_version = 'unknown' lines = cmd([gcc,'-v'])[1].strip().splitlines() version_lines = [x for x in lines if x.startswith('gcc version')] if len(version_lines) == 1: gcc_version = " ".join(version_lines[0].split()[2:]) if not full: return gcc_version.split()[0] return gcc_version def is_kdeinit_running(): '''Test if kdeinit is running''' # applications that use kdeinit will spawn it if it isn't running in the # test. This is a problem because it does not exit. This is a helper to # check for it. rc, report = cmd(['ps', 'x']) if 'kdeinit4 Running' not in report: print >>sys.stderr, ("kdeinit not running (you may start/stop any KDE application then run this script again)") return False return True def get_pkgconfig_flags(libs=[]): '''Find pkg-config flags for libraries''' assert (len(libs) > 0) rc, pkg_config = cmd(['pkg-config', '--cflags', '--libs'] + libs) expected = 0 if rc != expected: print >>sys.stderr, 'Got exit code %d, expected %d\n' % (rc, expected) assert(rc == expected) return pkg_config.split() class TestDaemon: '''Helper class to manage daemons consistently''' def __init__(self, init): '''Setup daemon attributes''' self.initscript = init def start(self): '''Start daemon''' rc, report = cmd([self.initscript, 'start']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) time.sleep(2) if expected != rc: return (False, result + report) if "fail" in report: return (False, "Found 'fail' in report\n" + report) return (True, "") def stop(self): '''Stop daemon''' rc, report = cmd([self.initscript, 'stop']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) if expected != rc: return (False, result + report) if "fail" in report: return (False, "Found 'fail' in report\n" + report) return (True, "") def reload(self): '''Reload daemon''' rc, report = cmd([self.initscript, 'force-reload']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) if expected != rc: return (False, result + report) if "fail" in report: return (False, "Found 'fail' in report\n" + report) return (True, "") def restart(self): '''Restart daemon''' (res, str) = self.stop() if not res: return (res, str) (res, str) = self.start() if not res: return (res, str) return (True, "") def status(self): '''Check daemon status''' rc, report = cmd([self.initscript, 'status']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) if expected != rc: return (False, result + report) if "fail" in report: return (False, "Found 'fail' in report\n" + report) return (True, "") class TestlibManager(object): '''Singleton class used to set up per-test-run information''' def __init__(self): # Set glibc aborts to dump to stderr instead of the tty so test output # is more sane. os.environ.setdefault('LIBC_FATAL_STDERR_','1') # check verbosity self.verbosity = False if (len(sys.argv) > 1 and '-v' in sys.argv[1:]): self.verbosity = True # Load LSB release file self.lsb_release = dict() if not os.path.exists('/usr/bin/lsb_release') and not os.path.exists('/bin/lsb_release'): raise OSError, "Please install 'lsb-release'" for line in subprocess.Popen(['lsb_release','-a'],stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0].splitlines(): field, value = line.split(':',1) value=value.strip() field=field.strip() # Convert numerics try: value = float(value) except: pass self.lsb_release.setdefault(field,value) # FIXME: hack OEM releases into known-Ubuntu versions if self.lsb_release['Distributor ID'] == "HP MIE (Mobile Internet Experience)": if self.lsb_release['Release'] == 1.0: self.lsb_release['Distributor ID'] = "Ubuntu" self.lsb_release['Release'] = 8.04 else: raise OSError, "Unknown version of HP MIE" # FIXME: hack to assume a most-recent release if we're not # running under Ubuntu. if self.lsb_release['Distributor ID'] not in ["Ubuntu","Linaro"]: self.lsb_release['Release'] = 10000 # Adjust Linaro release to pretend to be Ubuntu if self.lsb_release['Distributor ID'] in ["Linaro"]: self.lsb_release['Distributor ID'] = "Ubuntu" self.lsb_release['Release'] -= 0.01 # Load arch if not os.path.exists('/usr/bin/dpkg'): machine = cmd(['uname','-m'])[1].strip() if machine.endswith('86'): self.dpkg_arch = 'i386' elif machine.endswith('_64'): self.dpkg_arch = 'amd64' elif machine.startswith('arm'): self.dpkg_arch = 'armel' else: raise ValueError, "Unknown machine type '%s'" % (machine) else: self.dpkg_arch = cmd(['dpkg','--print-architecture'])[1].strip() # Find kernel version self.kernel_is_ubuntu = False self.kernel_version_signature = None self.kernel_version = cmd(["uname","-r"])[1].strip() versig = '/proc/version_signature' if os.path.exists(versig): self.kernel_is_ubuntu = True self.kernel_version_signature = file(versig).read().strip() self.kernel_version_ubuntu = self.kernel_version elif os.path.exists('/usr/bin/dpkg'): # this can easily be inaccurate but is only an issue for Dapper rc, out = cmd(['dpkg','-l','linux-image-%s' % (self.kernel_version)]) if rc == 0: self.kernel_version_signature = out.strip().split('\n').pop().split()[2] self.kernel_version_ubuntu = self.kernel_version_signature if self.kernel_version_signature == None: # Attempt to fall back to something for non-Debian-based self.kernel_version_signature = self.kernel_version self.kernel_version_ubuntu = self.kernel_version # Build ubuntu version without hardware suffix try: self.kernel_version_ubuntu = "-".join([x for x in self.kernel_version_signature.split(' ')[1].split('-') if re.search('^[0-9]', x)]) except: pass # Find gcc version self.gcc_version = get_gcc_version('gcc') # Find libc self.path_libc = [x.split()[2] for x in cmd(['ldd','/bin/ls'])[1].splitlines() if x.startswith('\tlibc.so.')][0] # Report self if self.verbosity: kernel = self.kernel_version_ubuntu if kernel != self.kernel_version_signature: kernel += " (%s)" % (self.kernel_version_signature) print >>sys.stdout, "Running test: '%s' distro: '%s %.2f' kernel: '%s' arch: '%s' uid: %d/%d SUDO_USER: '%s')" % ( \ sys.argv[0], self.lsb_release['Distributor ID'], self.lsb_release['Release'], kernel, self.dpkg_arch, os.geteuid(), os.getuid(), os.environ.get('SUDO_USER', '')) sys.stdout.flush() # Additional heuristics #if os.environ.get('SUDO_USER', os.environ.get('USER', '')) in ['mdeslaur']: # sys.stdout.write("Replying to Marc Deslauriers in http://launchpad.net/bugs/%d: " % random.randint(600000, 980000)) # sys.stdout.flush() # time.sleep(0.5) # sys.stdout.write("destroyed\n") # time.sleep(0.5) def hello(self, msg): print >>sys.stderr, "Hello from %s" % (msg) # The central instance manager = TestlibManager() class TestlibCase(unittest.TestCase): def __init__(self, *args): '''This is called for each TestCase test instance, which isn't much better than SetUp.''' unittest.TestCase.__init__(self, *args) # Attach to and duplicate dicts from manager singleton self.manager = manager #self.manager.hello(repr(self) + repr(*args)) self.my_verbosity = self.manager.verbosity self.lsb_release = self.manager.lsb_release self.dpkg_arch = self.manager.dpkg_arch self.kernel_version = self.manager.kernel_version self.kernel_version_signature = self.manager.kernel_version_signature self.kernel_version_ubuntu = self.manager.kernel_version_ubuntu self.kernel_is_ubuntu = self.manager.kernel_is_ubuntu self.gcc_version = self.manager.gcc_version self.path_libc = self.manager.path_libc def version_compare(self, one, two): return apt_pkg.VersionCompare(one,two) def assertFileType(self, filename, filetype): '''Checks the file type of the file specified''' (rc, report, out) = self._testlib_shell_cmd(["/usr/bin/file", "-b", filename]) out = out.strip() expected = 0 # Absolutely no idea why this happens on Hardy if self.lsb_release['Release'] == 8.04 and rc == 255 and len(out) > 0: rc = 0 result = 'Got exit code %d, expected %d:\n%s\n' % (rc, expected, report) self.assertEquals(expected, rc, result) filetype = '^%s$' % (filetype) result = 'File type reported by file: [%s], expected regex: [%s]\n' % (out, filetype) self.assertNotEquals(None, re.search(filetype, out), result) def yank_commonname_from_cert(self, certfile): '''Extract the commonName from a given PEM''' rc, out = cmd(['openssl','asn1parse','-in',certfile]) if rc == 0: ready = False for line in out.splitlines(): if ready: return line.split(':')[-1] if ':commonName' in line: ready = True return socket.getfqdn() def announce(self, text): if self.my_verbosity: print >>sys.stdout, "(%s) " % (text), sys.stdout.flush() def make_clean(self): rc, output = self.shell_cmd(['make','clean']) self.assertEquals(rc, 0, output) def get_makefile_compiler(self): # Find potential compiler name compiler = 'gcc' if os.path.exists('Makefile'): for line in open('Makefile'): if line.startswith('CC') and '=' in line: items = [x.strip() for x in line.split('=')] if items[0] == 'CC': compiler = items[1] break return compiler def make_target(self, target, expected=0): '''Compile a target and report output''' compiler = self.get_makefile_compiler() rc, output = self.shell_cmd(['make',target]) self.assertEquals(rc, expected, 'rc(%d)!=%d:\n' % (rc, expected) + output) self.assertTrue('%s ' % (compiler) in output, 'Expected "%s":' % (compiler) + output) return output # call as return testlib.skipped() def _skipped(self, reason=""): '''Provide a visible way to indicate that a test was skipped''' if reason != "": reason = ': %s' % (reason) self.announce("skipped%s" % (reason)) return False def _testlib_shell_cmd(self,args,stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT): argstr = "'" + "', '".join(args).strip() + "'" rc, out = cmd(args,stdin=stdin,stdout=stdout,stderr=stderr) report = 'Command: ' + argstr + '\nOutput:\n' + out return rc, report, out def shell_cmd(self, args, stdin=None): return cmd(args,stdin=stdin) def assertShellExitEquals(self, expected, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""): '''Test a shell command matches a specific exit code''' rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got exit code %d, expected %d\n' % (rc, expected) self.assertEquals(expected, rc, msg + result + report) def assertShellExitNotEquals(self, unwanted, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""): '''Test a shell command doesn't match a specific exit code''' rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got (unwanted) exit code %d\n' % rc self.assertNotEquals(unwanted, rc, msg + result + report) def assertShellOutputContains(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False): '''Test a shell command contains a specific output''' rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got exit code %d. Looking for text "%s"\n' % (rc, text) if not invert: self.assertTrue(text in out, msg + result + report) else: self.assertFalse(text in out, msg + result + report) def assertShellOutputEquals(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False, expected=None): '''Test a shell command matches a specific output''' rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got exit code %d. Looking for exact text "%s" (%s)\n' % (rc, text, " ".join(args)) if not invert: self.assertEquals(text, out, msg + result + report) else: self.assertNotEquals(text, out, msg + result + report) if expected != None: result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args)) self.assertEquals(rc, expected, msg + result + report) def _word_find(self, report, content, invert=False): '''Check for a specific string''' if invert: warning = 'Found "%s"\n' % content self.assertTrue(content not in report, warning + report) else: warning = 'Could not find "%s"\n' % content self.assertTrue(content in report, warning + report) def _test_sysctl_value(self, path, expected, msg=None, exists=True): sysctl = '/proc/sys/%s' % (path) self.assertEquals(exists, os.path.exists(sysctl), sysctl) value = None if exists: value = int(file(sysctl).read()) report = "%s is not %d: %d" % (sysctl, expected, value) if msg: report += " (%s)" % (msg) self.assertEquals(value, expected, report) return value def set_sysctl_value(self, path, desired): sysctl = '/proc/sys/%s' % (path) self.assertTrue(os.path.exists(sysctl),"%s does not exist" % (sysctl)) file(sysctl,'w').write(str(desired)) self._test_sysctl_value(path, desired) def kernel_at_least(self, introduced): return self.version_compare(self.kernel_version_ubuntu, introduced) >= 0 def kernel_claims_cve_fixed(self, cve): changelog = "/usr/share/doc/linux-image-%s/changelog.Debian.gz" % (self.kernel_version) if os.path.exists(changelog): for line in gzip.open(changelog): if cve in line and not "revert" in line and not "Revert" in line: return True return False class TestGroup: '''Create a temporary test group and remove it again in the dtor.''' def __init__(self, group=None, lower=False): '''Create a new group''' self.group = None if group: if group_exists(group): raise ValueError, 'group name already exists' else: while(True): group = random_string(7,lower=lower) if not group_exists(group): break assert subprocess.call(['groupadd',group]) == 0 self.group = group g = grp.getgrnam(self.group) self.gid = g[2] def __del__(self): '''Remove the created group.''' if self.group: rc, report = cmd(['groupdel', self.group]) assert rc == 0 class TestUser: '''Create a temporary test user and remove it again in the dtor.''' def __init__(self, login=None, home=True, group=None, uidmin=None, lower=False, shell=None): '''Create a new user account with a random password. By default, the login name is random, too, but can be explicitly specified with 'login'. By default, a home directory is created, this can be suppressed with 'home=False'.''' self.login = None if os.geteuid() != 0: raise ValueError, "You must be root to run this test" if login: if login_exists(login): raise ValueError, 'login name already exists' else: while(True): login = 't' + random_string(7,lower=lower) if not login_exists(login): break self.salt = random_string(2) self.password = random_string(8,lower=lower) self.crypted = crypt.crypt(self.password, self.salt) creation = ['useradd', '-p', self.crypted] if home: creation += ['-m'] if group: creation += ['-G',group] if uidmin: creation += ['-K','UID_MIN=%d'%uidmin] if shell: creation += ['-s',shell] creation += [login] assert subprocess.call(creation) == 0 # Set GECOS assert subprocess.call(['usermod','-c','Buddy %s' % (login),login]) == 0 self.login = login p = pwd.getpwnam(self.login) self.uid = p[2] self.gid = p[3] self.gecos = p[4] self.home = p[5] self.shell = p[6] def __del__(self): '''Remove the created user account.''' if self.login: # sanity check the login name so we don't accidentally wipe too much if len(self.login)>3 and not '/' in self.login: subprocess.call(['rm','-rf', '/home/'+self.login, '/var/mail/'+self.login]) rc, report = cmd(['userdel', '-f', self.login]) assert rc == 0 def add_to_group(self, group): '''Add user to the specified group name''' rc, report = cmd(['usermod', '-G', group, self.login]) if rc != 0: print report assert rc == 0 # Timeout handler using alarm() from John P. Speno's Pythonic Avocado class TimeoutFunctionException(Exception): """Exception to raise on a timeout""" pass class TimeoutFunction: def __init__(self, function, timeout): self.timeout = timeout self.function = function def handle_timeout(self, signum, frame): raise TimeoutFunctionException() def __call__(self, *args, **kwargs): old = signal.signal(signal.SIGALRM, self.handle_timeout) signal.alarm(self.timeout) try: result = self.function(*args, **kwargs) finally: signal.signal(signal.SIGALRM, old) signal.alarm(0) return result def main(): print "hi" unittest.main() debian/tests/control0000664000000000000000000000011512303401466011731 0ustar Tests: daemon testsuite Depends: open-iscsi, python Restrictions: needs-root debian/tests/testsuite0000664000000000000000000000017712150615460012313 0ustar #!/bin/bash #------------------- # Testing open-iscsi #------------------- set -e python `dirname $0`/test-open-iscsi.py 2>&1 debian/tests/test-open-iscsi.py0000664000000000000000000001755112150615460013743 0ustar #!/usr/bin/python # # test-open-iscsi.py quality assurance test script for open-iscsi # Copyright (C) 2011 Canonical Ltd. # Author: Jamie Strandboge # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3, # as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # packages required for test to run: # QRT-Packages: open-iscsi # packages where more than one package can satisfy a runtime requirement: # QRT-Alternates: # files and directories required for the test to run: # QRT-Depends: # privilege required for the test to run (remove line if running as user is okay): # QRT-Privilege: root ''' In general, this test should be run in a virtual machine (VM) or possibly a chroot and not on a production machine. While efforts are made to make these tests non-destructive, there is no guarantee this script will not alter the machine. You have been warned. How to run in a clean VM: $ sudo apt-get -y install python-unit && sudo ./test-PKG.py -v' How to run in a clean schroot named 'lucid': $ schroot -c lucid -u root -- sh -c 'apt-get -y install python-unit && ./test-PKG.py -v' NOTES: - currently only tested on Ubuntu 8.04 ''' import unittest, subprocess, sys, os import testlib import time # There are setup based on README.multipurpose-vm. Feel free to override. remote_server = '' username = 'ubuntu' password = 'passwd' username_in = 'ubuntu' password_in = 'ubuntupasswd' initiatorname = 'iqn.2009-10.com.example.hardy-multi:iscsi-01' try: from private.qrt.OpenIscsi import PrivateOpenIscsiTest except ImportError: class PrivateOpenIscsiTest(object): '''Empty class''' print >>sys.stdout, "Skipping private tests" class OpenIscsiTest(testlib.TestlibCase, PrivateOpenIscsiTest): '''Test my thing.''' def setUp(self): '''Set up prior to each test_* function''' self.pidfile = "/var/run/iscsid.pid" self.exe = "/sbin/iscsid" self.daemon = testlib.TestDaemon("/etc/init.d/open-iscsi") self.initiatorname_iscsi = '/etc/iscsi/initiatorname.iscsi' self.iscsid_conf = '/etc/iscsi/iscsid.conf' def tearDown(self): '''Clean up after each test_* function''' global remote_server global initiatorname # If remote server is setup, convert back to manual, logout, remove # testlib configs and restart (in that order) if remote_server != '': testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--op=update', '--name', 'node.startup', '--value=manual']) testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--op=update', '--name', 'node.conn[0].startup', '--value=manual']) testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--logout']) testlib.config_restore(self.initiatorname_iscsi) testlib.config_restore(self.iscsid_conf) self.daemon.restart() def test_daemon(self): '''Test iscsid''' self.assertTrue(self.daemon.stop()) time.sleep(2) self.assertFalse(testlib.check_pidfile(self.exe, self.pidfile)) self.assertTrue(self.daemon.start()) time.sleep(2) self.assertTrue(testlib.check_pidfile(os.path.basename(self.exe), self.pidfile)) self.assertTrue(self.daemon.restart()) time.sleep(2) self.assertTrue(testlib.check_pidfile(os.path.basename(self.exe), self.pidfile)) def test_discovery_with_server(self): '''Test iscsi_discovery to remote server''' global remote_server global username global password global username_in global password_in global initiatorname if remote_server == '': return self._skipped("--remote-server not specified") contents = ''' InitiatorName=%s InitiatorAlias=ubuntu ''' % (initiatorname) testlib.config_replace(self.initiatorname_iscsi, contents, True) contents = ''' node.session.auth.authmethod = CHAP node.session.auth.username = %s node.session.auth.password = %s node.session.auth.username_in = %s node.session.auth.password_in = %s discovery.sendtargets.auth.authmethod = CHAP discovery.sendtargets.auth.username = %s discovery.sendtargets.auth.password = %s discovery.sendtargets.auth.username_in = %s discovery.sendtargets.auth.password_in = %s ''' % (username, password, username_in, password_in, username, password, username_in, password_in) testlib.config_replace(self.iscsid_conf, contents, True) self.assertTrue(self.daemon.restart()) time.sleep(2) self.assertTrue(testlib.check_pidfile(os.path.basename(self.exe), self.pidfile)) rc, report = testlib.cmd(["/sbin/iscsi_discovery", remote_server]) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) self.assertEquals(expected, rc, result + report) for i in ['starting discovery to %s' % remote_server, 'Testing iser-login to target %s portal %s' % (initiatorname, remote_server), 'starting to test tcp-login to target %s portal %s' % (initiatorname, remote_server), 'discovered 1 targets at %s, connected to 1' % remote_server]: result = "Could not find '%s' in report:\n" % i self.assertTrue(i in report, result + report) if __name__ == '__main__': import optparse parser = optparse.OptionParser() parser.add_option("-v", "--verbose", dest="verbose", help="Verbose", action="store_true") parser.add_option("-s", "--remote-server", dest="remote_server", help="Specify host with available iSCSI volumes", metavar="HOST") parser.add_option("-n", "--initiatorname", dest="initiatorname", help="Specify initiatorname for use with --remote-server", metavar="NAME") parser.add_option("--password", dest="password", help="Specify password for use with --remote-server", metavar="PASS") parser.add_option("--password-in", dest="password_in", help="Specify password_in for use with --remote-server", metavar="PASS") parser.add_option("--username", dest="username", help="Specify username for use with --remote-server", metavar="USER") parser.add_option("--username-in", dest="username_in", help="Specify username_in for use with --remote-server", metavar="USER") (options, args) = parser.parse_args() if options.remote_server: remote_server = options.remote_server if options.username: username = options.username if options.password: password = options.password if options.username_in: username_in = options.username_in if options.password_in: password_in = options.password_in if options.initiatorname: initiatorname = options.initiatorname print "Connecting to remote server with:" print " host = %s " % remote_server print ' initiatorname = %s' % initiatorname print ' username = %s' % username print ' password = %s' % password print ' username_in = %s' % username_in print ' password_in = %s' % password_in suite = unittest.TestSuite() suite.addTest(unittest.TestLoader().loadTestsFromTestCase(OpenIscsiTest)) rc = unittest.TextTestRunner(verbosity=2).run(suite) if not rc.wasSuccessful(): sys.exit(1) debian/umountiscsi.sh.init0000664000000000000000000000406212150615442013052 0ustar #! /bin/sh ### BEGIN INIT INFO # Provides: umountiscsi.sh # Required-Start: # Required-Stop: $network $remote_fs sendsigs open-iscsi # Default-Start: # Default-Stop: 0 1 6 # Short-Description: Unmounts iSCSI filesystems # Description: Unmounts iSCSI filesystems ### END INIT INFO . /lib/init/vars.sh . /lib/lsb/init-functions # Include defaults if available if [ -f /etc/default/open-iscsi ]; then . /etc/default/open-iscsi fi do_stop () { log_daemon_msg "Unmounting iscsi-backed filesystems" umount_fail=0 if [ $HANDLE_NETDEV -eq 1 ]; then log_progress_msg "Unmounting all devices marked _netdev"; umount -a -O _netdev >/dev/null 2>&1 fi # Now handle iSCSI LVM Volumes if [ -n "$LVMGROUPS" ]; then log_daemon_msg "Deactivating iSCSI volume groups" for vg in "$LVMGROUPS"; do log_progress_msg $vg vgchange --available=n $vg if [ $? -ne 0 ]; then log_warning_msg "Cannot deactivate Volume Group $vg" umount_fail=1 fi done log_end_msg 0 fi for HOST_DIR in /sys/devices/platform/host*; do if ! [ -d $HOST_DIR/iscsi_host* ]; then continue fi for SESSION_DIR in $HOST_DIR/session*; do if ! [ -d $SESSION_DIR/target* ]; then continue fi for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do BLOCK_DEV=`echo "$BLOCK_FILE" | sed 's/.*block\///'` DOS_PARTITIONS="`awk "/^\/dev\/$BLOCK_DEV/ { print \\$2; }" < /proc/mounts`" for DEVICE in $DOS_PARTITIONS; do #log_progress_msg $DEVICE #echo $DEVICE umount $DEVICE exit_status=$? if ! [ $exit_status -eq 0 ]; then umount_fail=1 log_warning_msg "Could not unmount $DEVICE" fi done done done done if [ $umount_fail -ne 0 ]; then log_end_msg 1 exit 1 else log_end_msg 0 exit 0 fi } case "$1" in start) # No-op ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop|"") do_stop ;; *) echo "Usage: umountiscsi.sh [start|stop]" >&2 exit 3 ;; esac debian/open-iscsi.default0000664000000000000000000000066612150615442012617 0ustar # List of LVMed iSCSI Volume Groups. # Multiple Volume Groups can be specified with spaces LVMGROUPS="" # Handle _netdev devices # You can specify your iSCSI (LVMed or Multipathed or DM Encrypted) devices # with the _netdev mount option and open-iscsi will treat them accordingly # # Note: However, Hanling _netdev devices comes with the caveat that other _netdev mounts, # like an NFS share, also get pulled in with it HANDLE_NETDEV=1 debian/extra/0000775000000000000000000000000012150615740010314 5ustar debian/extra/initramfs.local-top0000664000000000000000000000545412150615442014133 0ustar #!/bin/sh PREREQ="" prereqs() { echo "$PREREQ" } case $1 in # get pre-requisites prereqs) prereqs exit 0 ;; esac do_iscsi_login () { # Bring in the main config . /conf/initramfs.conf for conf in conf/conf.d/*; do [ -f ${conf} ] && . ${conf} done . /scripts/functions wait_for_udev configure_networking # write info file for later consumption by iscsi-network-interface.conf if [ -n "${DEVICE}" ] && [ -e "/run/net-${DEVICE}.conf" ]; then echo "${DEVICE}" >/run/initramfs/open-iscsi.interface fi modprobe iscsi_tcp modprobe crc32c if [ -z $ISCSI_AUTO ]; then if [ -z $ISCSI_INITIATOR ]; then . /etc/initiatorname.iscsi ISCSI_INITIATOR=$InitiatorName fi if [ -z $ISCSI_TARGET_PORT ]; then ISCSI_TARGET_PORT=3260 fi if [ -z $ISCSI_TARGET_GROUP ]; then ISCSI_TARGET_GROUP=1 fi iscsistart -i $ISCSI_INITIATOR -t $ISCSI_TARGET_NAME \ -g $ISCSI_TARGET_GROUP -a $ISCSI_TARGET_IP \ -p $ISCSI_TARGET_PORT \ ${ISCSI_USERNAME:+-u "$ISCSI_USERNAME"} \ ${ISCSI_PASSWORD:+-w "$ISCSI_PASSWORD"} \ ${ISCSI_IN_USERNAME:+-U "$ISCSI_IN_USERNAME"}\ ${ISCSI_IN_PASSWORD:+-W "$ISCSI_IN_PASSWORD"} else modprobe iscsi_ibft iscsistart -b fi if [ -z $ISCSI_TARGET_PORT ]; then ISCSI_TARGET_PORT=3260 fi if [ -z $ISCSI_TARGET_GROUP ]; then ISCSI_TARGET_GROUP=1 fi for i in $ISCSI_TARGET_IP; do iscsistart -i $ISCSI_INITIATOR -t $ISCSI_TARGET_NAME \ -g $ISCSI_TARGET_GROUP -a $i \ -p $ISCSI_TARGET_PORT \ ${ISCSI_USERNAME:+-u "$ISCSI_USERNAME"} \ ${ISCSI_PASSWORD:+-w "$ISCSI_PASSWORD"} \ ${ISCSI_IN_USERNAME:+-U "$ISCSI_IN_USERNAME"}\ ${ISCSI_IN_PASSWORD:+-W "$ISCSI_IN_PASSWORD"} done } parse_iscsi_ops () { . /etc/iscsi.initramfs for x in $(cat /proc/cmdline); do case ${x} in iscsi_auto) ISCSI_AUTO=true ;; iscsi_initiator=*) ISCSI_INITIATOR="${x#iscsi_initiator=}" ;; iscsi_target_name=*) ISCSI_TARGET_NAME="${x#iscsi_target_name=}" ;; iscsi_target_ip=*) ISCSI_TARGET_IP="${x#iscsi_target_ip=}" ;; iscsi_target_port=*) ISCSI_TARGET_PORT="${x#iscsi_target_port=}" ;; iscsi_target_group=*) ISCSI_TARGET_GROUP="${x#iscsi_target_group=}" ;; iscsi_username=*) ISCSI_USERNAME="${x#iscsi_username=}" ;; iscsi_password=*) ISCSI_PASSWORD="${x#iscsi_password=}" ;; iscsi_in_username=*) ISCSI_IN_USERNAME="${x#iscsi_in_username=}" ;; iscsi_in_password=*) ISCSI_IN_PASSWORD="${x#iscsi_in_password=}" ;; esac done } if [ ! -x /sbin/iscsistart ]; then exit 0 fi parse_iscsi_ops if ( [ -z $ISCSI_TARGET_NAME ] || [ -z $ISCSI_TARGET_IP ] ) && [ -z $ISCSI_AUTO ]; then exit 0 fi do_iscsi_login udevadm settle exit 0 debian/extra/initramfs.hook0000664000000000000000000000100412150615442013164 0ustar #!/bin/sh PREREQ="udev" prereqs() { echo "$PREREQ" } case $1 in # get pre-requisites prereqs) prereqs exit 0 ;; esac if [ ! -e /etc/iscsi/iscsi.initramfs ]; then exit 0 fi # Hooks for loading iscsi bits into the initramfs . /usr/share/initramfs-tools/hook-functions copy_exec /usr/sbin/iscsistart /sbin cp /etc/iscsi/initiatorname.iscsi $DESTDIR/etc cp /etc/iscsi/iscsi.initramfs $DESTDIR/etc for x in crc32c libcrc32c iscsi_tcp libiscsi scsi_transport_iscsi iscsi_ibft; do manual_add_modules ${x} done