[packages/open-iscsi] - added redhat/fedora patches, bugfixes and full systemd support

baggins baggins at pld-linux.org
Tue Apr 1 12:06:09 CEST 2014


commit 6ae084502d00dd9fcb511007e0d73c09d69d87b4
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Tue Apr 1 11:43:32 2014 +0200

    - added redhat/fedora patches, bugfixes and full systemd support

 0043-idmb_rec_write-check-for-tpgt-first.patch     |  55 ++++
 ...initrd-option-to-set-run-from-initrd-hint.patch |  61 ++++
 ...c_write-seperate-old-and-new-style-writes.patch | 180 +++++++++++
 ..._rec_write-pick-tpgt-from-existing-record.patch |  87 ++++++
 ...csid-newroot-command-to-survive-switch_ro.patch | 158 ++++++++++
 ...scsiuio-systemd-socket-activation-support.patch |  58 ++++
 ...-param-parsing-for-advanced-node-creation.patch | 337 +++++++++++++++++++++
 ...emd-service-files-add-iscsi.service-for-s.patch |  93 ++++++
 0050-iscsi-boot-related-service-file-updates.patch |  74 +++++
 0058-iscsiuio-IPC-newroot-command.patch            | 122 ++++++++
 0059-iscsiuio-systemd-unit-files.patch             |  53 ++++
 ...-for-autostart-sessions-if-iscsi-is-not-u.patch |  30 ++
 ...f-setting-uid-gid-and-drop-supplementary-.patch |  68 +++++
 0065-fix-hardened-build-of-iscsiuio.patch          |  30 ++
 ...tart-socket-listeners-on-iscsiadm-command.patch |  28 ++
 open-iscsi.spec                                    |  39 +++
 16 files changed, 1473 insertions(+)
---
diff --git a/open-iscsi.spec b/open-iscsi.spec
index a29d115..67478c1 100644
--- a/open-iscsi.spec
+++ b/open-iscsi.spec
@@ -18,6 +18,21 @@ Source3:	%{name}-devices.init
 Source4:	iscsiuio.logrotate
 Patch0:		%{name}-build.patch
 Patch1:		%{name}-git.patch
+Patch31:	0043-idmb_rec_write-check-for-tpgt-first.patch
+Patch32:	0044-iscsid-add-initrd-option-to-set-run-from-initrd-hint.patch
+Patch33:	0045-idbm_rec_write-seperate-old-and-new-style-writes.patch
+Patch34:	0046-idbw_rec_write-pick-tpgt-from-existing-record.patch
+Patch35:	0047-iscsiadm-iscsid-newroot-command-to-survive-switch_ro.patch
+Patch36:	0047-iscsiuio-systemd-socket-activation-support.patch
+Patch37:	0048-iscsiadm-param-parsing-for-advanced-node-creation.patch
+Patch38:	0049-update-systemd-service-files-add-iscsi.service-for-s.patch
+Patch39:	0050-iscsi-boot-related-service-file-updates.patch
+Patch40:	0058-iscsiuio-IPC-newroot-command.patch
+Patch41:	0059-iscsiuio-systemd-unit-files.patch
+Patch42:	0062-Don-t-check-for-autostart-sessions-if-iscsi-is-not-u.patch
+Patch43:	0063-fix-order-of-setting-uid-gid-and-drop-supplementary-.patch
+Patch44:	0065-fix-hardened-build-of-iscsiuio.patch
+Patch45:	0066-start-socket-listeners-on-iscsiadm-command.patch
 URL:		http://www.open-iscsi.org/
 BuildRequires:	kmod-devel
 BuildRequires:	openssl-devel
@@ -59,6 +74,21 @@ informacji o protokole iSCSI znajduje się w standardach IETF na
 %setup -q -n %{name}-%{ver}-%{subver}
 %patch0 -p1
 %patch1 -p1
+%patch31 -p1
+%patch32 -p1
+%patch33 -p1
+%patch34 -p1
+%patch35 -p1
+%patch36 -p1
+%patch37 -p1
+%patch38 -p1
+%patch39 -p1
+%patch40 -p1
+%patch41 -p1
+%patch42 -p1
+%patch43 -p1
+%patch44 -p1
+%patch45 -p1
 
 %if %{with dynamic}
 sed -i -e 's/-static //' usr/Makefile
@@ -105,8 +135,13 @@ install usr/iscsistart $RPM_BUILD_ROOT%{_sbindir}
 install doc/iscsistart.8 $RPM_BUILD_ROOT%{_mandir}/man8
 install doc/iscsi-iname.8 $RPM_BUILD_ROOT%{_mandir}/man8
 
+install etc/systemd/iscsi.service $RPM_BUILD_ROOT%{systemdunitdir}
 install etc/systemd/iscsid.service $RPM_BUILD_ROOT%{systemdunitdir}
 install etc/systemd/iscsid.socket $RPM_BUILD_ROOT%{systemdunitdir}
+install etc/systemd/iscsiuio.service $RPM_BUILD_ROOT%{systemdunitdir}
+install etc/systemd/iscsiuio.socket $RPM_BUILD_ROOT%{systemdunitdir}
+
+install etc/systemd/iscsi-mark-root-nodes $RPM_BUILD_ROOT/lib/systemd/pld-helpers.d
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -152,8 +187,12 @@ fi
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/iscsiuio
 %attr(754,root,root) /etc/rc.d/init.d/iscsi
 %attr(754,root,root) /etc/rc.d/init.d/iscsi-devices
+%{systemdunitdir}/iscsi.service
 %{systemdunitdir}/iscsid.service
 %{systemdunitdir}/iscsid.socket
+%{systemdunitdir}/iscsiuio.service
+%{systemdunitdir}/iscsiuio.socket
+%attr(755,root,root) /lib/systemd/pld-helpers.d/iscsi-mark-root-nodes
 %attr(755,root,root) %{_sbindir}/iscsi-iname
 %attr(755,root,root) %{_sbindir}/iscsiadm
 %attr(755,root,root) %{_sbindir}/iscsid
diff --git a/0043-idmb_rec_write-check-for-tpgt-first.patch b/0043-idmb_rec_write-check-for-tpgt-first.patch
new file mode 100644
index 0000000..cdc958a
--- /dev/null
+++ b/0043-idmb_rec_write-check-for-tpgt-first.patch
@@ -0,0 +1,55 @@
+From 24a4d8156786dfd91dcc17b2472653e963ebd028 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 13 Aug 2013 10:59:44 -0700
+Subject: idmb_rec_write, check for tpgt first
+
+Factor out the check for a tpgt to a single place, before going crazy on
+the rec files.  Makes flow of this function easier to follow, and preps
+for splitting it up.
+---
+ usr/idbm.c | 18 +++++-------------
+ 1 file changed, 5 insertions(+), 13 deletions(-)
+
+diff --git a/usr/idbm.c b/usr/idbm.c
+index 1e4f8c8..0a88699 100644
+--- a/usr/idbm.c
++++ b/usr/idbm.c
+@@ -1849,6 +1849,10 @@ static int idbm_rec_write(node_rec_t *rec)
+ 	if (rc)
+ 		goto free_portal;
+ 
++	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
++		/* drop down to old style portal as config */
++		goto open_conf;
++
+ 	rc = stat(portal, &statb);
+ 	if (rc) {
+ 		rc = 0;
+@@ -1857,23 +1861,11 @@ static int idbm_rec_write(node_rec_t *rec)
+ 		 * set the tgpt. In new versions you must pass all the info in
+ 		 * from the start
+ 		 */
+-		if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
+-			/* drop down to old style portal as config */
+-			goto open_conf;
+-		else
+-			goto mkdir_portal;
++		goto mkdir_portal;
+ 	}
+ 
+ 	if (!S_ISDIR(statb.st_mode)) {
+ 		/*
+-		 * older iscsiadm versions had you create the config then set
+-		 * set the tgpt. In new versions you must pass all the info in
+-		 * from the start
+-		 */
+-		if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
+-			/* drop down to old style portal as config */
+-			goto open_conf;
+-		/*
+ 		 * Old style portal as a file, but with tpgt. Let's update it.
+ 		 */
+ 		if (unlink(portal)) {
+-- 
+1.8.1.4
+
diff --git a/0044-iscsid-add-initrd-option-to-set-run-from-initrd-hint.patch b/0044-iscsid-add-initrd-option-to-set-run-from-initrd-hint.patch
new file mode 100644
index 0000000..358b50c
--- /dev/null
+++ b/0044-iscsid-add-initrd-option-to-set-run-from-initrd-hint.patch
@@ -0,0 +1,61 @@
+From b1799fe84ed94a19bba6bcd7284ce8b038be4ffe Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Mon, 10 Dec 2012 13:20:47 -0800
+Subject: iscsid: add --initrd option to set run from initrd hint for systemd
+
+See http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
+
+Signed-off-by: Chris Leech <cleech at redhat.com>
+---
+ usr/iscsid.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/usr/iscsid.c b/usr/iscsid.c
+index b4bb65b..7d71085 100644
+--- a/usr/iscsid.c
++++ b/usr/iscsid.c
+@@ -61,6 +61,7 @@ static pid_t log_pid;
+ static gid_t gid;
+ static int daemonize = 1;
+ static int mgmt_ipc_fd;
++static int initrd = 0;
+ 
+ static struct option const long_options[] = {
+ 	{"config", required_argument, NULL, 'c'},
+@@ -73,6 +74,7 @@ static struct option const long_options[] = {
+ 	{"pid", required_argument, NULL, 'p'},
+ 	{"help", no_argument, NULL, 'h'},
+ 	{"version", no_argument, NULL, 'v'},
++	{"initrd", no_argument, &initrd, 1},
+ 	{NULL, 0, NULL, 0},
+ };
+ 
+@@ -95,6 +97,7 @@ Open-iSCSI initiator daemon.\n\
+   -p, --pid=pidfile       use pid file (default " PID_FILE ").\n\
+   -h, --help              display this help and exit\n\
+   -v, --version           display version and exit\n\
++  --initrd                run from initrd\n\
+ ");
+ 	}
+ 	exit(status);
+@@ -383,12 +386,17 @@ int main(int argc, char *argv[])
+ 		case 'h':
+ 			usage(0);
+ 			break;
++		case 0:
++			break;
+ 		default:
+ 			usage(1);
+ 			break;
+ 		}
+ 	}
+ 
++	if (initrd)
++		argv[0][0] = '@';
++
+ 	/* initialize logger */
+ 	log_pid = log_init(program_name, DEFAULT_AREA_SIZE,
+ 		      daemonize ? log_do_log_daemon : log_do_log_std, NULL);
+-- 
+1.7.11.7
+
diff --git a/0045-idbm_rec_write-seperate-old-and-new-style-writes.patch b/0045-idbm_rec_write-seperate-old-and-new-style-writes.patch
new file mode 100644
index 0000000..d138233
--- /dev/null
+++ b/0045-idbm_rec_write-seperate-old-and-new-style-writes.patch
@@ -0,0 +1,180 @@
+From 954a9492b5ed1de5907ad2a7d7cc0ae6215d8fac Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 13 Aug 2013 11:34:31 -0700
+Subject: idbm_rec_write, seperate old and new style writes
+
+Duplicates a small bit of code, but easier to understand and extened.
+---
+ usr/idbm.c | 116 +++++++++++++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 79 insertions(+), 37 deletions(-)
+
+diff --git a/usr/idbm.c b/usr/idbm.c
+index 0a88699..cb6ffd1 100644
+--- a/usr/idbm.c
++++ b/usr/idbm.c
+@@ -1808,7 +1808,7 @@ mkdir_portal:
+ 	return f;
+ }
+ 
+-static int idbm_rec_write(node_rec_t *rec)
++static int idbm_rec_write_new(node_rec_t *rec)
+ {
+ 	struct stat statb;
+ 	FILE *f;
+@@ -1820,38 +1820,8 @@ static int idbm_rec_write(node_rec_t *rec)
+ 		log_error("Could not alloc portal\n");
+ 		return ISCSI_ERR_NOMEM;
+ 	}
+-
+-	snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR);
+-	if (access(portal, F_OK) != 0) {
+-		if (mkdir(portal, 0660) != 0) {
+-			log_error("Could not make %s: %s\n", portal,
+-				  strerror(errno));
+-			rc = ISCSI_ERR_IDBM;
+-			goto free_portal;
+-		}
+-	}
+-
+-	snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name);
+-	if (access(portal, F_OK) != 0) {
+-		if (mkdir(portal, 0660) != 0) {
+-			log_error("Could not make %s: %s\n", portal,
+-				  strerror(errno));
+-			rc = ISCSI_ERR_IDBM;
+-			goto free_portal;
+-		}
+-	}
+-
+ 	snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
+ 		 rec->name, rec->conn[0].address, rec->conn[0].port);
+-	log_debug(5, "Looking for config file %s", portal);
+-
+-	rc = idbm_lock();
+-	if (rc)
+-		goto free_portal;
+-
+-	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
+-		/* drop down to old style portal as config */
+-		goto open_conf;
+ 
+ 	rc = stat(portal, &statb);
+ 	if (rc) {
+@@ -1872,11 +1842,11 @@ static int idbm_rec_write(node_rec_t *rec)
+ 			log_error("Could not convert %s: %s\n", portal,
+ 				  strerror(errno));
+ 			rc = ISCSI_ERR_IDBM;
+-			goto unlock;
++			goto free_portal;
+ 		}
+ 	} else {
+ 		rc = ISCSI_ERR_INVAL;
+-		goto unlock;
++		goto free_portal;
+ 	}	
+ 
+ mkdir_portal:
+@@ -1887,24 +1857,96 @@ mkdir_portal:
+ 			log_error("Could not make dir %s: %s\n",
+ 				  portal, strerror(errno));
+ 			rc = ISCSI_ERR_IDBM;
+-			goto unlock;
++			goto free_portal;
+ 		}
+ 	}
+ 
+ 	snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
+ 		 rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
+ 		 rec->iface.name);
+-open_conf:
++/* open_conf: */
+ 	f = fopen(portal, "w");
+ 	if (!f) {
+ 		log_error("Could not open %s: %sd\n", portal, strerror(errno));
+ 		rc = ISCSI_ERR_IDBM;
+-		goto unlock;
++		goto free_portal;
+ 	}
+ 
+ 	idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
+ 	fclose(f);
+-unlock:
++free_portal:
++	free(portal);
++	return rc;
++}
++
++static int idbm_rec_write_old(node_rec_t *rec)
++{
++	FILE *f;
++	char *portal;
++	int rc = 0;
++
++	portal = malloc(PATH_MAX);
++	if (!portal) {
++		log_error("Could not alloc portal\n");
++		return ISCSI_ERR_NOMEM;
++	}
++	snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
++		 rec->name, rec->conn[0].address, rec->conn[0].port);
++
++	f = fopen(portal, "w");
++	if (!f) {
++		log_error("Could not open %s: %sd\n", portal, strerror(errno));
++		rc = ISCSI_ERR_IDBM;
++		goto free_portal;
++	}
++	idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
++	fclose(f);
++free_portal:
++	free(portal);
++	return rc;
++}
++
++static int idbm_rec_write(node_rec_t *rec)
++{
++	char *portal;
++	int rc = 0;
++
++	portal = malloc(PATH_MAX);
++	if (!portal) {
++		log_error("Could not alloc portal\n");
++		return ISCSI_ERR_NOMEM;
++	}
++
++	snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR);
++	if (access(portal, F_OK) != 0) {
++		if (mkdir(portal, 0660) != 0) {
++			log_error("Could not make %s: %s\n", portal,
++				  strerror(errno));
++			rc = ISCSI_ERR_IDBM;
++			goto free_portal;
++		}
++	}
++
++	snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name);
++	if (access(portal, F_OK) != 0) {
++		if (mkdir(portal, 0660) != 0) {
++			log_error("Could not make %s: %s\n", portal,
++				  strerror(errno));
++			rc = ISCSI_ERR_IDBM;
++			goto free_portal;
++		}
++	}
++
++	rc = idbm_lock();
++	if (rc)
++		goto free_portal;
++
++	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
++		/* old style portal as config */
++		rc = idbm_rec_write_old(rec);
++	else
++		rc = idbm_rec_write_new(rec);
++
+ 	idbm_unlock();
+ free_portal:
+ 	free(portal);
+-- 
+1.8.1.4
+
diff --git a/0046-idbw_rec_write-pick-tpgt-from-existing-record.patch b/0046-idbw_rec_write-pick-tpgt-from-existing-record.patch
new file mode 100644
index 0000000..f69cef9
--- /dev/null
+++ b/0046-idbw_rec_write-pick-tpgt-from-existing-record.patch
@@ -0,0 +1,87 @@
+From ef61cd4912e90c8202598f2fa4e9f1842a5b5822 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 13 Aug 2013 12:39:07 -0700
+Subject: idbw_rec_write, pick tpgt from existing record
+
+On a static add (-m node -o new) without a user specified tpgt, looks
+for existing new style records with tpgt before creating an old style
+record without.  If one exists, take the tpgt from it an write an
+updated new style record instead.
+---
+ usr/idbm.c | 40 ++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 40 insertions(+)
+
+diff --git a/usr/idbm.c b/usr/idbm.c
+index cb6ffd1..0410079 100644
+--- a/usr/idbm.c
++++ b/usr/idbm.c
+@@ -27,6 +27,7 @@
+ #include <errno.h>
+ #include <dirent.h>
+ #include <limits.h>
++#include <glob.h>
+ #include <sys/stat.h>
+ #include <sys/file.h>
+ 
+@@ -162,6 +163,8 @@ static struct idbm *db;
+ 	_n++; \
+ } while(0)
+ 
++static int idbm_remove_disc_to_node_link(node_rec_t *rec, char *portal);
++
+ static void
+ idbm_recinfo_discovery(discovery_rec_t *r, recinfo_t *ri)
+ {
+@@ -1884,12 +1887,49 @@ static int idbm_rec_write_old(node_rec_t *rec)
+ 	FILE *f;
+ 	char *portal;
+ 	int rc = 0;
++	glob_t globbuf;
++	int i;
++	int tpgt = PORTAL_GROUP_TAG_UNKNOWN;
+ 
+ 	portal = malloc(PATH_MAX);
+ 	if (!portal) {
+ 		log_error("Could not alloc portal\n");
+ 		return ISCSI_ERR_NOMEM;
+ 	}
++
++	/* check for newer portal dir with tpgt */
++	snprintf(portal, PATH_MAX, "%s/%s/%s,%d,*", NODE_CONFIG_DIR,
++		 rec->name, rec->conn[0].address, rec->conn[0].port);
++	rc = glob(portal, GLOB_ONLYDIR, NULL, &globbuf);
++	if (!rc) {
++		if (globbuf.gl_pathc > 1)
++			log_warning("multiple tpg records for portal "
++				    "%s/%s:%d found", rec->name,
++				    rec->conn[0].address, rec->conn[0].port);
++		/* set pattern for sscanf matching of tpgt */
++		snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%%u", NODE_CONFIG_DIR,
++			 rec->name, rec->conn[0].address, rec->conn[0].port);
++		for (i = 0; i < globbuf.gl_pathc; i++) {
++			rc = sscanf(globbuf.gl_pathv[i], portal, &tpgt);
++			if (rc == 1)
++				break;
++		}
++		if (tpgt == PORTAL_GROUP_TAG_UNKNOWN)
++			log_warning("glob match on existing records, "
++				    "but no valid tpgt found");
++	}
++	globfree(&globbuf);
++	rc = 0;
++
++	/* if a tpgt was selected from an old record, write entry in new format */
++	if (tpgt != PORTAL_GROUP_TAG_UNKNOWN) {
++		log_warning("using tpgt %u from existing record", tpgt);
++		rec->tpgt = tpgt;
++		rc = idbm_remove_disc_to_node_link(rec, portal);
++		free(portal);
++		return idbm_rec_write_new(rec);
++	}
++
+ 	snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
+ 		 rec->name, rec->conn[0].address, rec->conn[0].port);
+ 
+-- 
+1.8.3.1
+
diff --git a/0047-iscsiadm-iscsid-newroot-command-to-survive-switch_ro.patch b/0047-iscsiadm-iscsid-newroot-command-to-survive-switch_ro.patch
new file mode 100644
index 0000000..7020e65
--- /dev/null
+++ b/0047-iscsiadm-iscsid-newroot-command-to-survive-switch_ro.patch
@@ -0,0 +1,158 @@
+From e5d7c7070358a5db8b849c8c5886e67881fe8906 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Fri, 7 Dec 2012 17:01:42 -0800
+Subject: [PATCH 47/47] iscsiadm, iscsid: newroot command to survive
+ switch_root
+
+When started from initramfs, iscsid needs to be able to chroot itself
+to the runtime filesystem before the switch_root occurs.  In the
+initramfs "iscsiadm --newroot {root fs mount before switch}" should be
+called before the switch_root.
+
+Signed-off-by: Chris Leech <cleech at redhat.com>
+---
+ usr/iscsiadm.c | 30 ++++++++++++++++++++++++++++++
+ usr/mgmt_ipc.c | 11 +++++++++++
+ usr/mgmt_ipc.h |  6 +++++-
+ 3 files changed, 46 insertions(+), 1 deletion(-)
+
+diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
+index da0a3ec..af6d607 100644
+--- a/usr/iscsiadm.c
++++ b/usr/iscsiadm.c
+@@ -117,6 +117,7 @@ static struct option const long_options[] =
+ 	{"interval", required_argument, NULL, 'i'},
+ 	{"flashnode_idx", optional_argument, NULL, 'x'},
+ 	{"portal_type", optional_argument, NULL, 'A'},
++	{"newroot", required_argument, NULL, 0},
+ 	{NULL, 0, NULL, 0},
+ };
+ static char *short_options = "RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:ux:A:";
+@@ -137,6 +138,7 @@ iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P  printlevel] [ -r sessionid
+ iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o  operation  ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]\n\
+ iscsiadm -m fw [ -d debug_level ] [ -l ]\n\
+ iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -x chap_tbl_idx ] ] | [ -C flashnode [ -A portal_type ] [ -x flashnode_idx ] ] | [ -C stats ] ] [ [ -o operation ] [ -n name ] [ -v value ] ] \n\
++iscsiadm --newroot switch_root_path\n\
+ iscsiadm -k priority\n");
+ 	}
+ 	exit(status);
+@@ -278,6 +280,22 @@ static void kill_iscsid(int priority)
+ 	}
+ }
+ 
++static void do_newroot(char *newroot)
++{
++	iscsiadm_req_t req;
++	iscsiadm_rsp_t rsp;
++	int rc;
++
++	memset(&req, 0, sizeof(req));
++	req.command = MGMT_IPC_NEWROOT;
++	strncpy(req.u.newroot.path, newroot, PATH_MAX);
++	rc = iscsid_exec_req(&req, &rsp, 0);
++	if (rc) {
++		iscsi_err_print_msg(rc);
++		log_error("Could not send NEWROOT command");
++	}
++}
++
+ /*
+  * TODO: we can display how the ifaces are related to node records.
+  * And we can add a scsi_host mode which would display how
+@@ -2800,6 +2818,7 @@ main(int argc, char **argv)
+ {
+ 	char *ip = NULL, *name = NULL, *value = NULL;
+ 	char *targetname = NULL, *group_session_mgmt_mode = NULL;
++	char *newroot = NULL;
+ 	int ch, longindex, mode=-1, port=-1, do_login=0, do_rescan=0;
+ 	int rc=0, sid=-1, op=OP_NOOP, type=-1, do_logout=0, do_stats=0;
+ 	int do_login_all=0, do_logout_all=0, info_level=-1, num_ifaces = 0;
+@@ -2837,6 +2856,12 @@ main(int argc, char **argv)
+ 	while ((ch = getopt_long(argc, argv, short_options,
+ 				 long_options, &longindex)) >= 0) {
+ 		switch (ch) {
++		case 0:
++			if (long_options[longindex].flag != 0)
++				break;
++			if (!strcmp(long_options[longindex].name, "newroot"))
++				newroot = optarg;
++			break;
+ 		case 'k':
+ 			killiscsid = atoi(optarg);
+ 			if (killiscsid < 0) {
+@@ -2989,6 +3014,11 @@ main(int argc, char **argv)
+ 		goto free_ifaces;
+ 	}
+ 
++	if (newroot) {
++		do_newroot(newroot);
++		goto free_ifaces;
++	}
++
+ 	if (mode < 0)
+ 		usage(ISCSI_ERR_INVAL);
+ 
+diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
+index 87bd346..5cb7143 100644
+--- a/usr/mgmt_ipc.c
++++ b/usr/mgmt_ipc.c
+@@ -226,6 +226,16 @@ mgmt_ipc_immediate_stop(queue_task_t *qtask)
+ }
+ 
+ static int
++mgmt_ipc_newroot(queue_task_t *qtask)
++{
++	char *newroot = qtask->req.u.newroot.path;
++	if (chdir(newroot) || chroot(".") || chdir("/"))
++		return ISCSI_ERR;
++	mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
++	return ISCSI_SUCCESS;
++}
++
++static int
+ mgmt_ipc_conn_remove(queue_task_t *qtask)
+ {
+ 	return ISCSI_ERR;
+@@ -534,6 +544,7 @@ static mgmt_ipc_fn_t *	mgmt_ipc_functions[__MGMT_IPC_MAX_COMMAND] = {
+ [MGMT_IPC_NOTIFY_DEL_NODE]	= mgmt_ipc_notify_del_node,
+ [MGMT_IPC_NOTIFY_ADD_PORTAL]	= mgmt_ipc_notify_add_portal,
+ [MGMT_IPC_NOTIFY_DEL_PORTAL]	= mgmt_ipc_notify_del_portal,
++[MGMT_IPC_NEWROOT]		= mgmt_ipc_newroot,
+ };
+ 
+ void mgmt_ipc_handle(int accept_fd)
+diff --git a/usr/mgmt_ipc.h b/usr/mgmt_ipc.h
+index 55972ed..102ffff 100644
+--- a/usr/mgmt_ipc.h
++++ b/usr/mgmt_ipc.h
+@@ -22,6 +22,7 @@
+ #include "types.h"
+ #include "iscsi_if.h"
+ #include "config.h"
++#include "limits.h"
+ 
+ #define ISCSIADM_NAMESPACE	"ISCSIADM_ABSTRACT_NAMESPACE"
+ #define PEERUSER_MAX		64
+@@ -46,6 +47,7 @@ typedef enum iscsiadm_cmd {
+ 	MGMT_IPC_NOTIFY_DEL_NODE	= 17,
+ 	MGMT_IPC_NOTIFY_ADD_PORTAL	= 18,
+ 	MGMT_IPC_NOTIFY_DEL_PORTAL	= 19,
++	MGMT_IPC_NEWROOT		= 20,
+ 
+ 	__MGMT_IPC_MAX_COMMAND
+ } iscsiadm_cmd_e;
+@@ -75,8 +77,10 @@ typedef struct iscsiadm_req {
+ 			int param;
+ 			/* TODO: make this variable len to support */
+ 			char value[IFNAMSIZ + 1];
+-
+ 		} set_host_param;
++		struct ipc_msg_newroot {
++			char path[PATH_MAX + 1];
++		} newroot;
+ 	} u;
+ } iscsiadm_req_t;
+ 
+-- 
+1.8.1.4
+
diff --git a/0047-iscsiuio-systemd-socket-activation-support.patch b/0047-iscsiuio-systemd-socket-activation-support.patch
new file mode 100644
index 0000000..896eba9
--- /dev/null
+++ b/0047-iscsiuio-systemd-socket-activation-support.patch
@@ -0,0 +1,58 @@
+From 8003178db245b43d04b27b559d5541ced24ec13f Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Wed, 19 Dec 2012 21:39:06 -0800
+Subject: [PATCH] iscsiuio systemd socket activation support
+
+---
+ iscsiuio/src/unix/iscsid_ipc.c | 28 ++++++++++++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
+index e22de0d..4908cb7 100644
+--- a/iscsiuio/src/unix/iscsid_ipc.c
++++ b/iscsiuio/src/unix/iscsid_ipc.c
+@@ -948,6 +948,30 @@ static void *iscsid_loop(void *arg)
+ 	pthread_exit(NULL);
+ }
+ 
++#define SD_SOCKET_FDS_START 3
++
++static int ipc_systemd(void)
++{
++	char *env;
++
++	env = getenv("LISTEN_PID");
++
++	if (!env || (strtoul(env, NULL, 10) != getpid()))
++		return -EINVAL;
++
++	env = getenv("LISTEN_FDS");
++
++	if (!env)
++		return -EINVAL;
++
++	if (strtoul(env, NULL, 10) != 1) {
++		LOG_ERR("Did not receive exactly one IPC socket from systemd");
++		return -EINVAL;
++	}
++
++	return SD_SOCKET_FDS_START;
++}
++
+ /******************************************************************************
+  *  Initialize/Cleanup routines
+  ******************************************************************************/
+@@ -961,6 +985,10 @@ int iscsid_init()
+ 	int rc, addr_len;
+ 	struct sockaddr_un addr;
+ 
++	iscsid_opts.fd = ipc_systemd();
++	if (iscsid_opts.fd >= 0)
++		return 0;
++
+ 	iscsid_opts.fd = socket(AF_LOCAL, SOCK_STREAM, 0);
+ 	if (iscsid_opts.fd < 0) {
+ 		LOG_ERR(PFX "Can not create IPC socket");
+-- 
+1.8.3.1
+
diff --git a/0048-iscsiadm-param-parsing-for-advanced-node-creation.patch b/0048-iscsiadm-param-parsing-for-advanced-node-creation.patch
new file mode 100644
index 0000000..a39833b
--- /dev/null
+++ b/0048-iscsiadm-param-parsing-for-advanced-node-creation.patch
@@ -0,0 +1,337 @@
+From b58f3b48a36821d10a3377acfcbf18113fba0c9d Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 18 Dec 2012 11:27:00 -0800
+Subject: [PATCH 48/48] iscsiadm: --param parsing for advanced node creation
+
+Share parse_param and apply_param code from iscsistart, allow using multiple
+--param options to set arbitrary fields in node mode.
+
+Signed-off-by: Chris Leech <cleech at redhat.com>
+---
+ usr/Makefile      |  2 +-
+ usr/iscsi_param.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ usr/iscsi_param.h |  7 ++++
+ usr/iscsiadm.c    | 16 ++++++++--
+ usr/iscsistart.c  | 91 ++--------------------------------------------------
+ 5 files changed, 120 insertions(+), 91 deletions(-)
+ create mode 100644 usr/iscsi_param.c
+ create mode 100644 usr/iscsi_param.h
+
+diff --git a/usr/Makefile b/usr/Makefile
+index 3d8ee22..a7e80c0 100644
+--- a/usr/Makefile
++++ b/usr/Makefile
+@@ -40,7 +40,7 @@ SYSDEPS_SRCS = $(wildcard ../utils/sysdeps/*.o)
+ ISCSI_LIB_SRCS = iscsi_util.o io.o auth.o iscsi_timer.o login.o log.o md5.o \
+ 	sha1.o iface.o idbm.o sysfs.o host.o session_info.o iscsi_sysfs.o \
+ 	iscsi_net_util.o iscsid_req.o transport.o iser.o cxgbi.o be2iscsi.o \
+-	initiator_common.o iscsi_err.o flashnode.o uip_mgmt_ipc.o \
++	initiator_common.o iscsi_err.o iscsi_param.o flashnode.o uip_mgmt_ipc.o \
+ 	$(IPC_OBJ)  $(SYSDEPS_SRCS)
+ # core initiator files
+ INITIATOR_SRCS = initiator.o scsi.o actor.o event_poll.o mgmt_ipc.o kern_err_table.o
+diff --git a/usr/iscsi_param.c b/usr/iscsi_param.c
+new file mode 100644
+index 0000000..c075e8f
+--- /dev/null
++++ b/usr/iscsi_param.c
+@@ -0,0 +1,95 @@
++#include <string.h>
++#include "log.h"
++#include "config.h"
++#include "idbm.h"
++#include "list.h"
++#include "iface.h"
++#include "idbm_fields.h"
++#include "iscsi_err.h"
++
++int apply_params(struct list_head *user_params, struct node_rec *rec)
++{
++	struct user_param *param;
++	int rc;
++
++	/* Must init this so we can check if user overrode them */
++	rec->session.initial_login_retry_max = -1;
++	rec->conn[0].timeo.noop_out_interval = -1;
++	rec->conn[0].timeo.noop_out_timeout = -1;
++
++	list_for_each_entry(param, user_params, list) {
++		/*
++		 * user may not have passed in all params that were set by
++		 * ibft/iscsi_boot, so clear out values that might conflict
++		 * with user overrides
++		 */
++		if (!strcmp(param->name, IFACE_NETNAME)) {
++			/* overriding netname so MAC will be for old netdev */
++			memset(rec->iface.hwaddress, 0,
++				sizeof(rec->iface.hwaddress));
++		} else if (!strcmp(param->name, IFACE_HWADDR)) {
++			/* overriding MAC so netdev will be for old MAC */
++			memset(rec->iface.netdev, 0, sizeof(rec->iface.netdev));
++		} else if (!strcmp(param->name, IFACE_TRANSPORTNAME)) {
++			/*
++			 * switching drivers so all old binding info is no
++			 * longer valid. Old values were either for offload
++			 * and we are switching to software or the reverse,
++			 * or switching types of cards (bnx2i to cxgb3i).
++			 */
++			memset(&rec->iface, 0, sizeof(rec->iface));
++			iface_setup_defaults(&rec->iface);
++		}
++	}
++
++	rc = idbm_node_set_rec_from_param(user_params, rec, 0);
++	if (rc)
++		return rc;
++
++	/*
++	 * For root boot we could not change this in older versions so
++	 * if user did not override then use the defaults.
++	 *
++	 * Increase to account for boot using static setup.
++	 */
++	if (rec->session.initial_login_retry_max == -1)
++		rec->session.initial_login_retry_max = 30;
++	/* we used to not be able to answer so turn off */
++	if (rec->conn[0].timeo.noop_out_interval == -1)
++		rec->conn[0].timeo.noop_out_interval = 0;
++	if (rec->conn[0].timeo.noop_out_timeout == -1)
++		rec->conn[0].timeo.noop_out_timeout = 0;
++
++	return 0;
++}
++
++int parse_param(struct list_head *user_params, char *param_str)
++{
++	struct user_param *param;
++	char *name, *value;
++
++	name = param_str;
++
++	value = strchr(param_str, '=');
++	if (!value) {
++		log_error("Invalid --param %s. Missing value.", param_str);
++		return ISCSI_ERR_INVAL;
++	}
++	*value = '\0';
++
++	value++;
++	if (!strlen(value)) {
++		log_error("Invalid --param %s. Missing value.", param_str);
++		return ISCSI_ERR_INVAL;
++	}
++
++	param = idbm_alloc_user_param(name, value);
++	if (!param) {
++		log_error("Could not allocate memory for param.");
++		return ISCSI_ERR_NOMEM;
++	}
++
++	list_add(&param->list, user_params);
++	return 0;
++}
++
+diff --git a/usr/iscsi_param.h b/usr/iscsi_param.h
+new file mode 100644
+index 0000000..8b7956c
+--- /dev/null
++++ b/usr/iscsi_param.h
+@@ -0,0 +1,7 @@
++#ifndef ISCSI_PARAM_H
++#define ISCSI_PARAM_H
++
++extern int parse_param(struct list_head *user_params, char *param_str);
++extern int apply_params(struct list_head *user_params, struct node_rec *rec);
++
++#endif
+diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
+index af6d607..2003d48 100644
+--- a/usr/iscsiadm.c
++++ b/usr/iscsiadm.c
+@@ -53,6 +53,7 @@
+ #include "iscsi_err.h"
+ #include "iscsi_ipc.h"
+ #include "iscsi_timer.h"
++#include "iscsi_param.h"
+ #include "flashnode.h"
+ 
+ static char program_name[] = "iscsiadm";
+@@ -118,6 +119,7 @@ static struct option const long_options[] =
+ 	{"flashnode_idx", optional_argument, NULL, 'x'},
+ 	{"portal_type", optional_argument, NULL, 'A'},
+ 	{"newroot", required_argument, NULL, 0},
++	{"param", required_argument, NULL, 0},
+ 	{NULL, 0, NULL, 0},
+ };
+ static char *short_options = "RlDVhm:a:b:c:C:p:P:T:H:i:I:U:k:L:d:r:n:v:o:sSt:ux:A:";
+@@ -133,7 +135,7 @@ iscsiadm -m discoverydb [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p
+ [ -o operation ] [ -n name ] [ -v value ] [ -lD ] ] \n\
+ iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ [ -p ip:port ] [ -l | -D ] ] \n\
+ iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,automatic ] [ -U all,manual,automatic ] [ -S ] [ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u | -R | -s] ] \
+-[ [ -o  operation  ] [ -n name ] [ -v value ] ]\n\
++[ [ -o  operation  ] [ -n name ] [ -v value ] ] [ --param=NAME=VALUE ]\n\
+ iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P  printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]\n\
+ iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o  operation  ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]\n\
+ iscsiadm -m fw [ -d debug_level ] [ -l ]\n\
+@@ -2834,9 +2836,11 @@ main(int argc, char **argv)
+ 	uint32_t host_no = -1;
+ 	struct user_param *param;
+ 	struct list_head params;
++	struct list_head user_params;
+ 
+ 	INIT_LIST_HEAD(&params);
+ 	INIT_LIST_HEAD(&ifaces);
++	INIT_LIST_HEAD(&user_params);
+ 	/* do not allow ctrl-c for now... */
+ 	memset(&sa_old, 0, sizeof(struct sigaction));
+ 	memset(&sa_new, 0, sizeof(struct sigaction));
+@@ -2859,8 +2863,14 @@ main(int argc, char **argv)
+ 		case 0:
+ 			if (long_options[longindex].flag != 0)
+ 				break;
+-			if (!strcmp(long_options[longindex].name, "newroot"))
++			if (!strcmp(long_options[longindex].name, "newroot")) {
+ 				newroot = optarg;
++				break;
++			}
++			if (!strcmp(long_options[longindex].name, "param")) {
++				parse_param(&user_params, optarg);
++				break;
++			}
+ 			break;
+ 		case 'k':
+ 			killiscsid = atoi(optarg);
+@@ -3169,6 +3179,8 @@ main(int argc, char **argv)
+ 			goto out;
+ 		}
+ 
++		apply_params(&user_params, rec);
++
+ 		rc = exec_node_op(op, do_login, do_logout, do_show,
+ 				  do_rescan, do_stats, info_level, rec,
+ 				  &params);
+diff --git a/usr/iscsistart.c b/usr/iscsistart.c
+index 6924d49..85be35b 100644
+--- a/usr/iscsistart.c
++++ b/usr/iscsistart.c
+@@ -50,6 +50,7 @@
+ #include "iscsid_req.h"
+ #include "iscsi_err.h"
+ #include "iface.h"
++#include "iscsi_param.h"
+ 
+ /* global config info */
+ /* initiator needs initiator name/alias */
+@@ -131,99 +132,13 @@ static int stop_event_loop(void)
+ 	return rc;
+ }
+ 
+-static int apply_params(struct node_rec *rec)
+-{
+-	struct user_param *param;
+-	int rc;
+-
+-	/* Must init this so we can check if user overrode them */
+-	rec->session.initial_login_retry_max = -1;
+-	rec->conn[0].timeo.noop_out_interval = -1;
+-	rec->conn[0].timeo.noop_out_timeout = -1;
+-
+-	list_for_each_entry(param, &user_params, list) {
+-		/*
+-		 * user may not have passed in all params that were set by
+-		 * ibft/iscsi_boot, so clear out values that might conflict
+-		 * with user overrides
+-		 */
+-		if (!strcmp(param->name, IFACE_NETNAME)) {
+-			/* overriding netname so MAC will be for old netdev */
+-			memset(rec->iface.hwaddress, 0,
+-				sizeof(rec->iface.hwaddress));
+-		} else if (!strcmp(param->name, IFACE_HWADDR)) {
+-			/* overriding MAC so netdev will be for old MAC */
+-			memset(rec->iface.netdev, 0, sizeof(rec->iface.netdev));
+-		} else if (!strcmp(param->name, IFACE_TRANSPORTNAME)) {
+-			/*
+-			 * switching drivers so all old binding info is no
+-			 * longer valid. Old values were either for offload
+-			 * and we are switching to software or the reverse,
+-			 * or switching types of cards (bnx2i to cxgb3i).
+-			 */
+-			memset(&rec->iface, 0, sizeof(rec->iface));
+-			iface_setup_defaults(&rec->iface);
+-		}
+-	}
+-
+-	rc = idbm_node_set_rec_from_param(&user_params, rec, 0);
+-	if (rc)
+-		return rc;
+-
+-	/*
+-	 * For root boot we could not change this in older versions so
+-	 * if user did not override then use the defaults.
+-	 *
+-	 * Increase to account for boot using static setup.
+-	 */
+-	if (rec->session.initial_login_retry_max == -1)
+-		rec->session.initial_login_retry_max = 30;
+-	/* we used to not be able to answer so turn off */
+-	if (rec->conn[0].timeo.noop_out_interval == -1)
+-		rec->conn[0].timeo.noop_out_interval = 0;
+-	if (rec->conn[0].timeo.noop_out_timeout == -1)
+-		rec->conn[0].timeo.noop_out_timeout = 0;
+-
+-	return 0;
+-}
+-
+-static int parse_param(char *param_str)
+-{
+-	struct user_param *param;
+-	char *name, *value;
+-
+-	name = param_str;
+-
+-	value = strchr(param_str, '=');
+-	if (!value) {
+-		log_error("Invalid --param %s. Missing value.", param_str);
+-		return ISCSI_ERR_INVAL;
+-	}
+-	*value = '\0';
+-
+-	value++;
+-	if (!strlen(value)) {
+-		log_error("Invalid --param %s. Missing value.", param_str);
+-		return ISCSI_ERR_INVAL;
+-	}
+-
+-	param = idbm_alloc_user_param(name, value);
+-	if (!param) {
+-		log_error("Could not allocate memory for param.");
+-		return ISCSI_ERR_NOMEM;
+-	}
+-
+-	list_add(&param->list, &user_params);
+-	return 0;
+-}
+-
+ static int login_session(struct node_rec *rec)
+ {
+ 	iscsiadm_req_t req;
+ 	iscsiadm_rsp_t rsp;
+ 	int rc, retries = 0;
+ 
+-	rc = apply_params(rec);
++	rc = apply_params(&user_params, rec);
+ 	if (rc)
+ 		return rc;
+ 
+@@ -426,7 +341,7 @@ int main(int argc, char *argv[])
+ 			fw_free_targets(&targets);
+ 			exit(0);
+ 		case 'P':
+-			err = parse_param(optarg);
++			err = parse_param(&user_params, optarg);
+ 			if (err)
+ 				exit(err);
+ 			break;
+-- 
+1.8.1.4
+
diff --git a/0049-update-systemd-service-files-add-iscsi.service-for-s.patch b/0049-update-systemd-service-files-add-iscsi.service-for-s.patch
new file mode 100644
index 0000000..966bb9f
--- /dev/null
+++ b/0049-update-systemd-service-files-add-iscsi.service-for-s.patch
@@ -0,0 +1,93 @@
+From 1c3b1d23e0b3f17399ffd4463cafad813b0444d5 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Wed, 19 Dec 2012 15:07:36 -0800
+Subject: update systemd service files, add iscsi.service for starting
+ sessions on boot
+
+Signed-off-by: Chris Leech <cleech at redhat.com>
+---
+ etc/systemd/iscsi.service         | 19 +++++++++++++++++++
+ etc/systemd/iscsi_mark_root_nodes | 14 ++++++++++++++
+ etc/systemd/iscsid.service        |  7 +++++--
+ etc/systemd/iscsid.socket         |  2 +-
+ 4 files changed, 39 insertions(+), 3 deletions(-)
+ create mode 100644 etc/systemd/iscsi.service
+ create mode 100755 etc/systemd/iscsi_mark_root_nodes
+
+diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service
+new file mode 100644
+index 0000000..bbd52fd
+--- /dev/null
++++ b/etc/systemd/iscsi.service
+@@ -0,0 +1,19 @@
++[Unit]
++Description=Login and scanning of iSCSI devices
++Documentation=man:iscsid(8) man:iscsiadm(8)
++DefaultDependencies=no
++Conflicts=shutdown.target
++After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
++Before=remote-fs-pre.target
++ConditionPathExists=/etc/iscsi/initiatorname.iscsi
++
++[Service]
++Type=oneshot
++RemainAfterExit=true
++ExecStart=/usr/libexec/iscsi_mark_root_nodes
++ExecStart=/sbin/iscsiadm -m node --loginall=automatic
++ExecStop=/bin/sync
++ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
++
++[Install]
++WantedBy=sysinit.target
+diff --git a/etc/systemd/iscsi_mark_root_nodes b/etc/systemd/iscsi_mark_root_nodes
+new file mode 100755
+index 0000000..c68475c
+--- /dev/null
++++ b/etc/systemd/iscsi_mark_root_nodes
+@@ -0,0 +1,14 @@
++#!/bin/bash
++
++ISCSIADM=/sbin/iscsiadm
++SESSION_FILE=/run/initramfs/iscsi.sessions
++
++if [ ! -f $SESSION_FILE ] ; then
++  exit 0
++fi
++
++while read t num i target; do
++  ip=${i%:*}
++  $ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
++done < $SESSION_FILE
++
+diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service
+index 028e0b3..653dd08 100644
+--- a/etc/systemd/iscsid.service
++++ b/etc/systemd/iscsid.service
+@@ -1,7 +1,10 @@
+ [Unit]
+ Description=Open-iSCSI
+-Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8)
+-After=network.target NetworkManager-wait-online.service iscsiuio.service tgtd.service targetcli.service
++Documentation=man:iscsid(8) man:iscsiadm(8)
++DefaultDependencies=no
++Conflicts=shutdown.target
++After=network.target iscsiuio.service
++Before=remote-fs-pre.target
+ 
+ [Service]
+ Type=forking
+diff --git a/etc/systemd/iscsid.socket b/etc/systemd/iscsid.socket
+index 832451d..58a8d12 100644
+--- a/etc/systemd/iscsid.socket
++++ b/etc/systemd/iscsid.socket
+@@ -1,6 +1,6 @@
+ [Unit]
+ Description=Open-iSCSI iscsid Socket
+-Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8)
++Documentation=man:iscsid(8) man:iscsiadm(8)
+ 
+ [Socket]
+ ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
+-- 
+1.7.11.7
+
diff --git a/0050-iscsi-boot-related-service-file-updates.patch b/0050-iscsi-boot-related-service-file-updates.patch
new file mode 100644
index 0000000..f670072
--- /dev/null
+++ b/0050-iscsi-boot-related-service-file-updates.patch
@@ -0,0 +1,74 @@
+From 8f79529354b4023c371e00091f11bdd523497639 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Mon, 19 Aug 2013 07:18:25 -0700
+Subject: iscsi boot related service file updates
+
+make sure iscsid gets started if there are any boot sessions running
+add reload target to fix double session problem when restarting from NM
+don't rely on session list passed from initrd, never got fully implemented
+---
+ etc/systemd/iscsi-mark-root-nodes | 13 +++++++++++++
+ etc/systemd/iscsi.service         |  3 ++-
+ etc/systemd/iscsi_mark_root_nodes | 14 --------------
+ 3 files changed, 15 insertions(+), 15 deletions(-)
+ create mode 100644 etc/systemd/iscsi-mark-root-nodes
+ delete mode 100644 etc/systemd/iscsi_mark_root_nodes
+
+diff --git a/etc/systemd/iscsi-mark-root-nodes b/etc/systemd/iscsi-mark-root-nodes
+new file mode 100644
+index 0000000..157be62
+--- /dev/null
++++ b/etc/systemd/iscsi-mark-root-nodes
+@@ -0,0 +1,12 @@
++#!/bin/sh
++
++ISCSIADM=/sbin/iscsiadm
++
++$ISCSIADM -m session >/dev/null 2>&1 || exit 0
++
++$ISCSIADM -m session | while read t num i target; do
++	ip=${i%:*}
++	$ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
++done
++
++systemctl start iscsid.service
+diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service
+index 7b4efee..d5712bd 100644
+--- a/etc/systemd/iscsi.service
++++ b/etc/systemd/iscsi.service
+@@ -10,10 +10,11 @@ ConditionDirectoryNotEmpty=/var/lib/iscsi/nodes
+ [Service]
+ Type=oneshot
+ RemainAfterExit=true
+-ExecStart=/usr/libexec/iscsi_mark_root_nodes
++ExecStart=/lib/systemd/pld-helpers.d/iscsi-mark-root-nodes
+ ExecStart=/sbin/iscsiadm -m node --loginall=automatic
+ ExecStop=/bin/sync
+ ExecStop=/sbin/iscsiadm -m node --logoutall=automatic
++ExecReload=/sbin/iscsiadm -m node --loginall=automatic
+ 
+ [Install]
+ WantedBy=sysinit.target
+diff --git a/etc/systemd/iscsi_mark_root_nodes b/etc/systemd/iscsi_mark_root_nodes
+deleted file mode 100644
+index c68475c..0000000
+--- a/etc/systemd/iscsi_mark_root_nodes
++++ /dev/null
+@@ -1,14 +0,0 @@
+-#!/bin/bash
+-
+-ISCSIADM=/sbin/iscsiadm
+-SESSION_FILE=/run/initramfs/iscsi.sessions
+-
+-if [ ! -f $SESSION_FILE ] ; then
+-  exit 0
+-fi
+-
+-while read t num i target; do
+-  ip=${i%:*}
+-  $ISCSIADM -m node -p $ip -T $target -o update -n node.startup -v onboot
+-done < $SESSION_FILE
+-
+-- 
+1.8.1.4
+
diff --git a/0058-iscsiuio-IPC-newroot-command.patch b/0058-iscsiuio-IPC-newroot-command.patch
new file mode 100644
index 0000000..fa3f4c7
--- /dev/null
+++ b/0058-iscsiuio-IPC-newroot-command.patch
@@ -0,0 +1,122 @@
+From 6e979154c9c51dedd54c91e46106e495a65ced43 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Wed, 2 Jan 2013 14:45:05 -0800
+Subject: [PATCH 58/58] iscsiuio IPC newroot command
+
+---
+ usr/mgmt_ipc.c     | 11 +++++++++++
+ usr/transport.c    |  1 +
+ usr/transport.h    |  1 +
+ usr/uip_mgmt_ipc.c | 14 ++++++++++++++
+ usr/uip_mgmt_ipc.h |  5 +++++
+ 5 files changed, 32 insertions(+)
+
+diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
+index 5cb7143..a8f8473 100644
+--- a/usr/mgmt_ipc.c
++++ b/usr/mgmt_ipc.c
+@@ -36,6 +36,7 @@
+ #include "sysdeps.h"
+ #include "iscsi_ipc.h"
+ #include "iscsi_err.h"
++#include "iscsi_sysfs.h"
+ 
+ #define PEERUSER_MAX	64
+ #define EXTMSG_MAX	(64 * 1024)
+@@ -229,8 +230,18 @@ static int
+ mgmt_ipc_newroot(queue_task_t *qtask)
+ {
+ 	char *newroot = qtask->req.u.newroot.path;
++	struct iscsi_transport *t;
++
+ 	if (chdir(newroot) || chroot(".") || chdir("/"))
+ 		return ISCSI_ERR;
++
++	/* if a registered transport has a separate userspace process,
++	 * notify it of the root change as well */
++	list_for_each_entry(t, &transports, list) {
++		if (t->template->newroot)
++			t->template->newroot(t, newroot);
++	}
++
+ 	mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
+ 	return ISCSI_SUCCESS;
+ }
+diff --git a/usr/transport.c b/usr/transport.c
+index 4d030a8..e0488ad 100644
+--- a/usr/transport.c
++++ b/usr/transport.c
+@@ -83,6 +83,7 @@ struct iscsi_transport_template bnx2i = {
+ 	.ep_poll	= ktransport_ep_poll,
+ 	.ep_disconnect	= ktransport_ep_disconnect,
+ 	.set_net_config = uip_broadcast_params,
++	.newroot	= uip_broadcast_newroot,
+ };
+ 
+ struct iscsi_transport_template be2iscsi = {
+diff --git a/usr/transport.h b/usr/transport.h
+index 388e4b1..d4d9ec7 100644
+--- a/usr/transport.h
++++ b/usr/transport.h
+@@ -39,6 +39,7 @@ struct iscsi_transport_template {
+ 	int (*set_net_config) (struct iscsi_transport *t,
+ 			       struct iface_rec *iface,
+ 			       struct iscsi_session *session);
++	void (*newroot) (struct iscsi_transport *t, char *path);
+ };
+ 
+ /* represents data path provider */
+diff --git a/usr/uip_mgmt_ipc.c b/usr/uip_mgmt_ipc.c
+index f3074ee..d5d496a 100644
+--- a/usr/uip_mgmt_ipc.c
++++ b/usr/uip_mgmt_ipc.c
+@@ -39,3 +39,17 @@ int uip_broadcast_params(struct iscsi_transport *t,
+ 			     sizeof(iscsid_uip_broadcast_header_t) +
+ 			     sizeof(*iface));
+ }
++
++int uip_broadcast_newroot(struct iscsi_transport *t, char *newroot)
++{
++	struct iscsid_uip_broadcast broadcast;
++
++	memset(&broadcast, 0, sizeof(broadcast));
++
++	broadcast.header.command = ISCSID_UIP_NEWROOT;
++	strncpy(broadcast.u.newroot.path, newroot, PATH_MAX);
++
++	return uip_broadcast(&broadcast,
++			     sizeof(iscsid_uip_broadcast_header_t) +
++			     PATH_MAX + 1);
++}
+diff --git a/usr/uip_mgmt_ipc.h b/usr/uip_mgmt_ipc.h
+index 29a4769..3ca4fb1 100644
+--- a/usr/uip_mgmt_ipc.h
++++ b/usr/uip_mgmt_ipc.h
+@@ -29,6 +29,7 @@
+ typedef enum iscsid_uip_cmd {
+ 	ISCSID_UIP_IPC_UNKNOWN			= 0,
+ 	ISCSID_UIP_IPC_GET_IFACE		= 1,
++	ISCSID_UIP_NEWROOT			= 2,
+ 
+ 	__ISCSID_UIP_IPC_MAX_COMMAND
+ } iscsid_uip_cmd_e;
+@@ -47,6 +48,9 @@ typedef struct iscsid_uip_broadcast {
+ 		struct ipc_broadcast_iface_rec {
+ 			struct iface_rec rec;
+ 		} iface_rec;
++		struct ipc_broadcast_newroot {
++			char path[PATH_MAX + 1];
++		} newroot;
+ 	} u;
+ } iscsid_uip_broadcast_t;
+ 
+@@ -69,5 +73,6 @@ extern int uip_broadcast_params(struct iscsi_transport *t,
+ 				struct iface_rec *iface,
+ 				struct iscsi_session *session);
+ 
++extern int uip_broadcast_newroot(struct iscsi_transport *t, char *path);
+ 
+ #endif /* UIP_MGMT_IPC_H */
+-- 
+1.8.1.4
+
diff --git a/0059-iscsiuio-systemd-unit-files.patch b/0059-iscsiuio-systemd-unit-files.patch
new file mode 100644
index 0000000..2d0e213
--- /dev/null
+++ b/0059-iscsiuio-systemd-unit-files.patch
@@ -0,0 +1,53 @@
+From 822b53e6c9ebb0fe7236ebd3b4c73b009100592d Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 22 Jan 2013 14:27:12 -0800
+Subject: iscsiuio systemd unit files
+
+---
+ etc/systemd/iscsiuio.service | 17 +++++++++++++++++
+ etc/systemd/iscsiuio.socket  |  9 +++++++++
+ 2 files changed, 26 insertions(+)
+ create mode 100644 etc/systemd/iscsiuio.service
+ create mode 100644 etc/systemd/iscsiuio.socket
+
+diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service
+new file mode 100644
+index 0000000..f0410b7
+--- /dev/null
++++ b/etc/systemd/iscsiuio.service
+@@ -0,0 +1,17 @@
++[Unit]
++Description=iSCSI UserSpace I/O driver
++Documentation=man:iscsiuio(8)
++DefaultDependencies=no
++Conflicts=shutdown.target
++Requires=iscsid.service
++BindTo=iscsid.service
++After=network.target
++Before=remote-fs-pre.target iscsid.service
++
++[Service]
++Type=forking
++PIDFile=/var/run/iscsiuio.pid
++ExecStart=/usr/sbin/iscsiuio
++
++[Install]
++WantedBy=multi-user.target
+diff --git a/etc/systemd/iscsiuio.socket b/etc/systemd/iscsiuio.socket
+new file mode 100644
+index 0000000..d42cedc
+--- /dev/null
++++ b/etc/systemd/iscsiuio.socket
+@@ -0,0 +1,9 @@
++[Unit]
++Description=Open-iSCSI iscsiuio Socket
++Documentation=man:iscsiuio(8)
++
++[Socket]
++ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
++
++[Install]
++WantedBy=sockets.target
+-- 
+1.7.11.7
+
diff --git a/0062-Don-t-check-for-autostart-sessions-if-iscsi-is-not-u.patch b/0062-Don-t-check-for-autostart-sessions-if-iscsi-is-not-u.patch
new file mode 100644
index 0000000..684463f
--- /dev/null
+++ b/0062-Don-t-check-for-autostart-sessions-if-iscsi-is-not-u.patch
@@ -0,0 +1,30 @@
+From ab79bdb20e37216ca969e06d63a952acfd023963 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 28 May 2013 13:12:27 -0700
+Subject: [PATCH] Don't check for autostart sessions if iscsi is not used (bug
+ #951951)
+
+Change conditional startup in iscsi.service to check for a non-empty
+nodes directory, instead of initiator-name.  This fits better with what
+it's doing, as there's no need to scan for autostart node records if
+there are no node records at all.
+---
+ etc/systemd/iscsi.service | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service
+index bbd52fd..7b4efee 100644
+--- a/etc/systemd/iscsi.service
++++ b/etc/systemd/iscsi.service
+@@ -5,7 +5,7 @@ DefaultDependencies=no
+ Conflicts=shutdown.target
+ After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service
+ Before=remote-fs-pre.target
+-ConditionPathExists=/etc/iscsi/initiatorname.iscsi
++ConditionDirectoryNotEmpty=/var/lib/iscsi/nodes
+ 
+ [Service]
+ Type=oneshot
+-- 
+1.8.1.4
+
diff --git a/0063-fix-order-of-setting-uid-gid-and-drop-supplementary-.patch b/0063-fix-order-of-setting-uid-gid-and-drop-supplementary-.patch
new file mode 100644
index 0000000..cedb4e0
--- /dev/null
+++ b/0063-fix-order-of-setting-uid-gid-and-drop-supplementary-.patch
@@ -0,0 +1,68 @@
+From 3cac85a3f97d0a22270166f428209f873b58c319 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Tue, 11 Jun 2013 11:25:27 -0700
+Subject: [PATCH] iscsid: fix order of setting uid/gid and drop supplementary
+ groups
+
+If using the user and group ID settings together the existing order of
+calling setuid first will almost always cause the setgid call to fail,
+assuming the new effective user id does not have the CAP_SETGID
+capability.  The effective group ID needs to change first.
+
+While we're at it, if iscsid is started as root it should drop any
+inherited supplementary group permissions.
+
+And if anyone is actually using this to try and isolate capabilities,
+they probably care enough to want to known that it is failing.  Make
+iscsid startup fail instead of just calling perror.
+
+Signed-off-by: Chris Leech <cleech at redhat.com>
+---
+ usr/iscsid.c | 23 +++++++++++++++++++----
+ 1 file changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/usr/iscsid.c b/usr/iscsid.c
+index b4bb65b..c0ea6fa 100644
+--- a/usr/iscsid.c
++++ b/usr/iscsid.c
+@@ -27,6 +27,7 @@
+ #include <unistd.h>
+ #include <string.h>
+ #include <signal.h>
++#include <grp.h>
+ #include <sys/mman.h>
+ #include <sys/utsname.h>
+ #include <sys/types.h>
+@@ -477,11 +478,25 @@ int main(int argc, char *argv[])
+ 		}
+ 	}
+ 
+-	if (uid && setuid(uid) < 0)
+-		perror("setuid\n");
++	if (gid && setgid(gid) < 0) {
++		log_error("Unable to setgid to %d\n", gid);
++		log_close(log_pid);
++		exit(ISCSI_ERR);
++	}
+ 
+-	if (gid && setgid(gid) < 0)
+-		perror("setgid\n");
++	if ((geteuid() == 0) && (getgroups(0, NULL))) {
++		if (setgroups(0, NULL) != 0) {
++			log_error("Unable to drop supplementary group ids\n");
++			log_close(log_pid);
++			exit(ISCSI_ERR);
++		}
++	}
++
++	if (uid && setuid(uid) < 0) {
++		log_error("Unable to setuid to %d\n", uid);
++		log_close(log_pid);
++		exit(ISCSI_ERR);
++	}
+ 
+ 	memset(&daemon_config, 0, sizeof (daemon_config));
+ 	daemon_config.pid_file = pid_file;
+-- 
+1.8.1.4
+
diff --git a/0065-fix-hardened-build-of-iscsiuio.patch b/0065-fix-hardened-build-of-iscsiuio.patch
new file mode 100644
index 0000000..83210c6
--- /dev/null
+++ b/0065-fix-hardened-build-of-iscsiuio.patch
@@ -0,0 +1,30 @@
+From 436ac9074def43ae09d7ecc28eec6cdc77a9d0e2 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Fri, 13 Sep 2013 16:56:51 -0700
+Subject: [PATCH 65/65] fix hardened build of iscsiuio
+
+The new iscsiuio code sets CFLAGS in configure.ac, wiping out the
+environment setup by rpm.  Patch that out.
+
+---
+ Makefile              | 2 +-
+ iscsiuio/configure    | 2 +-
+ iscsiuio/configure.ac | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+ mode change 100644 => 100755 iscsiuio/configure
+
+diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac
+index e9a5e32..d9a6bdb 100644
+--- a/iscsiuio/configure.ac
++++ b/iscsiuio/configure.ac
+@@ -52,7 +52,6 @@ AC_LIBTOOL_DLOPEN
+ # libtool stuff
+ AC_PROG_LIBTOOL
+ 
+-CFLAGS="-O2 -Wall"
+ ## check for --enable-debug first before checking CFLAGS before
+ ## so that we don't mix -O and -g
+ AC_ARG_ENABLE(debug,
+-- 
+1.8.1.4
+
diff --git a/0066-start-socket-listeners-on-iscsiadm-command.patch b/0066-start-socket-listeners-on-iscsiadm-command.patch
new file mode 100644
index 0000000..039e8d4
--- /dev/null
+++ b/0066-start-socket-listeners-on-iscsiadm-command.patch
@@ -0,0 +1,28 @@
+From 89e9c2ff66d069b812fabcd4fefe453bbcea73e4 Mon Sep 17 00:00:00 2001
+From: Chris Leech <cleech at redhat.com>
+Date: Mon, 25 Nov 2013 22:28:12 -0800
+Subject: [PATCH] start socket listeners on iscsiadm command
+
+fix for trying to run iscsiadm commands right after installing the rpm
+without manually starting the systemd units
+---
+ etc/iscsid.conf | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/etc/iscsid.conf b/etc/iscsid.conf
+index 1fd3000..412f130 100644
+--- a/etc/iscsid.conf
++++ b/etc/iscsid.conf
+@@ -17,7 +17,8 @@
+ # maintainers.
+ #
+ # Default for Fedora and RHEL. (uncomment to activate).
+-# iscsid.startup = /etc/rc.d/init.d/iscsid force-start
++# Use socket activation, but try to make sure the socket units are listening
++# iscsid.startup = /bin/systemctl start iscsid.socket iscsiuio.socket
+ # 
+ # Default for upstream open-iscsi scripts (uncomment to activate).
+ # iscsid.startup = /sbin/iscsid
+-- 
+1.8.3.1
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/open-iscsi.git/commitdiff/73d24d5e829ad5cd1b399f95fc288cb320b17a65



More information about the pld-cvs-commit mailing list