[Pkg-iscsi-maintainers] Bug#810702: Generate initiator name on install, not first boot

Martin Pitt martin.pitt at ubuntu.com
Mon Jan 11 11:45:30 UTC 2016


Package: open-iscsi
Version: 2.0.873+git0.3b4b4500-12
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch xenial

Hello,

In https://launchpad.net/bugs/1057635 it was reported that an
initramfs built during install does not contain a valid iscsi
initiator name. This is because /etc/iscsi/initiatorname.iscsi is
currently created by the init scripts, not the postinst. Thus if d-i
installs open-iscsi, or if you build an OS in a schroot, this will
never happen and the built initramfs will contain only the dummy
initiatorname.iscsi.

James Page fixed this a few years ago in Ubuntu, I adjusted the patch
to the current Debian version.

Disclaimer: I don't know much about open-iscsi, I'm just looking into
our delta and see what's still relevant and what would be beneficial
to Debian too.

Thanks for considering,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
diff -Nru open-iscsi-2.0.873+git0.3b4b4500/debian/changelog open-iscsi-2.0.873+git0.3b4b4500/debian/changelog
--- open-iscsi-2.0.873+git0.3b4b4500/debian/changelog	2015-10-21 11:49:30.000000000 +0200
+++ open-iscsi-2.0.873+git0.3b4b4500/debian/changelog	2016-01-11 12:39:48.000000000 +0100
@@ -1,3 +1,12 @@
+open-iscsi (2.0.873+git0.3b4b4500-13) UNRELEASED; urgency=medium
+
+  * debian/open-iscsi.postinst: 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. Drop debian/initiatorname.iscsi stub. (LP: #1057635)
+
+ -- Martin Pitt <martin.pitt at ubuntu.com>  Mon, 11 Jan 2016 12:38:07 +0100
+
 open-iscsi (2.0.873+git0.3b4b4500-12) unstable; urgency=low
 
   [ Christian Perrier ]
diff -Nru open-iscsi-2.0.873+git0.3b4b4500/debian/initiatorname.iscsi open-iscsi-2.0.873+git0.3b4b4500/debian/initiatorname.iscsi
--- open-iscsi-2.0.873+git0.3b4b4500/debian/initiatorname.iscsi	2015-08-20 15:51:06.000000000 +0200
+++ open-iscsi-2.0.873+git0.3b4b4500/debian/initiatorname.iscsi	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-GenerateName=yes
diff -Nru open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.install open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.install
--- open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.install	2015-10-21 11:49:30.000000000 +0200
+++ open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.install	2016-01-11 12:40:21.000000000 +0100
@@ -4,7 +4,6 @@
 usr/iscsistart                         /sbin
 utils/iscsi_discovery                  /sbin
 utils/iscsi-iname                      /sbin
-debian/initiatorname.iscsi             /etc/iscsi
 etc/iscsid.conf                        /etc/iscsi
 debian/extra/initramfs.hook         => /usr/share/initramfs-tools/hooks/iscsi
 debian/extra/initramfs.local-top    => /usr/share/initramfs-tools/scripts/local-top/iscsi
diff -Nru open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.postinst open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.postinst
--- open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.postinst	2015-10-21 11:49:30.000000000 +0200
+++ open-iscsi-2.0.873+git0.3b4b4500/debian/open-iscsi.postinst	2016-01-11 12:38:05.000000000 +0100
@@ -68,6 +68,30 @@
 		rmdir --ignore-fail-on-non-empty /var/lib/open-iscsi
 	fi
 
+        # generate a unique iSCSI InitiatorName
+        NAMEFILE=/etc/iscsi/initiatorname.iscsi
+        if [ ! -e $NAMEFILE ] && [ -z "$2" ] ; 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
+
 	update_initramfs
     ;;
 


More information about the Pkg-iscsi-maintainers mailing list