Merge ~paelzer/ubuntu/+source/open-iscsi:merge-2.1.4-impish into ubuntu/+source/open-iscsi:debian/sid

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: aa674e9976c6e53c0aa82f106afc58cf311419b8
Merge reported by: Christian Ehrhardt 
Merged at revision: 1f2323e82ff3b8675fa7464d7bc7b29bb89e8c5e
Proposed branch: ~paelzer/ubuntu/+source/open-iscsi:merge-2.1.4-impish
Merge into: ubuntu/+source/open-iscsi:debian/sid
Diff against target: 7102 lines (+5668/-203)
50 files modified
Changelog (+39/-0)
Makefile (+1/-0)
debian/README.Debian (+2/-2)
debian/changelog (+1252/-0)
debian/control (+14/-2)
debian/extra/initramfs.hook (+1/-1)
debian/extra/initramfs.local-bottom (+20/-0)
debian/extra/initramfs.local-top (+30/-2)
debian/extra/net-interface-handler (+80/-0)
debian/extra/startup-checks.sh (+1/-1)
debian/iscsi-network-interface.rules (+3/-0)
debian/iscsid.service (+1/-1)
debian/open-iscsi-udeb.start (+1/-1)
debian/open-iscsi.finalrd (+47/-0)
debian/open-iscsi.postinst (+26/-41)
debian/open-iscsi.service (+6/-6)
debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch (+25/-0)
debian/patches/series (+1/-3)
debian/rules (+27/-8)
debian/tests/README-boot-test.md (+139/-0)
debian/tests/control (+4/-0)
debian/tests/get-image (+227/-0)
debian/tests/install (+5/-2)
debian/tests/patch-image (+374/-0)
debian/tests/test-open-iscsi.py (+427/-0)
debian/tests/testlib.py (+1488/-0)
debian/tests/testsuite (+6/-0)
debian/tests/tgt-boot-test (+534/-0)
debian/tests/xkvm (+704/-0)
dev/null (+0/-58)
doc/iscsid.8 (+14/-9)
etc/systemd/iscsi.service (+3/-3)
etc/systemd/iscsid.service (+2/-1)
iscsiuio/configure.ac (+14/-3)
libopeniscsiusr/context.c (+5/-1)
libopeniscsiusr/idbm.c (+1/-1)
libopeniscsiusr/iface.c (+1/-1)
libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h (+1/-1)
libopeniscsiusr/node.c (+9/-0)
libopeniscsiusr/session.c (+35/-8)
libopeniscsiusr/sysfs.c (+4/-4)
libopeniscsiusr/version.h (+1/-1)
test/harness/util.py (+2/-2)
usr/Makefile (+2/-0)
usr/idbm.c (+36/-14)
usr/iface.c (+1/-1)
usr/iscsiadm.c (+18/-19)
usr/iscsid.c (+18/-3)
usr/iscsistart.c (+15/-2)
usr/version.h (+1/-1)
Reviewer Review Type Date Requested Status
Bryce Harrington (community) Approve
Canonical Server Pending
Canonical Server packageset reviewers Pending
Review via email: mp+405043@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Build is complete, tests have started and will hopefully run over night.
Ready for review.

I also pushed the usual tags
To ssh://git.launchpad.net/~paelzer/ubuntu/+source/open-iscsi
 * [new tag] lp1934290/logical/2.1.3-1ubuntu6 -> lp1934290/logical/2.1.3-1ubuntu6
 * [new tag] lp1934290/new/debian -> lp1934290/new/debian
 * [new tag] lp1934290/old/debian -> lp1934290/old/debian
 * [new tag] lp1934290/old/ubuntu -> lp1934290/old/ubuntu
 * [new tag] lp1934290/reconstruct/2.1.3-1ubuntu6 -> lp1934290/reconstruct/2.1.3-1ubuntu6
 * [new tag] lp1934290/split/2.1.3-1ubuntu6 -> lp1934290/split/2.1.3-1ubuntu6

Revision history for this message
Bryce Harrington (bryce) wrote :

* Changelog:
  - [√] old content and logical tag match as expected
  - [√] changelog entry correct version and targeted codename
  - [x] changelog entries correct
    + The bullets style should be * for 1st level, - for 2nd, and + for 3rd
  - [√] update-maintainer has been run

* Actual changes:
  - [√] no upstream changes to consider
  - [√] no further upstream version to consider
  - [√] debian changes look safe

* Old Delta:
  - [√] dropped changes are ok to be dropped
  - [√] nothing else to drop
  - [-] changes forwarded upstream/debian (if appropriate)

* New Delta:
  - [√] no new patches added
  - [-] patches match what was proposed upstream
  - [-] patches correctly included in debian/patches/series
  - [-] patches have correct DEP3 metadata

* Build/Test:
  - [√] build is ok
  - [√] verified PPA package installs/uninstalls
  - [√] autopkgtest against the PPA package passes
  - [-] sanity checks test fine

I did not exhaustively review the ubuntu delta but by spot checking things look as they should. The autopkgtests did not run in my container since they're marked breaks testbed, however the bileto run looks like it passed. The PPA package installed/uninstalled fine, and it built without issue in my local environment.

LGTM, +1

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for the review!

The bullet style was taken as it was in the past, but thanks for the hint - I've updated the Changelog for it.

The autopkgtests on Bileto didn't all kick in, so I had them running myself against the PPA on LP. That was good, I've realized one more thing that would be a pain.

Upgrading a cloud image revealed
(Reading database ... 65987 files and directories currently installed.)
Preparing to unpack .../libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb ...
Unpacking libopeniscsiusr (2.1.4-0ubuntu1~impishppa1) ...
dpkg: error processing archive /var/cache/apt/archives/libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libopeniscsiusr.so.0.2.0', which is also in package libopeniscsiusr0.2.0 2.1.3-1ubuntu6
Preparing to unpack .../open-iscsi_2.1.4-0ubuntu1~impishppa1_amd64.deb ...
Unpacking open-iscsi (2.1.4-0ubuntu1~impishppa1) over (2.1.3-1ubuntu6) ...
Errors were encountered while processing:
 /var/cache/apt/archives/libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb

That makes sense as from a Ubuntu users POV the merge implies a file rename. I'll add what is needed as that is a trivial common case.

Revision history for this message
Bryce Harrington (bryce) wrote :

On Fri, Jul 02, 2021 at 05:55:11AM -0000, Christian Ehrhardt  wrote:
> Thanks for the review!
>
> The bullet style was taken as it was in the past, but thanks for the hint - I've updated the Changelog for it.
>
> The autopkgtests on Bileto didn't all kick in, so I had them running myself against the PPA on LP. That was good, I've realized one more thing that would be a pain.
>
> Upgrading a cloud image revealed
> (Reading database ... 65987 files and directories currently installed.)
> Preparing to unpack .../libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb ...
> Unpacking libopeniscsiusr (2.1.4-0ubuntu1~impishppa1) ...
> dpkg: error processing archive /var/cache/apt/archives/libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb (--unpack):
> trying to overwrite '/usr/lib/x86_64-linux-gnu/libopeniscsiusr.so.0.2.0', which is also in package libopeniscsiusr0.2.0 2.1.3-1ubuntu6
> Preparing to unpack .../open-iscsi_2.1.4-0ubuntu1~impishppa1_amd64.deb ...
> Unpacking open-iscsi (2.1.4-0ubuntu1~impishppa1) over (2.1.3-1ubuntu6) ...
> Errors were encountered while processing:
> /var/cache/apt/archives/libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb
>
> That makes sense as from a Ubuntu users POV the merge implies a file rename. I'll add what is needed as that is a trivial common case.

Ahhh, in fact I ran into this problem too when I initially installed.
But then I removed/purged and reinstalled and then I couldn't figure out
how to reproduce it, so figured I just had something misconfigured to
begin with. That makes more sense though.

> --
> https://code.launchpad.net/~paelzer/ubuntu/+source/open-iscsi/+git/open-iscsi/+merge/405043
> You are reviewing the proposed merge of ~paelzer/ubuntu/+source/open-iscsi:merge-2.1.4-impish into ubuntu/+source/open-iscsi:debian/sid.

417664b... by Christian Ehrhardt 

d/control: Transition from libopeniscsiusr0.2.0 to libopeniscsiusr

We had
  libopeniscsiusr0.2.0 2.1.3-1ubuntu6
Containing file
  /usr/lib/x86_64-linux-gnu/libopeniscsiusr.so.0.2.0
Debian now finally resolved that, but in differnt package name
  libopeniscsiusr 2.1.4-0ubuntu1~impishppa1
Also all dependencies flipped to the new package name,
but we need to ensure a proper install ordering.

Otherwise this happens:
  Preparing to unpack .../libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb ...
  Unpacking libopeniscsiusr (2.1.4-0ubuntu1~impishppa1) ...
  dpkg: error processing archive /var/cache/apt/archives/libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb (--unpack):
   trying to overwrite '/usr/lib/x86_64-linux-gnu/libopeniscsiusr.so.0.2.0', which is also in package libopeniscsiusr0.2.0 2.1.3-1ubuntu6
  Preparing to unpack .../open-iscsi_2.1.4-0ubuntu1~impishppa1_amd64.deb ...
  Unpacking open-iscsi (2.1.4-0ubuntu1~impishppa1) over (2.1.3-1ubuntu6) ...
  Errors were encountered while processing:
   /var/cache/apt/archives/libopeniscsiusr_2.1.4-0ubuntu1~impishppa1_amd64.deb

For Debian that was a new package in 2.1.3-5, but for an Ubuntu user
that is case #5 of https://wiki.debian.org/PackageTransition
So we need to add breaks and a transitional.

This change can be dropped ater 22.04 as then all valid upgrade paths have gone
through this.

Signed-off-by: Christian Ehrhardt <email address hidden>

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The transitional was added and I pushed the branch.
Once rebuilds and tests show all-good I'll upload.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/open-iscsi
 * [new tag] upload/2.1.4-0ubuntu1 -> upload/2.1.4-0ubuntu1

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading open-iscsi_2.1.4-0ubuntu1.dsc: done.
  Uploading open-iscsi_2.1.4.orig.tar.gz: done.
  Uploading open-iscsi_2.1.4-0ubuntu1.debian.tar.xz: done.
  Uploading open-iscsi_2.1.4-0ubuntu1_source.buildinfo: done.
  Uploading open-iscsi_2.1.4-0ubuntu1_source.changes: done.
Successfully uploaded packages.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

this is in proposed now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Changelog b/Changelog
2index 78ed73e..bf18ec7 100644
3--- a/Changelog
4+++ b/Changelog
5@@ -1,3 +1,42 @@
6+open-iscsi-2.1.3 - open-iscsi-2.1.4
7+
8+Abhinav Rajagopalan (1):
9+ Fix typo in util.py
10+
11+Chris Leech (3):
12+ libopeniscsiusr: fix error messages
13+ libopeniscsiusr: skip over removed sessions
14+ libopeniscsiusr: dont error loudly if a session isn't found when working through iscsi_sessions_get()
15+
16+Fabian Möller (1):
17+ iscsid: Add NO_SYSTEMD to CFLAGS
18+
19+Helmut Grohne (1):
20+ Avoid hardcoding pkg-config to fix cross build
21+
22+John Schaeffer (1):
23+ Add etc/systemd/iscsi-init.service to SYSTEMDFILES Makefile variable
24+
25+Lee Duncan (4):
26+ iscsid: Do not allow conflicting pid-file options
27+ Fix iscsiadm segfault when exiting
28+ Fix iscsistart login issue when target is delayed.
29+ Enable iscsi.service asynchronous logins, cleanup services
30+
31+Matwey V. Kornilov (1):
32+ Wants=network-online.target in iscsi.service
33+
34+Patrick Lawrence (1):
35+ Change mkdir permissions to 0770, adjust usmask
36+
37+Wenchao Hao (4):
38+ idbm: Fix memory leak and NULL pointer dereference in idbm_rec_update_param()
39+ libopeniscsiusr: Fix memory leak in iscsi_nodes_get()
40+ libopeniscsiusr: Fix memory leak in iscsi_sessions_get()
41+ iscsiadm: Fix memory leak in iscsiadm
42+
43+---------------------------------------------------------------------------
44+
45 open-iscsi-2.1.2 - open-iscsi-2.1.3
46
47 Chris Leech (4):
48diff --git a/Makefile b/Makefile
49index 7b445a5..7f52cc8 100644
50--- a/Makefile
51+++ b/Makefile
52@@ -28,6 +28,7 @@ ETCFILES = etc/iscsid.conf
53 IFACEFILES = etc/iface.example
54 RULESFILES = utils/50-iscsi-firmware-login.rules
55 SYSTEMDFILES = etc/systemd/iscsi.service \
56+ etc/systemd/iscsi-init.service \
57 etc/systemd/iscsid.service etc/systemd/iscsid.socket \
58 etc/systemd/iscsiuio.service etc/systemd/iscsiuio.socket
59
60diff --git a/debian/README.Debian b/debian/README.Debian
61index f0c2568..43c7c81 100644
62--- a/debian/README.Debian
63+++ b/debian/README.Debian
64@@ -57,7 +57,7 @@ iSCSI Qualified Names (IQN) and initiatorname.iscsi
65 The initiatorname.iscsi file defines the iSCSI Qualified Name (IQN) of the iSCSI
66 initiator. This IQN is used by the initiator to identify itself to the target.
67
68-Example: InitiatorName=iqn.1993-08.org.debian:01:lnx-debian
69+Example: InitiatorName=iqn.2004-10.com.ubuntu:01:lnx-debian
70
71 While this name can be adjusted to suit your needs, once set, it should not be
72 changed. If you later change the InitiatorName, existing access control lists
73@@ -100,7 +100,7 @@ options in your initramfs:
74
75 Example Syntax:
76
77- ISCSI_INITIATOR="iqn.1993-08.org.debian:01:9b3e5634fdb9"
78+ ISCSI_INITIATOR="iqn.2004-10.com.ubuntu:01:9b3e5634fdb9"
79 ISCSI_TARGET_NAME=iqn.2008-01.com.example:storage.foo
80 ISCSI_TARGET_IP=192.168.1.1
81 ISCSI_TARGET_PORT=3260
82diff --git a/debian/changelog b/debian/changelog
83index dd0ef0d..021748a 100644
84--- a/debian/changelog
85+++ b/debian/changelog
86@@ -1,3 +1,76 @@
87+open-iscsi (2.1.4-0ubuntu1) impish; urgency=medium
88+
89+ * Merge with Debian unstable (LP: #1934290). Remaining changes:
90+ - debian/tests: Add Ubuntu autopkgtest suite:
91+ + d/t/README-boot-test.md: document test design
92+ + d/t/control: register testsuite
93+ + d/t/get-image: helper to fetch an ubuntu cloud image
94+ + d/t/patch-image: helper to modify an ubuntu cloud image
95+ + d/test-open-iscsi.py, d/t/testlib.py: various qa regression tests
96+ + d/t/testsuite: helper to invoke qa regression tests
97+ + d/t/tgt-boot-test: test using tgt to boot from iscsi
98+ + d/t/xkvm: helper to spawn a VM
99+ Note: this suite should be replaced by LIO that replaced TGT in main.
100+ - d/iscsid.service: Let iscsid systemd job run in privileged containers
101+ but not in unprivileged ones
102+ - debian/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
103+ run ipconfig to gather all DHCP config info, including DNS search
104+ domain, which iBFT can't provide.
105+ - Remove initramfs interfaces stamp in case no iscsi devs mounted
106+ If iscsi root was requested, but no iscsi devices were mounted, remove
107+ the initramfs interfaces stamp file. Meaning, that on shutdown there is
108+ no 30s delay, whilst trying to re-establish iscsi login to perform a
109+ logout.
110+ - add IPv6 support
111+ + Source /run/net6-*.conf when needed.
112+ + debian/extra/initramfs.local-top: handle IPv6 configs being shipped
113+ in DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
114+ /run/initramfs/open-iscsi.interface
115+ - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi
116+ logout hook and recommend finalrd and busybox for the logout hook
117+ to work.
118+ - Make iscsid socket-activated to only activate it as needed:
119+ + debian/open-iscsi.service: do not start or check iscsid.service
120+ + debian/rules: install and enable iscsid.socket
121+ + debian/open-iscsi.postinst:
122+ + run restart logic only if service is running on upgrade
123+ + drop no longer reachable upgrade path that affects iscsid
124+ + disable iscsid.service on upgrade
125+ + handle iscsid.socket to be started if the service is not running yet
126+ + d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
127+ run when udev disks are attached.
128+ + d/iscsid.service: Remove ExecStop= directive.
129+ + debian/tests/install: fix tests to work with socket activation
130+ + debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
131+ - debian/open-iscsi.service: Start open-iscsi systemd job when either
132+ /etc/iscsi/nodes or /sys/class/iscsi_session have content.
133+ - Prevent network interface that contains iscsi root from bouncing
134+ during boot or going down during shutdown if the system is using
135+ resolvconf or ifupdown:
136+ + d/iscsi-network-interface.rules
137+ + d/extra/net-interface-handler
138+ - debian/extra/initramfs.hook: add ib_iser to the list of modules
139+ included in the initramfs, so that we can in principle support
140+ iscsi root on infiniband.
141+ - debian/open-iscsi.kmod drop: (LP 1833586)
142+ no static module list is needed if we let iscsid load modules itself.
143+ - Stop producing udebs on i386 where we no longer have d-i or a kernel.
144+ - d/extra/initramfs.local-{top,bottom}: move removal of
145+ open-iscsi.interface file from local-top to local-bottom,
146+ and fix shell quoting issue that would result in /run/initramfs/
147+ open-iscsi.interface always being removed (LP 1872813)
148+ - d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds and
149+ initialization, because upstream's gcc10 support is incomplete. This
150+ change can be dropped when upstream has completed their gcc support.
151+ - d/README.Debian, d/extra/startup-checks.sh, d/open-iscsi-udeb.start,
152+ d/open-iscsi.postinst: Apply Ubuntu branding to iqn initiator name
153+ * Added changes
154+ - merge bug fix release 2.1.4 from upstream
155+ - Revert "Add patches from upstream" [upstream in 2.1.4]
156+ - d/control: Transition from libopeniscsiusr0.2.0 to libopeniscsiusr
157+
158+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 01 Jul 2021 14:13:08 +0200
159+
160 open-iscsi (2.1.3-5) unstable; urgency=medium
161
162 [ Cyril Brulebois ]
163@@ -33,6 +106,119 @@ open-iscsi (2.1.3-2) unstable; urgency=medium
164
165 -- Chris Hofstaedtler <zeha@debian.org> Sun, 07 Feb 2021 19:23:13 +0000
166
167+open-iscsi (2.1.3-1ubuntu6) hirsute; urgency=medium
168+
169+ * d/open-iscsi.finalrd: fix UID resolution issues in logout (LP: #1922976)
170+ Thanks to Michael Brown
171+
172+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 18 Mar 2021 09:44:07 +0100
173+
174+open-iscsi (2.1.3-1ubuntu5) hirsute; urgency=medium
175+
176+ * make d/t/testuite python3 compatible (LP: #1919461)
177+ - backport changes from qa-regression-testing since we diverged
178+ - various tests: make py3 compliant, fix formatting a bit
179+ - tests: convert deprecated assertEquals() to assertEqual()
180+ - Remove all references to python-utils
181+ - d/t/testlib.py: update to last state from
182+ git+ssh://git.launchpad.net/qa-regression-testing
183+ - d/t/{control,testsuite}: bump to use python3
184+ - d/t/test-open-iscsi.py: switch shebang to python3
185+ - d/t/test-open-iscsi.py: adapt to updated testlib
186+ * Add patches from upstream [this is from Debian upload 2.1.3-2]:
187+ - Fix memory leak in iscsiadm, Fix iscsiadm segfault when exiting, and
188+ - Fix iscsistart login issue when target is delayed. The last one should
189+ - fix iscsi-root with delayed network (Closes: #980085)
190+
191+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 18 Mar 2021 09:44:07 +0100
192+
193+open-iscsi (2.1.3-1ubuntu4) hirsute; urgency=medium
194+
195+ * Rebuild again so s390x pick up the right debhelper
196+
197+ -- Sebastien Bacher <seb128@ubuntu.com> Wed, 24 Feb 2021 16:29:41 +0100
198+
199+open-iscsi (2.1.3-1ubuntu3) hirsute; urgency=medium
200+
201+ * No-change rebuild to drop the udeb package.
202+
203+ -- Matthias Klose <doko@ubuntu.com> Mon, 22 Feb 2021 10:35:42 +0100
204+
205+open-iscsi (2.1.3-1ubuntu2) hirsute; urgency=medium
206+
207+ * Apply Ubuntu branding to iqn initiator name.
208+
209+ -- Dimitri John Ledkov <xnox@ubuntu.com> Wed, 17 Feb 2021 00:05:22 +0000
210+
211+open-iscsi (2.1.3-1ubuntu1) hirsute; urgency=medium
212+
213+ * Merge with Debian unstable. Remaining changes:
214+ - debian/tests: Add Ubuntu autopkgtest suite:
215+ - README-boot-test.md
216+ - tgt-boot-test: tests
217+ - test-open-iscsi.py
218+ - testlib.py
219+ - get-image
220+ - patch-image
221+ - testsuite
222+ - xkvm
223+ - d/iscsid.service: Let iscsid systemd job run in privileged containers
224+ but not in unprivileged ones
225+ - d/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
226+ run ipconfig to gather all DHCP config info, including DNS search
227+ domain, which iBFT can't provide.
228+ - Remove initramfs interfaces stamp in case no iscsi devs mounted.
229+ If iscsi root was requested, but no iscsi devices were mounted, remove
230+ the initramfs interfaces stamp file. Meaning, that on shutdown there is
231+ no 30s delay, whilst trying to re-establish iscsi login to perform a
232+ logout.
233+ - add IPv6 support
234+ - Source /run/net6-*.conf when needed.
235+ - d/extra/initramfs.local-top: handle IPv6 configs being shipped in
236+ DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
237+ .interface
238+ - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi logout
239+ hook and recommend finalrd and busybox for the logout hook to work.
240+ - Make iscsid socket-activated to only activate it as needed:
241+ - debian/open-iscsi.service: do not start or check iscsid.service
242+ - debian/rules: install and enable iscsid.socket
243+ - debian/open-iscsi.postinst:
244+ - run restart logic only if service is running on upgrade
245+ - drop no longer reachable upgrade path that affects iscsid
246+ - disable iscsid.service on upgrade
247+ - handle iscsid.socket to be started if the service is not running yet
248+ - d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
249+ run when udev disks are attached.
250+ - d/iscsid.service: Remove ExecStop= directive.
251+ - debian/tests/install: fix tests to work with socket activation
252+ - debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
253+ [updated to match 2.1.2]
254+ - debian/open-iscsi.service: Start open-iscsi systemd job when either
255+ /etc/iscsi/nodes or /sys/class/iscsi_session have content.
256+ - Prevent network interface that contains iscsi root from bouncing
257+ during boot or going down during shutdown if the system is using
258+ resolvconf or ifupdown:
259+ - d/iscsi-network-interface.rules
260+ - d/extra/net-interface-handler
261+ - d/extra/initramfs.hook: add ib_iser to the list of modules included in
262+ the initramfs, so that we can in principle support iscsi root on
263+ infiniband.
264+ - d/open-iscsi.kmod drop: (LP #1833586)
265+ no static module list is needed if we let iscsid load modules itself.
266+ - Stop producing udebs on i386 where we no longer have d-i or a kernel.
267+ - d/extra/initramfs.local-{top,bottom}: move removal of
268+ open-iscsi.interface file from local-top to local-bottom, and fix shell
269+ quoting issue that would result in /run/initramfs/ open-iscsi.interface
270+ always being removed (LP #1872813)
271+ - debian/control, debian/rules: Fix libopeniscsiusr binary package
272+ name (LP 1892228).
273+ - d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds
274+ and initialization, because upstream's gcc10 support is incomplete.
275+ This change can be dropped when upstream has completed their gcc
276+ support.
277+
278+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Tue, 19 Jan 2021 13:29:46 +0100
279+
280 open-iscsi (2.1.3-1) unstable; urgency=medium
281
282 * [afee47d] New upstream version 2.1.3
283@@ -51,6 +237,75 @@ open-iscsi (2.1.2-2) unstable; urgency=medium
284
285 -- Chris Hofstaedtler <zeha@debian.org> Sun, 06 Dec 2020 23:25:11 +0000
286
287+open-iscsi (2.1.2-1ubuntu1) hirsute; urgency=medium
288+
289+ * Merge with Debian unstable. Remaining changes:
290+ - debian/tests: Add Ubuntu autopkgtest suite:
291+ - README-boot-test.md
292+ - tgt-boot-test: tests
293+ - test-open-iscsi.py
294+ - testlib.py
295+ - get-image
296+ - patch-image
297+ - testsuite
298+ - xkvm
299+ - d/iscsid.service: Let iscsid systemd job run in privileged containers
300+ but not in unprivileged ones
301+ - d/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
302+ run ipconfig to gather all DHCP config info, including DNS search
303+ domain, which iBFT can't provide.
304+ - Remove initramfs interfaces stamp in case no iscsi devs mounted.
305+ If iscsi root was requested, but no iscsi devices were mounted, remove
306+ the initramfs interfaces stamp file. Meaning, that on shutdown there is
307+ no 30s delay, whilst trying to re-establish iscsi login to perform a
308+ logout.
309+ - add IPv6 support
310+ - Source /run/net6-*.conf when needed.
311+ - d/extra/initramfs.local-top: handle IPv6 configs being shipped in
312+ DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
313+ .interface
314+ - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi logout
315+ hook and recommend finalrd and busybox for the logout hook to work.
316+ - Make iscsid socket-activated to only activate it as needed:
317+ - debian/open-iscsi.service: do not start or check iscsid.service
318+ - debian/rules: install and enable iscsid.socket
319+ - debian/open-iscsi.postinst:
320+ - run restart logic only if service is running on upgrade
321+ - drop no longer reachable upgrade path that affects iscsid
322+ - disable iscsid.service on upgrade
323+ - handle iscsid.socket to be started if the service is not running yet
324+ - d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
325+ run when udev disks are attached.
326+ - d/iscsid.service: Remove ExecStop= directive.
327+ - debian/tests/install: fix tests to work with socket activation
328+ - debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
329+ [updated to match 2.1.2]
330+ - debian/open-iscsi.service: Start open-iscsi systemd job when either
331+ /etc/iscsi/nodes or /sys/class/iscsi_session have content.
332+ - Prevent network interface that contains iscsi root from bouncing
333+ during boot or going down during shutdown if the system is using
334+ resolvconf or ifupdown:
335+ - d/iscsi-network-interface.rules
336+ - d/extra/net-interface-handler
337+ - d/extra/initramfs.hook: add ib_iser to the list of modules included in
338+ the initramfs, so that we can in principle support iscsi root on
339+ infiniband.
340+ - d/open-iscsi.kmod drop: (LP #1833586)
341+ no static module list is needed if we let iscsid load modules itself.
342+ - Stop producing udebs on i386 where we no longer have d-i or a kernel.
343+ - d/extra/initramfs.local-{top,bottom}: move removal of
344+ open-iscsi.interface file from local-top to local-bottom, and fix shell
345+ quoting issue that would result in /run/initramfs/ open-iscsi.interface
346+ always being removed (LP #1872813)
347+ - debian/control, debian/rules: Fix libopeniscsiusr binary package
348+ name (LP 1892228).
349+ - d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds
350+ and initialization, because upstream's gcc10 support is incomplete.
351+ This change can be dropped when upstream has completed their gcc
352+ support.
353+
354+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 03 Dec 2020 14:44:39 +0100
355+
356 open-iscsi (2.1.2-1) unstable; urgency=medium
357
358 * [7f10701] New upstream version 2.1.2
359@@ -72,6 +327,86 @@ open-iscsi (2.1.1-2) unstable; urgency=medium
360
361 -- Ritesh Raj Sarraf <rrs@debian.org> Fri, 14 Aug 2020 12:32:16 +0530
362
363+open-iscsi (2.1.1-1ubuntu2) groovy; urgency=medium
364+
365+ * debian/control, debian/rules: Fix libopeniscsiusr binary package
366+ name (LP: #1892228).
367+ * debian/rules: Fix deprecated warning for dh_installinit that
368+ --no-restart-on-upgrade has been replaced by --no-stop-on-upgrade,
369+ which is equivalent in functionality (ref deb #837528).
370+
371+ -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Wed, 19 Aug 2020 19:08:47 +0000
372+
373+open-iscsi (2.1.1-1ubuntu1) groovy; urgency=medium
374+
375+ * New upstream version 2.1.1
376+ * d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds
377+ and initialization, because upstream's gcc10 support is incomplete.
378+ This change can be dropped when upstream has completed their gcc
379+ support.
380+ * Merge with Debian unstable (LP: #1891374). Remaining changes:
381+ - debian/tests: Add Ubuntu autopkgtest suite:
382+ - README-boot-test.md
383+ - tgt-boot-test: tests
384+ - test-open-iscsi.py
385+ - testlib.py
386+ - get-image
387+ - patch-image
388+ - testsuite
389+ - xkvm
390+ - d/iscsid.service: Let iscsid systemd job run in privileged containers
391+ but not in unprivileged ones
392+ - d/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
393+ run ipconfig to gather all DHCP config info, including DNS search
394+ domain, which iBFT can't provide.
395+ - Remove initramfs interfaces stamp in case no iscsi devs mounted.
396+ If iscsi root was requested, but no iscsi devices were mounted, remove
397+ the initramfs interfaces stamp file. Meaning, that on shutdown there is
398+ no 30s delay, whilst trying to re-establish iscsi login to perform a
399+ logout.
400+ - add IPv6 support
401+ - Source /run/net6-*.conf when needed.
402+ - d/extra/initramfs.local-top: handle IPv6 configs being shipped in
403+ DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
404+ .interface
405+ - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi logout
406+ hook and recommend finalrd and busybox for the logout hook to work.
407+ - Make iscsid socket-activated to only activate it as needed:
408+ - debian/open-iscsi.service: do not start or check iscsid.service
409+ - debian/rules: install and enable iscsid.socket
410+ - debian/open-iscsi.postinst:
411+ - run restart logic only if service is running on upgrade
412+ - drop no longer reachable upgrade path that affects iscsid
413+ - disable iscsid.service on upgrade
414+ - handle iscsid.socket to be started if the service is not running yet
415+ - d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
416+ run when udev disks are attached.
417+ - d/iscsid.service: Remove ExecStop= directive.
418+ - debian/tests/install: fix tests to work with socket activation
419+ - debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
420+ - debian/open-iscsi.service: Start open-iscsi systemd job when either
421+ /etc/iscsi/nodes or /sys/class/iscsi_session have content.
422+ - Prevent network interface that contains iscsi root from bouncing
423+ during boot or going down during shutdown if the system is using
424+ resolvconf or ifupdown:
425+ - d/iscsi-network-interface.rules
426+ - d/extra/net-interface-handler
427+ - d/extra/initramfs.hook: add ib_iser to the list of modules included in
428+ the initramfs, so that we can in principle support iscsi root on
429+ infiniband.
430+ - d/open-iscsi.kmod drop: (LP #1833586)
431+ no static module list is needed if we let iscsid load modules itself.
432+ - Stop producing udebs on i386 where we no longer have d-i or a kernel.
433+ - Use python2 instead of python in the autopkg tests: Next step for
434+ open-iscsi is to revist all iscsi-root feature and autopkgtests, so
435+ keep python2 to avoid re-work later.
436+ - d/extra/initramfs.local-{top,bottom}: move removal of
437+ open-iscsi.interface file from local-top to local-bottom, and fix shell
438+ quoting issue that would result in /run/initramfs/ open-iscsi.interface
439+ always being removed (LP #1872813)
440+
441+ -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Thu, 13 Aug 2020 04:29:43 +0000
442+
443 open-iscsi (2.1.1-1) experimental; urgency=medium
444
445 [ Rafael David Tinoco ]
446@@ -116,6 +451,98 @@ open-iscsi (2.1.1-1) experimental; urgency=medium
447
448 -- Ritesh Raj Sarraf <rrs@debian.org> Tue, 23 Jun 2020 20:38:47 +0530
449
450+open-iscsi (2.0.874-7.1ubuntu6.1) focal; urgency=medium
451+
452+ [ Ben Swartzlander ]
453+ * allow open-iscsi to disable auto-scan feature (LP: #1877617)
454+ - d/p/lp1877617-Allow-disabling-auto-LUN-scans.patch
455+ - d/p/lp1877617-Fix-manual-LUN-scans-feature.patch
456+
457+ -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Mon, 11 May 2020 02:03:33 +0000
458+
459+open-iscsi (2.0.874-7.1ubuntu6) focal; urgency=medium
460+
461+ * d/extra/initramfs.local-{top,bottom}: move removal of open-iscsi.interface
462+ file from local-top to local-bottom, and fix shell quoting issue that
463+ would result in /run/initramfs/open-iscsi.interface always being removed
464+ (LP: #1872813)
465+
466+ -- Daniel Watkins <oddbloke@ubuntu.com> Tue, 14 Apr 2020 16:54:37 -0400
467+
468+open-iscsi (2.0.874-7.1ubuntu5) focal; urgency=medium
469+
470+ * Use python2 instead of python in the autopkg tests.
471+
472+ -- Matthias Klose <doko@ubuntu.com> Thu, 30 Jan 2020 10:14:16 +0100
473+
474+open-iscsi (2.0.874-7.1ubuntu3) eoan; urgency=medium
475+
476+ * Stop producing udebs on i386 where we no longer have d-i or a kernel.
477+
478+ -- Adam Conrad <adconrad@ubuntu.com> Wed, 09 Oct 2019 14:10:37 -0600
479+
480+open-iscsi (2.0.874-7.1ubuntu2) eoan; urgency=medium
481+
482+ * debian/open-iscsi.kmod: drop; no static module list is needed if we let
483+ iscsid load modules itself. LP: #1833586.
484+ * debian/extra/initramfs.hook: add ib_iser to the list of modules
485+ included in the initramfs, so that we can in principle support iscsi
486+ root on infiniband.
487+
488+ -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 20 Jun 2019 13:48:46 -0700
489+
490+open-iscsi (2.0.874-7.1ubuntu1) eoan; urgency=low
491+
492+ * Merge from Debian unstable. Remaining changes:
493+ - debian/tests: Add Ubuntu autopkgtest.
494+ - debian/iscsi-network-interface.rules, debian/net-interface-handler,
495+ debian/open-iscsi.install:
496+ Prevent network interface that contains iscsi root from bouncing
497+ during boot or going down during shutdown if the system is using
498+ resolvconf or ifupdown.
499+ - Let iscsid systemd job run in privileged containers but not in
500+ unprivileged ones
501+ - Start open-iscsi systemd job when either /etc/iscsi/nodes or
502+ /sys/class/iscsi_session have content
503+ - add IPv6 support
504+ + Source /run/net6-*.conf when needed.
505+ + debian/extra/initramfs.local-top: handle IPv6 configs being
506+ shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
507+ can fill in /run/initramfs/open-iscsi.interface
508+ - make iscsid socket-activated to only activate it as needed
509+ + debian/iscsid.socket: systemd socket file for iscsid
510+ + debian/open-iscsi.service: do not start or check iscsid.service
511+ + debian/rules: install and enable iscsid.socket
512+ + debian/patches/iscid-conf-use-systemd.socket-patch: default to the
513+ socket
514+ + debian/open-iscsi.postinst:
515+ * run restart logic only if service is running on upgrade
516+ * drop no longer reachable upgrade path that affects iscsid
517+ * disable iscsid.service on upgrade
518+ * handle iscsid.socket to be started if the service is not running
519+ yet
520+ + d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
521+ run when udev disks are attached.
522+ + d/iscsid.service: Remove ExecStop= directive.
523+ + debian/tests/install: fix tests to work with socket activation
524+ - Ship finalrd logout hook.
525+ - debian/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
526+ run ipconfig to gather all DHCP config info, including DNS search
527+ domain, which iBFT can't provide.
528+ - If iscsi root was requested, but no iscsi devices were mounted, remove
529+ the initramfs interfaces stamp file. Meaning, that on shutdown there
530+ is no 30s delay, whilst trying to re-establish iscsi login to perform
531+ a logout.
532+ * Dropped changes, included in Debian:
533+ - Fix fail to build from source due to undefined reference to
534+ minor
535+ * Drop breaks on never-released version of finalrd.
536+ * debian/net-interface-handler: drop upstart support, unused since bionic.
537+ * Drop cleanup of upstart jobs, no longer needed post bionic.
538+ * debian/tests/daemon: drop, unused.
539+
540+ -- Steve Langasek <steve.langasek@ubuntu.com> Mon, 29 Apr 2019 16:13:37 -0700
541+
542 open-iscsi (2.0.874-7) unstable; urgency=medium
543
544 * [eeda27c] Enable back pristine-tar as we have now committed it
545@@ -131,6 +558,158 @@ open-iscsi (2.0.874-6) unstable; urgency=medium
546
547 -- Ritesh Raj Sarraf <rrs@debian.org> Fri, 05 Oct 2018 11:31:19 +0530
548
549+open-iscsi (2.0.874-5ubuntu15) disco; urgency=medium
550+
551+ * d/iscsid.service: Remove ExecStop= directive. Letting systemd
552+ handle termination prevents restart failures. (LP: #1821255)
553+
554+ -- Heitor R. Alves de Siqueira <halves@canonical.com> Thu, 28 Mar 2019 10:21:24 -0300
555+
556+open-iscsi (2.0.874-5ubuntu14) disco; urgency=medium
557+
558+ * debian/iscsi-disk.rules: Fix bug with LVM on top of iscsi devices.
559+ (LP: #1807978)
560+
561+ -- Scott Moser <smoser@ubuntu.com> Tue, 11 Dec 2018 19:01:14 -0500
562+
563+open-iscsi (2.0.874-5ubuntu13) disco; urgency=medium
564+
565+ [ Robert C Jennings & Dimitri John Ledkov ]
566+ * If iscsi root was requested, but no iscsi devices were mounted, remove
567+ the initramfs interfaces stamp file. Meaning, that on shutdown there
568+ is no 30s delay, whilst trying to re-establish iscsi login to perform
569+ a logout. LP: #1800681
570+
571+ -- Dimitri John Ledkov <xnox@ubuntu.com> Sun, 09 Dec 2018 22:29:20 +0000
572+
573+open-iscsi (2.0.874-5ubuntu12) disco; urgency=medium
574+
575+ [Scott Moser]
576+ * debian/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
577+ run ipconfig to gather all DHCP config info, including DNS search
578+ domain, which iBFT can't provide. (LP: #1806777)
579+
580+ -- Dan Streetman <ddstreet@canonical.com> Wed, 05 Dec 2018 11:28:12 -0500
581+
582+open-iscsi (2.0.874-5ubuntu11) disco; urgency=medium
583+
584+ * debian/tests/test-open-iscsi.py: Fix called process error.
585+ If no image was available for a release, a NameError exception would be
586+ raised.
587+
588+ -- Scott Moser <smoser@ubuntu.com> Wed, 14 Nov 2018 16:50:29 -0500
589+
590+open-iscsi (2.0.874-5ubuntu10) disco; urgency=medium
591+
592+ * d/iscsi-disk.rules, d/tests: Add a udev rule so that iscsid.service
593+ will be run when udev disks are attached. (LP: #1802354)
594+ * debian/tests: improve tgt boot test
595+ - disable snapd and snap.seeded services to avoid unnecessary
596+ resource consumption during tests.
597+ - save artifacts from the test run.
598+
599+ -- Scott Moser <smoser@ubuntu.com> Wed, 14 Nov 2018 16:05:46 -0500
600+
601+open-iscsi (2.0.874-5ubuntu9) cosmic; urgency=medium
602+
603+ * d/net-interface-handler: replace 'domainsearch' with the correct
604+ configuration option 'search' in net-interface-handler (LP: #1791108)
605+
606+ -- Victor Tapia <victor.tapia@canonical.com> Mon, 17 Sep 2018 15:58:34 +0200
607+
608+open-iscsi (2.0.874-5ubuntu8) cosmic; urgency=medium
609+
610+ * d/tests: insert some debug units in an attempt to diagnose any
611+ occurences of bug 1788188.
612+ * Fix fail to build from source due to undefined reference to
613+ minor (LP: #1791154)
614+
615+ -- Scott Moser <smoser@ubuntu.com> Tue, 21 Aug 2018 13:33:06 -0400
616+
617+open-iscsi (2.0.874-5ubuntu7) cosmic; urgency=medium
618+
619+ * d/tests: make interactive use of tgt-boot-test more usable by
620+ only using 'timeout' from the test harness.
621+ * debian/tests/README-boot-test.md: minor doc fixes and whitespace.
622+ * d/net-interface-handler: Apply changes only for the iscsi-root interface.
623+ (LP: #1785108)
624+
625+ -- Scott Moser <smoser@ubuntu.com> Tue, 07 Aug 2018 16:37:13 -0400
626+
627+open-iscsi (2.0.874-5ubuntu6) cosmic; urgency=medium
628+
629+ * Ship finalrd logout hook.
630+
631+ -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 03 Aug 2018 15:03:51 +0100
632+
633+open-iscsi (2.0.874-5ubuntu5) cosmic; urgency=medium
634+
635+ * Harden dep8 tests against effects due to slow execution on Launchpad
636+ infrastructure (LP: #1732028).
637+ - debian/tests/patch-image: remove problematic fstab entries
638+ - debian/tests/tgt-boot-test: ran xkvm in verbose mode
639+
640+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 19 Jul 2018 18:22:39 +0200
641+
642+open-iscsi (2.0.874-5ubuntu4) cosmic; urgency=medium
643+
644+ * debian/tests/install: ignore the potential stderr of the probing command
645+ that is meant to activate iscsid indirectly via the socket.
646+
647+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 30 May 2018 15:42:12 +0200
648+
649+open-iscsi (2.0.874-5ubuntu3) cosmic; urgency=medium
650+
651+ * make iscsid socket activated to only activate it as-needed (LP: #1755858)
652+ - debian/iscsid.socket: systemd socket file for iscsid
653+ - debian/open-iscsi.service: do not start or check iscsid.service
654+ - debian/rules: install and enable iscsid.socket
655+ - debian/patches/iscid-conf-use-systemd.socket-patch: default to the socket
656+ - debian/open-iscsi.postinst:
657+ + run restart logic only if service is running on upgrade
658+ + drop no more reachable upgrade path that affects iscsid
659+ + disable iscsid.service on upgrade
660+ + handle iscsid.socket to be started if the service is not running yet
661+ - debian/tests/install: fix tests to work with socket activation
662+
663+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 23 May 2018 15:50:01 +0200
664+
665+open-iscsi (2.0.874-5ubuntu2) bionic; urgency=medium
666+
667+ * debian/tests:
668+ - tgt-boot-test: Use 'timeout' to force a 60m timeout of the boot test.
669+ - README-boot-test.md: document environment variables BOOT_TIMEOUT
670+ and _USE_KVM.
671+
672+ -- Scott Moser <smoser@ubuntu.com> Wed, 21 Feb 2018 13:19:17 -0500
673+
674+open-iscsi (2.0.874-5ubuntu1) bionic; urgency=low
675+
676+ * Merge with Debian unstable. Remaining changes:
677+ - debian/tests: Add Ubuntu autopkgtests.
678+ - debian/iscsi-network-interface.rules, debian/net-interface-handler,
679+ debian/open-iscsi.install:
680+ Prevent network interface that contains iscsi root from bouncing
681+ during boot or going down during shutdown.
682+ Integrates with resolvconf and initramfs code that writes
683+ /run/initramfs/open-iscsi.interface
684+ - debian/open-iscsi.maintscript: clean up the obsolete
685+ iscsi-network-interface upstart job, file on upgrade.
686+ - Let iscsid systemd job run in privileged containers but not in
687+ unprivileged ones
688+ - Start open-iscsi systemd job when either /etc/iscsi/nodes or
689+ /sys/class/iscsi_session have content
690+ Based on patch by Nish Aravamudan, thanks! (LP #1576341)
691+ - add IPv6 support
692+ + add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
693+ LP #1621507
694+ + Source /run/net6-*.conf when needed.
695+ + debian/extra/initramfs.local-top: handle IPv6 configs being
696+ shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
697+ can fill in /run/initramfs/open-iscsi.interface (LP #1621507)
698+
699+ -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 12 Jan 2018 14:00:59 +0000
700+
701 open-iscsi (2.0.874-5) unstable; urgency=high
702
703 * [aeb86f7] Fix multiple security issues in iscsiuio. (CVE-2017-17840)
704@@ -138,6 +717,74 @@ open-iscsi (2.0.874-5) unstable; urgency=high
705
706 -- Christian Seiler <christian@iwakd.de> Sat, 23 Dec 2017 11:30:44 +0100
707
708+open-iscsi (2.0.874-4ubuntu5) bionic; urgency=medium
709+
710+ * debian/tests/patch-image: mount auxilary filesystems before upgrading
711+ packages. Fixes ADT tests, when triggered by packages, that need
712+ /proc, /dev, etc mounted to complete the upgrade.
713+
714+ -- Dimitri John Ledkov <xnox@ubuntu.com> Wed, 03 Jan 2018 12:21:05 +0000
715+
716+open-iscsi (2.0.874-4ubuntu4) bionic; urgency=medium
717+
718+ * debian/tests/test-open-iscsi.py: skip test if cloud image is unavailable.
719+ This solves flaky tests in restricted network environments as well as in
720+ the short period after opening a new release (LP: #1731907).
721+
722+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 16 Nov 2017 12:06:34 +0100
723+
724+open-iscsi (2.0.874-4ubuntu3) artful; urgency=medium
725+
726+ * debian/tests/xkvm: do not use kvm (-enable-kvm) by default if
727+ operating inside a vm. nested kvm is finicky.
728+
729+ -- Scott Moser <smoser@ubuntu.com> Wed, 11 Oct 2017 18:14:08 -0400
730+
731+open-iscsi (2.0.874-4ubuntu2) artful; urgency=medium
732+
733+ * debian/tests/test-open-iscsi.py: query systemd-resolved if present.
734+ Ubuntu images now have systemd-resolved managing /etc/resolv.conf
735+ so support test if that is the case (LP: #1715468).
736+
737+ -- Scott Moser <smoser@ubuntu.com> Wed, 06 Sep 2017 16:20:16 -0400
738+
739+open-iscsi (2.0.874-4ubuntu1) artful; urgency=medium
740+
741+ * Merge with Debian unstable. Remaining changes:
742+ - debian/tests: Add Ubuntu autopkgtests.
743+ - debian/iscsi-network-interface.rules, debian/net-interface-handler,
744+ debian/open-iscsi.install:
745+ Prevent network interface that contains iscsi root from bouncing
746+ during boot or going down during shutdown.
747+ Integrates with resolvconf and initramfs code that writes
748+ /run/initramfs/open-iscsi.interface
749+ - debian/open-iscsi.maintscript: clean up the obsolete
750+ iscsi-network-interface upstart job, file on upgrade.
751+ - Let iscsid systemd job run in privileged containers but not in
752+ unprivileged ones
753+ - Start open-iscsi systemd job when either /etc/iscsi/nodes or
754+ /sys/class/iscsi_session have content
755+ Based on patch by Nish Aravamudan, thanks! (LP #1576341)
756+ - add IPv6 support
757+ + add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
758+ LP #1621507
759+ + Source /run/net6-*.conf when needed.
760+ + debian/extra/initramfs.local-top: handle IPv6 configs being
761+ shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
762+ can fill in /run/initramfs/open-iscsi.interface (LP #1621507)
763+ * Drop:
764+ - d/extra/initramfs.local-top: When booting from iBFT,
765+ set the PROTO= entry in /run/net-*.conf accordingly,
766+ so that other tools, such as cloud-init, can use that
767+ information. (cloud-init fails if the current PROTO=none
768+ is used.) (LP: #1684039) (Closes: #866213)
769+ [ Fixed in Debian 2.0.874-4 ]
770+ * d/t/test-open-iscsi.py: drop test_daemon test
771+ - With the updates to the systemd units, the services do not run
772+ unless iSCSI is configured.
773+
774+ -- Nishanth Aravamudan <nish.aravamudan@canonical.com> Tue, 08 Aug 2017 16:16:27 -0700
775+
776 open-iscsi (2.0.874-4) unstable; urgency=medium
777
778 * [0347300] initramfs: populate PROTO= entry in /run/net-*.conf from iBFT
779@@ -152,6 +799,64 @@ open-iscsi (2.0.874-3) unstable; urgency=medium
780
781 -- Christian Seiler <christian@iwakd.de> Sun, 18 Jun 2017 22:01:22 +0200
782
783+open-iscsi (2.0.874-2ubuntu3) artful; urgency=medium
784+
785+ * d/t/test-open-iscsi.py: drop test_daemon test
786+ - With the updates to the systemd units, the services do not run
787+ unless iSCSI is configured.
788+
789+ -- Nishanth Aravamudan <nish.aravamudan@canonical.com> Tue, 08 Aug 2017 16:05:29 -0700
790+
791+open-iscsi (2.0.874-2ubuntu2) artful; urgency=medium
792+
793+ * d/extra/initramfs.local-top: When booting from iBFT,
794+ set the PROTO= entry in /run/net-*.conf accordingly,
795+ so that other tools, such as cloud-init, can use that
796+ information. (cloud-init fails if the current PROTO=none
797+ is used.) (LP: #1684039) (Closes: #866213)
798+
799+ -- Eric Desrochers <eric.desrochers@canonical.com> Wed, 05 Jul 2017 09:02:12 -0400
800+
801+open-iscsi (2.0.874-2ubuntu1) artful; urgency=medium
802+
803+ [ Nishanth Aravamudan ]
804+ * Merge with Debian unstable. Remaining changes:
805+ - debian/tests: Add Ubuntu autopkgtests.
806+ - debian/iscsi-network-interface.rules, debian/net-interface-handler,
807+ debian/open-iscsi.install:
808+ Prevent network interface that contains iscsi root from bouncing
809+ during boot or going down during shutdown.
810+ Integrates with resolvconf and initramfs code that writes
811+ /run/initramfs/open-iscsi.interface
812+ - debian/open-iscsi.maintscript: clean up the obsolete
813+ iscsi-network-interface upstart job, file on upgrade.
814+ - add IPv6 support
815+ + add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
816+ LP #1621507
817+ + Source /run/net6-*.conf when needed.
818+ + debian/extra/initramfs.local-top: handle IPv6 configs being
819+ shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
820+ can fill in /run/initramfs/open-iscsi.interface (LP #1621507)
821+ * Drop:
822+ - Make systemd job not run in containers (LP #1576341)
823+ [ This prevents running iscsi in privileged containers.
824+ Fixed differently in this upload. ]
825+ - Cherry-pick from Debian git repository (Christian Seiler):
826+ + open-iscsi-udeb: drop Depends: libnss-files-udeb
827+ (Closes #819685)
828+ [ Fixed in Debian ]
829+ - d/extra/initramfs.local-top whitespace change
830+ [ previously undocumented ]
831+
832+ [ Balint Reczey ]
833+ * Let iscsid systemd job run in privileged containers but not in
834+ unprivileged ones
835+ * Start open-iscsi systemd job when either /etc/iscsi/nodes or
836+ /sys/class/iscsi_session have content
837+ Based on patch by Nish Aravamudan, thanks! (LP #1576341)
838+
839+ -- Nishanth Aravamudan <nish.aravamudan@canonical.com> Tue, 09 May 2017 09:24:23 -0700
840+
841 open-iscsi (2.0.874-2) unstable; urgency=medium
842
843 [ Christian Seiler ]
844@@ -291,6 +996,155 @@ open-iscsi (2.0.873+git0.3b4b4500-15) unstable; urgency=medium
845
846 -- Christian Seiler <christian@iwakd.de> Fri, 20 May 2016 09:52:46 +0200
847
848+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu17) zesty; urgency=medium
849+
850+ * debian/tests:
851+ - README-boot-test.md: mention limited space caveat.
852+ - patch-image: fix handling of ADT_TEST_TRIGGERS if source package
853+ built more than one binary package.
854+ - test-open-iscsi.py: change to rely on patch-image
855+ adding package 'open-iscsi' rather than passing it in itself.
856+
857+ -- Scott Moser <smoser@ubuntu.com> Thu, 16 Feb 2017 15:47:58 -0500
858+
859+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu16) zesty; urgency=medium
860+
861+ * debian/tests: many improvements to the open-iscsi and tgt boot test.
862+ - only run test on amd64. just avoid timeout errors or other unrelated
863+ issues causing failure.
864+ - debian/tests/README-boot-test.md: add doc describing the tgt-boot-test
865+ - rename get-maas-eph to get-image
866+ - use a cloud image instead of a maas image for booting. The value in
867+ this is that we can then install open-iscsi inside the image and get an
868+ updated initramfs.
869+ - use subprocess.check_call rather than subprocess.call so that we
870+ actually catch errors.
871+ - update xkvm to what is in curtin/tools/xkvm
872+ - improve updating of images to consider ADT_TEST_TRIGGERS if set.
873+
874+ -- Scott Moser <smoser@ubuntu.com> Tue, 14 Feb 2017 17:07:00 -0500
875+
876+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu15) zesty; urgency=medium
877+
878+ * debian/tests/tgt-boot-test: set HOST_IP harder for the testsuite test.
879+
880+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Sun, 29 Jan 2017 13:05:47 -0500
881+
882+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu14) zesty; urgency=medium
883+
884+ * Make systemd job not run in containers (LP: #1576341)
885+
886+ -- Serge Hallyn <serge.hallyn@ubuntu.com> Sun, 15 Jan 2017 23:08:29 -0600
887+
888+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu13) zesty; urgency=medium
889+
890+ * Fix syntax error in previous changes. LP: #1621507
891+
892+ -- LaMont Jones <lamont@ubuntu.com> Fri, 09 Dec 2016 12:35:45 +0100
893+
894+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu12) zesty; urgency=medium
895+
896+ * debian/tests/tgt-boot-test: set HOST_IP to 10.0.2.2; it's suboptimal but
897+ given the test setup this will allow the right IPs to be used to bring up
898+ the iscsi target in the xkvm.
899+
900+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Thu, 08 Dec 2016 11:00:12 +0100
901+
902+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu11) zesty; urgency=medium
903+
904+ * debian/tests/tgt-boot-test: drop -serial stdio altogether since running
905+ the VM in -nographics mode will already output to stdout.
906+
907+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Tue, 22 Nov 2016 11:27:55 -0500
908+
909+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu10) zesty; urgency=medium
910+
911+ * debian/tests/tgt-boot-test: always log qemu serial to stdio so we can
912+ actually see what is going on during the tests.
913+
914+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Thu, 17 Nov 2016 11:01:27 -0500
915+
916+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu9) zesty; urgency=medium
917+
918+ [ LaMont Jones ]
919+ * Clean up net-interface-handler
920+ * Source /run/net6-*.conf when needed.
921+
922+ [ Mathieu Trudel-Lapierre ]
923+ * debian/extra/initramfs.local-top: handle IPv6 configs being shipped in
924+ DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
925+ /run/initramfs/open-iscsi.interface (LP: #1621507)
926+
927+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Thu, 03 Nov 2016 16:30:37 -0600
928+
929+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu8) yakkety; urgency=medium
930+
931+ * debian/tests/xkvm: don't --enable-kvm.
932+
933+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Wed, 05 Oct 2016 12:58:21 -0400
934+
935+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu7) yakkety; urgency=medium
936+
937+ * debian/tests/test-open-iscsi.py: glob to pick up open-iscsi.deb, which may
938+ be named differently depending on how autopkgtests are run.
939+
940+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Wed, 05 Oct 2016 09:56:25 -0400
941+
942+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu6) yakkety; urgency=medium
943+
944+ * debian/tests/test-open-iscsi.py: install the open-iscsi binary into a test
945+ MAAS image, so we can check bootability. Download the open-iscsi explicitly
946+ to /tmp before trying to copy it; so that we don't need to depend on ugly
947+ internal autopkgtest paths.
948+
949+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Tue, 04 Oct 2016 09:05:56 -0400
950+
951+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu5) yakkety; urgency=medium
952+
953+ * debian/tests/control: add build-needed since some of the new tests
954+ appear to require that (so they can reach open-iscsi.deb which is a build
955+ artifact from building in autopkgtest).
956+
957+ -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Mon, 03 Oct 2016 16:10:54 -0400
958+
959+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu4) yakkety; urgency=medium
960+
961+ * add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
962+ LP: #1621507
963+
964+ -- LaMont Jones <lamont@canonical.com> Tue, 20 Sep 2016 08:05:41 -0600
965+
966+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu3) xenial; urgency=medium
967+
968+ * Cherry-pick from Debian git repository (Christian Seiler):
969+ - open-iscsi-udeb: drop Depends: libnss-files-udeb (Closes: #819685)
970+
971+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 15 Apr 2016 16:54:26 +0100
972+
973+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu2) xenial; urgency=medium
974+
975+ * debian/tests: add two new tests. One to verify net-interface-handler is
976+ installed executable, and one to actually test that /etc/resolv.conf is
977+ updated with dhcp dns responses.
978+
979+ -- Diogo Matsubara <diogo.matsubara@gmail.com> Wed, 09 Mar 2016 12:56:42 -0300
980+
981+open-iscsi (2.0.873+git0.3b4b4500-14ubuntu1) xenial; urgency=medium
982+
983+ * Merge from debian. Remaining changes:
984+ - debian/tests: Add Ubuntu autopkgtest.
985+ - debian/iscsi-network-interface.rules, debian/net-interface-handler,
986+ debian/open-iscsi.install:
987+ Prevent network interface that contains iscsi root from bouncing
988+ during boot or going down during shutdown.
989+ Integrates with resolvconf and initramfs code that writes
990+ /run/initramfs/open-iscsi.interface
991+ - debian/open-iscsi.maintscript: clean up the obsolete
992+ iscsi-network-interface upstart job, file on upgrade.
993+ * make debian/net-interface-handler executable (LP: #1553017)
994+
995+ -- Scott Moser <smoser@ubuntu.com> Fri, 04 Mar 2016 13:17:45 -0500
996+
997 open-iscsi (2.0.873+git0.3b4b4500-14) unstable; urgency=medium
998
999 [ Christian Seiler ]
1000@@ -303,6 +1157,21 @@ open-iscsi (2.0.873+git0.3b4b4500-14) unstable; urgency=medium
1001
1002 -- Christian Seiler <christian@iwakd.de> Thu, 03 Mar 2016 18:47:46 +0100
1003
1004+open-iscsi (2.0.873+git0.3b4b4500-13ubuntu1) xenial; urgency=medium
1005+
1006+ * Merge from Debian (LP: #1546877). Remaining changes:
1007+ - debian/tests: Add Ubuntu autopkgtest.
1008+ - debian/iscsi-network-interface.rules, debian/net-interface-handler,
1009+ debian/open-iscsi.install:
1010+ Prevent network interface that contains iscsi root from bouncing
1011+ during boot or going down during shutdown.
1012+ Integrates with resolvconf and initramfs code that writes
1013+ /run/initramfs/open-iscsi.interface
1014+ - debian/open-iscsi.maintscript: clean up the obsolete
1015+ iscsi-network-interface upstart job, file on upgrade.
1016+
1017+ -- Scott Moser <smoser@ubuntu.com> Thu, 18 Feb 2016 00:53:37 -0500
1018+
1019 open-iscsi (2.0.873+git0.3b4b4500-13) unstable; urgency=medium
1020
1021 [ Christian Seiler ]
1022@@ -524,6 +1393,115 @@ open-iscsi (2.0.873+git0.3b4b4500-1) unstable; urgency=low
1023
1024 -- Ritesh Raj Sarraf <rrs@debian.org> Tue, 05 Nov 2013 21:45:47 +0530
1025
1026+open-iscsi (2.0.873-3ubuntu13) wily; urgency=medium
1027+
1028+ * debian/net-interface-handler: Create the resolvconf dir, to avoid failure
1029+ when resolvconf did not start yet; the udev rules run in parallel with
1030+ it. (LP: #1501033)
1031+
1032+ -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 06 Oct 2015 07:05:48 +0200
1033+
1034+open-iscsi (2.0.873-3ubuntu12) wily; urgency=medium
1035+
1036+ * Drop debian/ifup@.service.conf again, it ceased to work with net.agent in
1037+ wily and the whole idea of net-interface-handler is to *stop* ifupdown
1038+ from fiddling with the iscsi interface. Replace with udev rules
1039+ (debian/iscsi-network-interface.rules) which achieves this without relying
1040+ on ifupdown or a particular init system. (LP: #1463461)
1041+ * Drop debian/open-iscsi.iscsi-network-interface.upstart as well, obsolete
1042+ now. Also clean it up on upgrades.
1043+
1044+ -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 11 Jun 2015 11:58:29 +0200
1045+
1046+open-iscsi (2.0.873-3ubuntu11) vivid; urgency=medium
1047+
1048+ * Factor out logic from debian/open-iscsi.iscsi-network-interface.upstart
1049+ into debian/net-interface-handler, and install the latter in debian/rules.
1050+ * Add debian/ifup@.service.conf: Drop-in for ifup@.service to run
1051+ net-interface-handler under systemd. (LP: #1432829)
1052+
1053+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 27 Mar 2015 09:51:05 +0100
1054+
1055+open-iscsi (2.0.873-3ubuntu10) vivid; urgency=medium
1056+
1057+ * Start open-iscsi after installation and make sure initiatorname is
1058+ generated. (Patch backported from Debian)
1059+ * debian/tests/daemon: Stop calling the init.d script as we expect the
1060+ daemon to start automatically now.
1061+
1062+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 06 Mar 2015 13:17:26 +0100
1063+
1064+open-iscsi (2.0.873-3ubuntu9) trusty; urgency=medium
1065+
1066+ * Add missing python test dependency.
1067+
1068+ -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 26 Feb 2014 16:07:37 +0100
1069+
1070+open-iscsi (2.0.873-3ubuntu8) trusty; urgency=medium
1071+
1072+ * open-iscsi-udeb: Enable builds on armhf, arm64, ppc64el, x32 (LP: #1274203)
1073+
1074+ -- dann frazier <dann.frazier@canonical.com> Wed, 29 Jan 2014 12:34:45 -0700
1075+
1076+open-iscsi (2.0.873-3ubuntu7) saucy; urgency=low
1077+
1078+ * Use dh_autotools-dev to update config.sub|guess.
1079+
1080+ -- Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com> Fri, 11 Oct 2013 17:03:37 +0100
1081+
1082+open-iscsi (2.0.873-3ubuntu6) saucy; urgency=low
1083+
1084+ * debian/tests: Add autopkgtest.
1085+
1086+ -- Yolanda <yolanda.robla@canonical.com> Mon, 27 May 2013 10:39:35 +0200
1087+
1088+open-iscsi (2.0.873-3ubuntu5) quantal-proposed; urgency=low
1089+
1090+ * Ensure all udev events have been processed before trying to configure
1091+ iscsi networking in the initramfs (LP: #1066945):
1092+ - debian/extra/initramfs.local-top: Restore wait_for_udev call before
1093+ configure_networking to ensure network devices are present.
1094+
1095+ -- James Page <james.page@ubuntu.com> Wed, 17 Oct 2012 12:37:43 +0100
1096+
1097+open-iscsi (2.0.873-3ubuntu4) quantal-proposed; urgency=low
1098+
1099+ * Generate initiator name on install, not first boot, ensuring that the
1100+ initramfs built during install contains a valid iSCSI initiator name
1101+ resulting in a iSCSI based root volume that will actually boot
1102+ (LP: #1057635):
1103+ - debian/{rules,initiatorname.iscsi}: Don't install a default
1104+ initiatorname.iscsi.
1105+ - debian/open-iscsi.postinst: Generate initiatorname.iscsi on install.
1106+
1107+ -- James Page <james.page@ubuntu.com> Mon, 15 Oct 2012 12:42:53 +0100
1108+
1109+open-iscsi (2.0.873-3ubuntu3) quantal; urgency=low
1110+
1111+ * debian/open-iscsi.iscsi-network-interface.upstart: fix bad syntax
1112+ in 'post-stop'
1113+
1114+ -- Scott Moser <smoser@ubuntu.com> Mon, 17 Sep 2012 16:50:22 -0400
1115+
1116+open-iscsi (2.0.873-3ubuntu2) quantal; urgency=low
1117+
1118+ * debian/extra/initramfs.local-top: start writing
1119+ /run/initramfs/open-iscsi.interface file again (LP: #1050480)
1120+ * debian/open-iscsi.iscsi-network-interface.upstart: integrate with
1121+ resolvconf (LP: #1050487)
1122+
1123+ -- Scott Moser <smoser@ubuntu.com> Mon, 17 Sep 2012 15:46:26 -0400
1124+
1125+open-iscsi (2.0.873-3ubuntu1) quantal; urgency=low
1126+
1127+ * Merge from Debian. Remaining changes: (LP: #961114, LP: #677333)
1128+ - Add upstart job iscsi-network-interface
1129+ - Migrate from /var/run and /lib/init/rw to /run, from /var/lock to
1130+ /run/lock.
1131+ * Turn open-iscsi-utils into a transitional package
1132+
1133+ -- Stéphane Graber <stgraber@ubuntu.com> Tue, 10 Jul 2012 13:53:52 -0400
1134+
1135 open-iscsi (2.0.873-3) unstable; urgency=low
1136
1137 * [4939401] Fix build to install udeb stuff only on supported architectures
1138@@ -698,6 +1676,239 @@ open-iscsi (2.0.871-1) unstable; urgency=low
1139
1140 -- Ritesh Raj Sarraf <rrs@researchut.com> Sat, 06 Feb 2010 20:28:23 +0530
1141
1142+open-iscsi (2.0.871-0ubuntu9) oneiric-proposed; urgency=low
1143+
1144+ * Make sure the upstart job triggers ifupdown's upstart script to avoid
1145+ waiting 2 minutes at boot time for network to come up. (LP: #870214)
1146+
1147+ -- Stéphane Graber <stgraber@ubuntu.com> Tue, 11 Oct 2011 22:31:39 +0100
1148+
1149+open-iscsi (2.0.871-0ubuntu8) oneiric; urgency=low
1150+
1151+ * Disable open-iscsi init script when root is on iscsi (LP: #838809)
1152+
1153+ -- Stéphane Graber <stgraber@ubuntu.com> Thu, 15 Sep 2011 10:01:12 -0400
1154+
1155+open-iscsi (2.0.871-0ubuntu7) oneiric; urgency=low
1156+
1157+ * Migrate from /var/run and /lib/init/rw to /run, from /var/lock to
1158+ /run/lock, and from /dev/.initramfs to /run/initramfs.
1159+
1160+ -- Colin Watson <cjwatson@ubuntu.com> Thu, 14 Jul 2011 17:01:42 +0100
1161+
1162+open-iscsi (2.0.871-0ubuntu6) oneiric; urgency=low
1163+
1164+ * Fix initramfs iSCSI login (many thanks to Amos Hayes for lending me a
1165+ test system; LP: #728088):
1166+ - Write out /dev/.initramfs/open-iscsi.interface in the same subshell as
1167+ configure_networking, so that we can get at the value of DEVICE.
1168+ - Wait for udev to settle before attempting to configure networking.
1169+
1170+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 27 May 2011 23:27:31 +0100
1171+
1172+open-iscsi (2.0.871-0ubuntu5) maverick; urgency=low
1173+
1174+ * Include <sys/types.h> and <sys/stat.h> in usr/iscsi_sysfs.c for S_*
1175+ macros (LP: #600953).
1176+
1177+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 02 Jul 2010 17:08:14 +0100
1178+
1179+open-iscsi (2.0.871-0ubuntu4) lucid; urgency=low
1180+
1181+ * Revert ISCSI_NETDEVICE change; it's normally better to select the
1182+ interface by MAC address (LP: #473036).
1183+
1184+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 05 Feb 2010 12:06:06 -0800
1185+
1186+open-iscsi (2.0.871-0ubuntu3) lucid; urgency=low
1187+
1188+ * If ISCSI_NETDEVICE is set, configure that interface in the initramfs
1189+ (LP: #473036).
1190+
1191+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 22 Jan 2010 17:01:17 +0000
1192+
1193+open-iscsi (2.0.871-0ubuntu2) lucid; urgency=low
1194+
1195+ * Fix handling of ISCSI_USERNAME, ISCSI_PASSWORD, ISCSI_IN_USERNAME, and
1196+ ISCSI_IN_PASSWORD in iscsi.initramfs (closes: #525053).
1197+
1198+ -- Colin Watson <cjwatson@ubuntu.com> Mon, 14 Dec 2009 12:24:42 +0000
1199+
1200+open-iscsi (2.0.871-0ubuntu1) lucid; urgency=low
1201+
1202+ * New upstream release.
1203+ * If the root filesystem is on iSCSI, prevent the network interface used
1204+ for it from being brought up or down automatically (LP: #457767).
1205+ * Backport from upstream:
1206+ - Allow updating of discovery records (Hannes Reinecke).
1207+ - Fix discovery record use, rather than always using iscsid.conf
1208+ settings (Mike Christie).
1209+
1210+ -- Colin Watson <cjwatson@ubuntu.com> Thu, 10 Dec 2009 18:19:20 +0000
1211+
1212+open-iscsi (2.0.870.1-0ubuntu12) karmic; urgency=low
1213+
1214+ * debian/open-iscsi-udeb.finish-install: Stop checking
1215+ disk-detect/iscsi/enable, as that template doesn't exist any more.
1216+
1217+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 02 Oct 2009 18:49:18 +0100
1218+
1219+open-iscsi (2.0.870.1-0ubuntu11) karmic; urgency=low
1220+
1221+ * open-iscsi-utils Replaces: old versions of open-iscsi.
1222+ * SECURITY UPDATE: temporary file vulnerability (LP: #408915)
1223+ - utils/iscsi_discovery: store iscsiadm -m discovery result in a
1224+ variable rather than writing it to an insecurely-created temporary
1225+ file
1226+ - CVE-2009-1297
1227+
1228+ -- Colin Watson <cjwatson@ubuntu.com> Mon, 24 Aug 2009 23:42:10 +0100
1229+
1230+open-iscsi (2.0.870.1-0ubuntu10) karmic; urgency=low
1231+
1232+ * debian/control, debian/open-iscsi-utils.install,
1233+ open-iscsi-utils.manpages : create a new binary package which
1234+ contains /sbin/iscsiadm, needed for some packages to build against
1235+ (eg, libvirt), but not containing the init script, LP: #414986
1236+
1237+ -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 18 Aug 2009 08:11:34 -0500
1238+
1239+open-iscsi (2.0.870.1-0ubuntu9) karmic; urgency=low
1240+
1241+ * debian/open-iscsi.init: don't exit with error if
1242+ /lib/init/rw/sendsigs.omit.d/ doesn't exist (LP: #414986)
1243+
1244+ -- Jamie Strandboge <jamie@ubuntu.com> Mon, 17 Aug 2009 14:12:01 -0500
1245+
1246+open-iscsi (2.0.870.1-0ubuntu8) karmic; urgency=low
1247+
1248+ * Make sure network devices are always included in the initramfs if
1249+ booting with / on iSCSI.
1250+ * Retry initramfs network configuration for a while until it works (LP:
1251+ #237460).
1252+
1253+ -- Colin Watson <cjwatson@ubuntu.com> Tue, 11 Aug 2009 13:05:43 +0100
1254+
1255+open-iscsi (2.0.870.1-0ubuntu7) karmic; urgency=low
1256+
1257+ [ Colin Watson ]
1258+ * debian/open-iscsi-udeb.postinst, debian/open-iscsi-udeb.templates:
1259+ Remove; this is being taken over by disk-detect and partman-iscsi.
1260+ * debian/control: Remove XB-Installer-Menu-Item.
1261+
1262+ [ Mathias Gug ]
1263+ * debian/open-iscsi.postinst: Fix backwards use of update-rc.d (LP:
1264+ #306678).
1265+ * debian/open-iscsi.init: Overwrite existing pid file symlinks in
1266+ /lib/init/rw/sendsigs.omit.d/.
1267+
1268+ -- Colin Watson <cjwatson@ubuntu.com> Mon, 10 Aug 2009 13:28:41 +0100
1269+
1270+open-iscsi (2.0.870.1-0ubuntu6) karmic; urgency=low
1271+
1272+ * utils/iscsi_discovery: Fix several bashisms (test ==, &> redirection,
1273+ trap with numeric signals).
1274+
1275+ -- Colin Watson <cjwatson@ubuntu.com> Tue, 04 Aug 2009 12:30:44 +0100
1276+
1277+open-iscsi (2.0.870.1-0ubuntu5) karmic; urgency=low
1278+
1279+ * utils/iscsi_discovery: replace uses of awk with other shell voodoo, so
1280+ that this works in the installer. LP: #236640.
1281+ * debian/rules, debian/open-iscsi-udeb.dirs: install the open-isci-udeb
1282+ finish script to /usr/lib/finish-install.d, not to /lib/finish-install.d.
1283+ * debian/open-iscsi-udeb.finish-install: copy the config from the root
1284+ to the correct directory in the target.
1285+
1286+ -- Steve Langasek <steve.langasek@ubuntu.com> Tue, 07 Jul 2009 22:10:17 -0700
1287+
1288+open-iscsi (2.0.870.1-0ubuntu4) karmic; urgency=low
1289+
1290+ * debian/extra/initramfs.hook: iscsistart is in /sbin, not /usr/sbin (LP:
1291+ #364616).
1292+
1293+ -- Colin Watson <cjwatson@ubuntu.com> Thu, 02 Jul 2009 14:12:25 +0100
1294+
1295+open-iscsi (2.0.870.1-0ubuntu3) jaunty; urgency=low
1296+
1297+ * Invoke iscsi-iname using normal $PATH lookup rather than using an
1298+ incorrect explicit path (see LP #236640).
1299+
1300+ -- Colin Watson <cjwatson@ubuntu.com> Thu, 09 Apr 2009 16:49:08 +0100
1301+
1302+open-iscsi (2.0.870.1-0ubuntu2) jaunty; urgency=low
1303+
1304+ * debian/control: Drop udeb dependency on crypto-modules; as best as I can
1305+ tell, this is required for crc32c support, which is now built-in to the
1306+ Ubuntu kernels.
1307+
1308+ -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 03 Feb 2009 11:20:35 +0100
1309+
1310+open-iscsi (2.0.870.1-0ubuntu1) jaunty; urgency=low
1311+
1312+ * New upstream release:
1313+ - Support 2.6.26/27 kernels (LP: #289470).
1314+ - Fix iscsid shutdown (LP: #181188).
1315+ * Merge from Debian. Remaining Ubuntu changes:
1316+ - Note: Debian version isn't 870~rc3 but 869.2 which leads to a big
1317+ .diff.gz file. Only files in debian/ have been considered for this merge
1318+ since debian hasn't patched the source.
1319+ - debian/control, debian/rules, debian/open-iscsi-udeb*:
1320+ + Add open-iscsi-udeb.
1321+ - debian/open-iscsi.dirs:
1322+ + rename dirs to open-iscsi.dirs because of open-iscsi-udeb addition.
1323+ + drop network/if-up.d/ directory since we're using symlinks instead.
1324+ + utilities installed in /bin,/sbin rather than /usr/bin,/usr/sbin.
1325+ - debian/open-iscsi.init:
1326+ + utilities installed in /bin,/sbin rather than /usr/bin,/usr/sbin.
1327+ + lsb log messages.
1328+ + Don't generate initiatorname name (moved to postinst).
1329+ + Support for being called from ifup/ifdown scripts.
1330+ + Refactor start functions:
1331+ - move daemon start to startdaemon function.
1332+ - call udevadm settle rather then udevsettle (which doesn't do anything
1333+ useful).
1334+ - don't exit if the daemon is already running during sanitychecks.
1335+ Instead check in startdaemon if the daemon needs to be started.
1336+ - only start automatic targets if necessary.
1337+ - add waitfordevices function: called during rcS, waits for all
1338+ automatic targets to be ready. Iscsi targets are considered as
1339+ local block devices - they don't need to be marked with _netdev in
1340+ fstab. (LP: #227848)
1341+ - start targets if not run from rcS.
1342+ + Check status of iscsid daemon in addition to listing the iscsi sessions
1343+ when status action is called.
1344+ + Add iscsid to the list of processes that should not be killed by
1345+ sendsigs during shutdown (LP: #192080).
1346+ + Add starttargets, stoptargets and restarttargets to usage message.
1347+ - debian/rules:
1348+ + Install utilities /bin,/sbin rather than /usr/bin,/usr/sbin.
1349+ + Start open-iscsi at S25 (waiting for devices created by ifupdown
1350+ calls and before local filesystems are checked and mounted)
1351+ + stop at S41 (after local filesystems are unmounted). Don't use
1352+ umountiscsi.sh script from debian. (LP: #192080).
1353+ - debian/initiatorname.iscsi, debian/open-iscsi.postinst:
1354+ + Generate the random initiatorname during postinstall rather than in the
1355+ init script.
1356+ + Don't ship a default initiatorname.iscsi file.
1357+ - debian/open-iscsi.postinst:
1358+ + fix init script ordering on upgrades.
1359+ - debian/open-iscsi.links:
1360+ + symlink open-iscsi init script in if-up.d and if-down.d directory so
1361+ that the iscsi subsystem is started/stopped when network interfaces
1362+ are configured.
1363+ - debian/open-iscsi.postrm:
1364+ + delete iscsi configuration when the package is purged.
1365+ - utils/iscsi_discovery: De-bashify iscsi_discovery.
1366+ - usr/idbm.c: Fix build failure with new glibc. LP: #299843.
1367+ * Dropped:
1368+ - Exit without error if /sys is not available. Otherwise, it's not possible
1369+ to use this package as a build-dependency (in Debian).
1370+ - Drop upstream url in long description now that it's in the Homepage
1371+ field (in Debian).
1372+
1373+ -- Mathias Gug <mathiaz@ubuntu.com> Mon, 01 Dec 2008 10:45:03 -0500
1374+
1375 open-iscsi (2.0.870~rc3-0.6) unstable; urgency=low
1376
1377 * Non-maintainer upload.
1378@@ -797,6 +2008,47 @@ open-iscsi (2.0.869~rc4-1) experimental; urgency=low
1379
1380 -- Philipp Hug <debian@hug.cx> Sat, 12 Apr 2008 15:53:12 +0200
1381
1382+open-iscsi (2.0.865-1ubuntu5) jaunty; urgency=low
1383+
1384+ * Fix build failure with new glibc. LP: #299843.
1385+
1386+ -- Matthias Klose <doko@ubuntu.com> Thu, 27 Nov 2008 15:58:15 +0100
1387+
1388+open-iscsi (2.0.865-1ubuntu4) intrepid; urgency=low
1389+
1390+ * Exit without error if /sys is not available. Otherwise, it's not possible
1391+ to use this package as a build-dependency.
1392+
1393+ -- Soren Hansen <soren@ubuntu.com> Fri, 02 May 2008 00:57:02 +0200
1394+
1395+open-iscsi (2.0.865-1ubuntu3) hardy; urgency=low
1396+
1397+ * Migration of /usr/{bin,sbin,lib} -> to /{bin,sbin,lib}.
1398+ (LP: #208441)
1399+ * Push the shutdown scripts back. (LP: #196748)
1400+ * Update control to 3.7.3.
1401+ * Updated the maintainer according to spec.
1402+
1403+ -- Chuck Short <zulcss@ubuntu.com> Wed, 09 Apr 2008 18:09:28 -0400
1404+
1405+open-iscsi (2.0.865-1ubuntu2) hardy; urgency=low
1406+
1407+ * Fixed init script to point to the right iscsiadm. (LP: #206520)
1408+
1409+ -- Chuck Short <zulcss@ubuntu.com> Tue, 25 Mar 2008 09:53:08 -0400
1410+
1411+open-iscsi (2.0.865-1ubuntu1) hardy; urgency=low
1412+
1413+ * Add open-iscsi-udeb.
1414+ * Include iscsi_discovery.
1415+ * De-bashify iscsi_discovery.
1416+ * Start open-iscsi in single user mode.
1417+ * Properly lsb-ify init script.
1418+ * Modify Maintainer value to match the DebianMaintainerField
1419+ specification.
1420+
1421+ -- Soren Hansen <soren@ubuntu.com> Fri, 08 Feb 2008 11:56:11 +0100
1422+
1423 open-iscsi (2.0.865-1) unstable; urgency=low
1424
1425 * New upstream release
1426diff --git a/debian/control b/debian/control
1427index a69ce2c..daf7950 100644
1428--- a/debian/control
1429+++ b/debian/control
1430@@ -1,7 +1,8 @@
1431 Source: open-iscsi
1432 Section: net
1433 Priority: optional
1434-Maintainer: Debian iSCSI Maintainers <open-iscsi@packages.debian.org>
1435+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
1436+XSBC-Original-Maintainer: Debian iSCSI Maintainers <open-iscsi@packages.debian.org>
1437 Uploaders: Ritesh Raj Sarraf <rrs@debian.org>,
1438 Christian Seiler <christian@iwakd.de>,
1439 Chris Hofstaedtler <zeha@debian.org>
1440@@ -31,6 +32,7 @@ Depends: ${misc:Depends},
1441 ${shlibs:Depends},
1442 libopeniscsiusr,
1443 udev
1444+Recommends: ${busybox:Recommends}, finalrd (>= 3)
1445 Pre-Depends: debconf | debconf-2.0
1446 Description: iSCSI initiator tools
1447 The Open-iSCSI project is a high-performance, transport independent,
1448@@ -58,6 +60,8 @@ Package: libopeniscsiusr
1449 Architecture: linux-any
1450 Depends: ${misc:Depends},
1451 ${shlibs:Depends}
1452+Replaces: libopeniscsiusr0.2.0 (<< 2.1.4-0ubuntu1~)
1453+Breaks: libopeniscsiusr0.2.0 (<< 2.1.4-0ubuntu1~)
1454 Enhances: open-iscsi
1455 Description: iSCSI userspace library
1456 The Open-iSCSI project is a high-performance, transport independent,
1457@@ -139,7 +143,7 @@ Package: open-iscsi-udeb
1458 # linux kernel udebs) must exist for these architectures - so
1459 # check that before adding them to this list; the other
1460 # scsi-(core|common|...)-modules are NOT sufficient!
1461-Architecture: amd64 arm64 armhf i386 ia64 mips mipsel powerpc ppc64 ppc64el s390x
1462+Architecture: amd64 arm64 armhf ia64 mips mipsel powerpc ppc64 ppc64el s390x
1463 Section: debian-installer
1464 Package-Type: udeb
1465 Depends: ${misc:Depends},
1466@@ -150,3 +154,11 @@ Description: Configure iSCSI
1467 multi-platform implementation of RFC3720 iSCSI.
1468 .
1469 This is the minimal package (udeb) used by debian-installer.
1470+
1471+Package: libopeniscsiusr0.2.0
1472+Depends: libopeniscsiusr, ${misc:Depends}
1473+Architecture: all
1474+Priority: optional
1475+Section: oldlibs
1476+Description: transitional package
1477+ This is a transitional package. It can safely be removed.
1478diff --git a/debian/extra/initramfs.hook b/debian/extra/initramfs.hook
1479index 6a430eb..7458571 100755
1480--- a/debian/extra/initramfs.hook
1481+++ b/debian/extra/initramfs.hook
1482@@ -32,7 +32,7 @@ if [ -r /etc/iscsi/iscsi.initramfs ] ; then
1483 cp /etc/iscsi/iscsi.initramfs $DESTDIR/etc
1484 fi
1485
1486-for x in crc32c libcrc32c iscsi_tcp libiscsi scsi_transport_iscsi iscsi_ibft; do
1487+for x in crc32c libcrc32c ib_iser iscsi_tcp libiscsi scsi_transport_iscsi iscsi_ibft; do
1488 manual_add_modules ${x}
1489 done
1490 for x in cxgb3i cxgb4i; do
1491diff --git a/debian/extra/initramfs.local-bottom b/debian/extra/initramfs.local-bottom
1492index c32e5fe..06ddc56 100755
1493--- a/debian/extra/initramfs.local-bottom
1494+++ b/debian/extra/initramfs.local-bottom
1495@@ -7,4 +7,24 @@ if [ -x /sbin/iscsiuio ] && [ -e /run/initramfs/iscsiuio.pid ] ; then
1496 --name iscsiuio --exec /sbin/iscsiuio || :
1497 fi
1498
1499+# Remove the interface file if no disks are present
1500+if [ -f /run/initramfs/open-iscsi.interface ] ; then
1501+ found=0
1502+ for disk in /dev/disk/by-path/*-iscsi-*; do
1503+ if [ ! -e "$disk" ] ; then
1504+ # If we have no matches, we stil go through the for loop once with
1505+ # the pattern as a string
1506+ continue
1507+ fi
1508+ if ! readlink -f "$disk" > /dev/null ; then
1509+ continue
1510+ fi
1511+ found=1
1512+ break;
1513+ done
1514+ if [ $found = 0 ] ; then
1515+ rm /run/initramfs/open-iscsi.interface
1516+ fi
1517+fi
1518+
1519 exit 0
1520diff --git a/debian/extra/initramfs.local-top b/debian/extra/initramfs.local-top
1521index 1045c50..9f3af32 100755
1522--- a/debian/extra/initramfs.local-top
1523+++ b/debian/extra/initramfs.local-top
1524@@ -93,6 +93,7 @@ do_iscsi_login ()
1525 . /scripts/functions
1526
1527 udevadm settle
1528+ IBFT_DHCP_DEVICE=""
1529
1530 if [ -n "$ISCSI_AUTO" ] ; then
1531 # try to auto-configure network interface based
1532@@ -136,7 +137,13 @@ do_iscsi_login ()
1533 echo "UPTIME='${UPTIME}'"
1534 echo "DHCPLEASETIME='${DHCPLEASETIME}'"
1535 echo "DOMAINSEARCH=''"
1536- } > "/run/net-${DEVICE}.conf"
1537+ } > "/run/net-${DEVICE}.conf.ibft"
1538+ if [ "$PROTO" != "dhcp" -a "$DHCPLEASETIME" = "0" ]; then
1539+ # this is static ibft configuration.
1540+ mv "/run/net-${DEVICE}.conf.ibft" "/run/net-${DEVICE}.conf"
1541+ else
1542+ IBFT_DHCP_DEVICE="$DEVICE"
1543+ fi
1544 echo "${DEVICE}" > /run/initramfs/open-iscsi.interface
1545 # iscsistart -N doesn't set the default gateway. Therefore,
1546 # we need to add it ourselves. However, the ip command is
1547@@ -172,9 +179,23 @@ do_iscsi_login ()
1548
1549 # run configure_networking even if we have iscsi_auto, because there
1550 # could be other network interfaces that need to be configured
1551- # manually
1552+ # also, if we set up DHCP iBFT, we need ipconfig to run so it creates
1553+ # a proper /run/net-${DEVICE}.conf file that includes the DNS search
1554+ # domain, which we don't get in our iBFT data (see LP: #1806777)
1555 configure_networking
1556
1557+ if [ -n "$IBFT_DHCP_DEVICE" ]; then
1558+ if ! [ -e "/run/net-${DEVICE}.conf" ] ; then
1559+ echo "WARN: ipconfig dhcp failed, using iSCSI iBFT config - DNS search domain may be missing at runtime" >&2
1560+ # We have DHCP iBFT, but ipconfig DHCP failed;
1561+ # so we should fallback to just using the iBFT config,
1562+ # though that will not include the DNS search domain
1563+ mv "/run/net-${DEVICE}.conf.ibft" "/run/net-${DEVICE}.conf"
1564+ # need to re-run configure_networking to process conf file
1565+ configure_networking
1566+ fi
1567+ fi
1568+
1569 # Save network device we configured via configure_networking, but only
1570 # if we didn't already get one from autoconfiguration (then we always
1571 # prefer that).
1572@@ -186,6 +207,13 @@ do_iscsi_login ()
1573 fi
1574 if [ -n "${DEVICE}" ] ; then
1575 echo "${DEVICE}" > /run/initramfs/open-iscsi.interface
1576+ else
1577+ for i in /run/net6-*.conf; do
1578+ [ -e "${i}" ] && { . "${i}" ; break ; }
1579+ done
1580+ fi
1581+ if [ -z "${DEVICE}" ] && [ -n "${DEVICE6}" ] ; then
1582+ echo "${DEVICE6}" > /run/initramfs/open-iscsi.interface
1583 fi
1584 fi
1585
1586diff --git a/debian/extra/net-interface-handler b/debian/extra/net-interface-handler
1587new file mode 100755
1588index 0000000..9cd6e1e
1589--- /dev/null
1590+++ b/debian/extra/net-interface-handler
1591@@ -0,0 +1,80 @@
1592+#!/bin/sh -e
1593+# suppress configuration of network interface used
1594+# by iSCSI root device
1595+#
1596+# If the root filesystem is on iSCSI, then we must take care to avoid
1597+# changing the state of its network interface. To this end, the initramfs
1598+# leaves a note for us which interface was used, and we mangle
1599+# /run/network/ifstate manually to stop it being brought up or down
1600+# automatically. This is a slight layering violation, but, unfortunately,
1601+# ifupdown appears to have no way to do this without also running
1602+# /etc/network/*.d/ scripts.
1603+
1604+assert_interface() {
1605+ # udev sets INTERFACE to the name of the currently-processed nic.
1606+ [ -n "$INTERFACE" ] && return 0
1607+ echo "environment variable INTERFACE not set." 1>&2;
1608+ return 1
1609+}
1610+
1611+start() {
1612+ CR="
1613+"
1614+ assert_interface || return
1615+ ifile=/run/initramfs/open-iscsi.interface
1616+
1617+ [ -f "$ifile" ] && read iface < "$ifile" || return 0
1618+ [ "$INTERFACE" = "$iface" ] || return
1619+
1620+ if ! grep -qs "^$iface=" /run/network/ifstate; then
1621+ mkdir -p /run/network
1622+ echo "$iface=$iface" >>/run/network/ifstate
1623+
1624+ if [ -f /run/net-$iface.conf ]; then
1625+ conf=/run/net-$iface.conf
1626+ elif [ -f /run/net6-$iface.conf ]; then
1627+ conf=/run/net6-$iface.conf
1628+ else
1629+ conf=""
1630+ fi
1631+ if command -v resolvconf >/dev/null &&
1632+ [ -n "$conf" ]; then
1633+ . "$conf"
1634+ R=""
1635+ [ -n "$DOMAINSEARCH" ] && R="$R${CR}search $DOMAINSEARCH"
1636+ [ -n "$IPV6DOMAINSEARCH" ] && R="$R${CR}search $IPV6DOMAINSEARCH"
1637+ for ns in "$IPV4DNS0" "$IPV4DNS1" "$IPV6DNS0" "$IPV6DNS1"; do
1638+ [ -n "$ns" -a "$ns" != "0.0.0.0" ] && R="$R${CR}nameserver $ns"
1639+ done
1640+ if [ -n "$R" ]; then
1641+ # create the dir in case resolvconf did not start yet
1642+ mkdir -p /run/resolvconf/interface
1643+ resolvconf -a $iface.iscsi-network <<EOF
1644+${R#${CR}}
1645+EOF
1646+ fi
1647+ fi
1648+ fi
1649+}
1650+
1651+stop() {
1652+ assert_interface || return
1653+ ifile=/run/initramfs/open-iscsi.interface
1654+ [ -f "$ifile" ] && read iface < "$ifile" || return 0
1655+ [ "$INTERFACE" = "$iface" ] || return
1656+
1657+ if grep -qs "^$iface=" /run/network/ifstate; then
1658+ grep -v "^$iface=" /run/network/ifstate >/run/network/.ifstate.tmp || true
1659+ mv /run/network/.ifstate.tmp /run/network/ifstate
1660+
1661+ if command -v resolvconf >/dev/null; then
1662+ resolvconf -d $iface.iscsi-network
1663+ fi
1664+ fi
1665+}
1666+
1667+case "$1" in
1668+ start) start ;;
1669+ stop) stop ;;
1670+ *) echo "ERROR: must be called with 'start' or 'stop'" >&2; exit 1 ;;
1671+esac
1672diff --git a/debian/extra/startup-checks.sh b/debian/extra/startup-checks.sh
1673index a369785..a7c3ecd 100755
1674--- a/debian/extra/startup-checks.sh
1675+++ b/debian/extra/startup-checks.sh
1676@@ -33,7 +33,7 @@ if grep -q "^GenerateName=yes" $NAMEFILE ; then
1677 exit 1
1678 fi
1679 # Generate a unique InitiatorName and save it
1680- INAME=`/sbin/iscsi-iname -p iqn.1993-08.org.debian:01`
1681+ INAME=`/sbin/iscsi-iname -p iqn.2004-10.com.ubuntu:01`
1682 if [ "$INAME" != "" ] ; then
1683 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE
1684 echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE
1685diff --git a/debian/iscsi-network-interface.rules b/debian/iscsi-network-interface.rules
1686new file mode 100644
1687index 0000000..e0408d7
1688--- /dev/null
1689+++ b/debian/iscsi-network-interface.rules
1690@@ -0,0 +1,3 @@
1691+# run before 80-networking.rules to run before ifupdown
1692+SUBSYSTEM=="net", ACTION=="add", RUN+="/lib/open-iscsi/net-interface-handler start"
1693+SUBSYSTEM=="net", ACTION=="remove", RUN+="/lib/open-iscsi/net-interface-handler stop"
1694diff --git a/debian/iscsid.service b/debian/iscsid.service
1695index d05953d..c98fd7e 100644
1696--- a/debian/iscsid.service
1697+++ b/debian/iscsid.service
1698@@ -7,13 +7,13 @@ After=network.target network-online.target
1699 DefaultDependencies=no
1700 Conflicts=shutdown.target
1701 Before=shutdown.target
1702+ConditionVirtualization=!private-users
1703
1704 [Service]
1705 Type=forking
1706 PIDFile=/run/iscsid.pid
1707 ExecStartPre=/lib/open-iscsi/startup-checks.sh
1708 ExecStart=/sbin/iscsid
1709-ExecStop=/sbin/iscsiadm -k 0 2
1710
1711 [Install]
1712 WantedBy=sysinit.target
1713diff --git a/debian/open-iscsi-udeb.start b/debian/open-iscsi-udeb.start
1714index beea0ae..127b7bf 100644
1715--- a/debian/open-iscsi-udeb.start
1716+++ b/debian/open-iscsi-udeb.start
1717@@ -6,7 +6,7 @@
1718
1719 if ! [ -f /etc/iscsi/initiatorname.iscsi ]; then
1720 # Generate a unique InitiatorName and save it
1721- INAME=`iscsi-iname -p iqn.1993-08.org.debian:01`
1722+ INAME=`iscsi-iname -p iqn.2004-10.com.ubuntu:01`
1723 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/iscsi/initiatorname.iscsi
1724 echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/iscsi/initiatorname.iscsi
1725 echo "## If you change the InitiatorName, existing access control lists" >> /etc/iscsi/initiatorname.iscsi
1726diff --git a/debian/open-iscsi.finalrd b/debian/open-iscsi.finalrd
1727new file mode 100755
1728index 0000000..d0f4352
1729--- /dev/null
1730+++ b/debian/open-iscsi.finalrd
1731@@ -0,0 +1,47 @@
1732+#!/bin/sh
1733+# SPDX-License-Identifier: GPL-3.0-only
1734+
1735+set -e
1736+
1737+if [ "$1" = "setup" ]
1738+then
1739+ . /usr/share/initramfs-tools/hook-functions
1740+ copy_exec /bin/grep
1741+ copy_exec /bin/sleep
1742+ copy_exec /sbin/iscsiadm
1743+ copy_exec /sbin/iscsid
1744+ # hm, not sure why expr is copied
1745+ copy_exec /usr/bin/expr
1746+ copy_file config /etc/iscsi/iscsid.conf
1747+ copy_file config /etc/iscsi/initiatorname.iscsi
1748+ # needed to resolve UIDs (LP: #1922976)
1749+ copy_exec /usr/lib/*/libnss_files.so.*
1750+ exit 0
1751+fi
1752+
1753+# if not present in the environment, then fake a trivial passwd file (LP: #1922976)
1754+if [ ! -e /etc/passwd ] ; then
1755+ echo "root:x:0:0:root:/:/bin/sh" > /etc/passwd
1756+fi
1757+
1758+# re-establish connection and logout during shutdown
1759+# if initramfs did bring up open-iscsi on boot
1760+[ -f /open-iscsi.interface ] || exit 0
1761+
1762+iscsid
1763+
1764+# After restarting iscsid, wait for an active connection.
1765+# Limit the wait time in case of unexpected failure of iscsid.
1766+MAX_RETRIES=30
1767+RETRY=0
1768+while ! iscsiadm -m session -P 1 | grep -q "iSCSI Connection State: LOGGED IN"; do
1769+ RETRY=$(($RETRY + 1))
1770+ if [ $RETRY -gt $MAX_RETRIES ]; then
1771+ echo "Unexpected iSCSI Connection State, forcing iSCSI logout."
1772+ break
1773+ fi
1774+ sleep 1
1775+done
1776+
1777+# Issue an iSCSI logout.
1778+iscsiadm -m node -u
1779diff --git a/debian/open-iscsi.kmod b/debian/open-iscsi.kmod
1780deleted file mode 100644
1781index c5f90f3..0000000
1782--- a/debian/open-iscsi.kmod
1783+++ /dev/null
1784@@ -1,2 +0,0 @@
1785-iscsi_tcp
1786-ib_iser
1787diff --git a/debian/open-iscsi.postinst b/debian/open-iscsi.postinst
1788index f9867d4..ccc8ed7 100644
1789--- a/debian/open-iscsi.postinst
1790+++ b/debian/open-iscsi.postinst
1791@@ -17,16 +17,6 @@ restore_old_timeouts()
1792 case "$1" in
1793 configure)
1794
1795- # We switched over to modules-load.d logic, this is needed
1796- MODULES_FILE=/lib/modules-load.d/open-iscsi.conf
1797- if [ -f /etc/modules-load.d/open-iscsi.conf ] ; then
1798- MODULES_FILE=/etc/modules-load.d/open-iscsi.conf
1799- fi
1800- grep '^[^#]' $MODULES_FILE | while read module args ; do
1801- [ "$module" ] || continue
1802- modprobe $module $args >/dev/null 2>&1 || true
1803- done
1804-
1805 # Compatibility symlinks
1806 for file in iscsid iscsi_discovery iscsi-iname iscsistart; do
1807 if [ ! -e /usr/sbin/$file ]; then
1808@@ -37,7 +27,7 @@ case "$1" in
1809 # Generate a unique iSCSI InitiatorName
1810 NAMEFILE=/etc/iscsi/initiatorname.iscsi
1811 if [ ! -e $NAMEFILE ] && [ -z "$2" ] ; then
1812- INAME=$(iscsi-iname -p iqn.1993-08.org.debian:01)
1813+ INAME=$(iscsi-iname -p iqn.2004-10.com.ubuntu:01)
1814 if [ -n "$INAME" ] ; then
1815 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE
1816 echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE
1817@@ -65,7 +55,9 @@ esac
1818
1819 #DEBHELPER#
1820
1821-if [ "$1" = configure ] ; then
1822+if [ "$1" = configure ] && [ -n "$2" ] && [ -d /run/systemd/system ] &&
1823+ systemctl is-active iscsid.service > /dev/null
1824+then
1825 # There already is a check in preinst with a debconf prompt that
1826 # allows the administrator to abort. Don't abort here, because
1827 # leaving the package in a half-configured state is probably worse.
1828@@ -109,25 +101,9 @@ if [ "$1" = configure ] ; then
1829 # Just in case something goes wrong:
1830 sync
1831
1832- # Note: 3>&- is required because iscsid doesn't close unused
1833- # FDs, but debconf/confmodule will make the fd 3 point to
1834- # the original stdout (and stdout to stderr) to make sure
1835- # no program accidentally issues a command on stdout. On
1836- # sysvinit systems this combination (iscsid not closing
1837- # fds, fd 3 remaining open) will cause dpkg to wait
1838- # forever for the maintscript to finish. (iscsid keeps
1839- # this end of the pipe open even though the maintscript
1840- # is finished, so dpkg will never receive a POLLHUP on
1841- # its end of the pipe, waiting forever.) Closing fd 3
1842- # here is the simplest solution. This issue does not
1843- # occur with other init systems, since they start
1844- # services in a clean environment without any extraneous
1845- # open fds.
1846- if [ -n "$2" ]; then
1847- invoke-rc.d iscsid restart 3>&-
1848- else
1849- invoke-rc.d iscsid start 3>&-
1850- fi
1851+ # we want to be able to be explicit to start .service, but follow policy.d
1852+ # therefore use deb-systemd-invoke
1853+ deb-systemd-invoke restart iscsid.service || true
1854
1855 RETRIES=0
1856 while cat /sys/class/iscsi_session/session*/state 2>/dev/null | grep -qv LOGGED_IN ; do
1857@@ -149,17 +125,26 @@ if [ "$1" = configure ] ; then
1858
1859 restore_old_timeouts
1860 trap - EXIT
1861+fi
1862
1863- # Don't restart (and therefore stop) open-iscsi, because we don't
1864- # want to logout from targets during a simple upgrade. But also,
1865- # if for some reason there's some misconfigured target in the
1866- # config that couldn't be activated, don't break postinst, so
1867- # ignore the exit code.
1868- # See above for why 3>&- is here. (Technically it's not required
1869- # for postinst to work, but vgchange likes to complain about leaked
1870- # file descriptors, and we don't need to show that message to the
1871- # user.)
1872- invoke-rc.d open-iscsi start 3>&- || true
1873+if [ "$1" = configure ]; then
1874+ # With socket based activation one wants iscsid.socket to be active
1875+ # But on upgrades the iscsid.service might already be active
1876+ # Due to that directly starting iscsid.socket might fail:
1877+ # systemd[1]: iscsid.socket: Socket service iscsid.service already active, refusing.
1878+ # Therefore check if iscsid.service is:
1879+ # - active:
1880+ # - ok for now, do not start iscsid.socket as it would conflict
1881+ # - on a reboot .socket will be started as it is enabled
1882+ # - inactive:
1883+ # - start iscsid.socket - to be ready
1884+ # In both cases:
1885+ # - disable iscsid.service so it only starts by the socket after reboot
1886+ if [ -d /run/systemd/system ]; then
1887+ if ! systemctl is-active iscsid.service > /dev/null; then
1888+ deb-systemd-invoke start iscsid.socket || true
1889+ fi
1890+ fi
1891 fi
1892
1893 exit 0
1894diff --git a/debian/open-iscsi.service b/debian/open-iscsi.service
1895index a62825e..06f83fe 100644
1896--- a/debian/open-iscsi.service
1897+++ b/debian/open-iscsi.service
1898@@ -1,12 +1,16 @@
1899 [Unit]
1900 Description=Login to default iSCSI targets
1901 Documentation=man:iscsiadm(8) man:iscsid(8)
1902-Wants=network-online.target remote-fs-pre.target iscsid.service
1903+Wants=network-online.target remote-fs-pre.target
1904 After=network-online.target iscsid.service
1905 Before=remote-fs-pre.target
1906 DefaultDependencies=no
1907 Conflicts=shutdown.target
1908 Before=shutdown.target
1909+# Must have some pre-defined targets to login to
1910+ConditionDirectoryNotEmpty=|/etc/iscsi/nodes
1911+# or have a session to use via iscsid
1912+ConditionDirectoryNotEmpty=|/sys/class/iscsi_session
1913
1914 [Service]
1915 Type=oneshot
1916@@ -15,11 +19,7 @@ RemainAfterExit=true
1917 # and 15 if a session is alread logged in (which we do not
1918 # consider an error)
1919 SuccessExitStatus=15 21
1920-# iscsiadm will only work if iscsid is running. But we can't use a
1921-# Requires= dependency, since restarts of iscsid would then be
1922-# propagated to this service - and that would cause all sorts of
1923-# mayhem. Therefore, check it in ExecStartPre.
1924-ExecStartPre=/bin/systemctl --quiet is-active iscsid.service
1925+# Note: iscsid will be socket activated by iscsiadm
1926 ExecStart=/sbin/iscsiadm -m node --loginall=automatic
1927 ExecStart=/lib/open-iscsi/activate-storage.sh
1928 ExecStop=/lib/open-iscsi/umountiscsi.sh
1929diff --git a/debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch b/debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
1930new file mode 100644
1931index 0000000..d587922
1932--- /dev/null
1933+++ b/debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
1934@@ -0,0 +1,25 @@
1935+Description: default in iscid.conf to use iscsid.socket
1936+
1937+People do not want iscsid to run if not needed.
1938+To do so it is configured to be socket activated.
1939+Internally iscsid code has a fallback if the service is missing to run the
1940+command specified in iscsid.conf as "iscsid.startup".
1941+Set this to ensure the socket is active instead of calling the binary, which
1942+would not be what we want anyway as it would not be from the .service context.
1943+
1944+Forwarded: no (Downstream config)
1945+Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
1946+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1755858
1947+Reviewed-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
1948+Last-Update: 2020-08-13
1949+
1950+--- a/etc/iscsid.conf
1951++++ b/etc/iscsid.conf
1952+@@ -20,6 +20,7 @@
1953+ #
1954+ # Default for Fedora and RHEL. (uncomment to activate).
1955+ # iscsid.startup = /bin/systemctl start iscsid.socket iscsiuio.socket
1956++iscsid.startup = /bin/systemctl start iscsid.socket
1957+ #
1958+ # Default if you are not using systemd (uncomment to activate)
1959+ # iscsid.startup = /usr/bin/service start iscsid
1960diff --git a/debian/patches/series b/debian/patches/series
1961index 8585afd..909a8f3 100644
1962--- a/debian/patches/series
1963+++ b/debian/patches/series
1964@@ -1,3 +1 @@
1965-upstream/0001-iscsiadm-Fix-memory-leak-in-iscsiadm.patch
1966-upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch
1967-upstream/0003-Fix-iscsistart-login-issue-when-target-is-delayed.patch
1968+lp1755858-default-iscsid_conf-to-iscsid_socket.patch
1969diff --git a/debian/patches/upstream/0001-iscsiadm-Fix-memory-leak-in-iscsiadm.patch b/debian/patches/upstream/0001-iscsiadm-Fix-memory-leak-in-iscsiadm.patch
1970deleted file mode 100644
1971index dda9a00..0000000
1972--- a/debian/patches/upstream/0001-iscsiadm-Fix-memory-leak-in-iscsiadm.patch
1973+++ /dev/null
1974@@ -1,156 +0,0 @@
1975-From: Wenchao Hao <haowenchao@huawei.com>
1976-Date: Tue, 29 Dec 2020 20:30:25 +0800
1977-Subject: iscsiadm: Fix memory leak in iscsiadm
1978-
1979-Memory allocated by iscsi_context_new() would not be freed if
1980-error occurred during parameters parser stage and goto free_ifaces
1981-is used to jump to resource clean.
1982-
1983-Since all resource clean is performed after verified, so change
1984-all goto free_ifaces to goto out where handles resource better.
1985-
1986-Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
1987----
1988- libopeniscsiusr/context.c | 6 +++++-
1989- usr/iscsiadm.c | 27 +++++++++++++--------------
1990- 2 files changed, 18 insertions(+), 15 deletions(-)
1991-
1992-diff --git a/libopeniscsiusr/context.c b/libopeniscsiusr/context.c
1993-index fe92155..c5e869f 100644
1994---- a/libopeniscsiusr/context.c
1995-+++ b/libopeniscsiusr/context.c
1996-@@ -55,8 +55,12 @@ struct iscsi_context *iscsi_context_new(void)
1997-
1998- void iscsi_context_free(struct iscsi_context *ctx)
1999- {
2000-- if (ctx != NULL)
2001-+ if (ctx == NULL)
2002-+ return;
2003-+
2004-+ if (ctx->db)
2005- _idbm_free(ctx->db);
2006-+
2007- free(ctx);
2008- }
2009-
2010-diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
2011-index ea1643b..3987168 100644
2012---- a/usr/iscsiadm.c
2013-+++ b/usr/iscsiadm.c
2014-@@ -3627,7 +3627,7 @@ main(int argc, char **argv)
2015- "Priority must be greater than or "
2016- "equal to zero.", killiscsid);
2017- rc = ISCSI_ERR_INVAL;
2018-- goto free_ifaces;
2019-+ goto out;
2020- }
2021- break;
2022- case 't':
2023-@@ -3639,7 +3639,7 @@ main(int argc, char **argv)
2024- log_error("can not recognize operation: '%s'",
2025- optarg);
2026- rc = ISCSI_ERR_INVAL;
2027-- goto free_ifaces;
2028-+ goto out;
2029- }
2030- break;
2031- case 'n':
2032-@@ -3651,7 +3651,7 @@ main(int argc, char **argv)
2033- case 'H':
2034- host_no = parse_host_info(optarg, &rc);
2035- if (rc)
2036-- goto free_ifaces;
2037-+ goto out;
2038- break;
2039- case 'r':
2040- sid = iscsi_sysfs_get_sid_from_path(optarg);
2041-@@ -3659,7 +3659,7 @@ main(int argc, char **argv)
2042- log_error("invalid sid '%s'",
2043- optarg);
2044- rc = ISCSI_ERR_INVAL;
2045-- goto free_ifaces;
2046-+ goto out;
2047- }
2048- break;
2049- case 'R':
2050-@@ -3710,7 +3710,7 @@ main(int argc, char **argv)
2051- mode = str_to_mode(optarg);
2052- rc = verify_mode_params(argc, argv, mode);
2053- if (ISCSI_SUCCESS != rc)
2054-- goto free_ifaces;
2055-+ goto out;
2056- break;
2057- case 'C':
2058- sub_mode = str_to_submode(optarg);
2059-@@ -3739,11 +3739,11 @@ main(int argc, char **argv)
2060- printf("Invalid iface name %s. Must be from "
2061- "1 to %d characters.\n",
2062- optarg, ISCSI_MAX_IFACE_LEN - 1);
2063-- goto free_ifaces;
2064-+ goto out;
2065- } else if (!iface || rc) {
2066- printf("Could not add iface %s.", optarg);
2067- rc = ISCSI_ERR_INVAL;
2068-- goto free_ifaces;
2069-+ goto out;
2070- }
2071-
2072- list_add_tail(&iface->list, &ifaces);
2073-@@ -3760,7 +3760,7 @@ main(int argc, char **argv)
2074- log_error("Invalid index %s. %s.",
2075- optarg, strerror(errno));
2076- rc = ISCSI_ERR_INVAL;
2077-- goto free_ifaces;
2078-+ goto out;
2079- }
2080- break;
2081- case 'A':
2082-@@ -3778,7 +3778,7 @@ main(int argc, char **argv)
2083- if (!param) {
2084- log_error("Cannot allocate memory for params.");
2085- rc = ISCSI_ERR_NOMEM;
2086-- goto free_ifaces;
2087-+ goto out;
2088- }
2089- list_add_tail(&param->list, &params);
2090- name = NULL;
2091-@@ -3789,12 +3789,12 @@ main(int argc, char **argv)
2092- if (optopt) {
2093- log_error("unrecognized character '%c'", optopt);
2094- rc = ISCSI_ERR_INVAL;
2095-- goto free_ifaces;
2096-+ goto out;
2097- }
2098-
2099- if (killiscsid >= 0) {
2100- kill_iscsid(killiscsid, timeout);
2101-- goto free_ifaces;
2102-+ goto out;
2103- }
2104-
2105- if (mode < 0)
2106-@@ -3802,14 +3802,14 @@ main(int argc, char **argv)
2107-
2108- if (mode == MODE_FW) {
2109- rc = exec_fw_op(NULL, NULL, info_level, do_login, op);
2110-- goto free_ifaces;
2111-+ goto out;
2112- }
2113-
2114- increase_max_files();
2115- if (idbm_init(get_config_file)) {
2116- log_warning("exiting due to idbm configuration error");
2117- rc = ISCSI_ERR_IDBM;
2118-- goto free_ifaces;
2119-+ goto out;
2120- }
2121-
2122- switch (mode) {
2123-@@ -4070,7 +4070,6 @@ out:
2124- free(rec);
2125- iscsi_sessions_free(ses, se_count);
2126- idbm_terminate();
2127--free_ifaces:
2128- list_for_each_entry_safe(iface, tmp, &ifaces, list) {
2129- list_del(&iface->list);
2130- free(iface);
2131diff --git a/debian/patches/upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch b/debian/patches/upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch
2132deleted file mode 100644
2133index 183bdaa..0000000
2134--- a/debian/patches/upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch
2135+++ /dev/null
2136@@ -1,47 +0,0 @@
2137-From: Lee Duncan <lduncan@suse.com>
2138-Date: Tue, 26 Jan 2021 11:48:32 -0800
2139-Subject: Fix iscsiadm segfault when exiting
2140-
2141-Commit b532ad67d495d added some cleanup code
2142-to iscsiadm right before it exits, but it
2143-used a list_for_each_entry() to iterate through
2144-a list was being deleted, when it should use
2145-list_for_each_entry_safe().
2146-
2147-Fixes: b532ad67d495d
2148----
2149- usr/iscsiadm.c | 8 ++++----
2150- 1 file changed, 4 insertions(+), 4 deletions(-)
2151-
2152-diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
2153-index 3987168..bb6821d 100644
2154---- a/usr/iscsiadm.c
2155-+++ b/usr/iscsiadm.c
2156-@@ -3582,11 +3582,11 @@ main(int argc, char **argv)
2157- struct sigaction sa_old;
2158- struct sigaction sa_new;
2159- LIST_HEAD(ifaces);
2160-- struct iface_rec *iface = NULL, *tmp;
2161-+ struct iface_rec *iface = NULL, *tmp_iface;
2162- struct node_rec *rec = NULL;
2163- uint32_t host_no = MAX_HOST_NO + 1;
2164- uint64_t index = ULLONG_MAX;
2165-- struct user_param *param;
2166-+ struct user_param *param, *tmp_param;
2167- LIST_HEAD(params);
2168- struct iscsi_context *ctx = NULL;
2169- int librc = LIBISCSI_OK;
2170-@@ -4070,11 +4070,11 @@ out:
2171- free(rec);
2172- iscsi_sessions_free(ses, se_count);
2173- idbm_terminate();
2174-- list_for_each_entry_safe(iface, tmp, &ifaces, list) {
2175-+ list_for_each_entry_safe(iface, tmp_iface, &ifaces, list) {
2176- list_del(&iface->list);
2177- free(iface);
2178- }
2179-- list_for_each_entry(param, &params, list) {
2180-+ list_for_each_entry_safe(param, tmp_param, &params, list) {
2181- list_del(&param->list);
2182- idbm_free_user_param(param);
2183- }
2184diff --git a/debian/patches/upstream/0003-Fix-iscsistart-login-issue-when-target-is-delayed.patch b/debian/patches/upstream/0003-Fix-iscsistart-login-issue-when-target-is-delayed.patch
2185deleted file mode 100644
2186index 6602f3a..0000000
2187--- a/debian/patches/upstream/0003-Fix-iscsistart-login-issue-when-target-is-delayed.patch
2188+++ /dev/null
2189@@ -1,58 +0,0 @@
2190-From: Lee Duncan <lduncan@suse.com>
2191-Date: Thu, 4 Feb 2021 11:45:00 -0800
2192-Subject: Fix iscsistart login issue when target is delayed.
2193-
2194-Earlier commit 9258c8eae046 changed the return value fron
2195-iscsid_response() from ISCSI_ERR_ISCSID_NOTCONN to
2196-ISCSI_ERR_SESSION_NOT_CONNECTED in the case where no iscsi response is
2197-received when expected.
2198-
2199-This effected the login code in iscsistart when the target is not
2200-completely ready at iscsi login time. This commit updates iscsistart
2201-to expect the new error code, but fixing this uncovered another issue,
2202-causing iscsistart logins to continue to fail if the target returned its
2203-login response too slowly.
2204-
2205-This commit ups the timeout time for iscsistart logins from 1 second per
2206-try to 10 seconds per try. This is perhaps excessive, and a shorter
2207-delay would be more appropriate, but the retry/nanosleep logic in
2208-iscsistart meant to retry the login in such cases seems problematic in
2209-this case, since retrying the 2nd time returns "session already exists",
2210-and most iscsistart clients aren't prepared for the command to return a
2211-non-zero return value.
2212----
2213- usr/iscsistart.c | 17 +++++++++++++++--
2214- 1 file changed, 15 insertions(+), 2 deletions(-)
2215-
2216-diff --git a/usr/iscsistart.c b/usr/iscsistart.c
2217-index 73991b3..755489f 100644
2218---- a/usr/iscsistart.c
2219-+++ b/usr/iscsistart.c
2220-@@ -241,12 +241,25 @@ static int login_session(struct node_rec *rec)
2221- /*
2222- * Need to handle race where iscsid proc is starting up while we are
2223- * trying to connect. Retry with exponential backoff, start from 50 ms.
2224-+ *
2225-+ * NOTE: another race condition can occur if the system is just coming
2226-+ * up, where our login request will be sent, but the login response
2227-+ * takes a while. In such a case, if we timeout and give up, the
2228-+ * login response may still show up once we give up, in which case
2229-+ * it seems to get iscsistart into a state where it cannot try to
2230-+ * login again because it thinks there's already a session. So make
2231-+ * sure our timeout is long enough, on each try, to give the response
2232-+ * a chance to show up. The old value of 1 second was not enough,
2233-+ * so we multiply that by 10, which seems reasonable for initial
2234-+ * login.
2235- */
2236- for (msec = 50; msec <= 15000; msec <<= 1) {
2237-- rc = iscsid_exec_req(&req, &rsp, 0, ISCSID_REQ_TIMEOUT);
2238-+ int tmo = ISCSID_REQ_TIMEOUT * 10;
2239-+
2240-+ rc = iscsid_exec_req(&req, &rsp, 0, tmo);
2241- if (rc == 0) {
2242- return rc;
2243-- } else if (rc == ISCSI_ERR_ISCSID_NOTCONN) {
2244-+ } else if (rc == ISCSI_ERR_SESSION_NOT_CONNECTED) {
2245- ts.tv_sec = msec / 1000;
2246- ts.tv_nsec = (msec % 1000) * 1000000L;
2247-
2248diff --git a/debian/rules b/debian/rules
2249index 2451953..7eac4a3 100755
2250--- a/debian/rules
2251+++ b/debian/rules
2252@@ -11,6 +11,10 @@ export KBUILD_BUILD_TIMESTAMP = @$(SOURCE_DATE_EPOCH)
2253
2254 UDEB := $(filter open-iscsi-udeb,$(shell dh_listpackages))
2255
2256+# Fix gcc10 warnings as errors while upstream doesn't catch up
2257+export DEB_CFLAGS_PREPEND=-Wno-error=zero-length-bounds -Wno-error=format-overflow= -Wno-error=format-truncation= -Wno-error=maybe-uninitialized
2258+export DEB_CXXFLAGS_PREPEND=${DEB_CFLAGS_PREPEND}
2259+
2260 %:
2261 dh $@
2262
2263@@ -43,6 +47,9 @@ override_dh_auto_install:
2264 dh_install -p open-iscsi debian/extra/logout-all.sh lib/open-iscsi/
2265 dh_install -p open-iscsi debian/extra/startup-checks.sh lib/open-iscsi/
2266 dh_install -p open-iscsi debian/extra/activate-storage.sh lib/open-iscsi/
2267+ dh_install -p open-iscsi debian/extra/net-interface-handler lib/open-iscsi/
2268+ dh_install -p open-iscsi debian/open-iscsi.finalrd usr/share/finalrd/
2269+ dh_install -p open-iscsi etc/systemd/iscsid.socket lib/systemd/system/
2270 mkdir -p debian/open-iscsi/usr/bin
2271 ln -s /sbin/iscsiadm debian/open-iscsi/usr/bin/iscsiadm
2272 mkdir -p debian/open-iscsi/usr/share/initramfs-tools/hooks
2273@@ -51,10 +58,9 @@ override_dh_auto_install:
2274 cp -p debian/extra/initramfs.hook debian/open-iscsi/usr/share/initramfs-tools/hooks/iscsi
2275 cp -p debian/extra/initramfs.local-top debian/open-iscsi/usr/share/initramfs-tools/scripts/local-top/iscsi
2276 cp -p debian/extra/initramfs.local-bottom debian/open-iscsi/usr/share/initramfs-tools/scripts/local-bottom/iscsi
2277- mkdir -p debian/open-iscsi/lib/modules-load.d/
2278- cp -p debian/open-iscsi.kmod debian/open-iscsi/lib/modules-load.d/open-iscsi.conf
2279 mkdir -p debian/open-iscsi/lib/udev/rules.d/
2280 cp -p debian/open-iscsi.rules debian/open-iscsi/lib/udev/rules.d/70-open-iscsi.rules
2281+ cp -p debian/iscsi-network-interface.rules debian/open-iscsi/lib/udev/rules.d/70-iscsi-network-interface.rules
2282
2283 @# iscsiuio
2284 dh_install -p iscsiuio iscsiuio/src/unix/iscsiuio /sbin
2285@@ -77,17 +83,19 @@ ifneq ($(UDEB),)
2286 endif
2287
2288 override_dh_installinit:
2289- dh_installinit -p open-iscsi --name=iscsid
2290- dh_installinit -p open-iscsi
2291- dh_installinit -p iscsiuio
2292+ dh_installinit -p open-iscsi --no-start --no-enable --no-stop-on-upgrade --name=iscsid
2293+ dh_installinit -p open-iscsi --no-start --no-enable --no-stop-on-upgrade
2294+ dh_installinit -p iscsiuio --no-start --no-enable --no-stop-on-upgrade
2295
2296 override_dh_systemd_enable:
2297- dh_systemd_enable -p open-iscsi --name=iscsid
2298- dh_systemd_enable -p open-iscsi
2299+ dh_systemd_enable -p open-iscsi --name=iscsid --no-enable iscsid.service
2300+ dh_systemd_enable -p open-iscsi --name=iscsid iscsid.socket
2301+ dh_systemd_enable -p open-iscsi open-iscsi.service
2302 dh_systemd_enable -p iscsiuio
2303
2304 override_dh_systemd_start:
2305- dh_systemd_start -p open-iscsi --no-restart-on-upgrade iscsid.service open-iscsi.service
2306+ dh_systemd_start -p open-iscsi --no-restart-on-upgrade iscsid.socket
2307+ dh_systemd_start -p open-iscsi --no-restart-on-upgrade open-iscsi.service
2308 dh_systemd_start -p iscsiuio --no-restart-on-upgrade iscsiuio.service
2309
2310 override_dh_installman:
2311@@ -110,3 +118,14 @@ ifneq ($(UDEB),)
2312 else
2313 dh_makeshlibs
2314 endif
2315+
2316+# The following is taken from the initramfs-tools package. (We recommend
2317+# busybox in the initramfs because otherwise we don't have access to the
2318+# ip utility to set the default gateway after iscsistart -N is done.)
2319+# On Debian we can use either busybox or busybox-static, but on Ubuntu
2320+# and derivatives only busybox-initramfs will work.
2321+BUSYBOX_PACKAGES := $(shell if dpkg-vendor --derives-from ubuntu; then echo busybox-initramfs; else echo busybox busybox-static; fi)
2322+
2323+override_dh_gencontrol:
2324+ echo >> debian/open-iscsi.substvars "busybox:Recommends=$(wordlist 2,100,$(BUSYBOX_PACKAGES:%=| %))"
2325+ dh_gencontrol
2326diff --git a/debian/tests/README-boot-test.md b/debian/tests/README-boot-test.md
2327new file mode 100644
2328index 0000000..e45bbf0
2329--- /dev/null
2330+++ b/debian/tests/README-boot-test.md
2331@@ -0,0 +1,139 @@
2332+## open-iscsi boot test
2333+The purpose of this test (`CloudImageTest`) is to test the boot of a system
2334+using an iscsi root target. In order to accomplish that, the tests does
2335+
2336+ 1. Download Ubuntu cloud image
2337+ 2. installs the open-iscsi deb inside
2338+ 3. collect kernel and initramfs from inside
2339+ 4. register the image as a read-only iscsi target served by tgt
2340+ 5. boot kernel and initramfs with a command line to use the image as root.
2341+ And additionally attach a local disk for collecting output.
2342+ 6. provide user-data that executes commands, colects files and writes them
2343+ to the output disk and then shuts the system down.
2344+ 7. extract the collected files from the output disk and inspect them.
2345+
2346+The `CloudImageTest` uses qemu user networking.
2347+
2348+
2349+## Caveats
2350+
2351+ 1. It depends on a cloud-image being present.
2352+
2353+ Cloud-images are often not available for the first few weeks of a cycle.
2354+ If no cloud-image of 'REL' is available, then boot-test will skip.
2355+ If 'REL' is not known in distro-info-data, then test will fail.
2356+
2357+ This means that uploads of open-iscsi (or its dependencies) will not
2358+ be properly tested until a cloud-image is available, and will fail
2359+ until distro-info-data is uploaded.
2360+
2361+ 2. Installation of large packages via patch-image may fail.
2362+ An ubuntu image downloaded has only a small amount of extra space.
2363+ Installation of a new kernel into the target would probably fail.
2364+
2365+ If this becomes a problem, we could grow the disk like done at
2366+ https://gist.github.com/smoser/6a048a0e2795b48221fc44962202fa14
2367+
2368+
2369+### testing manually ###
2370+The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
2371+
2372+ * **patch-image**: this is used to install packages into the pristine image
2373+ and collect the kernel and initramfs out of the image. This allows us to
2374+ test the portions of open-iscsi that update the initramfs. Without
2375+ using the updated initramfs we wouldn't really be testing the new
2376+ open-iscsi.
2377+
2378+ It will upgrade any packages inside that are mentioned in
2379+ ADT_TEST_TRIGGERS environment. It will also install open-iscsi if
2380+ it is not in that list.
2381+
2382+ It installs packages into the target by copying the host system's
2383+ /etc/apt content in, and also includes copying local (file://) apt
2384+ repos into the target. This is necessary for the autopackage test
2385+ environment that adds local package repositories to sources.list.d.
2386+
2387+ It may also make other changes to the image to workaround bugs.
2388+ See --help output for list of bugs.
2389+
2390+ * **get-image**: This downloads an image from cloud-images.ubuntu.com. See
2391+ its Usage for more information. it downloads via stream data and verifies
2392+ download. One thing to note is that it does not overwrite existing files.
2393+
2394+ * **tgt-boot-test**: this registers an image in tgt locally, and then boots
2395+ kernel and initramfs to mount that. It knows how to build iscsi kernel
2396+ command lines.
2397+
2398+ By default, the xkvm process that is started will be allowed `60m` to
2399+ complete. This can be adjusted by setting `BOOT_TIMEOUT` in the
2400+ environment.
2401+
2402+ * **xkvm**: this is a helper/wrapper around qemu. It is taken from the curtin
2403+ projects tools/ directory. It allows some simplified command lines, and
2404+ most usefully, the '--netdev=<bridge>' argument will create a tun/tap
2405+ device and attach it to the bridge.
2406+
2407+ If the host system is not bare metal, kvm will not be
2408+ enabled in the guest that is lauched. To force use of kvm, set
2409+ _USE_KVM=1 in the environment. See 'should_try_kvm' in xkvm for details.
2410+
2411+Testing manually looks like this:
2412+
2413+ ## set up path to include debian/tests directory.
2414+ $ PATH=$PWD/debian/tests:$PATH
2415+
2416+ ## Get the image you want. This creates out.d/disk.img and disk.img.dist
2417+ $ get-image xenial.d xenial
2418+
2419+ ## patch the image with an open-iscsi, which creates xenial.d/kernel
2420+ ## and xenial.d/initrd from the kernel and initramfs inside the image.
2421+ $ apt-get download open-iscsi
2422+ $ deb=$(ls open-iscsi_*.deb | tail -n 1)
2423+ $ sudo ./debian/tests/patch-image \
2424+ --kernel=xenial.d/kernel --initrd=xenial.d/initrd
2425+ xenial.d/disk.img "$deb"
2426+
2427+ ## Boot the system, log in, look around.
2428+ $ tgt-boot-test -v xenial.d/disk.img xenial.d/kernel xenial.d/initrd
2429+
2430+
2431+### Features of tgt-boot-test ###
2432+
2433+tgt-boot-test does a number of useful things.
2434+
2435+ * determines the host address that the guest will use.
2436+ This should support ipv6 and ipv4 addresses on bridges, and
2437+ knows values that qemu's user networking uses. Flags passed to `--netdev`
2438+ are read intelligently. This can be overriden with `--host-addr`, but
2439+ it does a good job of determining what the right values are.
2440+
2441+ * provides a nocloud metadata service with a python web server that
2442+ supports ipv4 and ipv6.
2443+
2444+ * provides the ability to provide additional kernel command line options
2445+ or to provide a 'template' that references variables it knows such as
2446+ {iserver} (iscsi server) or {seed_url}.
2447+
2448+ * Sets ubuntu (passw0rd) and root password (root) and imports users
2449+ ssh keys to the ubuntu user.
2450+
2451+One thing to note is that yakkety's version of qemu does not run an ipv6
2452+dhcp server on its user-network, so a stateful dhclient request will not
2453+work.
2454+
2455+In order to create a bridge easily with a ipv6 dhcp server, you can use
2456+lxd at sufficent version (https://github.com/lxc/lxd/issues/2481).
2457+Assuming that bug is fixed, to create an ipv6 only bridge:
2458+
2459+ $ netname="ipv6-only"
2460+ $ lxc network create $netname
2461+ $ lxc network unset $netname ipv4.address
2462+ $ lxc network unset $netname ipv4.nat
2463+ $ lxc network set $netname ipv6.dhcp.stateful true
2464+
2465+Then, you can use tgt-boot-test with that:
2466+
2467+ $ PATH=$PWD/debian/tests:$PATH
2468+ $ ./debian/tests/tgt-boot-test -vv --netdev=ipv6-only \
2469+ --cmdline-ip="ip=off ip6=dhcp" \
2470+ disk.img kernel initramfs
2471diff --git a/debian/tests/control b/debian/tests/control
2472index 7b3c9e2..0fcfd11 100644
2473--- a/debian/tests/control
2474+++ b/debian/tests/control
2475@@ -1,6 +1,10 @@
2476 Tests: install
2477 Restrictions: needs-root, isolation-machine, breaks-testbed
2478
2479+Tests: testsuite
2480+Restrictions: needs-root isolation-machine breaks-testbed
2481+Depends: open-iscsi, python3, tgt, qemu-system, ubuntu-cloudimage-keyring, simplestreams, python3-netifaces, distro-info, cloud-image-utils, dctrl-tools, rsync
2482+
2483 Tests: nested
2484 Restrictions: needs-root, isolation-machine, breaks-testbed, allow-stderr
2485 Depends: targetcli-fb, qemu-system, qemu-utils, python3, python3-netifaces
2486diff --git a/debian/tests/get-image b/debian/tests/get-image
2487new file mode 100755
2488index 0000000..41b903c
2489--- /dev/null
2490+++ b/debian/tests/get-image
2491@@ -0,0 +1,227 @@
2492+#!/bin/bash
2493+Usage() {
2494+ cat <<EOF
2495+${0##*/} out-directory release
2496+
2497+By default, the cloud image for 'release' is downloaded from the
2498+daily cloud image stream.
2499+
2500+Additional arguments can change behavior of what is downloaded.
2501+Some supported arguments:
2502+ * cloud-daily: use daily stream [default]
2503+ * cloud-release: use release stream rather than daily stream.
2504+ * maas-release, maas-daily: download maas images instead of cloud-image
2505+ * hwe-N: download the hwe kernel from release 'N' instead of default
2506+ this is only respected if maas stream is used.
2507+ * YYYYMMDD[.X] : download the specific build version
2508+
2509+example:
2510+ ${0##*/} xenial_dir xenial cloud-daily
2511+EOF
2512+}
2513+TEMP_D=""
2514+
2515+NO_IMAGE_AVAILABLE_RC=3
2516+
2517+cleanup() {
2518+ [ ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
2519+}
2520+VERBOSITY=1
2521+inargs() {
2522+ local n=$1 x="";
2523+ shift;
2524+ for x in "$@"; do [ "$n" = "$x" ] && return 0; done;
2525+ return 1
2526+}
2527+debug() { [ $1 -ge $VERBOSITY ] || return 0; shift; echo "$@" 1>&2; }
2528+error() { echo "$@" 1>&2; }
2529+fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
2530+
2531+VERBOSITY=0
2532+TEMP_D=$(mktemp -d ${TMPDIR:-/tmp}/${0##*/}.XXXXXX) || exit 1
2533+trap cleanup EXIT
2534+
2535+arches=( ppc64el i386 amd64 )
2536+releases=( $(ubuntu-distro-info --all) )
2537+mbase="http://maas.ubuntu.com/images/ephemeral-v2"
2538+cbase="http://cloud-images.ubuntu.com"
2539+def_stream_type="cloud"
2540+stream_src=""
2541+curbase="$mbase"
2542+def_rel="xenial"
2543+vername=""
2544+
2545+[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; }
2546+[ $# -lt 2 ] && { Usage 1>&2; exit 1; }
2547+out_d="$1"
2548+shift
2549+
2550+myarch=$(uname -m)
2551+case "$myarch" in
2552+ ppc64*) def_arch="ppc64el";;
2553+ i?86) def_arch="i386";;
2554+ x86_64) def_arch="amd64";;
2555+ arm*) def_arch="armel";;
2556+esac
2557+
2558+pt=( )
2559+for x in "$@"; do
2560+ inargs "$x" "${arches[@]}" && pt[${#pt[@]}]=arch=$x && arch="$x" && continue
2561+ inargs "$x" "${releases[@]}" && pt[${#pt[@]}]="release=$x" && release=$x && continue
2562+ [ "$x" = "released" -o "$x" = "release" ] && x="releases"
2563+ case "$x" in
2564+ cloud-released|cloud-release) x="cloud-releases";;
2565+ maas-released|maas-release) x="maas-releases";;
2566+ esac
2567+
2568+ case "$x" in
2569+ maas|cloud) stream_type="$x";;
2570+ cloud-daily|maas-daily|cloud-releases|maas-releases)
2571+ stream_type="${x%-*}"
2572+ stream_sub=${x#*-};;
2573+ http://*) stream=$x;;
2574+ hwe-*) subarch="$x";;
2575+ subarch=*) subarch=${x#*=};;
2576+ *=*) pt[${#pt[@]}]="$x";;
2577+ *~*) pt[${#pt[@]}]="$x";;
2578+ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].[0-9])
2579+ pt[${#pt[@]}]="version_name=$x"
2580+ vername="$x";;
2581+ *) fail "Confused by input token '$x'";;
2582+ esac
2583+done
2584+
2585+[ -n "$stream_type" ] || stream_type="${def_stream_type}"
2586+if [ -z "$stream" ]; then
2587+ stream_sub=${stream_sub:-daily}
2588+ case "$stream_type" in
2589+ maas) stream="$mbase/$stream_sub";;
2590+ cloud) stream="$cbase/$stream_sub";;
2591+ *) fail "unknown stream_type '$stream_type'";;
2592+ esac
2593+fi
2594+
2595+[ -n "$arch" ] || pt[${#pt[@]}]="arch=$def_arch"
2596+
2597+if [ "$stream_type" = "maas" ]; then
2598+ if [ -z "$subarch" ]; then
2599+ t=${release#?}
2600+ first_letter=${release%${t}}
2601+ subarch="hwe-${first_letter}"
2602+ error "selected subarch=${subarch} for $release"
2603+ fi
2604+ pt[${#pt[@]}]="subarch=$subarch"
2605+ ofmt="%(sha256)s %(ftype)s %(subarch)s %(item_url)s"
2606+else
2607+ ofmt="%(sha256)s %(ftype)s %(item_url)s"
2608+fi
2609+
2610+OIFS="$IFS"
2611+mkdir -p "$out_d"
2612+case "$stream" in
2613+ *.json) :;;
2614+ *) keyring="/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg";;
2615+esac
2616+
2617+needs=""
2618+[ -n "$keyring" -a ! -f "$keyring" ] &&
2619+ needs="${needs} ubuntu-cloudimage-keyring"
2620+
2621+for pair in sstream-query:simplestreams tgt-admin:tgt; do
2622+ cmd=${pair%:*}
2623+ pkg=${pair#*:}
2624+ command -v "$cmd" >/dev/null 2>&1 || needs="$needs $pkg"
2625+done
2626+
2627+if [ -n "${needs# }" ]; then
2628+ error "missing dependencies"
2629+ fail "sudo apt-get install -qy ${needs# }"
2630+fi
2631+
2632+qcmd=( sstream-query ${keyring:+"--keyring=$keyring"} ${vername:---max=1}
2633+ --output-format="$ofmt" "${stream}" datatype="image-downloads"
2634+ "${pt[@]}" )
2635+echo "${qcmd[@]}"
2636+"${qcmd[@]}" > "${TEMP_D}/qout"
2637+roots=$(awk '$2 == "root-image.gz" || $2 == "disk1.img" { print $2 }' \
2638+ "${TEMP_D}/qout" | sort -u | wc -l)
2639+if [ "$roots" = "0" ]; then
2640+ error "No image available for $release in $stream${pt:+ (${pt[*]})}"
2641+ exit ${NO_IMAGE_AVAILABLE_RC}
2642+elif [ "$roots" != "1" ]; then
2643+ error "query resulted in '$roots' root images. expect 1 and only 1"
2644+ error "cmd was ${qcmd[*]}"
2645+ cat "${TEMP_D}/qout"
2646+ fail
2647+fi
2648+
2649+set -f
2650+while read line; do
2651+ set -- $line
2652+ if [ "$stream_type" = "maas" ]; then
2653+ sha256="$1"; ftype="$2"; subarch="$3"; url="$4"
2654+ else
2655+ sha256="$1"; ftype="$2"; url="$3"
2656+ fi
2657+ case "$ftype" in
2658+ boot-kernel|boot-initrd|root-image.gz|disk1.img) :;;
2659+ *) continue
2660+ esac
2661+ if [ "$ftype" = "root-image.gz" ]; then
2662+ fname="$ftype"
2663+ image_src="$out_d/$fname"
2664+ image="$out_d/root-image"
2665+ elif [ "$ftype" = "disk1.img" ]; then
2666+ fname="disk.img.dist"
2667+ image_src="$out_d/$fname"
2668+ image="$out_d/disk.img"
2669+ else
2670+ fname="$subarch/$ftype"
2671+ fi
2672+ out_f="${out_d}/$fname"
2673+ if [ -f "$out_f" ]; then
2674+ debug 1 "reusing existing '$out_f' rather than downloading $url."
2675+ continue
2676+ fi
2677+ [ -d "${out_f%/*}" ] || mkdir -p "${out_f%/*}"
2678+ tmp="${out_f}.tmp"
2679+ wget --progress=dot:mega -O "$tmp" "$url" || {
2680+ error "Failed to download $url to $tmp."
2681+ rm -f "$tmp"
2682+ exit 3
2683+ }
2684+ debug 1 "checksumming $tmp from $url"
2685+ out=$(sha256sum "$tmp") || {
2686+ error "Failed to checksum $tmp"
2687+ rm -f "$tmp"
2688+ exit 3;
2689+ }
2690+ found=${out% *}
2691+ if [ "$found" != "$sha256" ]; then
2692+ error "$tmp from $url found sha256 of $found. expected $sha256."
2693+ ls -l "$tmp" 1>&2
2694+ rm -f "$tmp"
2695+ exit 3
2696+ fi
2697+ mv "$tmp" "$out_f" || fail "failed renaming $tmp to $out_f"
2698+ echo "$fname" "$url" >> "$out_d/contents"
2699+done < "${TEMP_D}/qout"
2700+
2701+if [ ! -f "$image" ]; then
2702+ case "$image_src" in
2703+ */root-image.gz)
2704+ debug 1 "decompressing $image_src"
2705+ zcat "$image_src" > "$image.tmp" &&
2706+ mv "$image.tmp" "$image" ||
2707+ { rm -f "$image.tmp"; exit 1; }
2708+ ;;
2709+ */disk.img.dist)
2710+ debug 1 "converting qcow2 in $image_src -> raw in $image"
2711+ qemu-img convert -O raw "$image_src" "$image.tmp" &&
2712+ mv "$image.tmp" "$image" ||
2713+ { rm -f "$image.tmp"; exit 1; }
2714+ ;;
2715+ esac
2716+fi
2717+
2718+# vi: ts=4 expandtab
2719diff --git a/debian/tests/install b/debian/tests/install
2720index ae2fe79..5077b7b 100755
2721--- a/debian/tests/install
2722+++ b/debian/tests/install
2723@@ -28,5 +28,8 @@ grep -vq '^GenerateName=yes' /etc/iscsi/initiatorname.iscsi || die_with_file /et
2724 grep -q '^InitiatorName=' /etc/iscsi/initiatorname.iscsi || die_with_file /etc/iscsi/initiatorname.iscsi "InitiatorName is not set"
2725
2726 # Make sure the daemon is started
2727-service iscsid status || die "iscsid not running"
2728-pgrep -c iscsid >/dev/null || die "iscsid not running"
2729+systemctl is-active iscsid.socket || die "iscsid socket not running"
2730+# no-op discovery to socket activate service
2731+iscsiadm -m discovery -t sendtargets -p 127.0.0.1 >/dev/null 2>&1|| /bin/true
2732+systemctl is-active iscsid.service || die "iscsid service not running"
2733+pgrep -c iscsid >/dev/null || die "iscsid process not running"
2734diff --git a/debian/tests/patch-image b/debian/tests/patch-image
2735new file mode 100755
2736index 0000000..0688912
2737--- /dev/null
2738+++ b/debian/tests/patch-image
2739@@ -0,0 +1,374 @@
2740+#!/bin/bash
2741+
2742+VERBOSITY=1
2743+TEMP_D=""
2744+
2745+error() { echo "$@" 1>&2; }
2746+fail() { local r=$?; [ $r -eq 0 ] && r=1; failrc "$r" "$@"; }
2747+failrc() { local r=$1; shift; [ $# -eq 0 ] || error "$@"; exit $r; }
2748+
2749+Usage() {
2750+ cat <<EOF
2751+Usage: ${0##*/} [options] image [packages]
2752+ Patch image, upgrading [packages].
2753+ --kernel FILE copy kernel out to FILE
2754+ --initrd FILE copy initrd out to FILE
2755+
2756+ --krd-only only copy out kernel/initrd do not change image.
2757+ this is incompatible with 'packages'
2758+ it is a short-cut to specifying all the '--no-*'
2759+ options below.
2760+
2761+ --no-copy-apt do not copy host's apt repos in.
2762+
2763+ image modifications:
2764+ --no-update-fstab do not modify fstab (LP: #1732028)
2765+
2766+ if no packages are provided, and ADT_TEST_TRIGGERS is set
2767+ in environment, then it will be read for the list of packages.
2768+ to override that behavior pass package 'none'.
2769+EOF
2770+
2771+}
2772+
2773+bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return 1; }
2774+cleanup() {
2775+ [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
2776+}
2777+
2778+debug() {
2779+ local level=${1}; shift;
2780+ [ "${level}" -gt "${VERBOSITY}" ] && return
2781+ error "${@}"
2782+}
2783+
2784+adt_test_triggers_to_bin_pkgs() {
2785+ # ADT_TEST_TRIGGERS is space delimited <src>/version
2786+ # returns a scalar '_RET', caller has to expand
2787+ local tok src="" ver="" binpkgs=""
2788+ for tok in "$@"; do
2789+ src=${tok%/*}
2790+ ver=${tok#*/}
2791+ bin_packages_from_source_pkg "$src" "$ver" || return
2792+ if [ -z "${_RET}" ]; then
2793+ error "$tok: (source=$src ver=$ver) No packages available!"
2794+ return 1
2795+ fi
2796+ binpkgs="${binpkgs} ${_RET}"
2797+ done
2798+ _RET=${binpkgs# }
2799+}
2800+
2801+bin_packages_from_source_pkg() {
2802+ local pkg=$1 ver=${2} cmd="" out="" p="" ret=""
2803+ if ! command -v grep-aptavail >/dev/null; then
2804+ error "No command grep-aptavail: apt-get install dctrl-tools"
2805+ return 1
2806+ fi
2807+ cmd=( grep-aptavail --show-field=Package
2808+ --exact-match --field=Source:Package "$pkg" )
2809+ if [ -n "$ver" ]; then
2810+ cmd=( "${cmd[@]}" --and --field=Version "$ver" )
2811+ fi
2812+ out=$("${cmd[@]}" | sed 's,Package: ,,')
2813+ ret=""
2814+ for p in $out; do
2815+ ret="$ret ${p#Package: }${ver:+=${ver}}"
2816+ done
2817+ # if no version was provided, we could have multiple results
2818+ _RET=$(set -f; for i in ${ret}; do echo "$i"; done | sort -u)
2819+}
2820+
2821+update_fstab() {
2822+ # update_fstab(path) modify the fstab at path
2823+ # to remove problematic entries (LP: #1732028)
2824+ local fstab="$1"
2825+ if [ ! -e "$fstab.patch-image-dist" ]; then
2826+ cp "$fstab" "$fstab.patch-image-dist" ||
2827+ { error "failed backing up $fstab to $fstab.dist"; return 1; }
2828+ fi
2829+ sed -i '/^LABEL=UEFI/s/^/#/' "$fstab"
2830+}
2831+
2832+cat_debug_script() {
2833+ cat <<"EOF"
2834+#!/bin/sh
2835+set -f
2836+NAME=${1:-debug-pid-$$}
2837+[ "$(id -u)" = "0" ] && log="/run/${NAME}.log" || log="/tmp/${NAME}.log"
2838+
2839+msg() {
2840+ echo "===" "$@" "===" 1>&2
2841+}
2842+showcmd() {
2843+ msg "showcmd$" "$@"
2844+ "$@"
2845+}
2846+
2847+main() {
2848+ issues=$(journalctl | egrep "[.]mount: ")
2849+ if [ -z "$issues" ]; then
2850+ msg "$NAME:" "MOUNT ISSUES FOUND: NO"
2851+ else
2852+ msg "$NAME:" "MOUNT ISSUES FOUND: YES"
2853+ fi
2854+ showcmd systemctl list-units --no-pager --all --full "*.mount"
2855+ showcmd systemctl cat --no-pager --all --full "*.mount"
2856+ showcmd systemctl status --no-pager --all --full "*.mount"
2857+ showcmd cat /etc/fstab
2858+ showcmd cat /proc/1/mountinfo
2859+}
2860+
2861+main > "$log" 2>&1
2862+echo "============ $NAME ============="
2863+cat "$log"
2864+EOF
2865+}
2866+
2867+add_systemd_job() {
2868+ local target="$1" name="$2" after="$3" start="$4"
2869+ local spath="lib/systemd/system/xdebug-$name.service"
2870+ debug 1 "writing $name to $target/$spath"
2871+ cat > "$target/$spath" <<EOF
2872+[Unit]
2873+Description=Execute xdebug ${name}
2874+After=${after}
2875+
2876+[Service]
2877+Type=oneshot
2878+ExecStart=${start} ${name}
2879+RemainAfterExit=yes
2880+StandardOutput=journal+console
2881+
2882+[Install]
2883+WantedBy=multi-user.target
2884+EOF
2885+ [ $? -eq 0 ] || { error "failed writing $target/$spath"; return 1; }
2886+ local wantsdir="$target/etc/systemd/system/multi-user.target.wants"
2887+ ln -s "/$spath" "$wantsdir/" ||
2888+ { error "failed ln -s '/$spath' '$wantsdir/'"; return 1; }
2889+}
2890+
2891+insert_debug_1788188() {
2892+ # This is an attempt to collect more debug information in the
2893+ # event that the tests trigger LP: #1788188.
2894+ local target="$1"
2895+ [ "$target" = "/" -o -z "$target" ] &&
2896+ { error "target was / in insert_debug"; return 1; }
2897+ local script="usr/local/bin/debug-mounts"
2898+ cat_debug_script > "$target/$script" &&
2899+ chmod 755 "$target/$script" ||
2900+ { error "failed writing $target/script"; return 1; }
2901+ local name=""
2902+ ( set +f;
2903+ rm -f "$target/lib/systemd/system/xdebug"-*.service \
2904+ "$target/etc/systemd/system/"*.wants/xdebug*.service )
2905+ add_systemd_job "$target" network network-online.target "/$script" &&
2906+ add_systemd_job "$target" local-fs local-fs.target "/$script" ||
2907+ { error "failed adding systemd jobs"; return 1; }
2908+}
2909+
2910+main() {
2911+ local short_opts="hv"
2912+ local long_opts="help,no-copy-apt,initrd:,kernel:,verbose"
2913+ local getopt_out="" orig_args=""
2914+ orig_args=( "$@" )
2915+ getopt_out=$(getopt --name "${0##*/}" \
2916+ --options "${short_opts}" --long "${long_opts}" -- "$@") &&
2917+ eval set -- "${getopt_out}" ||
2918+ { bad_Usage; return; }
2919+
2920+ local cur="" next=""
2921+ local kernel="" initrd="" copy_apt=true krd_only=false
2922+ local update_fstab=true
2923+
2924+ while [ $# -ne 0 ]; do
2925+ cur="$1"; next="$2";
2926+ case "$cur" in
2927+ -h|--help) Usage ; exit 0;;
2928+ --krd-only) krd_only=true; shift;;
2929+ --no-copy-apt) copy_apt=false; shift;;
2930+ --no-update-fstab) update_fstab=false; shift;;
2931+ --kernel) kernel=$next; shift;;
2932+ --initrd) initrd=$next; shift;;
2933+ -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
2934+ --) shift; break;;
2935+ esac
2936+ shift;
2937+ done
2938+
2939+ [ $# -ne 0 ] || { bad_Usage "must provide at least image"; return; }
2940+
2941+ [ "$(id -u)" = "0" ] || fail "not root"
2942+ target="$1"
2943+ shift
2944+ if [ -f "$target" ]; then
2945+ local nargs=""
2946+ nargs=( "${orig_args[@]}" )
2947+ # replace the first occurance of target in orig args with _MOUNTPOINT_
2948+ for((i=0;i<${#nargs[@]};i++)); do
2949+ [ "${nargs[$i]}" = "$target" ] && nargs[$i]=_MOUNTPOINT_ && break
2950+ done
2951+ debug 1 "mic $target -- $0 ${nargs[*]}"
2952+ IMAGE="$target" exec mount-image-callback \
2953+ --system-resolvconf "$target" -- "$0" "${nargs[@]}"
2954+ fi
2955+
2956+ if [ ! -d "$target" ]; then
2957+ fail "$target: not a directory or file"
2958+ fi
2959+
2960+ local tsrc=${IMAGE:-${target}}
2961+ local packages=( )
2962+ packages=( "$@" )
2963+
2964+ if $krd_only; then
2965+ if [ "${#packages[@]}" != 0 -a "${packages[*]}" != "none" ]; then
2966+ error "--krd-only is incompatible with packages."
2967+ return 1
2968+ fi
2969+ debug 1 "--krd-only provided no changes will be done."
2970+ copy_apt=false
2971+ update_fstab=false
2972+ packages=( "none" )
2973+ fi
2974+
2975+ if [ "${#packages[@]}" = "1" -a "${packages[0]}" = "none" ]; then
2976+ packages=( )
2977+ elif [ "${#packages[@]}" -eq 0 -a -n "${ADT_TEST_TRIGGERS}" ]; then
2978+ adt_test_triggers_to_bin_pkgs ${ADT_TEST_TRIGGERS} ||
2979+ fail "failed to find binary packages " \
2980+ "from ADT_TEST_TRIGGERS=$ADT_TEST_TRIGGERS"
2981+ packages=( $_RET )
2982+ debug 1 "read ADT_TEST_TRIGGERS=$ADT_TEST_TRIGGERS to set" \
2983+ "packages=${packages[*]}"
2984+ else
2985+ local opackages="" debs="" pkg=""
2986+ opackages=( "${packages[@]}" )
2987+ packages=( )
2988+ debs=( )
2989+ for pkg in "${opackages[@]}"; do
2990+ [ -f "${pkg}" ] && debs[${#debs[@]}]="$pkg" ||
2991+ packages[${packages[@]}]="$pkg"
2992+ done
2993+ if [ "${#packages[@]}" -eq 0 -a "${#debs[@]}" -eq 0 ]; then
2994+ packages=( open-iscsi )
2995+ debug 1 "no packages or debs given, using packages=${packages[*]}"
2996+ fi
2997+ fi
2998+
2999+ # if open-iscsi is not in the packages list above, we handle it specifically
3000+ # so that even if the image did not have open-iscsi, it will get it.
3001+ local pkg="" mypkg="open-iscsi"
3002+ for pkg in "${packages[@]}"; do
3003+ case "$pkg" in
3004+ open-iscsi|open-iscsi/*) mypkg="none";;
3005+ esac
3006+ done
3007+
3008+ TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") ||
3009+ fail "failed to make tempdir"
3010+ trap cleanup EXIT
3011+
3012+ if $copy_apt; then
3013+ local distdir="${target}/etc/apt.dist.${0##*/}"
3014+ if [ ! -d "$distdir" ]; then
3015+ mv "$target/etc/apt" "$distdir" ||
3016+ fail "failed to backup /etc/apt in $tsrc"
3017+ fi
3018+ cp -a /etc/apt "$target/etc/" ||
3019+ fail "failed to replace /etc/apt in $tsrc"
3020+
3021+ # find file:// repos in apt sources and copy them in
3022+ local file_repos=""
3023+ file_repos=$(
3024+ fm='s,.*[[:space:]]file:///*\([^[[:space:]]*\).*,/\1,p'
3025+ shopt -s nullglob
3026+ for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do
3027+ sed -n -e 's/#.*//' -e "$fm" "$f"
3028+ done
3029+ )
3030+ local dir="" bdir="" tdir=""
3031+ for dir in ${file_repos}; do
3032+ tdir="${target}$(dirname $dir)/$(basename ${dir})"
3033+ if [ -d "$dir" ]; then
3034+ debug 1 "copying $dir -> $tdir"
3035+ mkdir -p "$tdir" ||
3036+ fail "failed to create $tdir"
3037+ rsync --delete -a "$dir/" "$tdir" ||
3038+ fail "failed copy from $dir/ to $tdir"
3039+ fi
3040+ done
3041+ fi
3042+
3043+ if $update_fstab; then
3044+ update_fstab "$target/etc/fstab" ||
3045+ { error "failed updating /etc/fstab in target"; return 1; }
3046+ fi
3047+
3048+ insert_debug_1788188 "$target" || return 1
3049+
3050+ mount -o bind /sys "$target"/sys || :
3051+ mount -o bind /proc "$target"/proc || :
3052+ mount -o bind /dev "$target"/dev || :
3053+ mount -o bind /dev/pts "$target"/dev/pts || :
3054+
3055+ debug 1 "${#packages[@]} packages: ${packages[*]}"
3056+ if [ "${#packages[@]}" != "0" ]; then
3057+ DEBIAN_FRONTEND=noninteractive chroot "$target" sh -exc '
3058+ mypkg=$1
3059+ shift
3060+ apt-get update -q
3061+ if [ "$mypkg" != "none" ]; then
3062+ apt-get install -qy "$mypkg"
3063+ fi
3064+ apt-get install -qy --only-upgrade "$@"' \
3065+ chroot-inst "$mypkg" "${packages[@]}" ||
3066+ fail "failed to install ${packages[*]} in $target"
3067+ fi
3068+
3069+ debug 1 "${#debs[@]} debs: ${debs[*]}"
3070+ if [ "${#debs[@]}" != "0" ]; then
3071+ local tmpd=""
3072+ tmpd=$(mktemp -d "${target}/tmp/${0##*/}.XXXXXX")
3073+ cp "${debs[@]}" "$tmpd"
3074+ DEBIAN_FRONTEND=noninteractive chroot "$target" sh -exc \
3075+ 'cd "$1"; shift; dpkg -i *.deb' debinstalls "${tmpd#${target}}"
3076+ rm -Rf "${tmpd}"
3077+ fi
3078+
3079+ umount "$target"/dev/pts || :
3080+ umount "$target"/dev || :
3081+ umount "$target"/proc || :
3082+ umount "$target"/sys || :
3083+
3084+ local kpath="" ipath=""
3085+ for f in "$target/boot/"*; do
3086+ case "${f##*/}" in
3087+ *.signed) continue;;
3088+ vmlinu?-*) kpath="$f";;
3089+ initrd.img-*) ipath="$f";;
3090+ esac
3091+ done
3092+
3093+ if [ -n "$kernel" ]; then
3094+ [ -n "$kpath" ] || fail "unable to find kernel in $tsrc"
3095+ debug 1 "using kernel ${kpath#${target}}"
3096+ cp "$kpath" "$kernel" ||
3097+ fail "failed copy $kpath to $kernel"
3098+ [ -z "$IMAGE" ] || chown "--reference=$IMAGE" "$kernel"
3099+ fi
3100+
3101+ if [ -n "$initrd" ]; then
3102+ [ -n "$ipath" ] || fail "unable to find initrd in $tsrc"
3103+ debug 1 "using initrd ${ipath#${target}}"
3104+ cp "$ipath" "$initrd" ||
3105+ fail "failed copy $ipath to $initrd"
3106+ [ -z "$IMAGE" ] || chown "--reference=$IMAGE" "$initrd"
3107+ fi
3108+
3109+}
3110+
3111+main "$@"
3112+
3113+# vi: ts=4 expandtab
3114diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
3115new file mode 100644
3116index 0000000..1ad8b4f
3117--- /dev/null
3118+++ b/debian/tests/test-open-iscsi.py
3119@@ -0,0 +1,427 @@
3120+#!/usr/bin/python3
3121+#
3122+# test-open-iscsi.py quality assurance test script for open-iscsi
3123+# Copyright (C) 2011 Canonical Ltd.
3124+# Author: Jamie Strandboge <jamie@canonical.com>
3125+#
3126+# This program is free software: you can redistribute it and/or modify
3127+# it under the terms of the GNU General Public License version 3,
3128+# as published by the Free Software Foundation.
3129+#
3130+# This program is distributed in the hope that it will be useful,
3131+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3132+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3133+# GNU General Public License for more details.
3134+#
3135+# You should have received a copy of the GNU General Public License
3136+# along with this program. If not, see <http://www.gnu.org/licenses/>.
3137+#
3138+# packages required for test to run:
3139+# QRT-Packages: open-iscsi
3140+# packages where more than one package can satisfy a runtime requirement:
3141+# QRT-Alternates:
3142+# files and directories required for the test to run:
3143+# QRT-Depends:
3144+# privilege required for the test to run (remove line if running as user is okay):
3145+# QRT-Privilege: root
3146+
3147+'''
3148+ In general, this test should be run in a virtual machine (VM) or possibly
3149+ a chroot and not on a production machine. While efforts are made to make
3150+ these tests non-destructive, there is no guarantee this script will not
3151+ alter the machine. You have been warned.
3152+
3153+ How to run in a clean VM:
3154+ $ sudo apt-get -y install <QRT-Packages> && sudo ./test-PKG.py -v'
3155+
3156+ How to run in a clean schroot named 'lucid':
3157+ $ schroot -c lucid -u root -- sh -c 'apt-get -y install <QRT-Packages> && ./test-PKG.py -v'
3158+
3159+
3160+ NOTES:
3161+ - currently only tested on Ubuntu 8.04
3162+'''
3163+
3164+from __future__ import print_function
3165+
3166+from netifaces import gateways, AF_INET
3167+import unittest, subprocess, sys, os, glob
3168+import shutil
3169+import testlib
3170+import textwrap
3171+from tempfile import mkdtemp
3172+import time
3173+
3174+# There are setup based on README.multipurpose-vm. Feel free to override.
3175+remote_server = ''
3176+username = 'ubuntu'
3177+password = 'passwd'
3178+username_in = 'ubuntu'
3179+password_in = 'ubuntupasswd'
3180+initiatorname = 'iqn.2009-10.com.example.hardy-multi:iscsi-01'
3181+
3182+COLLECT_USER_DATA = """\
3183+#cloud-config
3184+bukket:
3185+ - &get_resolved_status |
3186+ if [ "${1:--}" != "-" ]; then
3187+ exec >"$1" 2>&1
3188+ fi
3189+ if ! command -v systemd-resolve >/dev/null 2>&1; then
3190+ echo "systemd-resolve: not available."
3191+ exit
3192+ fi
3193+ if ! ( systemd-resolve --help | grep -q -- --status ); then
3194+ echo "systemd-resolve: no --status."
3195+ exit
3196+ fi
3197+ systemd-resolve --status --no-pager
3198+
3199+ - &get_iscsid_status |
3200+ [ "${1:--}" != "-" ] && exec >"$1" 2>&1
3201+ udevadm settle
3202+ systemctl is-active iscsid.service
3203+ systemctl status --no-pager --full iscsid.service
3204+
3205+ - &add_and_remove_tuntap |
3206+ #!/bin/sh
3207+ # LP: #1785108 would break dns when any device was removed.
3208+ tapdev="mytap0"
3209+ echo ==== Adding $tapdev ====
3210+ ip tuntap add mode tap user root $tapdev
3211+ udevadm settle
3212+ echo ==== Removing $tapdev ====
3213+ ip tuntap del mode tap $tapdev
3214+ udevadm settle
3215+
3216+ - &collect_debug_mounts |
3217+ [ "${1:--}" != "-" ] && exec >"$1" 2>&1
3218+ [ -x /usr/local/bin/debug-mounts ] || exit 0
3219+ /usr/local/bin/debug-mounts
3220+
3221+runcmd:
3222+ - [ sh, -c, *add_and_remove_tuntap ]
3223+ - [ mkdir, -p, /output ]
3224+ - [ cp, /etc/resolv.conf, /output ]
3225+ - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt ]
3226+ - [ sh, -c, *get_iscsid_status, --, /output/iscsid-status.txt ]
3227+ - [ sh, -c, *collect_debug_mounts, --, /output/debug-mounts.txt ]
3228+ - [ sh, -c, 'journalctl --boot=0 --output=short-monotonic > /output/journal.txt' ]
3229+ - [ sh, -c, 'dpkg-query --show > /output/manifest.txt' ]
3230+ - [ tar, -C, /output, -cf, /dev/disk/by-id/virtio-output-disk, . ]
3231+
3232+power_state:
3233+ mode: poweroff
3234+ message: cloud-init finished. Shutting down.
3235+ timeout: 60
3236+"""
3237+
3238+try:
3239+ from private.qrt.OpenIscsi import PrivateOpenIscsiTest
3240+except ImportError:
3241+ class PrivateOpenIscsiTest(object):
3242+ '''Empty class'''
3243+ print("Skipping private tests", file=sys.stdout)
3244+
3245+class OpenIscsiTest(testlib.TestlibCase, PrivateOpenIscsiTest):
3246+ '''Test my thing.'''
3247+
3248+ def setUp(self):
3249+ '''Set up prior to each test_* function'''
3250+ self.pidfile = "/var/run/iscsid.pid"
3251+ self.exe = "/sbin/iscsid"
3252+ self.daemon = testlib.TestDaemon("open-iscsi")
3253+ self.initiatorname_iscsi = '/etc/iscsi/initiatorname.iscsi'
3254+ self.iscsid_conf = '/etc/iscsi/iscsid.conf'
3255+
3256+ def tearDown(self):
3257+ '''Clean up after each test_* function'''
3258+ global remote_server
3259+ global initiatorname
3260+
3261+ # If remote server is setup, convert back to manual, logout, remove
3262+ # testlib configs and restart (in that order)
3263+ if remote_server != '':
3264+ testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--op=update', '--name', 'node.startup', '--value=manual'])
3265+ testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--op=update', '--name', 'node.conn[0].startup', '--value=manual'])
3266+ testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--logout'])
3267+
3268+ testlib.config_restore(self.initiatorname_iscsi)
3269+ testlib.config_restore(self.iscsid_conf)
3270+ self.daemon.restart()
3271+
3272+ def test_discovery_with_server(self):
3273+ '''Test iscsi_discovery to remote server'''
3274+ global remote_server
3275+ global username
3276+ global password
3277+ global username_in
3278+ global password_in
3279+ global initiatorname
3280+
3281+ if remote_server == '':
3282+ return self._skipped("--remote-server not specified")
3283+
3284+ contents = '''
3285+InitiatorName=%s
3286+InitiatorAlias=ubuntu
3287+''' % (initiatorname)
3288+ testlib.config_replace(self.initiatorname_iscsi, contents, True)
3289+
3290+ contents = '''
3291+node.session.auth.authmethod = CHAP
3292+node.session.auth.username = %s
3293+node.session.auth.password = %s
3294+node.session.auth.username_in = %s
3295+node.session.auth.password_in = %s
3296+
3297+discovery.sendtargets.auth.authmethod = CHAP
3298+discovery.sendtargets.auth.username = %s
3299+discovery.sendtargets.auth.password = %s
3300+discovery.sendtargets.auth.username_in = %s
3301+discovery.sendtargets.auth.password_in = %s
3302+''' % (username, password, username_in, password_in, username, password, username_in, password_in)
3303+ testlib.config_replace(self.iscsid_conf, contents, True)
3304+
3305+ self.assertTrue(self.daemon.restart())
3306+ time.sleep(2)
3307+ self.assertTrue(self.daemon.status()[0])
3308+
3309+ rc, report = testlib.cmd(["/sbin/iscsi_discovery", remote_server])
3310+ expected = 0
3311+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
3312+ self.assertEqual(expected, rc, result + report)
3313+ for i in ['starting discovery to %s' % remote_server,
3314+ 'Testing iser-login to target %s portal %s' % (initiatorname, remote_server),
3315+ 'starting to test tcp-login to target %s portal %s' % (initiatorname, remote_server),
3316+ 'discovered 1 targets at %s, connected to 1' % remote_server]:
3317+ result = "Could not find '%s' in report:\n" % i
3318+ self.assertTrue(i in report, result + report)
3319+
3320+ def test_net_interface_handler_execute_bit(self):
3321+ '''Test /lib/open-iscsi/net-interface-handler is executable.'''
3322+ nih_path = '/lib/open-iscsi/net-interface-handler'
3323+ self.assertTrue(os.access(nih_path, os.X_OK))
3324+
3325+class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
3326+ '''Test the cloud image can boot on iscsi root.
3327+
3328+ See README-boot-test.md for more information.
3329+ '''
3330+
3331+ @classmethod
3332+ def setUpClass(cls):
3333+ reason = (
3334+ "Skipped Cloud Image test on {arch}. whitelisted are: {whitelist}")
3335+ whitelisted = os.environ.get('WHITELIST_ARCHES', 'amd64').split(",")
3336+ curarch = testlib.manager.dpkg_arch
3337+ if testlib.manager.dpkg_arch not in whitelisted:
3338+ raise unittest.SkipTest(
3339+ reason.format(arch=curarch, whitelist=whitelisted))
3340+
3341+ here = os.path.dirname(os.path.abspath(__file__))
3342+ os.environ['PATH'] = "%s:%s" % (here, os.environ['PATH'])
3343+ release = os.environ.get(
3344+ "ISCSI_TEST_RELEASE", testlib.ubuntu_release())
3345+ image_d = os.path.join(here, '{}.d'.format(release))
3346+ # Download MAAS ephemeral image.
3347+ info = {'release': release,
3348+ 'image_d': image_d,
3349+ 'root_image': os.path.join(image_d, 'disk.img'),
3350+ 'kernel': os.path.join(image_d, 'kernel'),
3351+ 'initrd': os.path.join(image_d, 'initrd')}
3352+ try:
3353+ get_image(info['image_d'], release)
3354+ except subprocess.CalledProcessError as e:
3355+ if e.return_code != 3:
3356+ raise e
3357+ raise unittest.SkipTest(
3358+ "Cloud Image not available for release '%s'." % release)
3359+ if os.environ.get("NO_PATCH_IMAGE", "0") == "0":
3360+ patch_image(info['root_image'],
3361+ kernel=info['kernel'], initrd=info['initrd'])
3362+ cls.info = info
3363+ cls.here = here
3364+
3365+ def tearDown(self):
3366+ super(CloudImageTest, self).tearDown()
3367+ if os.path.exists(self.tmpdir):
3368+ shutil.rmtree(self.tmpdir)
3369+
3370+ def setUp(self):
3371+ super(CloudImageTest, self).setUp()
3372+ self.tmpdir = mkdtemp()
3373+ udp = os.path.join(self.tmpdir, 'user-data')
3374+ with open(udp, "w") as fp:
3375+ fp.write(COLLECT_USER_DATA)
3376+ self.info['user-data'] = udp
3377+
3378+ def create_output_disk(self):
3379+ path = os.path.join(self.tmpdir, 'output-disk.img')
3380+ subprocess.check_call([
3381+ 'qemu-img', 'create', '-f', 'raw', path, '10M'])
3382+ return path
3383+
3384+ def extract_files(self, path):
3385+ # get contents in a dictionary of tarball at 'path'
3386+ tmpdir = mkdtemp()
3387+ try:
3388+ subprocess.check_call(['tar', '-C', tmpdir, '-xf', path])
3389+ flist = {}
3390+ prefix = len(tmpdir) + 1
3391+ for root, dirs, files in os.walk(tmpdir):
3392+ for fname in files:
3393+ fpath = os.path.join(root, fname)
3394+ key = fpath[prefix:]
3395+ with open(fpath, "r") as fp:
3396+ flist[key] = fp.read()
3397+ return flist
3398+ finally:
3399+ shutil.rmtree(tmpdir)
3400+
3401+ def test_tgt_boot(self):
3402+ tgt_boot_cmd = os.path.join(self.here, 'tgt-boot-test')
3403+ # Add self.here to PATH so xkvm will be available to tgt-boot-test
3404+ dns_addr = '10.1.1.4'
3405+ rel_dir = '{}.d'.format(self.info['release'])
3406+ dns_search = 'example.com'
3407+ info = {'host': '10.1.1.2', 'dns': dns_addr,
3408+ 'dnssearch': dns_search, 'network': '10.1.1.0/24'}
3409+ netdev = ("--netdev=user,net={network},host={host},dns={dns},"
3410+ "dnssearch={dnssearch}").format(**info)
3411+
3412+ artifacts_dir = os.environ.get('AUTOPKGTEST_ARTIFACTS')
3413+ if artifacts_dir and not os.path.isdir(artifacts_dir):
3414+ os.makedirs(artifacts_dir)
3415+
3416+ output_disk = self.create_output_disk()
3417+ cmd = [
3418+ tgt_boot_cmd, '-v', netdev,
3419+ '--disk=%s,serial=output-disk' % output_disk,
3420+ '--user-data-add=%s' % self.info['user-data'],
3421+ self.info['root_image'], self.info['kernel'],
3422+ self.info['initrd']]
3423+ sys.stderr.write(' '.join(cmd) + "\n")
3424+
3425+ env = os.environ.copy()
3426+ env['BOOT_TIMEOUT'] = env.get('BOOT_TIMEOUT', '60m')
3427+ subprocess.check_call(cmd, env=env)
3428+
3429+ if artifacts_dir:
3430+ tgz = os.path.join(artifacts_dir, "tgt-collected.tar.gz")
3431+ shutil.copy(output_disk, tgz)
3432+ print("Copied output_disk '%s' to artifacts dir '%s'" %
3433+ (output_disk, tgz))
3434+
3435+ files = self.extract_files(output_disk)
3436+ print("collected files: %s" % files.keys())
3437+ resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
3438+ resolve_status = files.get('systemd-resolve-status.txt')
3439+
3440+ resolvconf_id = 'generated by resolvconf'
3441+ resolved_addr = "127.0.0.53"
3442+ if resolvconf_id in resolvconf:
3443+ print("resolvconf manages resolvconf.\n")
3444+ self.assertIn(
3445+ dns_addr, resolvconf,
3446+ msg = ("%s not in resolvconf contents: \n%s" %
3447+ (dns_addr, resolvconf)))
3448+ if dns_search in resolvconf:
3449+ print("%s was found in resolv.conf." % dns_search)
3450+ elif resolved_addr in resolvconf and dns_search in resolve_status:
3451+ # zesty has resolvconf and systemd-resolved.
3452+ print("%s was in resolve_status and %s in resolv.conf" %
3453+ (resolved_addr, dns_search))
3454+ else:
3455+ raise AssertionError(
3456+ "%s domain is not being searched." % dns_search)
3457+
3458+ else:
3459+ print("systemd-resolved managing resolve.conf\n")
3460+ self.assertIn(
3461+ resolved_addr, resolvconf,
3462+ msg="%s not in resolved resolv.conf: %s" % (resolved_addr,
3463+ resolvconf))
3464+ self.assertIn(dns_addr, resolve_status,
3465+ msg=("%s not in systemd-resolve status: %s" %
3466+ (dns_addr, resolve_status)))
3467+ self.assertIn(dns_search, resolve_status,
3468+ msg=("search addr '%s' not in systemd-resolve status: %s" %
3469+ (dns_search, resolve_status)))
3470+
3471+ # iscsid-status.txt has first line output from
3472+ # 'systemctl is-active iscsid.service' and then 'systemcl status'
3473+ iscsid_status = files.get('iscsid-status.txt')
3474+ is_active = iscsid_status.splitlines()[0]
3475+ self.assertEqual(
3476+ "active", is_active,
3477+ msg=("Expected iscsid.service active, found '%s'.\n%s\n" %
3478+ (is_active, iscsid_status)))
3479+
3480+
3481+def get_image(top_d, release):
3482+ cmd = ['get-image', top_d, 'cloud-daily', release]
3483+ subprocess.check_call(cmd)
3484+
3485+
3486+def patch_image(image, packages=None, kernel=None, initrd=None):
3487+ '''Patch root-image with dep8 built open-iscsi package.'''
3488+
3489+ if packages is None:
3490+ # an empty 'packages' to patch-image still installs open-iscsi
3491+ packages = []
3492+
3493+ cmd = ['patch-image', image]
3494+ if kernel:
3495+ cmd.append('--kernel=%s' % kernel)
3496+ if initrd:
3497+ cmd.append('--initrd=%s' % initrd)
3498+ cmd.extend(packages)
3499+
3500+ subprocess.check_call(cmd)
3501+
3502+
3503+if __name__ == '__main__':
3504+ import optparse
3505+ parser = optparse.OptionParser()
3506+ parser.add_option("-v", "--verbose", dest="verbose", help="Verbose", action="store_true")
3507+ parser.add_option("-s", "--remote-server", dest="remote_server", help="Specify host with available iSCSI volumes", metavar="HOST")
3508+
3509+ parser.add_option("-n", "--initiatorname", dest="initiatorname", help="Specify initiatorname for use with --remote-server", metavar="NAME")
3510+
3511+ parser.add_option("--password", dest="password", help="Specify password for use with --remote-server", metavar="PASS")
3512+ parser.add_option("--password-in", dest="password_in", help="Specify password_in for use with --remote-server", metavar="PASS")
3513+
3514+ parser.add_option("--username", dest="username", help="Specify username for use with --remote-server", metavar="USER")
3515+ parser.add_option("--username-in", dest="username_in", help="Specify username_in for use with --remote-server", metavar="USER")
3516+
3517+ (options, args) = parser.parse_args()
3518+
3519+ if options.remote_server:
3520+ remote_server = options.remote_server
3521+
3522+ if options.username:
3523+ username = options.username
3524+ if options.password:
3525+ password = options.password
3526+ if options.username_in:
3527+ username_in = options.username_in
3528+ if options.password_in:
3529+ password_in = options.password_in
3530+ if options.initiatorname:
3531+ initiatorname = options.initiatorname
3532+ print("Connecting to remote server with:")
3533+ print(" host = %s " % remote_server)
3534+ print(' initiatorname = %s' % initiatorname)
3535+ print(' username = %s' % username)
3536+ print(' password = %s' % password)
3537+ print(' username_in = %s' % username_in)
3538+ print(' password_in = %s' % password_in)
3539+
3540+ suite = unittest.TestSuite()
3541+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(OpenIscsiTest))
3542+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
3543+ CloudImageTest))
3544+ rc = unittest.TextTestRunner(verbosity=2).run(suite)
3545+ if not rc.wasSuccessful():
3546+ sys.exit(1)
3547diff --git a/debian/tests/testlib.py b/debian/tests/testlib.py
3548new file mode 100644
3549index 0000000..dce4252
3550--- /dev/null
3551+++ b/debian/tests/testlib.py
3552@@ -0,0 +1,1488 @@
3553+from __future__ import print_function
3554+#
3555+# testlib.py quality assurance test script
3556+# Copyright (C) 2008-2016 Canonical Ltd.
3557+#
3558+# This library is free software; you can redistribute it and/or
3559+# modify it under the terms of the GNU Library General Public
3560+# License as published by the Free Software Foundation; either
3561+# version 2 of the License.
3562+#
3563+# This library is distributed in the hope that it will be useful,
3564+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3565+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3566+# Library General Public License for more details.
3567+#
3568+# You should have received a copy of the GNU Library General Public
3569+# License along with this program. If not, see
3570+# <http://www.gnu.org/licenses/>.
3571+#
3572+
3573+'''Common classes and functions for package tests.'''
3574+
3575+import crypt
3576+import glob
3577+import grp
3578+import gzip
3579+import os
3580+import os.path
3581+import platform
3582+import pwd
3583+import random
3584+import re
3585+import shutil
3586+import socket
3587+import string
3588+import subprocess
3589+import sys
3590+import tempfile
3591+import time
3592+import unittest
3593+
3594+from stat import ST_SIZE
3595+
3596+# Don't make python-pexpect mandatory
3597+try:
3598+ import pexpect
3599+except ImportError:
3600+ pass
3601+
3602+import warnings
3603+warnings.filterwarnings('ignore', message=r'.*apt_pkg\.TagFile.*', category=DeprecationWarning)
3604+try:
3605+ import apt_pkg
3606+ # cope with apt_pkg api changes.
3607+ if 'init_system' in dir(apt_pkg):
3608+ apt_pkg.init_system()
3609+ else:
3610+ apt_pkg.InitSystem()
3611+except:
3612+ # On non-Debian system, fall back to simple comparison without debianisms
3613+ class apt_pkg(object):
3614+ @staticmethod
3615+ def version_compare(one, two):
3616+ list_one = one.split('.')
3617+ list_two = two.split('.')
3618+ while len(list_one) > 0 and len(list_two) > 0:
3619+ try:
3620+ if int(list_one[0]) > int(list_two[0]):
3621+ return 1
3622+ if int(list_one[0]) < int(list_two[0]):
3623+ return -1
3624+ except:
3625+ # ugh, non-numerics in the version, fall back to
3626+ # string comparison, which will be wrong for e.g.
3627+ # 3.2 vs 3.16rc1
3628+ if list_one[0] > list_two[0]:
3629+ return 1
3630+ if list_one[0] < list_two[0]:
3631+ return -1
3632+ list_one.pop(0)
3633+ list_two.pop(0)
3634+ return 0
3635+
3636+ @staticmethod
3637+ def VersionCompare(one, two):
3638+ return apt_pkg.version_compare(one, two)
3639+
3640+bogus_nxdomain = "208.69.32.132"
3641+
3642+# http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html
3643+# This is needed so that the subprocesses that produce endless output
3644+# actually quit when the reader goes away.
3645+import signal
3646+def subprocess_setup():
3647+ # Python installs a SIGPIPE handler by default. This is usually not what
3648+ # non-Python subprocesses expect.
3649+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
3650+
3651+
3652+class TimedOutException(Exception):
3653+ def __init__(self, value="Timed Out"):
3654+ self.value = value
3655+
3656+ def __str__(self):
3657+ return repr(self.value)
3658+
3659+
3660+def _restore_backup(path):
3661+ pathbackup = path + '.autotest'
3662+ if os.path.exists(pathbackup):
3663+ shutil.move(pathbackup, path)
3664+
3665+
3666+def _save_backup(path):
3667+ pathbackup = path + '.autotest'
3668+ if os.path.exists(path) and not os.path.exists(pathbackup):
3669+ shutil.copy2(path, pathbackup)
3670+ # copy2 does not copy ownership, so do it here.
3671+ # Reference: http://docs.python.org/library/shutil.html
3672+ a = os.stat(path)
3673+ os.chown(pathbackup, a[4], a[5])
3674+
3675+
3676+def config_copydir(path):
3677+ if os.path.exists(path) and not os.path.isdir(path):
3678+ raise OSError("'%s' is not a directory" % (path))
3679+ _restore_backup(path)
3680+
3681+ pathbackup = path + '.autotest'
3682+ if os.path.exists(path):
3683+ shutil.copytree(path, pathbackup, symlinks=True)
3684+
3685+
3686+def config_replace(path, contents, append=False):
3687+ '''Replace (or append) to a config file'''
3688+ _restore_backup(path)
3689+ if os.path.exists(path):
3690+ _save_backup(path)
3691+ if append:
3692+ with open(path) as fh:
3693+ contents = fh.read() + contents
3694+ with open(path, 'w') as fh:
3695+ fh.write(contents)
3696+
3697+
3698+def config_comment(path, field):
3699+ _save_backup(path)
3700+ contents = ""
3701+ with open(path) as fh:
3702+ for line in fh:
3703+ if re.search("^\s*%s\s*=" % (field), line):
3704+ line = "#" + line
3705+ contents += line
3706+
3707+ with open(path + '.new', 'w') as new_fh:
3708+ new_fh.write(contents)
3709+ os.rename(path + '.new', path)
3710+
3711+
3712+def config_set(path, field, value, spaces=True):
3713+ _save_backup(path)
3714+ contents = ""
3715+ if spaces:
3716+ setting = '%s = %s\n' % (field, value)
3717+ else:
3718+ setting = '%s=%s\n' % (field, value)
3719+ found = False
3720+ with open(path) as fh:
3721+ for line in fh:
3722+ if re.search("^\s*%s\s*=" % (field), line):
3723+ found = True
3724+ line = setting
3725+ contents += line
3726+ if not found:
3727+ contents += setting
3728+
3729+ with open(path + '.new', 'w') as new_config:
3730+ new_config.write(contents)
3731+ os.rename(path + '.new', path)
3732+
3733+
3734+def config_patch(path, patch, depth=1):
3735+ '''Patch a config file'''
3736+ _restore_backup(path)
3737+ _save_backup(path)
3738+
3739+ handle, name = mkstemp_fill(patch)
3740+ rc = subprocess.call(['/usr/bin/patch', '-p%s' % depth, path], stdin=handle, stdout=subprocess.PIPE)
3741+ os.unlink(name)
3742+ if rc != 0:
3743+ raise Exception("Patch failed")
3744+
3745+
3746+def config_restore(path):
3747+ '''Rename a replaced config file back to its initial state'''
3748+ _restore_backup(path)
3749+
3750+
3751+def timeout(secs, f, *args):
3752+ def handler(signum, frame):
3753+ raise TimedOutException()
3754+
3755+ old = signal.signal(signal.SIGALRM, handler)
3756+ result = None
3757+ signal.alarm(secs)
3758+ try:
3759+ result = f(*args)
3760+ finally:
3761+ signal.alarm(0)
3762+ signal.signal(signal.SIGALRM, old)
3763+
3764+ return result
3765+
3766+
3767+def require_nonroot():
3768+ if os.geteuid() == 0:
3769+ print("This series of tests should be run as a regular user with sudo access, not as root.", file=sys.stderr)
3770+ sys.exit(1)
3771+
3772+
3773+def require_root():
3774+ if os.geteuid() != 0:
3775+ print("This series of tests should be run with root privileges (e.g. via sudo).", file=sys.stderr)
3776+ sys.exit(1)
3777+
3778+
3779+def require_sudo():
3780+ if os.geteuid() != 0 or os.environ.get('SUDO_USER', None) is None:
3781+ print("This series of tests must be run under sudo.", file=sys.stderr)
3782+ sys.exit(1)
3783+ if os.environ['SUDO_USER'] == 'root':
3784+ print('Please run this test using sudo from a regular user. (You ran sudo from root.)', file=sys.stderr)
3785+ sys.exit(1)
3786+
3787+
3788+def random_string(length, lower=False):
3789+ '''Return a random string, consisting of ASCII letters, with given
3790+ length.'''
3791+
3792+ s = ''
3793+ selection = string.ascii_letters
3794+ if lower:
3795+ selection = string.ascii_lowercase
3796+ maxind = len(selection) - 1
3797+ for l in range(length):
3798+ s += selection[random.randint(0, maxind)]
3799+ return s
3800+
3801+
3802+def mkstemp_fill(contents, suffix='', prefix='testlib-', dir=None):
3803+ '''As tempfile.mkstemp does, return a (file, name) pair, but with
3804+ prefilled contents.'''
3805+
3806+ handle, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)
3807+ os.close(handle)
3808+ handle = open(name, "w+")
3809+ handle.write(contents)
3810+ handle.flush()
3811+ handle.seek(0)
3812+
3813+ return handle, name
3814+
3815+
3816+def create_fill(path, contents, mode=0o644):
3817+ '''Safely create a page'''
3818+ # make the temp file in the same dir as the destination file so we
3819+ # don't get invalid cross-device link errors when we rename
3820+ handle, name = mkstemp_fill(contents, dir=os.path.dirname(path))
3821+ handle.close()
3822+ os.rename(name, path)
3823+ os.chmod(path, mode)
3824+
3825+
3826+def login_exists(login):
3827+ '''Checks whether the given login exists on the system.'''
3828+
3829+ try:
3830+ pwd.getpwnam(login)
3831+ return True
3832+ except KeyError:
3833+ return False
3834+
3835+
3836+def group_exists(group):
3837+ '''Checks whether the given login exists on the system.'''
3838+
3839+ try:
3840+ grp.getgrnam(group)
3841+ return True
3842+ except KeyError:
3843+ return False
3844+
3845+
3846+def is_empty_file(path):
3847+ '''test if file is empty, returns True if so'''
3848+ with open(path) as fh:
3849+ return (len(fh.read()) == 0)
3850+
3851+
3852+def recursive_rm(dirPath, contents_only=False):
3853+ '''recursively remove directory'''
3854+ names = os.listdir(dirPath)
3855+ for name in names:
3856+ path = os.path.join(dirPath, name)
3857+ if os.path.islink(path) or not os.path.isdir(path):
3858+ os.unlink(path)
3859+ else:
3860+ recursive_rm(path)
3861+ if not contents_only:
3862+ os.rmdir(dirPath)
3863+
3864+
3865+def check_pidfile(exe, pidfile):
3866+ '''Checks if pid in pidfile is running'''
3867+ if not os.path.exists(pidfile):
3868+ return False
3869+
3870+ # get the pid
3871+ try:
3872+ with open(pidfile, 'r') as fd:
3873+ pid = fd.readline().rstrip('\n')
3874+ except:
3875+ return False
3876+
3877+ return check_pid(exe, pid)
3878+
3879+
3880+def check_pid(exe, pid):
3881+ '''Checks if pid is running'''
3882+ cmdline = "/proc/%s/cmdline" % (str(pid))
3883+ if not os.path.exists(cmdline):
3884+ return False
3885+
3886+ # get the command line
3887+ try:
3888+ with open(cmdline, 'r') as fd:
3889+ tmp = fd.readline().split('\0')
3890+ except:
3891+ return False
3892+
3893+ # this allows us to match absolute paths or just the executable name
3894+ if re.match('^' + exe + '$', tmp[0]) or \
3895+ re.match('.*/' + exe + '$', tmp[0]) or \
3896+ re.match('^' + exe + ': ', tmp[0]) or \
3897+ re.match('^\(' + exe + '\)', tmp[0]):
3898+ return True
3899+
3900+ return False
3901+
3902+
3903+def check_port(port, proto, ver=4):
3904+ '''Check if something is listening on the specified port.
3905+ WARNING: for some reason this does not work with a bind mounted /proc
3906+ '''
3907+ assert (port >= 1)
3908+ assert (port <= 65535)
3909+ assert (proto.lower() == "tcp" or proto.lower() == "udp")
3910+ assert (ver == 4 or ver == 6)
3911+
3912+ fn = "/proc/net/%s" % (proto)
3913+ if ver == 6:
3914+ fn += str(ver)
3915+
3916+ rc, report = cmd(['cat', fn])
3917+ assert (rc == 0)
3918+
3919+ hport = "%0.4x" % port
3920+
3921+ if re.search(': [0-9a-f]{8}:%s [0-9a-f]' % str(hport).lower(), report.lower()):
3922+ return True
3923+ return False
3924+
3925+
3926+def get_arch():
3927+ '''Get the current architecture'''
3928+ rc, report = cmd(['uname', '-m'])
3929+ assert (rc == 0)
3930+ return report.strip()
3931+
3932+
3933+def get_multiarch_tuple():
3934+ '''Get the current debian multiarch tuple'''
3935+
3936+ # XXX dpkg-architecture on Ubuntu 12.04 requires -q be adjacent to
3937+ # the variable name
3938+ rc, report = cmd(['dpkg-architecture', '-qDEB_HOST_MULTIARCH'])
3939+ assert (rc == 0)
3940+ return report.strip()
3941+
3942+
3943+def get_bits():
3944+ '''return the default architecture number of bits (32 or 64, usually)'''
3945+ return platform.architecture()[0][0:2]
3946+
3947+
3948+def get_memory():
3949+ '''Gets total ram and swap'''
3950+ meminfo = "/proc/meminfo"
3951+ memtotal = 0
3952+ swaptotal = 0
3953+ if not os.path.exists(meminfo):
3954+ return (False, False)
3955+
3956+ try:
3957+ fd = open(meminfo, 'r')
3958+ for line in fd.readlines():
3959+ splitline = line.split()
3960+ if splitline[0] == 'MemTotal:':
3961+ memtotal = int(splitline[1])
3962+ elif splitline[0] == 'SwapTotal:':
3963+ swaptotal = int(splitline[1])
3964+ fd.close()
3965+ except:
3966+ return (False, False)
3967+
3968+ return (memtotal, swaptotal)
3969+
3970+
3971+def is_running_in_vm():
3972+ '''Check if running under a VM'''
3973+ # add other virtualization environments here
3974+ for search in ['QEMU Virtual CPU']:
3975+ rc, report = cmd_pipe(['dmesg'], ['grep', search])
3976+ if rc == 0:
3977+ return True
3978+ return False
3979+
3980+
3981+def ubuntu_release():
3982+ '''Get the Ubuntu release'''
3983+ f = "/etc/lsb-release"
3984+ try:
3985+ size = os.stat(f)[ST_SIZE]
3986+ except:
3987+ return "UNKNOWN"
3988+
3989+ if size > 1024 * 1024:
3990+ raise IOError('Could not open "%s" (too big)' % f)
3991+
3992+ with open("/etc/lsb-release", 'r') as fh:
3993+ lines = fh.readlines()
3994+
3995+ pat = re.compile(r'DISTRIB_CODENAME')
3996+ for line in lines:
3997+ if pat.search(line):
3998+ return line.split('=')[1].rstrip('\n').rstrip('\r')
3999+
4000+ return "UNKNOWN"
4001+
4002+
4003+def cmd(command, input=None, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, stdin=None, timeout=None, env=None, shell=False, text=True):
4004+ '''Try to execute given command (array) and return its stdout, or return
4005+ a textual error if it failed.'''
4006+
4007+ try:
4008+ sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, preexec_fn=subprocess_setup, env=env, universal_newlines=text, shell=shell)
4009+ if sys.version_info[0] >= 3 and sys.version_info[1] > 3:
4010+ out, outerr = sp.communicate(input, timeout=timeout)
4011+ else:
4012+ out, outerr = sp.communicate(input)
4013+ except OSError as e:
4014+ return [127, str(e)]
4015+
4016+ # Handle redirection of stdout
4017+ if out is None:
4018+ out = ''
4019+ # Handle redirection of stderr
4020+ if outerr is None:
4021+ outerr = ''
4022+ if text == False:
4023+ out = str(out)
4024+ return [sp.returncode, out + outerr]
4025+
4026+
4027+def cmd_pipe(command1, command2, input=None, stderr=subprocess.STDOUT, stdin=None):
4028+ '''Try to pipe command1 into command2.'''
4029+ try:
4030+ sp1 = subprocess.Popen(command1, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, close_fds=True)
4031+ sp2 = subprocess.Popen(command2, stdin=sp1.stdout, stdout=subprocess.PIPE, stderr=stderr, close_fds=True, universal_newlines=True)
4032+ except OSError as e:
4033+ return [127, str(e)]
4034+
4035+ out = sp2.communicate(input)[0]
4036+ # ensure we don't leak open files and that sp1 is stopped
4037+ sp1.stdout.close()
4038+ sp1.wait()
4039+ return [sp2.returncode, out]
4040+
4041+
4042+def cwd_has_enough_space(cdir, total_bytes):
4043+ '''Determine if the partition of the current working directory has 'bytes'
4044+ free.'''
4045+ rc, df_output = cmd(['df'])
4046+ if rc != 0:
4047+ result = 'df failed, got exit code %d, expected %d\n' % (rc, 0)
4048+ raise OSError(result)
4049+ if rc != 0:
4050+ return False
4051+
4052+ kb = total_bytes / 1024
4053+
4054+ mounts = dict()
4055+ for line in df_output.splitlines():
4056+ if '/' not in line:
4057+ continue
4058+ tmp = line.split()
4059+ mounts[tmp[5]] = int(tmp[3])
4060+
4061+ cdir = os.getcwd()
4062+ while cdir != '/':
4063+ if cdir not in mounts:
4064+ cdir = os.path.dirname(cdir)
4065+ continue
4066+ return kb < mounts[cdir]
4067+
4068+ return kb < mounts['/']
4069+
4070+
4071+def get_md5(filename):
4072+ '''Gets the md5sum of the file specified'''
4073+
4074+ (rc, report) = cmd(["/usr/bin/md5sum", "-b", filename])
4075+ expected = 0
4076+ assert (expected == rc)
4077+
4078+ return report.split(' ')[0]
4079+
4080+
4081+def dpkg_compare_installed_version(pkg, check, version):
4082+ '''Gets the version for the installed package, and compares it to the
4083+ specified version.
4084+ '''
4085+ (rc, report) = cmd(["/usr/bin/dpkg", "-s", pkg])
4086+ assert (rc == 0)
4087+ assert ("Status: install ok installed" in report)
4088+ installed_version = ""
4089+ for line in report.splitlines():
4090+ if line.startswith("Version: "):
4091+ installed_version = line.split()[1]
4092+
4093+ assert (installed_version != "")
4094+
4095+ (rc, report) = cmd(["/usr/bin/dpkg", "--compare-versions", installed_version, check, version])
4096+ assert (rc == 0 or rc == 1)
4097+ if rc == 0:
4098+ return True
4099+ return False
4100+
4101+
4102+def _run_apt_command(pkg_list, apt_cmd='install'):
4103+ env = os.environ.copy()
4104+ env['DEBIAN_FRONTEND'] = 'noninteractive'
4105+ # debugging version, but on precise doesn't actually run dpkg
4106+ # command = ['apt-get', '-y', '--force-yes', '-o', 'Dpkg::Options::=--force-confold', '-o', 'Debug::pkgDPkgPM=true', apt_cmd]
4107+ command = ['apt-get', '-y', '--force-yes', '-o', 'Dpkg::Options::=--force-confold', apt_cmd]
4108+ command.extend(pkg_list)
4109+ rc, report = cmd(command)
4110+ return rc, report
4111+
4112+
4113+# note: for the following install_* functions, you probably want the
4114+# versions in the TestlibCase class (see below)
4115+def install_builddeps(src_pkg):
4116+ rc, report = _run_apt_command([src_pkg], 'build-dep')
4117+ assert(rc == 0)
4118+
4119+
4120+def install_package(package):
4121+ rc, report = _run_apt_command([package], 'install')
4122+ assert(rc == 0)
4123+
4124+
4125+def install_packages(pkg_list):
4126+ rc, report = _run_apt_command(pkg_list, 'install')
4127+ assert(rc == 0)
4128+
4129+
4130+def prepare_source(source, builder, cached_src, build_src, patch_system):
4131+ '''Download and unpack source package, installing necessary build depends,
4132+ adjusting the permissions for the 'builder' user, and returning the
4133+ directory of the unpacked source. Patch system can be one of:
4134+ - cdbs
4135+ - dpatch
4136+ - quilt
4137+ - quiltv3
4138+ - None (not the string)
4139+
4140+ This is normally used like this:
4141+
4142+ def setUp(self):
4143+ ...
4144+ self.topdir = os.getcwd()
4145+ self.cached_src = os.path.join(os.getcwd(), "source")
4146+ self.tmpdir = tempfile.mkdtemp(prefix='testlib', dir='/tmp')
4147+ self.builder = testlib.TestUser()
4148+ testlib.cmd(['chgrp', self.builder.login, self.tmpdir])
4149+ os.chmod(self.tmpdir, 0o775)
4150+
4151+ def tearDown(self):
4152+ ...
4153+ self.builder = None
4154+ self.topdir = os.getcwd()
4155+ if os.path.exists(self.tmpdir):
4156+ testlib.recursive_rm(self.tmpdir)
4157+
4158+ def test_suite_build(self):
4159+ ...
4160+ build_dir = testlib.prepare_source('foo', \
4161+ self.builder, \
4162+ self.cached_src, \
4163+ os.path.join(self.tmpdir, \
4164+ os.path.basename(self.cached_src)),
4165+ "quilt")
4166+ os.chdir(build_dir)
4167+
4168+ # Example for typical build, adjust as necessary
4169+ print("")
4170+ print(" make clean")
4171+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'clean'])
4172+
4173+ print(" configure")
4174+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, './configure', '--prefix=%s' % self.tmpdir, '--enable-debug'])
4175+
4176+ print(" make (will take a while)")
4177+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make'])
4178+
4179+ print(" make check (will take a while)",)
4180+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'check'])
4181+ expected = 0
4182+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
4183+ self.assertEqual(expected, rc, result + report)
4184+
4185+ def test_suite_cleanup(self):
4186+ ...
4187+ if os.path.exists(self.cached_src):
4188+ testlib.recursive_rm(self.cached_src)
4189+
4190+ It is up to the caller to clean up cached_src and build_src (as in the
4191+ above example, often the build_src is in a tmpdir that is cleaned in
4192+ tearDown() and the cached_src is cleaned in a one time clean-up
4193+ operation (eg 'test_suite_cleanup()) which must be run after the build
4194+ suite test (obviously).
4195+ '''
4196+
4197+ # Make sure we have a clean slate
4198+ assert (os.path.exists(os.path.dirname(build_src)))
4199+ assert (not os.path.exists(build_src))
4200+
4201+ cdir = os.getcwd()
4202+ if os.path.exists(cached_src):
4203+ shutil.copytree(cached_src, build_src)
4204+ os.chdir(build_src)
4205+ else:
4206+ # Only install the build dependencies on the initial setup
4207+ install_builddeps(source)
4208+ os.makedirs(build_src)
4209+ os.chdir(build_src)
4210+
4211+ # These are always needed
4212+ pkgs = ['build-essential', 'dpkg-dev', 'fakeroot']
4213+ install_packages(pkgs)
4214+
4215+ rc, report = cmd(['apt-get', 'source', source])
4216+ assert (rc == 0)
4217+ shutil.copytree(build_src, cached_src)
4218+ print("(unpacked %s)" % os.path.basename(glob.glob('%s_*.dsc' % source)[0]), end=' ')
4219+
4220+ unpacked_dir = os.path.join(build_src, glob.glob('%s-*' % source)[0])
4221+
4222+ # Now apply the patches. Do it here so that we don't mess up our cached
4223+ # sources.
4224+ os.chdir(unpacked_dir)
4225+ assert (patch_system in ['cdbs', 'dpatch', 'quilt', 'quiltv3', None])
4226+ if patch_system is not None and patch_system != "quiltv3":
4227+ if patch_system == "quilt":
4228+ os.environ.setdefault('QUILT_PATCHES', 'debian/patches')
4229+ rc, report = cmd(['quilt', 'push', '-a'])
4230+ assert (rc == 0)
4231+ elif patch_system == "cdbs":
4232+ rc, report = cmd(['./debian/rules', 'apply-patches'])
4233+ assert (rc == 0)
4234+ elif patch_system == "dpatch":
4235+ rc, report = cmd(['dpatch', 'apply-all'])
4236+ assert (rc == 0)
4237+
4238+ cmd(['chown', '-R', '%s:%s' % (builder.uid, builder.gid), build_src])
4239+ os.chdir(cdir)
4240+
4241+ return unpacked_dir
4242+
4243+
4244+def get_changelog_version(source_dir):
4245+ '''Extract a package version from a changelog'''
4246+ package_version = ""
4247+
4248+ changelog_file = os.path.join(source_dir, "debian/changelog")
4249+
4250+ if os.path.exists(changelog_file):
4251+ changelog = open(changelog_file, 'r')
4252+ header = changelog.readline().split()
4253+ package_version = header[1].strip('()')
4254+
4255+ return package_version
4256+
4257+
4258+def _aa_status():
4259+ '''Get aa-status output'''
4260+ exe = "/usr/sbin/aa-status"
4261+ assert (os.path.exists(exe))
4262+ if os.geteuid() == 0:
4263+ return cmd([exe])
4264+ return cmd(['sudo', exe])
4265+
4266+
4267+def is_apparmor_loaded(path):
4268+ '''Check if profile is loaded'''
4269+ rc, report = _aa_status()
4270+ if rc != 0:
4271+ return False
4272+
4273+ for line in report.splitlines():
4274+ if line.endswith(path):
4275+ return True
4276+ return False
4277+
4278+
4279+def is_apparmor_confined(path):
4280+ '''Check if application is confined'''
4281+ rc, report = _aa_status()
4282+ if rc != 0:
4283+ return False
4284+
4285+ for line in report.splitlines():
4286+ if re.search('%s \(' % path, line):
4287+ return True
4288+ return False
4289+
4290+
4291+def check_apparmor(path, first_ubuntu_release, is_running=True):
4292+ '''Check if path is loaded and confined for everything higher than the
4293+ first Ubuntu release specified.
4294+
4295+ Usage:
4296+ rc, report = testlib.check_apparmor('/usr/sbin/foo', 8.04, is_running=True)
4297+ if rc < 0:
4298+ return self._skipped(report)
4299+
4300+ expected = 0
4301+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
4302+ self.assertEqual(expected, rc, result + report)
4303+ '''
4304+ global manager
4305+ rc = -1
4306+
4307+ if manager.lsb_release["Release"] < first_ubuntu_release:
4308+ return (rc, "Skipped apparmor check")
4309+
4310+ if not os.path.exists('/sbin/apparmor_parser'):
4311+ return (rc, "Skipped (couldn't find apparmor_parser)")
4312+
4313+ rc = 0
4314+ msg = ""
4315+ if not is_apparmor_loaded(path):
4316+ rc = 1
4317+ msg = "Profile not loaded for '%s'" % path
4318+
4319+ # this check only makes sense it the 'path' is currently executing
4320+ if is_running and rc == 0 and not is_apparmor_confined(path):
4321+ rc = 1
4322+ msg = "'%s' is not running in enforce mode" % path
4323+
4324+ return (rc, msg)
4325+
4326+
4327+def get_gcc_version(gcc, full=True):
4328+ gcc_version = 'none'
4329+ if not gcc.startswith('/'):
4330+ gcc = '/usr/bin/%s' % (gcc)
4331+ if os.path.exists(gcc):
4332+ gcc_version = 'unknown'
4333+ lines = cmd([gcc, '-v'])[1].strip().splitlines()
4334+ version_lines = [x for x in lines if x.startswith('gcc version')]
4335+ if len(version_lines) == 1:
4336+ gcc_version = " ".join(version_lines[0].split()[2:])
4337+ if not full:
4338+ return gcc_version.split()[0]
4339+ return gcc_version
4340+
4341+
4342+def is_kdeinit_running():
4343+ '''Test if kdeinit is running'''
4344+ # applications that use kdeinit will spawn it if it isn't running in the
4345+ # test. This is a problem because it does not exit. This is a helper to
4346+ # check for it.
4347+ rc, report = cmd(['ps', 'x'])
4348+ if 'kdeinit4 Running' not in report:
4349+ print("kdeinit not running (you may start/stop any KDE application then run this script again)", file=sys.stderr)
4350+ return False
4351+ return True
4352+
4353+
4354+def get_pkgconfig_flags(libs=[]):
4355+ '''Find pkg-config flags for libraries'''
4356+ assert (len(libs) > 0)
4357+ rc, pkg_config = cmd(['pkg-config', '--cflags', '--libs'] + libs)
4358+ expected = 0
4359+ if rc != expected:
4360+ print('Got exit code %d, expected %d\n' % (rc, expected), file=sys.stderr)
4361+ assert(rc == expected)
4362+ return pkg_config.split()
4363+
4364+
4365+def cap_to_name(cap_num):
4366+ '''given an integer, return the capability name'''
4367+ rc, output = cmd(['capsh', '--decode=%x' % cap_num])
4368+ expected = 0
4369+ if rc != expected:
4370+ print('capsh: got exit code %d, expected %d\n' % (rc, expected), file=sys.stderr)
4371+ cap_name = output.strip().split('=')[1]
4372+ return cap_name
4373+
4374+
4375+def enumerate_capabilities():
4376+ i = 0
4377+ cap_list = []
4378+ done = False
4379+ while not done:
4380+ cap_name = cap_to_name(pow(2, i))
4381+ if cap_name == str(i):
4382+ done = True
4383+ else:
4384+ cap_list.append(cap_name)
4385+ i += 1
4386+ if i > 64:
4387+ done = True
4388+ return cap_list
4389+
4390+
4391+def _run_snap_install(snapname, track="latest/stable", classic=False):
4392+ # crude, but effective
4393+ if os.path.exists(os.path.join("/snap", snapname)):
4394+ return 0, ""
4395+
4396+ command = ["snap", "install", "--channel=%s" % track, snapname]
4397+ if classic:
4398+ command.append("--classic")
4399+ rc, report = cmd(command)
4400+ return rc, report
4401+
4402+
4403+def _run_snap_remove(snapname):
4404+ # crude, but effective
4405+ if not os.path.exists(os.path.join("/snap", snapname)):
4406+ return 0, ""
4407+
4408+ command = ["snap", "remove", "--purge", snapname]
4409+ rc, report = cmd(command)
4410+ return rc, report
4411+
4412+
4413+def install_snap(self, snapname, track="latest/stable", classic=False):
4414+ rc, report = _run_snap_install(snapname, track, classic)
4415+ self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
4416+ (snapname, report))
4417+
4418+
4419+def remove_snap(self, snapname):
4420+ rc, report = _run_snap_remove(snapname)
4421+ self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
4422+ (snapname, report))
4423+
4424+
4425+class TestDaemon:
4426+ '''Helper class to manage daemons consistently'''
4427+ def __init__(self, service_name):
4428+ '''Setup daemon attributes'''
4429+ if os.path.isfile('/usr/sbin/service') or os.path.islink('/usr/sbin/service'):
4430+ self.test_daemon_commands = ['service', service_name]
4431+ else:
4432+ self.test_daemon_commands = ['/etc/init.d/' + service_name]
4433+
4434+ def _run_command(self, action, seconds_to_wait=2):
4435+ command = list(self.test_daemon_commands)
4436+ command.append(action)
4437+ rc, report = cmd(command)
4438+ expected = 0
4439+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
4440+ time.sleep(seconds_to_wait)
4441+ if expected != rc:
4442+ return False, result + report
4443+
4444+ if "fail" in report:
4445+ return False, "Found 'fail' in report\n" + report
4446+
4447+ return True, ""
4448+
4449+ def start(self):
4450+ '''Start daemon'''
4451+ return self._run_command('start')
4452+
4453+ def stop(self):
4454+ '''Stop daemon'''
4455+ return self._run_command('stop')
4456+
4457+ def reload(self):
4458+ '''Reload daemon'''
4459+ return self._run_command('force-reload')
4460+
4461+ def restart(self):
4462+ if self.test_daemon_commands[0] == 'service':
4463+ return self._run_command('restart')
4464+ else:
4465+ '''Restart daemon'''
4466+ (res, str) = self.stop()
4467+ if not res:
4468+ return res, str
4469+
4470+ (res, str) = self.start()
4471+ if not res:
4472+ return res, str
4473+
4474+ return True, ""
4475+
4476+ def force_restart(self):
4477+ '''Restart daemon even if already stopped'''
4478+ self.stop()
4479+
4480+ (res, str) = self.start()
4481+ if not res:
4482+ return res, str
4483+
4484+ return True, ""
4485+
4486+ def status(self):
4487+ '''Check daemon status'''
4488+ return self._run_command('status')
4489+
4490+
4491+class TestlibManager(object):
4492+ '''Singleton class used to set up per-test-run information'''
4493+ def __init__(self):
4494+ # Set glibc aborts to dump to stderr instead of the tty so test output
4495+ # is more sane.
4496+ os.environ.setdefault('LIBC_FATAL_STDERR_', '1')
4497+
4498+ # check verbosity
4499+ self.verbosity = False
4500+ if (len(sys.argv) > 1 and '-v' in sys.argv[1:]):
4501+ self.verbosity = True
4502+
4503+ # Load LSB release file
4504+ self.lsb_release = dict()
4505+ if not os.path.exists('/usr/bin/lsb_release') and not os.path.exists('/bin/lsb_release'):
4506+ raise OSError("Please install 'lsb-release'")
4507+ for line in subprocess.Popen(['lsb_release', '-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate()[0].splitlines():
4508+ field, value = line.split(':', 1)
4509+ value = value.strip()
4510+ field = field.strip()
4511+ # Convert numerics
4512+ try:
4513+ value = float(value)
4514+ except:
4515+ pass
4516+ self.lsb_release.setdefault(field, value)
4517+
4518+ # FIXME: hack OEM releases into known-Ubuntu versions
4519+ if self.lsb_release['Distributor ID'] == "HP MIE (Mobile Internet Experience)":
4520+ if self.lsb_release['Release'] == 1.0:
4521+ self.lsb_release['Distributor ID'] = "Ubuntu"
4522+ self.lsb_release['Release'] = 8.04
4523+ else:
4524+ raise OSError("Unknown version of HP MIE")
4525+
4526+ # FIXME: hack to assume a most-recent release if we're not
4527+ # running under Ubuntu.
4528+ if self.lsb_release['Distributor ID'] not in ["Ubuntu", "Linaro"]:
4529+ self.lsb_release['Release'] = 10000
4530+ # Adjust Linaro release to pretend to be Ubuntu
4531+ if self.lsb_release['Distributor ID'] in ["Linaro"]:
4532+ self.lsb_release['Distributor ID'] = "Ubuntu"
4533+ self.lsb_release['Release'] -= 0.01
4534+
4535+ # Load arch
4536+ if not os.path.exists('/usr/bin/dpkg'):
4537+ machine = cmd(['uname', '-m'])[1].strip()
4538+ if machine.endswith('86'):
4539+ self.dpkg_arch = 'i386'
4540+ elif machine.endswith('_64'):
4541+ self.dpkg_arch = 'amd64'
4542+ elif machine.startswith('arm'):
4543+ self.dpkg_arch = 'armel'
4544+ else:
4545+ raise ValueError("Unknown machine type '%s'" % (machine))
4546+ else:
4547+ self.dpkg_arch = cmd(['dpkg', '--print-architecture'])[1].strip()
4548+
4549+ # Find kernel version
4550+ self.kernel_is_ubuntu = False
4551+ self.kernel_version_signature = None
4552+ self.kernel_version = cmd(["uname", "-r"])[1].strip()
4553+ versig = '/proc/version_signature'
4554+ if os.path.exists(versig):
4555+ self.kernel_is_ubuntu = True
4556+ self.kernel_version_signature = open(versig).read().strip()
4557+ self.kernel_version_ubuntu = self.kernel_version
4558+ elif os.path.exists('/usr/bin/dpkg'):
4559+ # this can easily be inaccurate but is only an issue for Dapper
4560+ rc, out = cmd(['dpkg', '-l', 'linux-image-%s' % (self.kernel_version)])
4561+ if rc == 0:
4562+ self.kernel_version_signature = out.strip().split('\n').pop().split()[2]
4563+ self.kernel_version_ubuntu = self.kernel_version_signature
4564+ if self.kernel_version_signature is None:
4565+ # Attempt to fall back to something for non-Debian-based
4566+ self.kernel_version_signature = self.kernel_version
4567+ self.kernel_version_ubuntu = self.kernel_version
4568+ # Build ubuntu version without hardware suffix
4569+ try:
4570+ self.kernel_version_ubuntu = "-".join([x for x in self.kernel_version_signature.split(' ')[1].split('-') if re.search('^[0-9]', x)])
4571+ except:
4572+ pass
4573+
4574+ # Find gcc version
4575+ self.gcc_version = get_gcc_version('gcc')
4576+
4577+ # Find libc
4578+ self.path_libc = [x.split()[2] for x in cmd(['ldd', '/bin/ls'])[1].splitlines() if x.startswith('\tlibc.so.')][0]
4579+
4580+ # Report self
4581+ if self.verbosity:
4582+ kernel = self.kernel_version_ubuntu
4583+ if kernel != self.kernel_version_signature:
4584+ kernel += " (%s)" % (self.kernel_version_signature)
4585+ print("Running test: '%s' distro: '%s %.2f' kernel: '%s' arch: '%s' uid: %d/%d SUDO_USER: '%s')" % (
4586+ sys.argv[0],
4587+ self.lsb_release['Distributor ID'],
4588+ self.lsb_release['Release'],
4589+ kernel,
4590+ self.dpkg_arch,
4591+ os.geteuid(), os.getuid(),
4592+ os.environ.get('SUDO_USER', '')), file=sys.stdout)
4593+ sys.stdout.flush()
4594+
4595+ # Additional heuristics
4596+ # if os.environ.get('SUDO_USER', os.environ.get('USER', '')) in ['mdeslaur']:
4597+ # sys.stdout.write("Replying to Marc Deslauriers in http://launchpad.net/bugs/%d: " % random.randint(600000, 980000))
4598+ # sys.stdout.flush()
4599+ # time.sleep(0.5)
4600+ # sys.stdout.write("destroyed\n")
4601+ # time.sleep(0.5)
4602+
4603+ def hello(self, msg):
4604+ print("Hello from %s" % (msg), file=sys.stderr)
4605+# The central instance
4606+manager = TestlibManager()
4607+
4608+
4609+class TestlibCase(unittest.TestCase):
4610+ def __init__(self, *args):
4611+ '''This is called for each TestCase test instance, which isn't much better
4612+ than SetUp.'''
4613+
4614+ unittest.TestCase.__init__(self, *args)
4615+
4616+ # Attach to and duplicate dicts from manager singleton
4617+ self.manager = manager
4618+ # self.manager.hello(repr(self) + repr(*args))
4619+ self.my_verbosity = self.manager.verbosity
4620+ self.lsb_release = self.manager.lsb_release
4621+ self.dpkg_arch = self.manager.dpkg_arch
4622+ self.kernel_version = self.manager.kernel_version
4623+ self.kernel_version_signature = self.manager.kernel_version_signature
4624+ self.kernel_version_ubuntu = self.manager.kernel_version_ubuntu
4625+ self.kernel_is_ubuntu = self.manager.kernel_is_ubuntu
4626+ self.gcc_version = self.manager.gcc_version
4627+ self.path_libc = self.manager.path_libc
4628+
4629+ def version_compare(self, one, two):
4630+ if 'version_compare' in dir(apt_pkg):
4631+ return apt_pkg.version_compare(one, two)
4632+ else:
4633+ return apt_pkg.VersionCompare(one, two)
4634+
4635+ def assertFileType(self, filename, filetype, strict=True):
4636+ '''Checks the file type of the file specified'''
4637+
4638+ (rc, report, out) = self._testlib_shell_cmd(["/usr/bin/file", "-b", filename])
4639+ out = out.strip()
4640+ expected = 0
4641+ # Absolutely no idea why this happens on Hardy
4642+ if self.lsb_release['Release'] == 8.04 and rc == 255 and len(out) > 0:
4643+ rc = 0
4644+ result = 'Got exit code %d, expected %d:\n%s\n' % (rc, expected, report)
4645+ self.assertEqual(expected, rc, result)
4646+
4647+ if strict:
4648+ filetype = '^%s$' % (filetype)
4649+ else:
4650+ # accept if the beginning of the line matches
4651+ filetype = '^%s' % (filetype)
4652+ result = 'File type reported by file: [%s], expected regex: [%s]\n' % (out, filetype)
4653+ self.assertNotEqual(None, re.search(filetype, out), result)
4654+
4655+ def yank_commonname_from_cert(self, certfile):
4656+ '''Extract the commonName from a given PEM'''
4657+ rc, out = cmd(['openssl', 'asn1parse', '-in', certfile])
4658+ if rc == 0:
4659+ ready = False
4660+ for line in out.splitlines():
4661+ if ready:
4662+ return line.split(':')[-1]
4663+ if ':commonName' in line:
4664+ ready = True
4665+ return socket.getfqdn()
4666+
4667+ def announce(self, text):
4668+ if self.my_verbosity:
4669+ print("(%s) " % (text), file=sys.stderr, end='')
4670+ sys.stdout.flush()
4671+
4672+ def make_clean(self):
4673+ rc, output = self.shell_cmd(['make', 'clean'])
4674+ self.assertEqual(rc, 0, output)
4675+
4676+ def get_makefile_compiler(self):
4677+ # Find potential compiler name
4678+ compiler = 'gcc'
4679+ if os.path.exists('Makefile'):
4680+ for line in open('Makefile'):
4681+ if line.startswith('CC') and '=' in line:
4682+ items = [x.strip() for x in line.split('=')]
4683+ if items[0] == 'CC':
4684+ compiler = items[1]
4685+ break
4686+ return compiler
4687+
4688+ def make_target(self, target, expected=0):
4689+ '''Compile a target and report output'''
4690+
4691+ compiler = self.get_makefile_compiler()
4692+ rc, output = self.shell_cmd(['make', target])
4693+ self.assertEqual(rc, expected, 'rc(%d)!=%d:\n' % (rc, expected) + output)
4694+ self.assertTrue('%s ' % (compiler) in output, 'Expected "%s":' % (compiler) + output)
4695+ return output
4696+
4697+ # call as return testlib.skipped()
4698+ def _skipped(self, reason=""):
4699+ '''Provide a visible way to indicate that a test was skipped'''
4700+ if reason != "":
4701+ reason = ': %s' % (reason)
4702+ self.announce("skipped%s" % (reason))
4703+ return False
4704+
4705+ def _testlib_shell_cmd(self, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=None):
4706+ argstr = "'" + "', '".join(args).strip() + "'"
4707+ rc, out = cmd(args, stdin=stdin, stdout=stdout, stderr=stderr, env=env)
4708+ report = 'Command: ' + argstr + '\nOutput:\n' + out
4709+ return rc, report, out
4710+
4711+ def shell_cmd(self, args, stdin=None):
4712+ return cmd(args, stdin=stdin)
4713+
4714+ def assertShellExitEquals(self, expected, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=None, msg="", bare_report=False):
4715+ '''Test a shell command matches a specific exit code'''
4716+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr, env=env)
4717+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
4718+ self.assertEqual(expected, rc, msg + result + report)
4719+ if bare_report:
4720+ return out
4721+ else:
4722+ return report
4723+
4724+ def assertShellExitSuccess(self, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=None, msg="", bare_report=False):
4725+ '''Same as assertShellEquals but with an expected exit status of 0 (success).'''
4726+ return self.assertShellExitEquals(0, args, stdin, stdout, stderr, env, msg, bare_report)
4727+
4728+ # make sure exit value is in a list of expected values
4729+ def assertShellExitIn(self, expected, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""):
4730+ '''Test a shell command matches a specific exit code'''
4731+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
4732+ result = 'Got exit code %d, expected one of %s\n' % (rc, ', '.join(map(str, expected)))
4733+ self.assertIn(rc, expected, msg + result + report)
4734+
4735+ def assertShellExitNotEquals(self, unwanted, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""):
4736+ '''Test a shell command doesn't match a specific exit code'''
4737+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
4738+ result = 'Got (unwanted) exit code %d\n' % rc
4739+ self.assertNotEqual(unwanted, rc, msg + result + report)
4740+
4741+ def assertShellOutputContains(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False, expected=None):
4742+ '''Test a shell command contains a specific output'''
4743+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
4744+ result = 'Got exit code %d. Looking for text "%s"\n' % (rc, text)
4745+ if not invert:
4746+ self.assertTrue(text in out, msg + result + report)
4747+ else:
4748+ self.assertFalse(text in out, msg + result + report)
4749+ if expected is not None:
4750+ result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args))
4751+ self.assertEqual(rc, expected, msg + result + report)
4752+
4753+ def assertShellOutputEquals(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False, expected=None):
4754+ '''Test a shell command matches a specific output'''
4755+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
4756+ result = 'Got exit code %d. Looking for exact text "%s" (%s)\n' % (rc, text, " ".join(args))
4757+ if not invert:
4758+ self.assertEqual(text, out, msg + result + report)
4759+ else:
4760+ self.assertNotEqual(text, out, msg + result + report)
4761+ if expected is not None:
4762+ result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args))
4763+ self.assertEqual(rc, expected, msg + result + report)
4764+
4765+ def _word_find(self, report, content, invert=False):
4766+ '''Check for a specific string'''
4767+ if invert:
4768+ warning = 'Found "%s"\n' % content
4769+ self.assertTrue(content not in report, warning + report)
4770+ else:
4771+ warning = 'Could not find "%s"\n' % content
4772+ self.assertTrue(content in report, warning + report)
4773+
4774+ def _test_sysctl_value(self, path, expected, msg=None, exists=True):
4775+ sysctl = '/proc/sys/%s' % (path)
4776+ self.assertEqual(exists, os.path.exists(sysctl), sysctl)
4777+ value = None
4778+ if exists:
4779+ with open(sysctl) as sysctl_fd:
4780+ value = int(sysctl_fd.read())
4781+ report = "%s is not %d: %d" % (sysctl, expected, value)
4782+ if msg:
4783+ report += " (%s)" % (msg)
4784+ self.assertEqual(value, expected, report)
4785+ return value
4786+
4787+ def set_sysctl_value(self, path, desired):
4788+ sysctl = '/proc/sys/%s' % (path)
4789+ self.assertTrue(os.path.exists(sysctl), "%s does not exist" % (sysctl))
4790+ with open(sysctl, 'w') as sysctl_fh:
4791+ sysctl_fh.write(str(desired))
4792+ self._test_sysctl_value(path, desired)
4793+
4794+ def kernel_at_least(self, introduced):
4795+ return self.version_compare(self.kernel_version_ubuntu,
4796+ introduced) >= 0
4797+
4798+ def kernel_claims_cve_fixed(self, cve):
4799+ changelog = "/usr/share/doc/linux-image-%s/changelog.Debian.gz" % (self.kernel_version)
4800+ if os.path.exists(changelog):
4801+ for line in gzip.open(changelog):
4802+ if cve in line and "revert" not in line and "Revert" not in line:
4803+ return True
4804+ return False
4805+
4806+ def install_builddeps(self, src_pkg):
4807+ rc, report = _run_apt_command([src_pkg], 'build-dep')
4808+ self.assertEqual(0, rc, 'Failed to install build-deps for %s\nOutput:\n%s' % (src_pkg, report))
4809+
4810+ def install_package(self, package):
4811+ rc, report = _run_apt_command([package], 'install')
4812+ self.assertEqual(0, rc, 'Failed to install package %s\nOutput:\n%s' % (package, report))
4813+
4814+ def install_packages(self, pkg_list):
4815+ rc, report = _run_apt_command(pkg_list, 'install')
4816+ self.assertEqual(0, rc, 'Failed to install packages %s\nOutput:\n%s' % (','.join(pkg_list), report))
4817+
4818+ def install_snap(self, snapname, track="latest/stable", classic=False):
4819+ rc, report = _run_snap_install(snapname, track, classic)
4820+ self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
4821+ (snapname, report))
4822+
4823+ def remove_snap(self, snapname):
4824+ rc, report = _run_snap_remove(snapname)
4825+ self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
4826+ (snapname, report))
4827+
4828+
4829+class TestGroup:
4830+ '''Create a temporary test group and remove it again in the dtor.'''
4831+
4832+ def __init__(self, group=None, lower=False):
4833+ '''Create a new group'''
4834+
4835+ self.group = None
4836+ if group:
4837+ if group_exists(group):
4838+ raise ValueError('group name already exists')
4839+ else:
4840+ while(True):
4841+ group = random_string(7, lower=lower)
4842+ if not group_exists(group):
4843+ break
4844+
4845+ assert subprocess.call(['groupadd', group]) == 0
4846+ self.group = group
4847+ g = grp.getgrnam(self.group)
4848+ self.gid = g[2]
4849+
4850+ def __del__(self):
4851+ '''Remove the created group.'''
4852+
4853+ if self.group:
4854+ rc, report = cmd(['groupdel', self.group])
4855+ assert rc == 0
4856+
4857+
4858+class TestUser:
4859+ '''Create a temporary test user and remove it again in the dtor.'''
4860+
4861+ def __init__(self, login=None, home=True, group=None, uidmin=None, lower=False, shell=None):
4862+ '''Create a new user account with a random password.
4863+
4864+ By default, the login name is random, too, but can be explicitly
4865+ specified with 'login'. By default, a home directory is created, this
4866+ can be suppressed with 'home=False'.'''
4867+
4868+ self.login = None
4869+
4870+ if os.geteuid() != 0:
4871+ raise ValueError("You must be root to run this test")
4872+
4873+ if login:
4874+ if login_exists(login):
4875+ raise ValueError('login name already exists')
4876+ else:
4877+ while(True):
4878+ login = 't' + random_string(7, lower=lower)
4879+ if not login_exists(login):
4880+ break
4881+
4882+ # when fips is enabled, python2.7 crypt.crypt() returns None
4883+ # for DES salts for being too weak. Force sha256 with "$5$" for
4884+ # the salt. XXX in python3, the salt is optional and will
4885+ # generate strong passwords automatically.
4886+ self.salt = "$5$%s" % random_string(2)
4887+ self.password = random_string(8, lower=lower)
4888+ self.crypted = crypt.crypt(self.password, self.salt)
4889+
4890+ creation = ['useradd', '-p', self.crypted]
4891+ if home:
4892+ creation += ['-m']
4893+ if group:
4894+ creation += ['-G', group]
4895+ if uidmin:
4896+ creation += ['-K', 'UID_MIN=%d' % uidmin]
4897+ if shell:
4898+ creation += ['-s', shell]
4899+ creation += [login]
4900+ assert subprocess.call(creation) == 0
4901+ # Set GECOS
4902+ assert subprocess.call(['usermod', '-c', 'Buddy %s' % (login), login]) == 0
4903+
4904+ self.login = login
4905+ p = pwd.getpwnam(self.login)
4906+ self.uid = p[2]
4907+ self.gid = p[3]
4908+ self.gecos = p[4]
4909+ self.home = p[5]
4910+ self.shell = p[6]
4911+
4912+ def __del__(self):
4913+ '''Remove the created user account.'''
4914+
4915+ if self.login:
4916+ # sanity check the login name so we don't accidentally wipe too much
4917+ if len(self.login) > 3 and '/' not in self.login:
4918+ subprocess.call(['rm', '-rf', '/home/' + self.login, '/var/mail/' + self.login])
4919+ rc, report = cmd(['userdel', '-f', self.login])
4920+ assert rc == 0
4921+
4922+ def add_to_group(self, group):
4923+ '''Add user to the specified group name'''
4924+ rc, report = cmd(['usermod', '-G', group, self.login])
4925+ if rc != 0:
4926+ print(report)
4927+ assert rc == 0
4928+
4929+
4930+class AddUser:
4931+ '''Create a temporary test user and remove it again in the dtor.'''
4932+
4933+ def __init__(self, login=None, home=True, encrypt_home=False, group=None, lower=False, shell=None):
4934+ '''Create a new user account with a random password.
4935+
4936+ By default, the login name is random, too, but can be explicitly
4937+ specified with 'login'. By default, a home directory is created, this
4938+ can be suppressed with 'home=False'.
4939+
4940+ This class differs from the TestUser class in that the adduser/deluser
4941+ tools are used rather than the useradd/user/del tools. The adduser
4942+ program is the only commandline program that can be used to add a new
4943+ user with an encrypted home directory. It is possible that the AddUser
4944+ class may replace the TestUser class in the future.'''
4945+
4946+ self.login = None
4947+
4948+ if os.geteuid() != 0:
4949+ raise ValueError("You must be root to run this test")
4950+
4951+ if login:
4952+ if login_exists(login):
4953+ raise ValueError('login name already exists')
4954+ else:
4955+ while(True):
4956+ login = 't' + random_string(7, lower=True)
4957+ if not login_exists(login):
4958+ break
4959+
4960+ self.password = random_string(8, lower=lower)
4961+
4962+ creation = ['adduser', '--quiet']
4963+
4964+ if not home:
4965+ creation += ['--no-create-home']
4966+ elif encrypt_home:
4967+ creation += ['--encrypt-home']
4968+
4969+ if shell:
4970+ creation += ['--shell', shell]
4971+
4972+ creation += ['--gecos', 'Buddy %s' % (login), login]
4973+
4974+ child = pexpect.spawn(creation.pop(0), creation, timeout=5)
4975+ assert child.expect(b'(Enter new UNIX|New) password:') == 0
4976+ child.sendline(self.password)
4977+ assert child.expect(b'Retype new (UNIX )?password:') == 0
4978+ child.sendline(self.password)
4979+
4980+ child.wait()
4981+ child.close()
4982+ assert child.exitstatus == 0
4983+ assert child.signalstatus is None
4984+
4985+ self.login = login
4986+
4987+ if group:
4988+ assert self.add_to_group(group) == 0
4989+
4990+ p = pwd.getpwnam(self.login)
4991+ self.uid = p[2]
4992+ self.gid = p[3]
4993+ self.gecos = p[4]
4994+ self.home = p[5]
4995+ self.shell = p[6]
4996+
4997+ def __del__(self):
4998+ '''Remove the created user account.'''
4999+
5000+ if self.login:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches