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
diff --git a/Changelog b/Changelog
index 78ed73e..bf18ec7 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,42 @@
1open-iscsi-2.1.3 - open-iscsi-2.1.4
2
3Abhinav Rajagopalan (1):
4 Fix typo in util.py
5
6Chris Leech (3):
7 libopeniscsiusr: fix error messages
8 libopeniscsiusr: skip over removed sessions
9 libopeniscsiusr: dont error loudly if a session isn't found when working through iscsi_sessions_get()
10
11Fabian Möller (1):
12 iscsid: Add NO_SYSTEMD to CFLAGS
13
14Helmut Grohne (1):
15 Avoid hardcoding pkg-config to fix cross build
16
17John Schaeffer (1):
18 Add etc/systemd/iscsi-init.service to SYSTEMDFILES Makefile variable
19
20Lee Duncan (4):
21 iscsid: Do not allow conflicting pid-file options
22 Fix iscsiadm segfault when exiting
23 Fix iscsistart login issue when target is delayed.
24 Enable iscsi.service asynchronous logins, cleanup services
25
26Matwey V. Kornilov (1):
27 Wants=network-online.target in iscsi.service
28
29Patrick Lawrence (1):
30 Change mkdir permissions to 0770, adjust usmask
31
32Wenchao Hao (4):
33 idbm: Fix memory leak and NULL pointer dereference in idbm_rec_update_param()
34 libopeniscsiusr: Fix memory leak in iscsi_nodes_get()
35 libopeniscsiusr: Fix memory leak in iscsi_sessions_get()
36 iscsiadm: Fix memory leak in iscsiadm
37
38---------------------------------------------------------------------------
39
1open-iscsi-2.1.2 - open-iscsi-2.1.340open-iscsi-2.1.2 - open-iscsi-2.1.3
241
3Chris Leech (4):42Chris Leech (4):
diff --git a/Makefile b/Makefile
index 7b445a5..7f52cc8 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,7 @@ ETCFILES = etc/iscsid.conf
28IFACEFILES = etc/iface.example28IFACEFILES = etc/iface.example
29RULESFILES = utils/50-iscsi-firmware-login.rules29RULESFILES = utils/50-iscsi-firmware-login.rules
30SYSTEMDFILES = etc/systemd/iscsi.service \30SYSTEMDFILES = etc/systemd/iscsi.service \
31 etc/systemd/iscsi-init.service \
31 etc/systemd/iscsid.service etc/systemd/iscsid.socket \32 etc/systemd/iscsid.service etc/systemd/iscsid.socket \
32 etc/systemd/iscsiuio.service etc/systemd/iscsiuio.socket33 etc/systemd/iscsiuio.service etc/systemd/iscsiuio.socket
3334
diff --git a/debian/README.Debian b/debian/README.Debian
index f0c2568..43c7c81 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -57,7 +57,7 @@ iSCSI Qualified Names (IQN) and initiatorname.iscsi
57The initiatorname.iscsi file defines the iSCSI Qualified Name (IQN) of the iSCSI 57The initiatorname.iscsi file defines the iSCSI Qualified Name (IQN) of the iSCSI
58initiator. This IQN is used by the initiator to identify itself to the target.58initiator. This IQN is used by the initiator to identify itself to the target.
5959
60Example: InitiatorName=iqn.1993-08.org.debian:01:lnx-debian60Example: InitiatorName=iqn.2004-10.com.ubuntu:01:lnx-debian
6161
62While this name can be adjusted to suit your needs, once set, it should not be 62While this name can be adjusted to suit your needs, once set, it should not be
63changed. If you later change the InitiatorName, existing access control lists 63changed. If you later change the InitiatorName, existing access control lists
@@ -100,7 +100,7 @@ options in your initramfs:
100100
101 Example Syntax:101 Example Syntax:
102102
103 ISCSI_INITIATOR="iqn.1993-08.org.debian:01:9b3e5634fdb9"103 ISCSI_INITIATOR="iqn.2004-10.com.ubuntu:01:9b3e5634fdb9"
104 ISCSI_TARGET_NAME=iqn.2008-01.com.example:storage.foo104 ISCSI_TARGET_NAME=iqn.2008-01.com.example:storage.foo
105 ISCSI_TARGET_IP=192.168.1.1105 ISCSI_TARGET_IP=192.168.1.1
106 ISCSI_TARGET_PORT=3260106 ISCSI_TARGET_PORT=3260
diff --git a/debian/changelog b/debian/changelog
index dd0ef0d..021748a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,76 @@
1open-iscsi (2.1.4-0ubuntu1) impish; urgency=medium
2
3 * Merge with Debian unstable (LP: #1934290). Remaining changes:
4 - debian/tests: Add Ubuntu autopkgtest suite:
5 + d/t/README-boot-test.md: document test design
6 + d/t/control: register testsuite
7 + d/t/get-image: helper to fetch an ubuntu cloud image
8 + d/t/patch-image: helper to modify an ubuntu cloud image
9 + d/test-open-iscsi.py, d/t/testlib.py: various qa regression tests
10 + d/t/testsuite: helper to invoke qa regression tests
11 + d/t/tgt-boot-test: test using tgt to boot from iscsi
12 + d/t/xkvm: helper to spawn a VM
13 Note: this suite should be replaced by LIO that replaced TGT in main.
14 - d/iscsid.service: Let iscsid systemd job run in privileged containers
15 but not in unprivileged ones
16 - debian/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
17 run ipconfig to gather all DHCP config info, including DNS search
18 domain, which iBFT can't provide.
19 - Remove initramfs interfaces stamp in case no iscsi devs mounted
20 If iscsi root was requested, but no iscsi devices were mounted, remove
21 the initramfs interfaces stamp file. Meaning, that on shutdown there is
22 no 30s delay, whilst trying to re-establish iscsi login to perform a
23 logout.
24 - add IPv6 support
25 + Source /run/net6-*.conf when needed.
26 + debian/extra/initramfs.local-top: handle IPv6 configs being shipped
27 in DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
28 /run/initramfs/open-iscsi.interface
29 - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi
30 logout hook and recommend finalrd and busybox for the logout hook
31 to work.
32 - Make iscsid socket-activated to only activate it as needed:
33 + debian/open-iscsi.service: do not start or check iscsid.service
34 + debian/rules: install and enable iscsid.socket
35 + debian/open-iscsi.postinst:
36 + run restart logic only if service is running on upgrade
37 + drop no longer reachable upgrade path that affects iscsid
38 + disable iscsid.service on upgrade
39 + handle iscsid.socket to be started if the service is not running yet
40 + d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
41 run when udev disks are attached.
42 + d/iscsid.service: Remove ExecStop= directive.
43 + debian/tests/install: fix tests to work with socket activation
44 + debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
45 - debian/open-iscsi.service: Start open-iscsi systemd job when either
46 /etc/iscsi/nodes or /sys/class/iscsi_session have content.
47 - Prevent network interface that contains iscsi root from bouncing
48 during boot or going down during shutdown if the system is using
49 resolvconf or ifupdown:
50 + d/iscsi-network-interface.rules
51 + d/extra/net-interface-handler
52 - debian/extra/initramfs.hook: add ib_iser to the list of modules
53 included in the initramfs, so that we can in principle support
54 iscsi root on infiniband.
55 - debian/open-iscsi.kmod drop: (LP 1833586)
56 no static module list is needed if we let iscsid load modules itself.
57 - Stop producing udebs on i386 where we no longer have d-i or a kernel.
58 - d/extra/initramfs.local-{top,bottom}: move removal of
59 open-iscsi.interface file from local-top to local-bottom,
60 and fix shell quoting issue that would result in /run/initramfs/
61 open-iscsi.interface always being removed (LP 1872813)
62 - d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds and
63 initialization, because upstream's gcc10 support is incomplete. This
64 change can be dropped when upstream has completed their gcc support.
65 - d/README.Debian, d/extra/startup-checks.sh, d/open-iscsi-udeb.start,
66 d/open-iscsi.postinst: Apply Ubuntu branding to iqn initiator name
67 * Added changes
68 - merge bug fix release 2.1.4 from upstream
69 - Revert "Add patches from upstream" [upstream in 2.1.4]
70 - d/control: Transition from libopeniscsiusr0.2.0 to libopeniscsiusr
71
72 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 01 Jul 2021 14:13:08 +0200
73
1open-iscsi (2.1.3-5) unstable; urgency=medium74open-iscsi (2.1.3-5) unstable; urgency=medium
275
3 [ Cyril Brulebois ]76 [ Cyril Brulebois ]
@@ -33,6 +106,119 @@ open-iscsi (2.1.3-2) unstable; urgency=medium
33106
34 -- Chris Hofstaedtler <zeha@debian.org> Sun, 07 Feb 2021 19:23:13 +0000107 -- Chris Hofstaedtler <zeha@debian.org> Sun, 07 Feb 2021 19:23:13 +0000
35108
109open-iscsi (2.1.3-1ubuntu6) hirsute; urgency=medium
110
111 * d/open-iscsi.finalrd: fix UID resolution issues in logout (LP: #1922976)
112 Thanks to Michael Brown
113
114 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 18 Mar 2021 09:44:07 +0100
115
116open-iscsi (2.1.3-1ubuntu5) hirsute; urgency=medium
117
118 * make d/t/testuite python3 compatible (LP: #1919461)
119 - backport changes from qa-regression-testing since we diverged
120 - various tests: make py3 compliant, fix formatting a bit
121 - tests: convert deprecated assertEquals() to assertEqual()
122 - Remove all references to python-utils
123 - d/t/testlib.py: update to last state from
124 git+ssh://git.launchpad.net/qa-regression-testing
125 - d/t/{control,testsuite}: bump to use python3
126 - d/t/test-open-iscsi.py: switch shebang to python3
127 - d/t/test-open-iscsi.py: adapt to updated testlib
128 * Add patches from upstream [this is from Debian upload 2.1.3-2]:
129 - Fix memory leak in iscsiadm, Fix iscsiadm segfault when exiting, and
130 - Fix iscsistart login issue when target is delayed. The last one should
131 - fix iscsi-root with delayed network (Closes: #980085)
132
133 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 18 Mar 2021 09:44:07 +0100
134
135open-iscsi (2.1.3-1ubuntu4) hirsute; urgency=medium
136
137 * Rebuild again so s390x pick up the right debhelper
138
139 -- Sebastien Bacher <seb128@ubuntu.com> Wed, 24 Feb 2021 16:29:41 +0100
140
141open-iscsi (2.1.3-1ubuntu3) hirsute; urgency=medium
142
143 * No-change rebuild to drop the udeb package.
144
145 -- Matthias Klose <doko@ubuntu.com> Mon, 22 Feb 2021 10:35:42 +0100
146
147open-iscsi (2.1.3-1ubuntu2) hirsute; urgency=medium
148
149 * Apply Ubuntu branding to iqn initiator name.
150
151 -- Dimitri John Ledkov <xnox@ubuntu.com> Wed, 17 Feb 2021 00:05:22 +0000
152
153open-iscsi (2.1.3-1ubuntu1) hirsute; urgency=medium
154
155 * Merge with Debian unstable. Remaining changes:
156 - debian/tests: Add Ubuntu autopkgtest suite:
157 - README-boot-test.md
158 - tgt-boot-test: tests
159 - test-open-iscsi.py
160 - testlib.py
161 - get-image
162 - patch-image
163 - testsuite
164 - xkvm
165 - d/iscsid.service: Let iscsid systemd job run in privileged containers
166 but not in unprivileged ones
167 - d/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
168 run ipconfig to gather all DHCP config info, including DNS search
169 domain, which iBFT can't provide.
170 - Remove initramfs interfaces stamp in case no iscsi devs mounted.
171 If iscsi root was requested, but no iscsi devices were mounted, remove
172 the initramfs interfaces stamp file. Meaning, that on shutdown there is
173 no 30s delay, whilst trying to re-establish iscsi login to perform a
174 logout.
175 - add IPv6 support
176 - Source /run/net6-*.conf when needed.
177 - d/extra/initramfs.local-top: handle IPv6 configs being shipped in
178 DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
179 .interface
180 - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi logout
181 hook and recommend finalrd and busybox for the logout hook to work.
182 - Make iscsid socket-activated to only activate it as needed:
183 - debian/open-iscsi.service: do not start or check iscsid.service
184 - debian/rules: install and enable iscsid.socket
185 - debian/open-iscsi.postinst:
186 - run restart logic only if service is running on upgrade
187 - drop no longer reachable upgrade path that affects iscsid
188 - disable iscsid.service on upgrade
189 - handle iscsid.socket to be started if the service is not running yet
190 - d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
191 run when udev disks are attached.
192 - d/iscsid.service: Remove ExecStop= directive.
193 - debian/tests/install: fix tests to work with socket activation
194 - debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
195 [updated to match 2.1.2]
196 - debian/open-iscsi.service: Start open-iscsi systemd job when either
197 /etc/iscsi/nodes or /sys/class/iscsi_session have content.
198 - Prevent network interface that contains iscsi root from bouncing
199 during boot or going down during shutdown if the system is using
200 resolvconf or ifupdown:
201 - d/iscsi-network-interface.rules
202 - d/extra/net-interface-handler
203 - d/extra/initramfs.hook: add ib_iser to the list of modules included in
204 the initramfs, so that we can in principle support iscsi root on
205 infiniband.
206 - d/open-iscsi.kmod drop: (LP #1833586)
207 no static module list is needed if we let iscsid load modules itself.
208 - Stop producing udebs on i386 where we no longer have d-i or a kernel.
209 - d/extra/initramfs.local-{top,bottom}: move removal of
210 open-iscsi.interface file from local-top to local-bottom, and fix shell
211 quoting issue that would result in /run/initramfs/ open-iscsi.interface
212 always being removed (LP #1872813)
213 - debian/control, debian/rules: Fix libopeniscsiusr binary package
214 name (LP 1892228).
215 - d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds
216 and initialization, because upstream's gcc10 support is incomplete.
217 This change can be dropped when upstream has completed their gcc
218 support.
219
220 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Tue, 19 Jan 2021 13:29:46 +0100
221
36open-iscsi (2.1.3-1) unstable; urgency=medium222open-iscsi (2.1.3-1) unstable; urgency=medium
37223
38 * [afee47d] New upstream version 2.1.3224 * [afee47d] New upstream version 2.1.3
@@ -51,6 +237,75 @@ open-iscsi (2.1.2-2) unstable; urgency=medium
51237
52 -- Chris Hofstaedtler <zeha@debian.org> Sun, 06 Dec 2020 23:25:11 +0000238 -- Chris Hofstaedtler <zeha@debian.org> Sun, 06 Dec 2020 23:25:11 +0000
53239
240open-iscsi (2.1.2-1ubuntu1) hirsute; urgency=medium
241
242 * Merge with Debian unstable. Remaining changes:
243 - debian/tests: Add Ubuntu autopkgtest suite:
244 - README-boot-test.md
245 - tgt-boot-test: tests
246 - test-open-iscsi.py
247 - testlib.py
248 - get-image
249 - patch-image
250 - testsuite
251 - xkvm
252 - d/iscsid.service: Let iscsid systemd job run in privileged containers
253 but not in unprivileged ones
254 - d/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
255 run ipconfig to gather all DHCP config info, including DNS search
256 domain, which iBFT can't provide.
257 - Remove initramfs interfaces stamp in case no iscsi devs mounted.
258 If iscsi root was requested, but no iscsi devices were mounted, remove
259 the initramfs interfaces stamp file. Meaning, that on shutdown there is
260 no 30s delay, whilst trying to re-establish iscsi login to perform a
261 logout.
262 - add IPv6 support
263 - Source /run/net6-*.conf when needed.
264 - d/extra/initramfs.local-top: handle IPv6 configs being shipped in
265 DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
266 .interface
267 - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi logout
268 hook and recommend finalrd and busybox for the logout hook to work.
269 - Make iscsid socket-activated to only activate it as needed:
270 - debian/open-iscsi.service: do not start or check iscsid.service
271 - debian/rules: install and enable iscsid.socket
272 - debian/open-iscsi.postinst:
273 - run restart logic only if service is running on upgrade
274 - drop no longer reachable upgrade path that affects iscsid
275 - disable iscsid.service on upgrade
276 - handle iscsid.socket to be started if the service is not running yet
277 - d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
278 run when udev disks are attached.
279 - d/iscsid.service: Remove ExecStop= directive.
280 - debian/tests/install: fix tests to work with socket activation
281 - debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
282 [updated to match 2.1.2]
283 - debian/open-iscsi.service: Start open-iscsi systemd job when either
284 /etc/iscsi/nodes or /sys/class/iscsi_session have content.
285 - Prevent network interface that contains iscsi root from bouncing
286 during boot or going down during shutdown if the system is using
287 resolvconf or ifupdown:
288 - d/iscsi-network-interface.rules
289 - d/extra/net-interface-handler
290 - d/extra/initramfs.hook: add ib_iser to the list of modules included in
291 the initramfs, so that we can in principle support iscsi root on
292 infiniband.
293 - d/open-iscsi.kmod drop: (LP #1833586)
294 no static module list is needed if we let iscsid load modules itself.
295 - Stop producing udebs on i386 where we no longer have d-i or a kernel.
296 - d/extra/initramfs.local-{top,bottom}: move removal of
297 open-iscsi.interface file from local-top to local-bottom, and fix shell
298 quoting issue that would result in /run/initramfs/ open-iscsi.interface
299 always being removed (LP #1872813)
300 - debian/control, debian/rules: Fix libopeniscsiusr binary package
301 name (LP 1892228).
302 - d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds
303 and initialization, because upstream's gcc10 support is incomplete.
304 This change can be dropped when upstream has completed their gcc
305 support.
306
307 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 03 Dec 2020 14:44:39 +0100
308
54open-iscsi (2.1.2-1) unstable; urgency=medium309open-iscsi (2.1.2-1) unstable; urgency=medium
55310
56 * [7f10701] New upstream version 2.1.2311 * [7f10701] New upstream version 2.1.2
@@ -72,6 +327,86 @@ open-iscsi (2.1.1-2) unstable; urgency=medium
72327
73 -- Ritesh Raj Sarraf <rrs@debian.org> Fri, 14 Aug 2020 12:32:16 +0530328 -- Ritesh Raj Sarraf <rrs@debian.org> Fri, 14 Aug 2020 12:32:16 +0530
74329
330open-iscsi (2.1.1-1ubuntu2) groovy; urgency=medium
331
332 * debian/control, debian/rules: Fix libopeniscsiusr binary package
333 name (LP: #1892228).
334 * debian/rules: Fix deprecated warning for dh_installinit that
335 --no-restart-on-upgrade has been replaced by --no-stop-on-upgrade,
336 which is equivalent in functionality (ref deb #837528).
337
338 -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Wed, 19 Aug 2020 19:08:47 +0000
339
340open-iscsi (2.1.1-1ubuntu1) groovy; urgency=medium
341
342 * New upstream version 2.1.1
343 * d/rules: Don't FTBFS due to warnings new in gcc10 regarding bounds
344 and initialization, because upstream's gcc10 support is incomplete.
345 This change can be dropped when upstream has completed their gcc
346 support.
347 * Merge with Debian unstable (LP: #1891374). Remaining changes:
348 - debian/tests: Add Ubuntu autopkgtest suite:
349 - README-boot-test.md
350 - tgt-boot-test: tests
351 - test-open-iscsi.py
352 - testlib.py
353 - get-image
354 - patch-image
355 - testsuite
356 - xkvm
357 - d/iscsid.service: Let iscsid systemd job run in privileged containers
358 but not in unprivileged ones
359 - d/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
360 run ipconfig to gather all DHCP config info, including DNS search
361 domain, which iBFT can't provide.
362 - Remove initramfs interfaces stamp in case no iscsi devs mounted.
363 If iscsi root was requested, but no iscsi devices were mounted, remove
364 the initramfs interfaces stamp file. Meaning, that on shutdown there is
365 no 30s delay, whilst trying to re-establish iscsi login to perform a
366 logout.
367 - add IPv6 support
368 - Source /run/net6-*.conf when needed.
369 - d/extra/initramfs.local-top: handle IPv6 configs being shipped in
370 DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
371 .interface
372 - d/rules, d/open-iscsi.finalrd, d/control: ship the finalrd iscsi logout
373 hook and recommend finalrd and busybox for the logout hook to work.
374 - Make iscsid socket-activated to only activate it as needed:
375 - debian/open-iscsi.service: do not start or check iscsid.service
376 - debian/rules: install and enable iscsid.socket
377 - debian/open-iscsi.postinst:
378 - run restart logic only if service is running on upgrade
379 - drop no longer reachable upgrade path that affects iscsid
380 - disable iscsid.service on upgrade
381 - handle iscsid.socket to be started if the service is not running yet
382 - d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
383 run when udev disks are attached.
384 - d/iscsid.service: Remove ExecStop= directive.
385 - debian/tests/install: fix tests to work with socket activation
386 - debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
387 - debian/open-iscsi.service: Start open-iscsi systemd job when either
388 /etc/iscsi/nodes or /sys/class/iscsi_session have content.
389 - Prevent network interface that contains iscsi root from bouncing
390 during boot or going down during shutdown if the system is using
391 resolvconf or ifupdown:
392 - d/iscsi-network-interface.rules
393 - d/extra/net-interface-handler
394 - d/extra/initramfs.hook: add ib_iser to the list of modules included in
395 the initramfs, so that we can in principle support iscsi root on
396 infiniband.
397 - d/open-iscsi.kmod drop: (LP #1833586)
398 no static module list is needed if we let iscsid load modules itself.
399 - Stop producing udebs on i386 where we no longer have d-i or a kernel.
400 - Use python2 instead of python in the autopkg tests: Next step for
401 open-iscsi is to revist all iscsi-root feature and autopkgtests, so
402 keep python2 to avoid re-work later.
403 - d/extra/initramfs.local-{top,bottom}: move removal of
404 open-iscsi.interface file from local-top to local-bottom, and fix shell
405 quoting issue that would result in /run/initramfs/ open-iscsi.interface
406 always being removed (LP #1872813)
407
408 -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Thu, 13 Aug 2020 04:29:43 +0000
409
75open-iscsi (2.1.1-1) experimental; urgency=medium410open-iscsi (2.1.1-1) experimental; urgency=medium
76411
77 [ Rafael David Tinoco ]412 [ Rafael David Tinoco ]
@@ -116,6 +451,98 @@ open-iscsi (2.1.1-1) experimental; urgency=medium
116451
117 -- Ritesh Raj Sarraf <rrs@debian.org> Tue, 23 Jun 2020 20:38:47 +0530452 -- Ritesh Raj Sarraf <rrs@debian.org> Tue, 23 Jun 2020 20:38:47 +0530
118453
454open-iscsi (2.0.874-7.1ubuntu6.1) focal; urgency=medium
455
456 [ Ben Swartzlander ]
457 * allow open-iscsi to disable auto-scan feature (LP: #1877617)
458 - d/p/lp1877617-Allow-disabling-auto-LUN-scans.patch
459 - d/p/lp1877617-Fix-manual-LUN-scans-feature.patch
460
461 -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Mon, 11 May 2020 02:03:33 +0000
462
463open-iscsi (2.0.874-7.1ubuntu6) focal; urgency=medium
464
465 * d/extra/initramfs.local-{top,bottom}: move removal of open-iscsi.interface
466 file from local-top to local-bottom, and fix shell quoting issue that
467 would result in /run/initramfs/open-iscsi.interface always being removed
468 (LP: #1872813)
469
470 -- Daniel Watkins <oddbloke@ubuntu.com> Tue, 14 Apr 2020 16:54:37 -0400
471
472open-iscsi (2.0.874-7.1ubuntu5) focal; urgency=medium
473
474 * Use python2 instead of python in the autopkg tests.
475
476 -- Matthias Klose <doko@ubuntu.com> Thu, 30 Jan 2020 10:14:16 +0100
477
478open-iscsi (2.0.874-7.1ubuntu3) eoan; urgency=medium
479
480 * Stop producing udebs on i386 where we no longer have d-i or a kernel.
481
482 -- Adam Conrad <adconrad@ubuntu.com> Wed, 09 Oct 2019 14:10:37 -0600
483
484open-iscsi (2.0.874-7.1ubuntu2) eoan; urgency=medium
485
486 * debian/open-iscsi.kmod: drop; no static module list is needed if we let
487 iscsid load modules itself. LP: #1833586.
488 * debian/extra/initramfs.hook: add ib_iser to the list of modules
489 included in the initramfs, so that we can in principle support iscsi
490 root on infiniband.
491
492 -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 20 Jun 2019 13:48:46 -0700
493
494open-iscsi (2.0.874-7.1ubuntu1) eoan; urgency=low
495
496 * Merge from Debian unstable. Remaining changes:
497 - debian/tests: Add Ubuntu autopkgtest.
498 - debian/iscsi-network-interface.rules, debian/net-interface-handler,
499 debian/open-iscsi.install:
500 Prevent network interface that contains iscsi root from bouncing
501 during boot or going down during shutdown if the system is using
502 resolvconf or ifupdown.
503 - Let iscsid systemd job run in privileged containers but not in
504 unprivileged ones
505 - Start open-iscsi systemd job when either /etc/iscsi/nodes or
506 /sys/class/iscsi_session have content
507 - add IPv6 support
508 + Source /run/net6-*.conf when needed.
509 + debian/extra/initramfs.local-top: handle IPv6 configs being
510 shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
511 can fill in /run/initramfs/open-iscsi.interface
512 - make iscsid socket-activated to only activate it as needed
513 + debian/iscsid.socket: systemd socket file for iscsid
514 + debian/open-iscsi.service: do not start or check iscsid.service
515 + debian/rules: install and enable iscsid.socket
516 + debian/patches/iscid-conf-use-systemd.socket-patch: default to the
517 socket
518 + debian/open-iscsi.postinst:
519 * run restart logic only if service is running on upgrade
520 * drop no longer reachable upgrade path that affects iscsid
521 * disable iscsid.service on upgrade
522 * handle iscsid.socket to be started if the service is not running
523 yet
524 + d/iscsi-disk.rules: Add a udev rule so that iscsid.service will be
525 run when udev disks are attached.
526 + d/iscsid.service: Remove ExecStop= directive.
527 + debian/tests/install: fix tests to work with socket activation
528 - Ship finalrd logout hook.
529 - debian/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
530 run ipconfig to gather all DHCP config info, including DNS search
531 domain, which iBFT can't provide.
532 - If iscsi root was requested, but no iscsi devices were mounted, remove
533 the initramfs interfaces stamp file. Meaning, that on shutdown there
534 is no 30s delay, whilst trying to re-establish iscsi login to perform
535 a logout.
536 * Dropped changes, included in Debian:
537 - Fix fail to build from source due to undefined reference to
538 minor
539 * Drop breaks on never-released version of finalrd.
540 * debian/net-interface-handler: drop upstart support, unused since bionic.
541 * Drop cleanup of upstart jobs, no longer needed post bionic.
542 * debian/tests/daemon: drop, unused.
543
544 -- Steve Langasek <steve.langasek@ubuntu.com> Mon, 29 Apr 2019 16:13:37 -0700
545
119open-iscsi (2.0.874-7) unstable; urgency=medium546open-iscsi (2.0.874-7) unstable; urgency=medium
120547
121 * [eeda27c] Enable back pristine-tar as we have now committed it548 * [eeda27c] Enable back pristine-tar as we have now committed it
@@ -131,6 +558,158 @@ open-iscsi (2.0.874-6) unstable; urgency=medium
131558
132 -- Ritesh Raj Sarraf <rrs@debian.org> Fri, 05 Oct 2018 11:31:19 +0530559 -- Ritesh Raj Sarraf <rrs@debian.org> Fri, 05 Oct 2018 11:31:19 +0530
133560
561open-iscsi (2.0.874-5ubuntu15) disco; urgency=medium
562
563 * d/iscsid.service: Remove ExecStop= directive. Letting systemd
564 handle termination prevents restart failures. (LP: #1821255)
565
566 -- Heitor R. Alves de Siqueira <halves@canonical.com> Thu, 28 Mar 2019 10:21:24 -0300
567
568open-iscsi (2.0.874-5ubuntu14) disco; urgency=medium
569
570 * debian/iscsi-disk.rules: Fix bug with LVM on top of iscsi devices.
571 (LP: #1807978)
572
573 -- Scott Moser <smoser@ubuntu.com> Tue, 11 Dec 2018 19:01:14 -0500
574
575open-iscsi (2.0.874-5ubuntu13) disco; urgency=medium
576
577 [ Robert C Jennings & Dimitri John Ledkov ]
578 * If iscsi root was requested, but no iscsi devices were mounted, remove
579 the initramfs interfaces stamp file. Meaning, that on shutdown there
580 is no 30s delay, whilst trying to re-establish iscsi login to perform
581 a logout. LP: #1800681
582
583 -- Dimitri John Ledkov <xnox@ubuntu.com> Sun, 09 Dec 2018 22:29:20 +0000
584
585open-iscsi (2.0.874-5ubuntu12) disco; urgency=medium
586
587 [Scott Moser]
588 * debian/extra/initramfs.local-top: handle iSCSI iBFT DHCP to correctly
589 run ipconfig to gather all DHCP config info, including DNS search
590 domain, which iBFT can't provide. (LP: #1806777)
591
592 -- Dan Streetman <ddstreet@canonical.com> Wed, 05 Dec 2018 11:28:12 -0500
593
594open-iscsi (2.0.874-5ubuntu11) disco; urgency=medium
595
596 * debian/tests/test-open-iscsi.py: Fix called process error.
597 If no image was available for a release, a NameError exception would be
598 raised.
599
600 -- Scott Moser <smoser@ubuntu.com> Wed, 14 Nov 2018 16:50:29 -0500
601
602open-iscsi (2.0.874-5ubuntu10) disco; urgency=medium
603
604 * d/iscsi-disk.rules, d/tests: Add a udev rule so that iscsid.service
605 will be run when udev disks are attached. (LP: #1802354)
606 * debian/tests: improve tgt boot test
607 - disable snapd and snap.seeded services to avoid unnecessary
608 resource consumption during tests.
609 - save artifacts from the test run.
610
611 -- Scott Moser <smoser@ubuntu.com> Wed, 14 Nov 2018 16:05:46 -0500
612
613open-iscsi (2.0.874-5ubuntu9) cosmic; urgency=medium
614
615 * d/net-interface-handler: replace 'domainsearch' with the correct
616 configuration option 'search' in net-interface-handler (LP: #1791108)
617
618 -- Victor Tapia <victor.tapia@canonical.com> Mon, 17 Sep 2018 15:58:34 +0200
619
620open-iscsi (2.0.874-5ubuntu8) cosmic; urgency=medium
621
622 * d/tests: insert some debug units in an attempt to diagnose any
623 occurences of bug 1788188.
624 * Fix fail to build from source due to undefined reference to
625 minor (LP: #1791154)
626
627 -- Scott Moser <smoser@ubuntu.com> Tue, 21 Aug 2018 13:33:06 -0400
628
629open-iscsi (2.0.874-5ubuntu7) cosmic; urgency=medium
630
631 * d/tests: make interactive use of tgt-boot-test more usable by
632 only using 'timeout' from the test harness.
633 * debian/tests/README-boot-test.md: minor doc fixes and whitespace.
634 * d/net-interface-handler: Apply changes only for the iscsi-root interface.
635 (LP: #1785108)
636
637 -- Scott Moser <smoser@ubuntu.com> Tue, 07 Aug 2018 16:37:13 -0400
638
639open-iscsi (2.0.874-5ubuntu6) cosmic; urgency=medium
640
641 * Ship finalrd logout hook.
642
643 -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 03 Aug 2018 15:03:51 +0100
644
645open-iscsi (2.0.874-5ubuntu5) cosmic; urgency=medium
646
647 * Harden dep8 tests against effects due to slow execution on Launchpad
648 infrastructure (LP: #1732028).
649 - debian/tests/patch-image: remove problematic fstab entries
650 - debian/tests/tgt-boot-test: ran xkvm in verbose mode
651
652 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 19 Jul 2018 18:22:39 +0200
653
654open-iscsi (2.0.874-5ubuntu4) cosmic; urgency=medium
655
656 * debian/tests/install: ignore the potential stderr of the probing command
657 that is meant to activate iscsid indirectly via the socket.
658
659 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 30 May 2018 15:42:12 +0200
660
661open-iscsi (2.0.874-5ubuntu3) cosmic; urgency=medium
662
663 * make iscsid socket activated to only activate it as-needed (LP: #1755858)
664 - debian/iscsid.socket: systemd socket file for iscsid
665 - debian/open-iscsi.service: do not start or check iscsid.service
666 - debian/rules: install and enable iscsid.socket
667 - debian/patches/iscid-conf-use-systemd.socket-patch: default to the socket
668 - debian/open-iscsi.postinst:
669 + run restart logic only if service is running on upgrade
670 + drop no more reachable upgrade path that affects iscsid
671 + disable iscsid.service on upgrade
672 + handle iscsid.socket to be started if the service is not running yet
673 - debian/tests/install: fix tests to work with socket activation
674
675 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 23 May 2018 15:50:01 +0200
676
677open-iscsi (2.0.874-5ubuntu2) bionic; urgency=medium
678
679 * debian/tests:
680 - tgt-boot-test: Use 'timeout' to force a 60m timeout of the boot test.
681 - README-boot-test.md: document environment variables BOOT_TIMEOUT
682 and _USE_KVM.
683
684 -- Scott Moser <smoser@ubuntu.com> Wed, 21 Feb 2018 13:19:17 -0500
685
686open-iscsi (2.0.874-5ubuntu1) bionic; urgency=low
687
688 * Merge with Debian unstable. Remaining changes:
689 - debian/tests: Add Ubuntu autopkgtests.
690 - debian/iscsi-network-interface.rules, debian/net-interface-handler,
691 debian/open-iscsi.install:
692 Prevent network interface that contains iscsi root from bouncing
693 during boot or going down during shutdown.
694 Integrates with resolvconf and initramfs code that writes
695 /run/initramfs/open-iscsi.interface
696 - debian/open-iscsi.maintscript: clean up the obsolete
697 iscsi-network-interface upstart job, file on upgrade.
698 - Let iscsid systemd job run in privileged containers but not in
699 unprivileged ones
700 - Start open-iscsi systemd job when either /etc/iscsi/nodes or
701 /sys/class/iscsi_session have content
702 Based on patch by Nish Aravamudan, thanks! (LP #1576341)
703 - add IPv6 support
704 + add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
705 LP #1621507
706 + Source /run/net6-*.conf when needed.
707 + debian/extra/initramfs.local-top: handle IPv6 configs being
708 shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
709 can fill in /run/initramfs/open-iscsi.interface (LP #1621507)
710
711 -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 12 Jan 2018 14:00:59 +0000
712
134open-iscsi (2.0.874-5) unstable; urgency=high713open-iscsi (2.0.874-5) unstable; urgency=high
135714
136 * [aeb86f7] Fix multiple security issues in iscsiuio. (CVE-2017-17840)715 * [aeb86f7] Fix multiple security issues in iscsiuio. (CVE-2017-17840)
@@ -138,6 +717,74 @@ open-iscsi (2.0.874-5) unstable; urgency=high
138717
139 -- Christian Seiler <christian@iwakd.de> Sat, 23 Dec 2017 11:30:44 +0100718 -- Christian Seiler <christian@iwakd.de> Sat, 23 Dec 2017 11:30:44 +0100
140719
720open-iscsi (2.0.874-4ubuntu5) bionic; urgency=medium
721
722 * debian/tests/patch-image: mount auxilary filesystems before upgrading
723 packages. Fixes ADT tests, when triggered by packages, that need
724 /proc, /dev, etc mounted to complete the upgrade.
725
726 -- Dimitri John Ledkov <xnox@ubuntu.com> Wed, 03 Jan 2018 12:21:05 +0000
727
728open-iscsi (2.0.874-4ubuntu4) bionic; urgency=medium
729
730 * debian/tests/test-open-iscsi.py: skip test if cloud image is unavailable.
731 This solves flaky tests in restricted network environments as well as in
732 the short period after opening a new release (LP: #1731907).
733
734 -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 16 Nov 2017 12:06:34 +0100
735
736open-iscsi (2.0.874-4ubuntu3) artful; urgency=medium
737
738 * debian/tests/xkvm: do not use kvm (-enable-kvm) by default if
739 operating inside a vm. nested kvm is finicky.
740
741 -- Scott Moser <smoser@ubuntu.com> Wed, 11 Oct 2017 18:14:08 -0400
742
743open-iscsi (2.0.874-4ubuntu2) artful; urgency=medium
744
745 * debian/tests/test-open-iscsi.py: query systemd-resolved if present.
746 Ubuntu images now have systemd-resolved managing /etc/resolv.conf
747 so support test if that is the case (LP: #1715468).
748
749 -- Scott Moser <smoser@ubuntu.com> Wed, 06 Sep 2017 16:20:16 -0400
750
751open-iscsi (2.0.874-4ubuntu1) artful; urgency=medium
752
753 * Merge with Debian unstable. Remaining changes:
754 - debian/tests: Add Ubuntu autopkgtests.
755 - debian/iscsi-network-interface.rules, debian/net-interface-handler,
756 debian/open-iscsi.install:
757 Prevent network interface that contains iscsi root from bouncing
758 during boot or going down during shutdown.
759 Integrates with resolvconf and initramfs code that writes
760 /run/initramfs/open-iscsi.interface
761 - debian/open-iscsi.maintscript: clean up the obsolete
762 iscsi-network-interface upstart job, file on upgrade.
763 - Let iscsid systemd job run in privileged containers but not in
764 unprivileged ones
765 - Start open-iscsi systemd job when either /etc/iscsi/nodes or
766 /sys/class/iscsi_session have content
767 Based on patch by Nish Aravamudan, thanks! (LP #1576341)
768 - add IPv6 support
769 + add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
770 LP #1621507
771 + Source /run/net6-*.conf when needed.
772 + debian/extra/initramfs.local-top: handle IPv6 configs being
773 shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
774 can fill in /run/initramfs/open-iscsi.interface (LP #1621507)
775 * Drop:
776 - d/extra/initramfs.local-top: When booting from iBFT,
777 set the PROTO= entry in /run/net-*.conf accordingly,
778 so that other tools, such as cloud-init, can use that
779 information. (cloud-init fails if the current PROTO=none
780 is used.) (LP: #1684039) (Closes: #866213)
781 [ Fixed in Debian 2.0.874-4 ]
782 * d/t/test-open-iscsi.py: drop test_daemon test
783 - With the updates to the systemd units, the services do not run
784 unless iSCSI is configured.
785
786 -- Nishanth Aravamudan <nish.aravamudan@canonical.com> Tue, 08 Aug 2017 16:16:27 -0700
787
141open-iscsi (2.0.874-4) unstable; urgency=medium788open-iscsi (2.0.874-4) unstable; urgency=medium
142789
143 * [0347300] initramfs: populate PROTO= entry in /run/net-*.conf from iBFT790 * [0347300] initramfs: populate PROTO= entry in /run/net-*.conf from iBFT
@@ -152,6 +799,64 @@ open-iscsi (2.0.874-3) unstable; urgency=medium
152799
153 -- Christian Seiler <christian@iwakd.de> Sun, 18 Jun 2017 22:01:22 +0200800 -- Christian Seiler <christian@iwakd.de> Sun, 18 Jun 2017 22:01:22 +0200
154801
802open-iscsi (2.0.874-2ubuntu3) artful; urgency=medium
803
804 * d/t/test-open-iscsi.py: drop test_daemon test
805 - With the updates to the systemd units, the services do not run
806 unless iSCSI is configured.
807
808 -- Nishanth Aravamudan <nish.aravamudan@canonical.com> Tue, 08 Aug 2017 16:05:29 -0700
809
810open-iscsi (2.0.874-2ubuntu2) artful; urgency=medium
811
812 * d/extra/initramfs.local-top: When booting from iBFT,
813 set the PROTO= entry in /run/net-*.conf accordingly,
814 so that other tools, such as cloud-init, can use that
815 information. (cloud-init fails if the current PROTO=none
816 is used.) (LP: #1684039) (Closes: #866213)
817
818 -- Eric Desrochers <eric.desrochers@canonical.com> Wed, 05 Jul 2017 09:02:12 -0400
819
820open-iscsi (2.0.874-2ubuntu1) artful; urgency=medium
821
822 [ Nishanth Aravamudan ]
823 * Merge with Debian unstable. Remaining changes:
824 - debian/tests: Add Ubuntu autopkgtests.
825 - debian/iscsi-network-interface.rules, debian/net-interface-handler,
826 debian/open-iscsi.install:
827 Prevent network interface that contains iscsi root from bouncing
828 during boot or going down during shutdown.
829 Integrates with resolvconf and initramfs code that writes
830 /run/initramfs/open-iscsi.interface
831 - debian/open-iscsi.maintscript: clean up the obsolete
832 iscsi-network-interface upstart job, file on upgrade.
833 - add IPv6 support
834 + add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
835 LP #1621507
836 + Source /run/net6-*.conf when needed.
837 + debian/extra/initramfs.local-top: handle IPv6 configs being
838 shipped in DEVICE6 or /run/net6-*.conf in the initramfs, so we
839 can fill in /run/initramfs/open-iscsi.interface (LP #1621507)
840 * Drop:
841 - Make systemd job not run in containers (LP #1576341)
842 [ This prevents running iscsi in privileged containers.
843 Fixed differently in this upload. ]
844 - Cherry-pick from Debian git repository (Christian Seiler):
845 + open-iscsi-udeb: drop Depends: libnss-files-udeb
846 (Closes #819685)
847 [ Fixed in Debian ]
848 - d/extra/initramfs.local-top whitespace change
849 [ previously undocumented ]
850
851 [ Balint Reczey ]
852 * Let iscsid systemd job run in privileged containers but not in
853 unprivileged ones
854 * Start open-iscsi systemd job when either /etc/iscsi/nodes or
855 /sys/class/iscsi_session have content
856 Based on patch by Nish Aravamudan, thanks! (LP #1576341)
857
858 -- Nishanth Aravamudan <nish.aravamudan@canonical.com> Tue, 09 May 2017 09:24:23 -0700
859
155open-iscsi (2.0.874-2) unstable; urgency=medium860open-iscsi (2.0.874-2) unstable; urgency=medium
156861
157 [ Christian Seiler ]862 [ Christian Seiler ]
@@ -291,6 +996,155 @@ open-iscsi (2.0.873+git0.3b4b4500-15) unstable; urgency=medium
291996
292 -- Christian Seiler <christian@iwakd.de> Fri, 20 May 2016 09:52:46 +0200997 -- Christian Seiler <christian@iwakd.de> Fri, 20 May 2016 09:52:46 +0200
293998
999open-iscsi (2.0.873+git0.3b4b4500-14ubuntu17) zesty; urgency=medium
1000
1001 * debian/tests:
1002 - README-boot-test.md: mention limited space caveat.
1003 - patch-image: fix handling of ADT_TEST_TRIGGERS if source package
1004 built more than one binary package.
1005 - test-open-iscsi.py: change to rely on patch-image
1006 adding package 'open-iscsi' rather than passing it in itself.
1007
1008 -- Scott Moser <smoser@ubuntu.com> Thu, 16 Feb 2017 15:47:58 -0500
1009
1010open-iscsi (2.0.873+git0.3b4b4500-14ubuntu16) zesty; urgency=medium
1011
1012 * debian/tests: many improvements to the open-iscsi and tgt boot test.
1013 - only run test on amd64. just avoid timeout errors or other unrelated
1014 issues causing failure.
1015 - debian/tests/README-boot-test.md: add doc describing the tgt-boot-test
1016 - rename get-maas-eph to get-image
1017 - use a cloud image instead of a maas image for booting. The value in
1018 this is that we can then install open-iscsi inside the image and get an
1019 updated initramfs.
1020 - use subprocess.check_call rather than subprocess.call so that we
1021 actually catch errors.
1022 - update xkvm to what is in curtin/tools/xkvm
1023 - improve updating of images to consider ADT_TEST_TRIGGERS if set.
1024
1025 -- Scott Moser <smoser@ubuntu.com> Tue, 14 Feb 2017 17:07:00 -0500
1026
1027open-iscsi (2.0.873+git0.3b4b4500-14ubuntu15) zesty; urgency=medium
1028
1029 * debian/tests/tgt-boot-test: set HOST_IP harder for the testsuite test.
1030
1031 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Sun, 29 Jan 2017 13:05:47 -0500
1032
1033open-iscsi (2.0.873+git0.3b4b4500-14ubuntu14) zesty; urgency=medium
1034
1035 * Make systemd job not run in containers (LP: #1576341)
1036
1037 -- Serge Hallyn <serge.hallyn@ubuntu.com> Sun, 15 Jan 2017 23:08:29 -0600
1038
1039open-iscsi (2.0.873+git0.3b4b4500-14ubuntu13) zesty; urgency=medium
1040
1041 * Fix syntax error in previous changes. LP: #1621507
1042
1043 -- LaMont Jones <lamont@ubuntu.com> Fri, 09 Dec 2016 12:35:45 +0100
1044
1045open-iscsi (2.0.873+git0.3b4b4500-14ubuntu12) zesty; urgency=medium
1046
1047 * debian/tests/tgt-boot-test: set HOST_IP to 10.0.2.2; it's suboptimal but
1048 given the test setup this will allow the right IPs to be used to bring up
1049 the iscsi target in the xkvm.
1050
1051 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Thu, 08 Dec 2016 11:00:12 +0100
1052
1053open-iscsi (2.0.873+git0.3b4b4500-14ubuntu11) zesty; urgency=medium
1054
1055 * debian/tests/tgt-boot-test: drop -serial stdio altogether since running
1056 the VM in -nographics mode will already output to stdout.
1057
1058 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Tue, 22 Nov 2016 11:27:55 -0500
1059
1060open-iscsi (2.0.873+git0.3b4b4500-14ubuntu10) zesty; urgency=medium
1061
1062 * debian/tests/tgt-boot-test: always log qemu serial to stdio so we can
1063 actually see what is going on during the tests.
1064
1065 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Thu, 17 Nov 2016 11:01:27 -0500
1066
1067open-iscsi (2.0.873+git0.3b4b4500-14ubuntu9) zesty; urgency=medium
1068
1069 [ LaMont Jones ]
1070 * Clean up net-interface-handler
1071 * Source /run/net6-*.conf when needed.
1072
1073 [ Mathieu Trudel-Lapierre ]
1074 * debian/extra/initramfs.local-top: handle IPv6 configs being shipped in
1075 DEVICE6 or /run/net6-*.conf in the initramfs, so we can fill in
1076 /run/initramfs/open-iscsi.interface (LP: #1621507)
1077
1078 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Thu, 03 Nov 2016 16:30:37 -0600
1079
1080open-iscsi (2.0.873+git0.3b4b4500-14ubuntu8) yakkety; urgency=medium
1081
1082 * debian/tests/xkvm: don't --enable-kvm.
1083
1084 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Wed, 05 Oct 2016 12:58:21 -0400
1085
1086open-iscsi (2.0.873+git0.3b4b4500-14ubuntu7) yakkety; urgency=medium
1087
1088 * debian/tests/test-open-iscsi.py: glob to pick up open-iscsi.deb, which may
1089 be named differently depending on how autopkgtests are run.
1090
1091 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Wed, 05 Oct 2016 09:56:25 -0400
1092
1093open-iscsi (2.0.873+git0.3b4b4500-14ubuntu6) yakkety; urgency=medium
1094
1095 * debian/tests/test-open-iscsi.py: install the open-iscsi binary into a test
1096 MAAS image, so we can check bootability. Download the open-iscsi explicitly
1097 to /tmp before trying to copy it; so that we don't need to depend on ugly
1098 internal autopkgtest paths.
1099
1100 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Tue, 04 Oct 2016 09:05:56 -0400
1101
1102open-iscsi (2.0.873+git0.3b4b4500-14ubuntu5) yakkety; urgency=medium
1103
1104 * debian/tests/control: add build-needed since some of the new tests
1105 appear to require that (so they can reach open-iscsi.deb which is a build
1106 artifact from building in autopkgtest).
1107
1108 -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Mon, 03 Oct 2016 16:10:54 -0400
1109
1110open-iscsi (2.0.873+git0.3b4b4500-14ubuntu4) yakkety; urgency=medium
1111
1112 * add support for IPV6{DOMAINSEARCH,DNS0,DNS1} to net-interface-handler
1113 LP: #1621507
1114
1115 -- LaMont Jones <lamont@canonical.com> Tue, 20 Sep 2016 08:05:41 -0600
1116
1117open-iscsi (2.0.873+git0.3b4b4500-14ubuntu3) xenial; urgency=medium
1118
1119 * Cherry-pick from Debian git repository (Christian Seiler):
1120 - open-iscsi-udeb: drop Depends: libnss-files-udeb (Closes: #819685)
1121
1122 -- Colin Watson <cjwatson@ubuntu.com> Fri, 15 Apr 2016 16:54:26 +0100
1123
1124open-iscsi (2.0.873+git0.3b4b4500-14ubuntu2) xenial; urgency=medium
1125
1126 * debian/tests: add two new tests. One to verify net-interface-handler is
1127 installed executable, and one to actually test that /etc/resolv.conf is
1128 updated with dhcp dns responses.
1129
1130 -- Diogo Matsubara <diogo.matsubara@gmail.com> Wed, 09 Mar 2016 12:56:42 -0300
1131
1132open-iscsi (2.0.873+git0.3b4b4500-14ubuntu1) xenial; urgency=medium
1133
1134 * Merge from debian. Remaining changes:
1135 - debian/tests: Add Ubuntu autopkgtest.
1136 - debian/iscsi-network-interface.rules, debian/net-interface-handler,
1137 debian/open-iscsi.install:
1138 Prevent network interface that contains iscsi root from bouncing
1139 during boot or going down during shutdown.
1140 Integrates with resolvconf and initramfs code that writes
1141 /run/initramfs/open-iscsi.interface
1142 - debian/open-iscsi.maintscript: clean up the obsolete
1143 iscsi-network-interface upstart job, file on upgrade.
1144 * make debian/net-interface-handler executable (LP: #1553017)
1145
1146 -- Scott Moser <smoser@ubuntu.com> Fri, 04 Mar 2016 13:17:45 -0500
1147
294open-iscsi (2.0.873+git0.3b4b4500-14) unstable; urgency=medium1148open-iscsi (2.0.873+git0.3b4b4500-14) unstable; urgency=medium
2951149
296 [ Christian Seiler ]1150 [ Christian Seiler ]
@@ -303,6 +1157,21 @@ open-iscsi (2.0.873+git0.3b4b4500-14) unstable; urgency=medium
3031157
304 -- Christian Seiler <christian@iwakd.de> Thu, 03 Mar 2016 18:47:46 +01001158 -- Christian Seiler <christian@iwakd.de> Thu, 03 Mar 2016 18:47:46 +0100
3051159
1160open-iscsi (2.0.873+git0.3b4b4500-13ubuntu1) xenial; urgency=medium
1161
1162 * Merge from Debian (LP: #1546877). Remaining changes:
1163 - debian/tests: Add Ubuntu autopkgtest.
1164 - debian/iscsi-network-interface.rules, debian/net-interface-handler,
1165 debian/open-iscsi.install:
1166 Prevent network interface that contains iscsi root from bouncing
1167 during boot or going down during shutdown.
1168 Integrates with resolvconf and initramfs code that writes
1169 /run/initramfs/open-iscsi.interface
1170 - debian/open-iscsi.maintscript: clean up the obsolete
1171 iscsi-network-interface upstart job, file on upgrade.
1172
1173 -- Scott Moser <smoser@ubuntu.com> Thu, 18 Feb 2016 00:53:37 -0500
1174
306open-iscsi (2.0.873+git0.3b4b4500-13) unstable; urgency=medium1175open-iscsi (2.0.873+git0.3b4b4500-13) unstable; urgency=medium
3071176
308 [ Christian Seiler ]1177 [ Christian Seiler ]
@@ -524,6 +1393,115 @@ open-iscsi (2.0.873+git0.3b4b4500-1) unstable; urgency=low
5241393
525 -- Ritesh Raj Sarraf <rrs@debian.org> Tue, 05 Nov 2013 21:45:47 +05301394 -- Ritesh Raj Sarraf <rrs@debian.org> Tue, 05 Nov 2013 21:45:47 +0530
5261395
1396open-iscsi (2.0.873-3ubuntu13) wily; urgency=medium
1397
1398 * debian/net-interface-handler: Create the resolvconf dir, to avoid failure
1399 when resolvconf did not start yet; the udev rules run in parallel with
1400 it. (LP: #1501033)
1401
1402 -- Martin Pitt <martin.pitt@ubuntu.com> Tue, 06 Oct 2015 07:05:48 +0200
1403
1404open-iscsi (2.0.873-3ubuntu12) wily; urgency=medium
1405
1406 * Drop debian/ifup@.service.conf again, it ceased to work with net.agent in
1407 wily and the whole idea of net-interface-handler is to *stop* ifupdown
1408 from fiddling with the iscsi interface. Replace with udev rules
1409 (debian/iscsi-network-interface.rules) which achieves this without relying
1410 on ifupdown or a particular init system. (LP: #1463461)
1411 * Drop debian/open-iscsi.iscsi-network-interface.upstart as well, obsolete
1412 now. Also clean it up on upgrades.
1413
1414 -- Martin Pitt <martin.pitt@ubuntu.com> Thu, 11 Jun 2015 11:58:29 +0200
1415
1416open-iscsi (2.0.873-3ubuntu11) vivid; urgency=medium
1417
1418 * Factor out logic from debian/open-iscsi.iscsi-network-interface.upstart
1419 into debian/net-interface-handler, and install the latter in debian/rules.
1420 * Add debian/ifup@.service.conf: Drop-in for ifup@.service to run
1421 net-interface-handler under systemd. (LP: #1432829)
1422
1423 -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 27 Mar 2015 09:51:05 +0100
1424
1425open-iscsi (2.0.873-3ubuntu10) vivid; urgency=medium
1426
1427 * Start open-iscsi after installation and make sure initiatorname is
1428 generated. (Patch backported from Debian)
1429 * debian/tests/daemon: Stop calling the init.d script as we expect the
1430 daemon to start automatically now.
1431
1432 -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 06 Mar 2015 13:17:26 +0100
1433
1434open-iscsi (2.0.873-3ubuntu9) trusty; urgency=medium
1435
1436 * Add missing python test dependency.
1437
1438 -- Martin Pitt <martin.pitt@ubuntu.com> Wed, 26 Feb 2014 16:07:37 +0100
1439
1440open-iscsi (2.0.873-3ubuntu8) trusty; urgency=medium
1441
1442 * open-iscsi-udeb: Enable builds on armhf, arm64, ppc64el, x32 (LP: #1274203)
1443
1444 -- dann frazier <dann.frazier@canonical.com> Wed, 29 Jan 2014 12:34:45 -0700
1445
1446open-iscsi (2.0.873-3ubuntu7) saucy; urgency=low
1447
1448 * Use dh_autotools-dev to update config.sub|guess.
1449
1450 -- Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com> Fri, 11 Oct 2013 17:03:37 +0100
1451
1452open-iscsi (2.0.873-3ubuntu6) saucy; urgency=low
1453
1454 * debian/tests: Add autopkgtest.
1455
1456 -- Yolanda <yolanda.robla@canonical.com> Mon, 27 May 2013 10:39:35 +0200
1457
1458open-iscsi (2.0.873-3ubuntu5) quantal-proposed; urgency=low
1459
1460 * Ensure all udev events have been processed before trying to configure
1461 iscsi networking in the initramfs (LP: #1066945):
1462 - debian/extra/initramfs.local-top: Restore wait_for_udev call before
1463 configure_networking to ensure network devices are present.
1464
1465 -- James Page <james.page@ubuntu.com> Wed, 17 Oct 2012 12:37:43 +0100
1466
1467open-iscsi (2.0.873-3ubuntu4) quantal-proposed; urgency=low
1468
1469 * Generate initiator name on install, not first boot, ensuring that the
1470 initramfs built during install contains a valid iSCSI initiator name
1471 resulting in a iSCSI based root volume that will actually boot
1472 (LP: #1057635):
1473 - debian/{rules,initiatorname.iscsi}: Don't install a default
1474 initiatorname.iscsi.
1475 - debian/open-iscsi.postinst: Generate initiatorname.iscsi on install.
1476
1477 -- James Page <james.page@ubuntu.com> Mon, 15 Oct 2012 12:42:53 +0100
1478
1479open-iscsi (2.0.873-3ubuntu3) quantal; urgency=low
1480
1481 * debian/open-iscsi.iscsi-network-interface.upstart: fix bad syntax
1482 in 'post-stop'
1483
1484 -- Scott Moser <smoser@ubuntu.com> Mon, 17 Sep 2012 16:50:22 -0400
1485
1486open-iscsi (2.0.873-3ubuntu2) quantal; urgency=low
1487
1488 * debian/extra/initramfs.local-top: start writing
1489 /run/initramfs/open-iscsi.interface file again (LP: #1050480)
1490 * debian/open-iscsi.iscsi-network-interface.upstart: integrate with
1491 resolvconf (LP: #1050487)
1492
1493 -- Scott Moser <smoser@ubuntu.com> Mon, 17 Sep 2012 15:46:26 -0400
1494
1495open-iscsi (2.0.873-3ubuntu1) quantal; urgency=low
1496
1497 * Merge from Debian. Remaining changes: (LP: #961114, LP: #677333)
1498 - Add upstart job iscsi-network-interface
1499 - Migrate from /var/run and /lib/init/rw to /run, from /var/lock to
1500 /run/lock.
1501 * Turn open-iscsi-utils into a transitional package
1502
1503 -- Stéphane Graber <stgraber@ubuntu.com> Tue, 10 Jul 2012 13:53:52 -0400
1504
527open-iscsi (2.0.873-3) unstable; urgency=low1505open-iscsi (2.0.873-3) unstable; urgency=low
5281506
529 * [4939401] Fix build to install udeb stuff only on supported architectures1507 * [4939401] Fix build to install udeb stuff only on supported architectures
@@ -698,6 +1676,239 @@ open-iscsi (2.0.871-1) unstable; urgency=low
6981676
699 -- Ritesh Raj Sarraf <rrs@researchut.com> Sat, 06 Feb 2010 20:28:23 +05301677 -- Ritesh Raj Sarraf <rrs@researchut.com> Sat, 06 Feb 2010 20:28:23 +0530
7001678
1679open-iscsi (2.0.871-0ubuntu9) oneiric-proposed; urgency=low
1680
1681 * Make sure the upstart job triggers ifupdown's upstart script to avoid
1682 waiting 2 minutes at boot time for network to come up. (LP: #870214)
1683
1684 -- Stéphane Graber <stgraber@ubuntu.com> Tue, 11 Oct 2011 22:31:39 +0100
1685
1686open-iscsi (2.0.871-0ubuntu8) oneiric; urgency=low
1687
1688 * Disable open-iscsi init script when root is on iscsi (LP: #838809)
1689
1690 -- Stéphane Graber <stgraber@ubuntu.com> Thu, 15 Sep 2011 10:01:12 -0400
1691
1692open-iscsi (2.0.871-0ubuntu7) oneiric; urgency=low
1693
1694 * Migrate from /var/run and /lib/init/rw to /run, from /var/lock to
1695 /run/lock, and from /dev/.initramfs to /run/initramfs.
1696
1697 -- Colin Watson <cjwatson@ubuntu.com> Thu, 14 Jul 2011 17:01:42 +0100
1698
1699open-iscsi (2.0.871-0ubuntu6) oneiric; urgency=low
1700
1701 * Fix initramfs iSCSI login (many thanks to Amos Hayes for lending me a
1702 test system; LP: #728088):
1703 - Write out /dev/.initramfs/open-iscsi.interface in the same subshell as
1704 configure_networking, so that we can get at the value of DEVICE.
1705 - Wait for udev to settle before attempting to configure networking.
1706
1707 -- Colin Watson <cjwatson@ubuntu.com> Fri, 27 May 2011 23:27:31 +0100
1708
1709open-iscsi (2.0.871-0ubuntu5) maverick; urgency=low
1710
1711 * Include <sys/types.h> and <sys/stat.h> in usr/iscsi_sysfs.c for S_*
1712 macros (LP: #600953).
1713
1714 -- Colin Watson <cjwatson@ubuntu.com> Fri, 02 Jul 2010 17:08:14 +0100
1715
1716open-iscsi (2.0.871-0ubuntu4) lucid; urgency=low
1717
1718 * Revert ISCSI_NETDEVICE change; it's normally better to select the
1719 interface by MAC address (LP: #473036).
1720
1721 -- Colin Watson <cjwatson@ubuntu.com> Fri, 05 Feb 2010 12:06:06 -0800
1722
1723open-iscsi (2.0.871-0ubuntu3) lucid; urgency=low
1724
1725 * If ISCSI_NETDEVICE is set, configure that interface in the initramfs
1726 (LP: #473036).
1727
1728 -- Colin Watson <cjwatson@ubuntu.com> Fri, 22 Jan 2010 17:01:17 +0000
1729
1730open-iscsi (2.0.871-0ubuntu2) lucid; urgency=low
1731
1732 * Fix handling of ISCSI_USERNAME, ISCSI_PASSWORD, ISCSI_IN_USERNAME, and
1733 ISCSI_IN_PASSWORD in iscsi.initramfs (closes: #525053).
1734
1735 -- Colin Watson <cjwatson@ubuntu.com> Mon, 14 Dec 2009 12:24:42 +0000
1736
1737open-iscsi (2.0.871-0ubuntu1) lucid; urgency=low
1738
1739 * New upstream release.
1740 * If the root filesystem is on iSCSI, prevent the network interface used
1741 for it from being brought up or down automatically (LP: #457767).
1742 * Backport from upstream:
1743 - Allow updating of discovery records (Hannes Reinecke).
1744 - Fix discovery record use, rather than always using iscsid.conf
1745 settings (Mike Christie).
1746
1747 -- Colin Watson <cjwatson@ubuntu.com> Thu, 10 Dec 2009 18:19:20 +0000
1748
1749open-iscsi (2.0.870.1-0ubuntu12) karmic; urgency=low
1750
1751 * debian/open-iscsi-udeb.finish-install: Stop checking
1752 disk-detect/iscsi/enable, as that template doesn't exist any more.
1753
1754 -- Colin Watson <cjwatson@ubuntu.com> Fri, 02 Oct 2009 18:49:18 +0100
1755
1756open-iscsi (2.0.870.1-0ubuntu11) karmic; urgency=low
1757
1758 * open-iscsi-utils Replaces: old versions of open-iscsi.
1759 * SECURITY UPDATE: temporary file vulnerability (LP: #408915)
1760 - utils/iscsi_discovery: store iscsiadm -m discovery result in a
1761 variable rather than writing it to an insecurely-created temporary
1762 file
1763 - CVE-2009-1297
1764
1765 -- Colin Watson <cjwatson@ubuntu.com> Mon, 24 Aug 2009 23:42:10 +0100
1766
1767open-iscsi (2.0.870.1-0ubuntu10) karmic; urgency=low
1768
1769 * debian/control, debian/open-iscsi-utils.install,
1770 open-iscsi-utils.manpages : create a new binary package which
1771 contains /sbin/iscsiadm, needed for some packages to build against
1772 (eg, libvirt), but not containing the init script, LP: #414986
1773
1774 -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 18 Aug 2009 08:11:34 -0500
1775
1776open-iscsi (2.0.870.1-0ubuntu9) karmic; urgency=low
1777
1778 * debian/open-iscsi.init: don't exit with error if
1779 /lib/init/rw/sendsigs.omit.d/ doesn't exist (LP: #414986)
1780
1781 -- Jamie Strandboge <jamie@ubuntu.com> Mon, 17 Aug 2009 14:12:01 -0500
1782
1783open-iscsi (2.0.870.1-0ubuntu8) karmic; urgency=low
1784
1785 * Make sure network devices are always included in the initramfs if
1786 booting with / on iSCSI.
1787 * Retry initramfs network configuration for a while until it works (LP:
1788 #237460).
1789
1790 -- Colin Watson <cjwatson@ubuntu.com> Tue, 11 Aug 2009 13:05:43 +0100
1791
1792open-iscsi (2.0.870.1-0ubuntu7) karmic; urgency=low
1793
1794 [ Colin Watson ]
1795 * debian/open-iscsi-udeb.postinst, debian/open-iscsi-udeb.templates:
1796 Remove; this is being taken over by disk-detect and partman-iscsi.
1797 * debian/control: Remove XB-Installer-Menu-Item.
1798
1799 [ Mathias Gug ]
1800 * debian/open-iscsi.postinst: Fix backwards use of update-rc.d (LP:
1801 #306678).
1802 * debian/open-iscsi.init: Overwrite existing pid file symlinks in
1803 /lib/init/rw/sendsigs.omit.d/.
1804
1805 -- Colin Watson <cjwatson@ubuntu.com> Mon, 10 Aug 2009 13:28:41 +0100
1806
1807open-iscsi (2.0.870.1-0ubuntu6) karmic; urgency=low
1808
1809 * utils/iscsi_discovery: Fix several bashisms (test ==, &> redirection,
1810 trap with numeric signals).
1811
1812 -- Colin Watson <cjwatson@ubuntu.com> Tue, 04 Aug 2009 12:30:44 +0100
1813
1814open-iscsi (2.0.870.1-0ubuntu5) karmic; urgency=low
1815
1816 * utils/iscsi_discovery: replace uses of awk with other shell voodoo, so
1817 that this works in the installer. LP: #236640.
1818 * debian/rules, debian/open-iscsi-udeb.dirs: install the open-isci-udeb
1819 finish script to /usr/lib/finish-install.d, not to /lib/finish-install.d.
1820 * debian/open-iscsi-udeb.finish-install: copy the config from the root
1821 to the correct directory in the target.
1822
1823 -- Steve Langasek <steve.langasek@ubuntu.com> Tue, 07 Jul 2009 22:10:17 -0700
1824
1825open-iscsi (2.0.870.1-0ubuntu4) karmic; urgency=low
1826
1827 * debian/extra/initramfs.hook: iscsistart is in /sbin, not /usr/sbin (LP:
1828 #364616).
1829
1830 -- Colin Watson <cjwatson@ubuntu.com> Thu, 02 Jul 2009 14:12:25 +0100
1831
1832open-iscsi (2.0.870.1-0ubuntu3) jaunty; urgency=low
1833
1834 * Invoke iscsi-iname using normal $PATH lookup rather than using an
1835 incorrect explicit path (see LP #236640).
1836
1837 -- Colin Watson <cjwatson@ubuntu.com> Thu, 09 Apr 2009 16:49:08 +0100
1838
1839open-iscsi (2.0.870.1-0ubuntu2) jaunty; urgency=low
1840
1841 * debian/control: Drop udeb dependency on crypto-modules; as best as I can
1842 tell, this is required for crc32c support, which is now built-in to the
1843 Ubuntu kernels.
1844
1845 -- Dustin Kirkland <kirkland@ubuntu.com> Tue, 03 Feb 2009 11:20:35 +0100
1846
1847open-iscsi (2.0.870.1-0ubuntu1) jaunty; urgency=low
1848
1849 * New upstream release:
1850 - Support 2.6.26/27 kernels (LP: #289470).
1851 - Fix iscsid shutdown (LP: #181188).
1852 * Merge from Debian. Remaining Ubuntu changes:
1853 - Note: Debian version isn't 870~rc3 but 869.2 which leads to a big
1854 .diff.gz file. Only files in debian/ have been considered for this merge
1855 since debian hasn't patched the source.
1856 - debian/control, debian/rules, debian/open-iscsi-udeb*:
1857 + Add open-iscsi-udeb.
1858 - debian/open-iscsi.dirs:
1859 + rename dirs to open-iscsi.dirs because of open-iscsi-udeb addition.
1860 + drop network/if-up.d/ directory since we're using symlinks instead.
1861 + utilities installed in /bin,/sbin rather than /usr/bin,/usr/sbin.
1862 - debian/open-iscsi.init:
1863 + utilities installed in /bin,/sbin rather than /usr/bin,/usr/sbin.
1864 + lsb log messages.
1865 + Don't generate initiatorname name (moved to postinst).
1866 + Support for being called from ifup/ifdown scripts.
1867 + Refactor start functions:
1868 - move daemon start to startdaemon function.
1869 - call udevadm settle rather then udevsettle (which doesn't do anything
1870 useful).
1871 - don't exit if the daemon is already running during sanitychecks.
1872 Instead check in startdaemon if the daemon needs to be started.
1873 - only start automatic targets if necessary.
1874 - add waitfordevices function: called during rcS, waits for all
1875 automatic targets to be ready. Iscsi targets are considered as
1876 local block devices - they don't need to be marked with _netdev in
1877 fstab. (LP: #227848)
1878 - start targets if not run from rcS.
1879 + Check status of iscsid daemon in addition to listing the iscsi sessions
1880 when status action is called.
1881 + Add iscsid to the list of processes that should not be killed by
1882 sendsigs during shutdown (LP: #192080).
1883 + Add starttargets, stoptargets and restarttargets to usage message.
1884 - debian/rules:
1885 + Install utilities /bin,/sbin rather than /usr/bin,/usr/sbin.
1886 + Start open-iscsi at S25 (waiting for devices created by ifupdown
1887 calls and before local filesystems are checked and mounted)
1888 + stop at S41 (after local filesystems are unmounted). Don't use
1889 umountiscsi.sh script from debian. (LP: #192080).
1890 - debian/initiatorname.iscsi, debian/open-iscsi.postinst:
1891 + Generate the random initiatorname during postinstall rather than in the
1892 init script.
1893 + Don't ship a default initiatorname.iscsi file.
1894 - debian/open-iscsi.postinst:
1895 + fix init script ordering on upgrades.
1896 - debian/open-iscsi.links:
1897 + symlink open-iscsi init script in if-up.d and if-down.d directory so
1898 that the iscsi subsystem is started/stopped when network interfaces
1899 are configured.
1900 - debian/open-iscsi.postrm:
1901 + delete iscsi configuration when the package is purged.
1902 - utils/iscsi_discovery: De-bashify iscsi_discovery.
1903 - usr/idbm.c: Fix build failure with new glibc. LP: #299843.
1904 * Dropped:
1905 - Exit without error if /sys is not available. Otherwise, it's not possible
1906 to use this package as a build-dependency (in Debian).
1907 - Drop upstream url in long description now that it's in the Homepage
1908 field (in Debian).
1909
1910 -- Mathias Gug <mathiaz@ubuntu.com> Mon, 01 Dec 2008 10:45:03 -0500
1911
701open-iscsi (2.0.870~rc3-0.6) unstable; urgency=low1912open-iscsi (2.0.870~rc3-0.6) unstable; urgency=low
7021913
703 * Non-maintainer upload.1914 * Non-maintainer upload.
@@ -797,6 +2008,47 @@ open-iscsi (2.0.869~rc4-1) experimental; urgency=low
7972008
798 -- Philipp Hug <debian@hug.cx> Sat, 12 Apr 2008 15:53:12 +02002009 -- Philipp Hug <debian@hug.cx> Sat, 12 Apr 2008 15:53:12 +0200
7992010
2011open-iscsi (2.0.865-1ubuntu5) jaunty; urgency=low
2012
2013 * Fix build failure with new glibc. LP: #299843.
2014
2015 -- Matthias Klose <doko@ubuntu.com> Thu, 27 Nov 2008 15:58:15 +0100
2016
2017open-iscsi (2.0.865-1ubuntu4) intrepid; urgency=low
2018
2019 * Exit without error if /sys is not available. Otherwise, it's not possible
2020 to use this package as a build-dependency.
2021
2022 -- Soren Hansen <soren@ubuntu.com> Fri, 02 May 2008 00:57:02 +0200
2023
2024open-iscsi (2.0.865-1ubuntu3) hardy; urgency=low
2025
2026 * Migration of /usr/{bin,sbin,lib} -> to /{bin,sbin,lib}.
2027 (LP: #208441)
2028 * Push the shutdown scripts back. (LP: #196748)
2029 * Update control to 3.7.3.
2030 * Updated the maintainer according to spec.
2031
2032 -- Chuck Short <zulcss@ubuntu.com> Wed, 09 Apr 2008 18:09:28 -0400
2033
2034open-iscsi (2.0.865-1ubuntu2) hardy; urgency=low
2035
2036 * Fixed init script to point to the right iscsiadm. (LP: #206520)
2037
2038 -- Chuck Short <zulcss@ubuntu.com> Tue, 25 Mar 2008 09:53:08 -0400
2039
2040open-iscsi (2.0.865-1ubuntu1) hardy; urgency=low
2041
2042 * Add open-iscsi-udeb.
2043 * Include iscsi_discovery.
2044 * De-bashify iscsi_discovery.
2045 * Start open-iscsi in single user mode.
2046 * Properly lsb-ify init script.
2047 * Modify Maintainer value to match the DebianMaintainerField
2048 specification.
2049
2050 -- Soren Hansen <soren@ubuntu.com> Fri, 08 Feb 2008 11:56:11 +0100
2051
800open-iscsi (2.0.865-1) unstable; urgency=low2052open-iscsi (2.0.865-1) unstable; urgency=low
8012053
802 * New upstream release2054 * New upstream release
diff --git a/debian/control b/debian/control
index a69ce2c..daf7950 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,8 @@
1Source: open-iscsi1Source: open-iscsi
2Section: net2Section: net
3Priority: optional3Priority: optional
4Maintainer: Debian iSCSI Maintainers <open-iscsi@packages.debian.org>4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5XSBC-Original-Maintainer: Debian iSCSI Maintainers <open-iscsi@packages.debian.org>
5Uploaders: Ritesh Raj Sarraf <rrs@debian.org>,6Uploaders: Ritesh Raj Sarraf <rrs@debian.org>,
6 Christian Seiler <christian@iwakd.de>,7 Christian Seiler <christian@iwakd.de>,
7 Chris Hofstaedtler <zeha@debian.org>8 Chris Hofstaedtler <zeha@debian.org>
@@ -31,6 +32,7 @@ Depends: ${misc:Depends},
31 ${shlibs:Depends},32 ${shlibs:Depends},
32 libopeniscsiusr,33 libopeniscsiusr,
33 udev34 udev
35Recommends: ${busybox:Recommends}, finalrd (>= 3)
34Pre-Depends: debconf | debconf-2.036Pre-Depends: debconf | debconf-2.0
35Description: iSCSI initiator tools37Description: iSCSI initiator tools
36 The Open-iSCSI project is a high-performance, transport independent,38 The Open-iSCSI project is a high-performance, transport independent,
@@ -58,6 +60,8 @@ Package: libopeniscsiusr
58Architecture: linux-any60Architecture: linux-any
59Depends: ${misc:Depends},61Depends: ${misc:Depends},
60 ${shlibs:Depends}62 ${shlibs:Depends}
63Replaces: libopeniscsiusr0.2.0 (<< 2.1.4-0ubuntu1~)
64Breaks: libopeniscsiusr0.2.0 (<< 2.1.4-0ubuntu1~)
61Enhances: open-iscsi65Enhances: open-iscsi
62Description: iSCSI userspace library66Description: iSCSI userspace library
63 The Open-iSCSI project is a high-performance, transport independent,67 The Open-iSCSI project is a high-performance, transport independent,
@@ -139,7 +143,7 @@ Package: open-iscsi-udeb
139# linux kernel udebs) must exist for these architectures - so143# linux kernel udebs) must exist for these architectures - so
140# check that before adding them to this list; the other144# check that before adding them to this list; the other
141# scsi-(core|common|...)-modules are NOT sufficient!145# scsi-(core|common|...)-modules are NOT sufficient!
142Architecture: amd64 arm64 armhf i386 ia64 mips mipsel powerpc ppc64 ppc64el s390x146Architecture: amd64 arm64 armhf ia64 mips mipsel powerpc ppc64 ppc64el s390x
143Section: debian-installer147Section: debian-installer
144Package-Type: udeb148Package-Type: udeb
145Depends: ${misc:Depends},149Depends: ${misc:Depends},
@@ -150,3 +154,11 @@ Description: Configure iSCSI
150 multi-platform implementation of RFC3720 iSCSI.154 multi-platform implementation of RFC3720 iSCSI.
151 .155 .
152 This is the minimal package (udeb) used by debian-installer.156 This is the minimal package (udeb) used by debian-installer.
157
158Package: libopeniscsiusr0.2.0
159Depends: libopeniscsiusr, ${misc:Depends}
160Architecture: all
161Priority: optional
162Section: oldlibs
163Description: transitional package
164 This is a transitional package. It can safely be removed.
diff --git a/debian/extra/initramfs.hook b/debian/extra/initramfs.hook
index 6a430eb..7458571 100755
--- a/debian/extra/initramfs.hook
+++ b/debian/extra/initramfs.hook
@@ -32,7 +32,7 @@ if [ -r /etc/iscsi/iscsi.initramfs ] ; then
32 cp /etc/iscsi/iscsi.initramfs $DESTDIR/etc32 cp /etc/iscsi/iscsi.initramfs $DESTDIR/etc
33fi33fi
3434
35for x in crc32c libcrc32c iscsi_tcp libiscsi scsi_transport_iscsi iscsi_ibft; do35for x in crc32c libcrc32c ib_iser iscsi_tcp libiscsi scsi_transport_iscsi iscsi_ibft; do
36 manual_add_modules ${x}36 manual_add_modules ${x}
37done37done
38for x in cxgb3i cxgb4i; do38for x in cxgb3i cxgb4i; do
diff --git a/debian/extra/initramfs.local-bottom b/debian/extra/initramfs.local-bottom
index c32e5fe..06ddc56 100755
--- a/debian/extra/initramfs.local-bottom
+++ b/debian/extra/initramfs.local-bottom
@@ -7,4 +7,24 @@ if [ -x /sbin/iscsiuio ] && [ -e /run/initramfs/iscsiuio.pid ] ; then
7 --name iscsiuio --exec /sbin/iscsiuio || :7 --name iscsiuio --exec /sbin/iscsiuio || :
8fi8fi
99
10# Remove the interface file if no disks are present
11if [ -f /run/initramfs/open-iscsi.interface ] ; then
12 found=0
13 for disk in /dev/disk/by-path/*-iscsi-*; do
14 if [ ! -e "$disk" ] ; then
15 # If we have no matches, we stil go through the for loop once with
16 # the pattern as a string
17 continue
18 fi
19 if ! readlink -f "$disk" > /dev/null ; then
20 continue
21 fi
22 found=1
23 break;
24 done
25 if [ $found = 0 ] ; then
26 rm /run/initramfs/open-iscsi.interface
27 fi
28fi
29
10exit 030exit 0
diff --git a/debian/extra/initramfs.local-top b/debian/extra/initramfs.local-top
index 1045c50..9f3af32 100755
--- a/debian/extra/initramfs.local-top
+++ b/debian/extra/initramfs.local-top
@@ -93,6 +93,7 @@ do_iscsi_login ()
93 . /scripts/functions93 . /scripts/functions
9494
95 udevadm settle95 udevadm settle
96 IBFT_DHCP_DEVICE=""
9697
97 if [ -n "$ISCSI_AUTO" ] ; then98 if [ -n "$ISCSI_AUTO" ] ; then
98 # try to auto-configure network interface based99 # try to auto-configure network interface based
@@ -136,7 +137,13 @@ do_iscsi_login ()
136 echo "UPTIME='${UPTIME}'"137 echo "UPTIME='${UPTIME}'"
137 echo "DHCPLEASETIME='${DHCPLEASETIME}'"138 echo "DHCPLEASETIME='${DHCPLEASETIME}'"
138 echo "DOMAINSEARCH=''"139 echo "DOMAINSEARCH=''"
139 } > "/run/net-${DEVICE}.conf"140 } > "/run/net-${DEVICE}.conf.ibft"
141 if [ "$PROTO" != "dhcp" -a "$DHCPLEASETIME" = "0" ]; then
142 # this is static ibft configuration.
143 mv "/run/net-${DEVICE}.conf.ibft" "/run/net-${DEVICE}.conf"
144 else
145 IBFT_DHCP_DEVICE="$DEVICE"
146 fi
140 echo "${DEVICE}" > /run/initramfs/open-iscsi.interface147 echo "${DEVICE}" > /run/initramfs/open-iscsi.interface
141 # iscsistart -N doesn't set the default gateway. Therefore,148 # iscsistart -N doesn't set the default gateway. Therefore,
142 # we need to add it ourselves. However, the ip command is149 # we need to add it ourselves. However, the ip command is
@@ -172,9 +179,23 @@ do_iscsi_login ()
172179
173 # run configure_networking even if we have iscsi_auto, because there180 # run configure_networking even if we have iscsi_auto, because there
174 # could be other network interfaces that need to be configured181 # could be other network interfaces that need to be configured
175 # manually182 # also, if we set up DHCP iBFT, we need ipconfig to run so it creates
183 # a proper /run/net-${DEVICE}.conf file that includes the DNS search
184 # domain, which we don't get in our iBFT data (see LP: #1806777)
176 configure_networking185 configure_networking
177186
187 if [ -n "$IBFT_DHCP_DEVICE" ]; then
188 if ! [ -e "/run/net-${DEVICE}.conf" ] ; then
189 echo "WARN: ipconfig dhcp failed, using iSCSI iBFT config - DNS search domain may be missing at runtime" >&2
190 # We have DHCP iBFT, but ipconfig DHCP failed;
191 # so we should fallback to just using the iBFT config,
192 # though that will not include the DNS search domain
193 mv "/run/net-${DEVICE}.conf.ibft" "/run/net-${DEVICE}.conf"
194 # need to re-run configure_networking to process conf file
195 configure_networking
196 fi
197 fi
198
178 # Save network device we configured via configure_networking, but only199 # Save network device we configured via configure_networking, but only
179 # if we didn't already get one from autoconfiguration (then we always200 # if we didn't already get one from autoconfiguration (then we always
180 # prefer that).201 # prefer that).
@@ -186,6 +207,13 @@ do_iscsi_login ()
186 fi207 fi
187 if [ -n "${DEVICE}" ] ; then208 if [ -n "${DEVICE}" ] ; then
188 echo "${DEVICE}" > /run/initramfs/open-iscsi.interface209 echo "${DEVICE}" > /run/initramfs/open-iscsi.interface
210 else
211 for i in /run/net6-*.conf; do
212 [ -e "${i}" ] && { . "${i}" ; break ; }
213 done
214 fi
215 if [ -z "${DEVICE}" ] && [ -n "${DEVICE6}" ] ; then
216 echo "${DEVICE6}" > /run/initramfs/open-iscsi.interface
189 fi217 fi
190 fi218 fi
191219
diff --git a/debian/extra/net-interface-handler b/debian/extra/net-interface-handler
192new file mode 100755220new file mode 100755
index 0000000..9cd6e1e
--- /dev/null
+++ b/debian/extra/net-interface-handler
@@ -0,0 +1,80 @@
1#!/bin/sh -e
2# suppress configuration of network interface used
3# by iSCSI root device
4#
5# If the root filesystem is on iSCSI, then we must take care to avoid
6# changing the state of its network interface. To this end, the initramfs
7# leaves a note for us which interface was used, and we mangle
8# /run/network/ifstate manually to stop it being brought up or down
9# automatically. This is a slight layering violation, but, unfortunately,
10# ifupdown appears to have no way to do this without also running
11# /etc/network/*.d/ scripts.
12
13assert_interface() {
14 # udev sets INTERFACE to the name of the currently-processed nic.
15 [ -n "$INTERFACE" ] && return 0
16 echo "environment variable INTERFACE not set." 1>&2;
17 return 1
18}
19
20start() {
21 CR="
22"
23 assert_interface || return
24 ifile=/run/initramfs/open-iscsi.interface
25
26 [ -f "$ifile" ] && read iface < "$ifile" || return 0
27 [ "$INTERFACE" = "$iface" ] || return
28
29 if ! grep -qs "^$iface=" /run/network/ifstate; then
30 mkdir -p /run/network
31 echo "$iface=$iface" >>/run/network/ifstate
32
33 if [ -f /run/net-$iface.conf ]; then
34 conf=/run/net-$iface.conf
35 elif [ -f /run/net6-$iface.conf ]; then
36 conf=/run/net6-$iface.conf
37 else
38 conf=""
39 fi
40 if command -v resolvconf >/dev/null &&
41 [ -n "$conf" ]; then
42 . "$conf"
43 R=""
44 [ -n "$DOMAINSEARCH" ] && R="$R${CR}search $DOMAINSEARCH"
45 [ -n "$IPV6DOMAINSEARCH" ] && R="$R${CR}search $IPV6DOMAINSEARCH"
46 for ns in "$IPV4DNS0" "$IPV4DNS1" "$IPV6DNS0" "$IPV6DNS1"; do
47 [ -n "$ns" -a "$ns" != "0.0.0.0" ] && R="$R${CR}nameserver $ns"
48 done
49 if [ -n "$R" ]; then
50 # create the dir in case resolvconf did not start yet
51 mkdir -p /run/resolvconf/interface
52 resolvconf -a $iface.iscsi-network <<EOF
53${R#${CR}}
54EOF
55 fi
56 fi
57 fi
58}
59
60stop() {
61 assert_interface || return
62 ifile=/run/initramfs/open-iscsi.interface
63 [ -f "$ifile" ] && read iface < "$ifile" || return 0
64 [ "$INTERFACE" = "$iface" ] || return
65
66 if grep -qs "^$iface=" /run/network/ifstate; then
67 grep -v "^$iface=" /run/network/ifstate >/run/network/.ifstate.tmp || true
68 mv /run/network/.ifstate.tmp /run/network/ifstate
69
70 if command -v resolvconf >/dev/null; then
71 resolvconf -d $iface.iscsi-network
72 fi
73 fi
74}
75
76case "$1" in
77 start) start ;;
78 stop) stop ;;
79 *) echo "ERROR: must be called with 'start' or 'stop'" >&2; exit 1 ;;
80esac
diff --git a/debian/extra/startup-checks.sh b/debian/extra/startup-checks.sh
index a369785..a7c3ecd 100755
--- a/debian/extra/startup-checks.sh
+++ b/debian/extra/startup-checks.sh
@@ -33,7 +33,7 @@ if grep -q "^GenerateName=yes" $NAMEFILE ; then
33 exit 133 exit 1
34 fi34 fi
35 # Generate a unique InitiatorName and save it35 # Generate a unique InitiatorName and save it
36 INAME=`/sbin/iscsi-iname -p iqn.1993-08.org.debian:01`36 INAME=`/sbin/iscsi-iname -p iqn.2004-10.com.ubuntu:01`
37 if [ "$INAME" != "" ] ; then37 if [ "$INAME" != "" ] ; then
38 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE38 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE
39 echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE39 echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE
diff --git a/debian/iscsi-network-interface.rules b/debian/iscsi-network-interface.rules
40new file mode 10064440new file mode 100644
index 0000000..e0408d7
--- /dev/null
+++ b/debian/iscsi-network-interface.rules
@@ -0,0 +1,3 @@
1# run before 80-networking.rules to run before ifupdown
2SUBSYSTEM=="net", ACTION=="add", RUN+="/lib/open-iscsi/net-interface-handler start"
3SUBSYSTEM=="net", ACTION=="remove", RUN+="/lib/open-iscsi/net-interface-handler stop"
diff --git a/debian/iscsid.service b/debian/iscsid.service
index d05953d..c98fd7e 100644
--- a/debian/iscsid.service
+++ b/debian/iscsid.service
@@ -7,13 +7,13 @@ After=network.target network-online.target
7DefaultDependencies=no7DefaultDependencies=no
8Conflicts=shutdown.target8Conflicts=shutdown.target
9Before=shutdown.target9Before=shutdown.target
10ConditionVirtualization=!private-users
1011
11[Service]12[Service]
12Type=forking13Type=forking
13PIDFile=/run/iscsid.pid14PIDFile=/run/iscsid.pid
14ExecStartPre=/lib/open-iscsi/startup-checks.sh15ExecStartPre=/lib/open-iscsi/startup-checks.sh
15ExecStart=/sbin/iscsid16ExecStart=/sbin/iscsid
16ExecStop=/sbin/iscsiadm -k 0 2
1717
18[Install]18[Install]
19WantedBy=sysinit.target19WantedBy=sysinit.target
diff --git a/debian/open-iscsi-udeb.start b/debian/open-iscsi-udeb.start
index beea0ae..127b7bf 100644
--- a/debian/open-iscsi-udeb.start
+++ b/debian/open-iscsi-udeb.start
@@ -6,7 +6,7 @@
66
7if ! [ -f /etc/iscsi/initiatorname.iscsi ]; then7if ! [ -f /etc/iscsi/initiatorname.iscsi ]; then
8 # Generate a unique InitiatorName and save it8 # Generate a unique InitiatorName and save it
9 INAME=`iscsi-iname -p iqn.1993-08.org.debian:01`9 INAME=`iscsi-iname -p iqn.2004-10.com.ubuntu:01`
10 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/iscsi/initiatorname.iscsi10 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/iscsi/initiatorname.iscsi
11 echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/iscsi/initiatorname.iscsi11 echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/iscsi/initiatorname.iscsi
12 echo "## If you change the InitiatorName, existing access control lists" >> /etc/iscsi/initiatorname.iscsi12 echo "## If you change the InitiatorName, existing access control lists" >> /etc/iscsi/initiatorname.iscsi
diff --git a/debian/open-iscsi.finalrd b/debian/open-iscsi.finalrd
13new file mode 10075513new file mode 100755
index 0000000..d0f4352
--- /dev/null
+++ b/debian/open-iscsi.finalrd
@@ -0,0 +1,47 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-3.0-only
3
4set -e
5
6if [ "$1" = "setup" ]
7then
8 . /usr/share/initramfs-tools/hook-functions
9 copy_exec /bin/grep
10 copy_exec /bin/sleep
11 copy_exec /sbin/iscsiadm
12 copy_exec /sbin/iscsid
13 # hm, not sure why expr is copied
14 copy_exec /usr/bin/expr
15 copy_file config /etc/iscsi/iscsid.conf
16 copy_file config /etc/iscsi/initiatorname.iscsi
17 # needed to resolve UIDs (LP: #1922976)
18 copy_exec /usr/lib/*/libnss_files.so.*
19 exit 0
20fi
21
22# if not present in the environment, then fake a trivial passwd file (LP: #1922976)
23if [ ! -e /etc/passwd ] ; then
24 echo "root:x:0:0:root:/:/bin/sh" > /etc/passwd
25fi
26
27# re-establish connection and logout during shutdown
28# if initramfs did bring up open-iscsi on boot
29[ -f /open-iscsi.interface ] || exit 0
30
31iscsid
32
33# After restarting iscsid, wait for an active connection.
34# Limit the wait time in case of unexpected failure of iscsid.
35MAX_RETRIES=30
36RETRY=0
37while ! iscsiadm -m session -P 1 | grep -q "iSCSI Connection State: LOGGED IN"; do
38 RETRY=$(($RETRY + 1))
39 if [ $RETRY -gt $MAX_RETRIES ]; then
40 echo "Unexpected iSCSI Connection State, forcing iSCSI logout."
41 break
42 fi
43 sleep 1
44done
45
46# Issue an iSCSI logout.
47iscsiadm -m node -u
diff --git a/debian/open-iscsi.kmod b/debian/open-iscsi.kmod
0deleted file mode 10064448deleted file mode 100644
index c5f90f3..0000000
--- a/debian/open-iscsi.kmod
+++ /dev/null
@@ -1,2 +0,0 @@
1iscsi_tcp
2ib_iser
diff --git a/debian/open-iscsi.postinst b/debian/open-iscsi.postinst
index f9867d4..ccc8ed7 100644
--- a/debian/open-iscsi.postinst
+++ b/debian/open-iscsi.postinst
@@ -17,16 +17,6 @@ restore_old_timeouts()
17case "$1" in17case "$1" in
18 configure)18 configure)
1919
20 # We switched over to modules-load.d logic, this is needed
21 MODULES_FILE=/lib/modules-load.d/open-iscsi.conf
22 if [ -f /etc/modules-load.d/open-iscsi.conf ] ; then
23 MODULES_FILE=/etc/modules-load.d/open-iscsi.conf
24 fi
25 grep '^[^#]' $MODULES_FILE | while read module args ; do
26 [ "$module" ] || continue
27 modprobe $module $args >/dev/null 2>&1 || true
28 done
29
30 # Compatibility symlinks20 # Compatibility symlinks
31 for file in iscsid iscsi_discovery iscsi-iname iscsistart; do21 for file in iscsid iscsi_discovery iscsi-iname iscsistart; do
32 if [ ! -e /usr/sbin/$file ]; then22 if [ ! -e /usr/sbin/$file ]; then
@@ -37,7 +27,7 @@ case "$1" in
37 # Generate a unique iSCSI InitiatorName27 # Generate a unique iSCSI InitiatorName
38 NAMEFILE=/etc/iscsi/initiatorname.iscsi28 NAMEFILE=/etc/iscsi/initiatorname.iscsi
39 if [ ! -e $NAMEFILE ] && [ -z "$2" ] ; then29 if [ ! -e $NAMEFILE ] && [ -z "$2" ] ; then
40 INAME=$(iscsi-iname -p iqn.1993-08.org.debian:01)30 INAME=$(iscsi-iname -p iqn.2004-10.com.ubuntu:01)
41 if [ -n "$INAME" ] ; then31 if [ -n "$INAME" ] ; then
42 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE32 echo "## DO NOT EDIT OR REMOVE THIS FILE!" > $NAMEFILE
43 echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE33 echo "## If you remove this file, the iSCSI daemon will not start." >> $NAMEFILE
@@ -65,7 +55,9 @@ esac
6555
66#DEBHELPER#56#DEBHELPER#
6757
68if [ "$1" = configure ] ; then58if [ "$1" = configure ] && [ -n "$2" ] && [ -d /run/systemd/system ] &&
59 systemctl is-active iscsid.service > /dev/null
60then
69 # There already is a check in preinst with a debconf prompt that61 # There already is a check in preinst with a debconf prompt that
70 # allows the administrator to abort. Don't abort here, because62 # allows the administrator to abort. Don't abort here, because
71 # leaving the package in a half-configured state is probably worse.63 # leaving the package in a half-configured state is probably worse.
@@ -109,25 +101,9 @@ if [ "$1" = configure ] ; then
109 # Just in case something goes wrong:101 # Just in case something goes wrong:
110 sync102 sync
111103
112 # Note: 3>&- is required because iscsid doesn't close unused104 # we want to be able to be explicit to start .service, but follow policy.d
113 # FDs, but debconf/confmodule will make the fd 3 point to105 # therefore use deb-systemd-invoke
114 # the original stdout (and stdout to stderr) to make sure106 deb-systemd-invoke restart iscsid.service || true
115 # no program accidentally issues a command on stdout. On
116 # sysvinit systems this combination (iscsid not closing
117 # fds, fd 3 remaining open) will cause dpkg to wait
118 # forever for the maintscript to finish. (iscsid keeps
119 # this end of the pipe open even though the maintscript
120 # is finished, so dpkg will never receive a POLLHUP on
121 # its end of the pipe, waiting forever.) Closing fd 3
122 # here is the simplest solution. This issue does not
123 # occur with other init systems, since they start
124 # services in a clean environment without any extraneous
125 # open fds.
126 if [ -n "$2" ]; then
127 invoke-rc.d iscsid restart 3>&-
128 else
129 invoke-rc.d iscsid start 3>&-
130 fi
131107
132 RETRIES=0108 RETRIES=0
133 while cat /sys/class/iscsi_session/session*/state 2>/dev/null | grep -qv LOGGED_IN ; do109 while cat /sys/class/iscsi_session/session*/state 2>/dev/null | grep -qv LOGGED_IN ; do
@@ -149,17 +125,26 @@ if [ "$1" = configure ] ; then
149125
150 restore_old_timeouts126 restore_old_timeouts
151 trap - EXIT127 trap - EXIT
128fi
152129
153 # Don't restart (and therefore stop) open-iscsi, because we don't130if [ "$1" = configure ]; then
154 # want to logout from targets during a simple upgrade. But also,131 # With socket based activation one wants iscsid.socket to be active
155 # if for some reason there's some misconfigured target in the132 # But on upgrades the iscsid.service might already be active
156 # config that couldn't be activated, don't break postinst, so133 # Due to that directly starting iscsid.socket might fail:
157 # ignore the exit code.134 # systemd[1]: iscsid.socket: Socket service iscsid.service already active, refusing.
158 # See above for why 3>&- is here. (Technically it's not required135 # Therefore check if iscsid.service is:
159 # for postinst to work, but vgchange likes to complain about leaked136 # - active:
160 # file descriptors, and we don't need to show that message to the137 # - ok for now, do not start iscsid.socket as it would conflict
161 # user.)138 # - on a reboot .socket will be started as it is enabled
162 invoke-rc.d open-iscsi start 3>&- || true139 # - inactive:
140 # - start iscsid.socket - to be ready
141 # In both cases:
142 # - disable iscsid.service so it only starts by the socket after reboot
143 if [ -d /run/systemd/system ]; then
144 if ! systemctl is-active iscsid.service > /dev/null; then
145 deb-systemd-invoke start iscsid.socket || true
146 fi
147 fi
163fi148fi
164149
165exit 0150exit 0
diff --git a/debian/open-iscsi.service b/debian/open-iscsi.service
index a62825e..06f83fe 100644
--- a/debian/open-iscsi.service
+++ b/debian/open-iscsi.service
@@ -1,12 +1,16 @@
1[Unit]1[Unit]
2Description=Login to default iSCSI targets2Description=Login to default iSCSI targets
3Documentation=man:iscsiadm(8) man:iscsid(8)3Documentation=man:iscsiadm(8) man:iscsid(8)
4Wants=network-online.target remote-fs-pre.target iscsid.service4Wants=network-online.target remote-fs-pre.target
5After=network-online.target iscsid.service5After=network-online.target iscsid.service
6Before=remote-fs-pre.target6Before=remote-fs-pre.target
7DefaultDependencies=no7DefaultDependencies=no
8Conflicts=shutdown.target8Conflicts=shutdown.target
9Before=shutdown.target9Before=shutdown.target
10# Must have some pre-defined targets to login to
11ConditionDirectoryNotEmpty=|/etc/iscsi/nodes
12# or have a session to use via iscsid
13ConditionDirectoryNotEmpty=|/sys/class/iscsi_session
1014
11[Service]15[Service]
12Type=oneshot16Type=oneshot
@@ -15,11 +19,7 @@ RemainAfterExit=true
15# and 15 if a session is alread logged in (which we do not19# and 15 if a session is alread logged in (which we do not
16# consider an error)20# consider an error)
17SuccessExitStatus=15 2121SuccessExitStatus=15 21
18# iscsiadm will only work if iscsid is running. But we can't use a22# Note: iscsid will be socket activated by iscsiadm
19# Requires= dependency, since restarts of iscsid would then be
20# propagated to this service - and that would cause all sorts of
21# mayhem. Therefore, check it in ExecStartPre.
22ExecStartPre=/bin/systemctl --quiet is-active iscsid.service
23ExecStart=/sbin/iscsiadm -m node --loginall=automatic23ExecStart=/sbin/iscsiadm -m node --loginall=automatic
24ExecStart=/lib/open-iscsi/activate-storage.sh24ExecStart=/lib/open-iscsi/activate-storage.sh
25ExecStop=/lib/open-iscsi/umountiscsi.sh25ExecStop=/lib/open-iscsi/umountiscsi.sh
diff --git a/debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch b/debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
26new file mode 10064426new file mode 100644
index 0000000..d587922
--- /dev/null
+++ b/debian/patches/lp1755858-default-iscsid_conf-to-iscsid_socket.patch
@@ -0,0 +1,25 @@
1Description: default in iscid.conf to use iscsid.socket
2
3People do not want iscsid to run if not needed.
4To do so it is configured to be socket activated.
5Internally iscsid code has a fallback if the service is missing to run the
6command specified in iscsid.conf as "iscsid.startup".
7Set this to ensure the socket is active instead of calling the binary, which
8would not be what we want anyway as it would not be from the .service context.
9
10Forwarded: no (Downstream config)
11Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
12Bug-Ubuntu: https://bugs.launchpad.net/bugs/1755858
13Reviewed-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
14Last-Update: 2020-08-13
15
16--- a/etc/iscsid.conf
17+++ b/etc/iscsid.conf
18@@ -20,6 +20,7 @@
19 #
20 # Default for Fedora and RHEL. (uncomment to activate).
21 # iscsid.startup = /bin/systemctl start iscsid.socket iscsiuio.socket
22+iscsid.startup = /bin/systemctl start iscsid.socket
23 #
24 # Default if you are not using systemd (uncomment to activate)
25 # iscsid.startup = /usr/bin/service start iscsid
diff --git a/debian/patches/series b/debian/patches/series
index 8585afd..909a8f3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1 @@
1upstream/0001-iscsiadm-Fix-memory-leak-in-iscsiadm.patch1lp1755858-default-iscsid_conf-to-iscsid_socket.patch
2upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch
3upstream/0003-Fix-iscsistart-login-issue-when-target-is-delayed.patch
diff --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
4deleted file mode 1006442deleted file mode 100644
index dda9a00..0000000
--- a/debian/patches/upstream/0001-iscsiadm-Fix-memory-leak-in-iscsiadm.patch
+++ /dev/null
@@ -1,156 +0,0 @@
1From: Wenchao Hao <haowenchao@huawei.com>
2Date: Tue, 29 Dec 2020 20:30:25 +0800
3Subject: iscsiadm: Fix memory leak in iscsiadm
4
5Memory allocated by iscsi_context_new() would not be freed if
6error occurred during parameters parser stage and goto free_ifaces
7is used to jump to resource clean.
8
9Since all resource clean is performed after verified, so change
10all goto free_ifaces to goto out where handles resource better.
11
12Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
13---
14 libopeniscsiusr/context.c | 6 +++++-
15 usr/iscsiadm.c | 27 +++++++++++++--------------
16 2 files changed, 18 insertions(+), 15 deletions(-)
17
18diff --git a/libopeniscsiusr/context.c b/libopeniscsiusr/context.c
19index fe92155..c5e869f 100644
20--- a/libopeniscsiusr/context.c
21+++ b/libopeniscsiusr/context.c
22@@ -55,8 +55,12 @@ struct iscsi_context *iscsi_context_new(void)
23
24 void iscsi_context_free(struct iscsi_context *ctx)
25 {
26- if (ctx != NULL)
27+ if (ctx == NULL)
28+ return;
29+
30+ if (ctx->db)
31 _idbm_free(ctx->db);
32+
33 free(ctx);
34 }
35
36diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
37index ea1643b..3987168 100644
38--- a/usr/iscsiadm.c
39+++ b/usr/iscsiadm.c
40@@ -3627,7 +3627,7 @@ main(int argc, char **argv)
41 "Priority must be greater than or "
42 "equal to zero.", killiscsid);
43 rc = ISCSI_ERR_INVAL;
44- goto free_ifaces;
45+ goto out;
46 }
47 break;
48 case 't':
49@@ -3639,7 +3639,7 @@ main(int argc, char **argv)
50 log_error("can not recognize operation: '%s'",
51 optarg);
52 rc = ISCSI_ERR_INVAL;
53- goto free_ifaces;
54+ goto out;
55 }
56 break;
57 case 'n':
58@@ -3651,7 +3651,7 @@ main(int argc, char **argv)
59 case 'H':
60 host_no = parse_host_info(optarg, &rc);
61 if (rc)
62- goto free_ifaces;
63+ goto out;
64 break;
65 case 'r':
66 sid = iscsi_sysfs_get_sid_from_path(optarg);
67@@ -3659,7 +3659,7 @@ main(int argc, char **argv)
68 log_error("invalid sid '%s'",
69 optarg);
70 rc = ISCSI_ERR_INVAL;
71- goto free_ifaces;
72+ goto out;
73 }
74 break;
75 case 'R':
76@@ -3710,7 +3710,7 @@ main(int argc, char **argv)
77 mode = str_to_mode(optarg);
78 rc = verify_mode_params(argc, argv, mode);
79 if (ISCSI_SUCCESS != rc)
80- goto free_ifaces;
81+ goto out;
82 break;
83 case 'C':
84 sub_mode = str_to_submode(optarg);
85@@ -3739,11 +3739,11 @@ main(int argc, char **argv)
86 printf("Invalid iface name %s. Must be from "
87 "1 to %d characters.\n",
88 optarg, ISCSI_MAX_IFACE_LEN - 1);
89- goto free_ifaces;
90+ goto out;
91 } else if (!iface || rc) {
92 printf("Could not add iface %s.", optarg);
93 rc = ISCSI_ERR_INVAL;
94- goto free_ifaces;
95+ goto out;
96 }
97
98 list_add_tail(&iface->list, &ifaces);
99@@ -3760,7 +3760,7 @@ main(int argc, char **argv)
100 log_error("Invalid index %s. %s.",
101 optarg, strerror(errno));
102 rc = ISCSI_ERR_INVAL;
103- goto free_ifaces;
104+ goto out;
105 }
106 break;
107 case 'A':
108@@ -3778,7 +3778,7 @@ main(int argc, char **argv)
109 if (!param) {
110 log_error("Cannot allocate memory for params.");
111 rc = ISCSI_ERR_NOMEM;
112- goto free_ifaces;
113+ goto out;
114 }
115 list_add_tail(&param->list, &params);
116 name = NULL;
117@@ -3789,12 +3789,12 @@ main(int argc, char **argv)
118 if (optopt) {
119 log_error("unrecognized character '%c'", optopt);
120 rc = ISCSI_ERR_INVAL;
121- goto free_ifaces;
122+ goto out;
123 }
124
125 if (killiscsid >= 0) {
126 kill_iscsid(killiscsid, timeout);
127- goto free_ifaces;
128+ goto out;
129 }
130
131 if (mode < 0)
132@@ -3802,14 +3802,14 @@ main(int argc, char **argv)
133
134 if (mode == MODE_FW) {
135 rc = exec_fw_op(NULL, NULL, info_level, do_login, op);
136- goto free_ifaces;
137+ goto out;
138 }
139
140 increase_max_files();
141 if (idbm_init(get_config_file)) {
142 log_warning("exiting due to idbm configuration error");
143 rc = ISCSI_ERR_IDBM;
144- goto free_ifaces;
145+ goto out;
146 }
147
148 switch (mode) {
149@@ -4070,7 +4070,6 @@ out:
150 free(rec);
151 iscsi_sessions_free(ses, se_count);
152 idbm_terminate();
153-free_ifaces:
154 list_for_each_entry_safe(iface, tmp, &ifaces, list) {
155 list_del(&iface->list);
156 free(iface);
diff --git a/debian/patches/upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch b/debian/patches/upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch
157deleted file mode 1006440deleted file mode 100644
index 183bdaa..0000000
--- a/debian/patches/upstream/0002-Fix-iscsiadm-segfault-when-exiting.patch
+++ /dev/null
@@ -1,47 +0,0 @@
1From: Lee Duncan <lduncan@suse.com>
2Date: Tue, 26 Jan 2021 11:48:32 -0800
3Subject: Fix iscsiadm segfault when exiting
4
5Commit b532ad67d495d added some cleanup code
6to iscsiadm right before it exits, but it
7used a list_for_each_entry() to iterate through
8a list was being deleted, when it should use
9list_for_each_entry_safe().
10
11Fixes: b532ad67d495d
12---
13 usr/iscsiadm.c | 8 ++++----
14 1 file changed, 4 insertions(+), 4 deletions(-)
15
16diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
17index 3987168..bb6821d 100644
18--- a/usr/iscsiadm.c
19+++ b/usr/iscsiadm.c
20@@ -3582,11 +3582,11 @@ main(int argc, char **argv)
21 struct sigaction sa_old;
22 struct sigaction sa_new;
23 LIST_HEAD(ifaces);
24- struct iface_rec *iface = NULL, *tmp;
25+ struct iface_rec *iface = NULL, *tmp_iface;
26 struct node_rec *rec = NULL;
27 uint32_t host_no = MAX_HOST_NO + 1;
28 uint64_t index = ULLONG_MAX;
29- struct user_param *param;
30+ struct user_param *param, *tmp_param;
31 LIST_HEAD(params);
32 struct iscsi_context *ctx = NULL;
33 int librc = LIBISCSI_OK;
34@@ -4070,11 +4070,11 @@ out:
35 free(rec);
36 iscsi_sessions_free(ses, se_count);
37 idbm_terminate();
38- list_for_each_entry_safe(iface, tmp, &ifaces, list) {
39+ list_for_each_entry_safe(iface, tmp_iface, &ifaces, list) {
40 list_del(&iface->list);
41 free(iface);
42 }
43- list_for_each_entry(param, &params, list) {
44+ list_for_each_entry_safe(param, tmp_param, &params, list) {
45 list_del(&param->list);
46 idbm_free_user_param(param);
47 }
diff --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
48deleted file mode 1006440deleted file mode 100644
index 6602f3a..0000000
--- a/debian/patches/upstream/0003-Fix-iscsistart-login-issue-when-target-is-delayed.patch
+++ /dev/null
@@ -1,58 +0,0 @@
1From: Lee Duncan <lduncan@suse.com>
2Date: Thu, 4 Feb 2021 11:45:00 -0800
3Subject: Fix iscsistart login issue when target is delayed.
4
5Earlier commit 9258c8eae046 changed the return value fron
6iscsid_response() from ISCSI_ERR_ISCSID_NOTCONN to
7ISCSI_ERR_SESSION_NOT_CONNECTED in the case where no iscsi response is
8received when expected.
9
10This effected the login code in iscsistart when the target is not
11completely ready at iscsi login time. This commit updates iscsistart
12to expect the new error code, but fixing this uncovered another issue,
13causing iscsistart logins to continue to fail if the target returned its
14login response too slowly.
15
16This commit ups the timeout time for iscsistart logins from 1 second per
17try to 10 seconds per try. This is perhaps excessive, and a shorter
18delay would be more appropriate, but the retry/nanosleep logic in
19iscsistart meant to retry the login in such cases seems problematic in
20this case, since retrying the 2nd time returns "session already exists",
21and most iscsistart clients aren't prepared for the command to return a
22non-zero return value.
23---
24 usr/iscsistart.c | 17 +++++++++++++++--
25 1 file changed, 15 insertions(+), 2 deletions(-)
26
27diff --git a/usr/iscsistart.c b/usr/iscsistart.c
28index 73991b3..755489f 100644
29--- a/usr/iscsistart.c
30+++ b/usr/iscsistart.c
31@@ -241,12 +241,25 @@ static int login_session(struct node_rec *rec)
32 /*
33 * Need to handle race where iscsid proc is starting up while we are
34 * trying to connect. Retry with exponential backoff, start from 50 ms.
35+ *
36+ * NOTE: another race condition can occur if the system is just coming
37+ * up, where our login request will be sent, but the login response
38+ * takes a while. In such a case, if we timeout and give up, the
39+ * login response may still show up once we give up, in which case
40+ * it seems to get iscsistart into a state where it cannot try to
41+ * login again because it thinks there's already a session. So make
42+ * sure our timeout is long enough, on each try, to give the response
43+ * a chance to show up. The old value of 1 second was not enough,
44+ * so we multiply that by 10, which seems reasonable for initial
45+ * login.
46 */
47 for (msec = 50; msec <= 15000; msec <<= 1) {
48- rc = iscsid_exec_req(&req, &rsp, 0, ISCSID_REQ_TIMEOUT);
49+ int tmo = ISCSID_REQ_TIMEOUT * 10;
50+
51+ rc = iscsid_exec_req(&req, &rsp, 0, tmo);
52 if (rc == 0) {
53 return rc;
54- } else if (rc == ISCSI_ERR_ISCSID_NOTCONN) {
55+ } else if (rc == ISCSI_ERR_SESSION_NOT_CONNECTED) {
56 ts.tv_sec = msec / 1000;
57 ts.tv_nsec = (msec % 1000) * 1000000L;
58
diff --git a/debian/rules b/debian/rules
index 2451953..7eac4a3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,10 @@ export KBUILD_BUILD_TIMESTAMP = @$(SOURCE_DATE_EPOCH)
1111
12UDEB := $(filter open-iscsi-udeb,$(shell dh_listpackages))12UDEB := $(filter open-iscsi-udeb,$(shell dh_listpackages))
1313
14# Fix gcc10 warnings as errors while upstream doesn't catch up
15export DEB_CFLAGS_PREPEND=-Wno-error=zero-length-bounds -Wno-error=format-overflow= -Wno-error=format-truncation= -Wno-error=maybe-uninitialized
16export DEB_CXXFLAGS_PREPEND=${DEB_CFLAGS_PREPEND}
17
14%:18%:
15 dh $@19 dh $@
1620
@@ -43,6 +47,9 @@ override_dh_auto_install:
43 dh_install -p open-iscsi debian/extra/logout-all.sh lib/open-iscsi/47 dh_install -p open-iscsi debian/extra/logout-all.sh lib/open-iscsi/
44 dh_install -p open-iscsi debian/extra/startup-checks.sh lib/open-iscsi/48 dh_install -p open-iscsi debian/extra/startup-checks.sh lib/open-iscsi/
45 dh_install -p open-iscsi debian/extra/activate-storage.sh lib/open-iscsi/49 dh_install -p open-iscsi debian/extra/activate-storage.sh lib/open-iscsi/
50 dh_install -p open-iscsi debian/extra/net-interface-handler lib/open-iscsi/
51 dh_install -p open-iscsi debian/open-iscsi.finalrd usr/share/finalrd/
52 dh_install -p open-iscsi etc/systemd/iscsid.socket lib/systemd/system/
46 mkdir -p debian/open-iscsi/usr/bin53 mkdir -p debian/open-iscsi/usr/bin
47 ln -s /sbin/iscsiadm debian/open-iscsi/usr/bin/iscsiadm54 ln -s /sbin/iscsiadm debian/open-iscsi/usr/bin/iscsiadm
48 mkdir -p debian/open-iscsi/usr/share/initramfs-tools/hooks55 mkdir -p debian/open-iscsi/usr/share/initramfs-tools/hooks
@@ -51,10 +58,9 @@ override_dh_auto_install:
51 cp -p debian/extra/initramfs.hook debian/open-iscsi/usr/share/initramfs-tools/hooks/iscsi58 cp -p debian/extra/initramfs.hook debian/open-iscsi/usr/share/initramfs-tools/hooks/iscsi
52 cp -p debian/extra/initramfs.local-top debian/open-iscsi/usr/share/initramfs-tools/scripts/local-top/iscsi59 cp -p debian/extra/initramfs.local-top debian/open-iscsi/usr/share/initramfs-tools/scripts/local-top/iscsi
53 cp -p debian/extra/initramfs.local-bottom debian/open-iscsi/usr/share/initramfs-tools/scripts/local-bottom/iscsi60 cp -p debian/extra/initramfs.local-bottom debian/open-iscsi/usr/share/initramfs-tools/scripts/local-bottom/iscsi
54 mkdir -p debian/open-iscsi/lib/modules-load.d/
55 cp -p debian/open-iscsi.kmod debian/open-iscsi/lib/modules-load.d/open-iscsi.conf
56 mkdir -p debian/open-iscsi/lib/udev/rules.d/61 mkdir -p debian/open-iscsi/lib/udev/rules.d/
57 cp -p debian/open-iscsi.rules debian/open-iscsi/lib/udev/rules.d/70-open-iscsi.rules62 cp -p debian/open-iscsi.rules debian/open-iscsi/lib/udev/rules.d/70-open-iscsi.rules
63 cp -p debian/iscsi-network-interface.rules debian/open-iscsi/lib/udev/rules.d/70-iscsi-network-interface.rules
5864
59 @# iscsiuio65 @# iscsiuio
60 dh_install -p iscsiuio iscsiuio/src/unix/iscsiuio /sbin66 dh_install -p iscsiuio iscsiuio/src/unix/iscsiuio /sbin
@@ -77,17 +83,19 @@ ifneq ($(UDEB),)
77endif83endif
7884
79override_dh_installinit:85override_dh_installinit:
80 dh_installinit -p open-iscsi --name=iscsid86 dh_installinit -p open-iscsi --no-start --no-enable --no-stop-on-upgrade --name=iscsid
81 dh_installinit -p open-iscsi87 dh_installinit -p open-iscsi --no-start --no-enable --no-stop-on-upgrade
82 dh_installinit -p iscsiuio88 dh_installinit -p iscsiuio --no-start --no-enable --no-stop-on-upgrade
8389
84override_dh_systemd_enable:90override_dh_systemd_enable:
85 dh_systemd_enable -p open-iscsi --name=iscsid91 dh_systemd_enable -p open-iscsi --name=iscsid --no-enable iscsid.service
86 dh_systemd_enable -p open-iscsi92 dh_systemd_enable -p open-iscsi --name=iscsid iscsid.socket
93 dh_systemd_enable -p open-iscsi open-iscsi.service
87 dh_systemd_enable -p iscsiuio94 dh_systemd_enable -p iscsiuio
8895
89override_dh_systemd_start:96override_dh_systemd_start:
90 dh_systemd_start -p open-iscsi --no-restart-on-upgrade iscsid.service open-iscsi.service97 dh_systemd_start -p open-iscsi --no-restart-on-upgrade iscsid.socket
98 dh_systemd_start -p open-iscsi --no-restart-on-upgrade open-iscsi.service
91 dh_systemd_start -p iscsiuio --no-restart-on-upgrade iscsiuio.service99 dh_systemd_start -p iscsiuio --no-restart-on-upgrade iscsiuio.service
92100
93override_dh_installman:101override_dh_installman:
@@ -110,3 +118,14 @@ ifneq ($(UDEB),)
110else118else
111 dh_makeshlibs119 dh_makeshlibs
112endif120endif
121
122# The following is taken from the initramfs-tools package. (We recommend
123# busybox in the initramfs because otherwise we don't have access to the
124# ip utility to set the default gateway after iscsistart -N is done.)
125# On Debian we can use either busybox or busybox-static, but on Ubuntu
126# and derivatives only busybox-initramfs will work.
127BUSYBOX_PACKAGES := $(shell if dpkg-vendor --derives-from ubuntu; then echo busybox-initramfs; else echo busybox busybox-static; fi)
128
129override_dh_gencontrol:
130 echo >> debian/open-iscsi.substvars "busybox:Recommends=$(wordlist 2,100,$(BUSYBOX_PACKAGES:%=| %))"
131 dh_gencontrol
diff --git a/debian/tests/README-boot-test.md b/debian/tests/README-boot-test.md
113new file mode 100644132new file mode 100644
index 0000000..e45bbf0
--- /dev/null
+++ b/debian/tests/README-boot-test.md
@@ -0,0 +1,139 @@
1## open-iscsi boot test
2The purpose of this test (`CloudImageTest`) is to test the boot of a system
3using an iscsi root target. In order to accomplish that, the tests does
4
5 1. Download Ubuntu cloud image
6 2. installs the open-iscsi deb inside
7 3. collect kernel and initramfs from inside
8 4. register the image as a read-only iscsi target served by tgt
9 5. boot kernel and initramfs with a command line to use the image as root.
10 And additionally attach a local disk for collecting output.
11 6. provide user-data that executes commands, colects files and writes them
12 to the output disk and then shuts the system down.
13 7. extract the collected files from the output disk and inspect them.
14
15The `CloudImageTest` uses qemu user networking.
16
17
18## Caveats
19
20 1. It depends on a cloud-image being present.
21
22 Cloud-images are often not available for the first few weeks of a cycle.
23 If no cloud-image of 'REL' is available, then boot-test will skip.
24 If 'REL' is not known in distro-info-data, then test will fail.
25
26 This means that uploads of open-iscsi (or its dependencies) will not
27 be properly tested until a cloud-image is available, and will fail
28 until distro-info-data is uploaded.
29
30 2. Installation of large packages via patch-image may fail.
31 An ubuntu image downloaded has only a small amount of extra space.
32 Installation of a new kernel into the target would probably fail.
33
34 If this becomes a problem, we could grow the disk like done at
35 https://gist.github.com/smoser/6a048a0e2795b48221fc44962202fa14
36
37
38### testing manually ###
39The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
40
41 * **patch-image**: this is used to install packages into the pristine image
42 and collect the kernel and initramfs out of the image. This allows us to
43 test the portions of open-iscsi that update the initramfs. Without
44 using the updated initramfs we wouldn't really be testing the new
45 open-iscsi.
46
47 It will upgrade any packages inside that are mentioned in
48 ADT_TEST_TRIGGERS environment. It will also install open-iscsi if
49 it is not in that list.
50
51 It installs packages into the target by copying the host system's
52 /etc/apt content in, and also includes copying local (file://) apt
53 repos into the target. This is necessary for the autopackage test
54 environment that adds local package repositories to sources.list.d.
55
56 It may also make other changes to the image to workaround bugs.
57 See --help output for list of bugs.
58
59 * **get-image**: This downloads an image from cloud-images.ubuntu.com. See
60 its Usage for more information. it downloads via stream data and verifies
61 download. One thing to note is that it does not overwrite existing files.
62
63 * **tgt-boot-test**: this registers an image in tgt locally, and then boots
64 kernel and initramfs to mount that. It knows how to build iscsi kernel
65 command lines.
66
67 By default, the xkvm process that is started will be allowed `60m` to
68 complete. This can be adjusted by setting `BOOT_TIMEOUT` in the
69 environment.
70
71 * **xkvm**: this is a helper/wrapper around qemu. It is taken from the curtin
72 projects tools/ directory. It allows some simplified command lines, and
73 most usefully, the '--netdev=<bridge>' argument will create a tun/tap
74 device and attach it to the bridge.
75
76 If the host system is not bare metal, kvm will not be
77 enabled in the guest that is lauched. To force use of kvm, set
78 _USE_KVM=1 in the environment. See 'should_try_kvm' in xkvm for details.
79
80Testing manually looks like this:
81
82 ## set up path to include debian/tests directory.
83 $ PATH=$PWD/debian/tests:$PATH
84
85 ## Get the image you want. This creates out.d/disk.img and disk.img.dist
86 $ get-image xenial.d xenial
87
88 ## patch the image with an open-iscsi, which creates xenial.d/kernel
89 ## and xenial.d/initrd from the kernel and initramfs inside the image.
90 $ apt-get download open-iscsi
91 $ deb=$(ls open-iscsi_*.deb | tail -n 1)
92 $ sudo ./debian/tests/patch-image \
93 --kernel=xenial.d/kernel --initrd=xenial.d/initrd
94 xenial.d/disk.img "$deb"
95
96 ## Boot the system, log in, look around.
97 $ tgt-boot-test -v xenial.d/disk.img xenial.d/kernel xenial.d/initrd
98
99
100### Features of tgt-boot-test ###
101
102tgt-boot-test does a number of useful things.
103
104 * determines the host address that the guest will use.
105 This should support ipv6 and ipv4 addresses on bridges, and
106 knows values that qemu's user networking uses. Flags passed to `--netdev`
107 are read intelligently. This can be overriden with `--host-addr`, but
108 it does a good job of determining what the right values are.
109
110 * provides a nocloud metadata service with a python web server that
111 supports ipv4 and ipv6.
112
113 * provides the ability to provide additional kernel command line options
114 or to provide a 'template' that references variables it knows such as
115 {iserver} (iscsi server) or {seed_url}.
116
117 * Sets ubuntu (passw0rd) and root password (root) and imports users
118 ssh keys to the ubuntu user.
119
120One thing to note is that yakkety's version of qemu does not run an ipv6
121dhcp server on its user-network, so a stateful dhclient request will not
122work.
123
124In order to create a bridge easily with a ipv6 dhcp server, you can use
125lxd at sufficent version (https://github.com/lxc/lxd/issues/2481).
126Assuming that bug is fixed, to create an ipv6 only bridge:
127
128 $ netname="ipv6-only"
129 $ lxc network create $netname
130 $ lxc network unset $netname ipv4.address
131 $ lxc network unset $netname ipv4.nat
132 $ lxc network set $netname ipv6.dhcp.stateful true
133
134Then, you can use tgt-boot-test with that:
135
136 $ PATH=$PWD/debian/tests:$PATH
137 $ ./debian/tests/tgt-boot-test -vv --netdev=ipv6-only \
138 --cmdline-ip="ip=off ip6=dhcp" \
139 disk.img kernel initramfs
diff --git a/debian/tests/control b/debian/tests/control
index 7b3c9e2..0fcfd11 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,6 +1,10 @@
1Tests: install1Tests: install
2Restrictions: needs-root, isolation-machine, breaks-testbed2Restrictions: needs-root, isolation-machine, breaks-testbed
33
4Tests: testsuite
5Restrictions: needs-root isolation-machine breaks-testbed
6Depends: open-iscsi, python3, tgt, qemu-system, ubuntu-cloudimage-keyring, simplestreams, python3-netifaces, distro-info, cloud-image-utils, dctrl-tools, rsync
7
4Tests: nested8Tests: nested
5Restrictions: needs-root, isolation-machine, breaks-testbed, allow-stderr9Restrictions: needs-root, isolation-machine, breaks-testbed, allow-stderr
6Depends: targetcli-fb, qemu-system, qemu-utils, python3, python3-netifaces10Depends: targetcli-fb, qemu-system, qemu-utils, python3, python3-netifaces
diff --git a/debian/tests/get-image b/debian/tests/get-image
7new file mode 10075511new file mode 100755
index 0000000..41b903c
--- /dev/null
+++ b/debian/tests/get-image
@@ -0,0 +1,227 @@
1#!/bin/bash
2Usage() {
3 cat <<EOF
4${0##*/} out-directory release
5
6By default, the cloud image for 'release' is downloaded from the
7daily cloud image stream.
8
9Additional arguments can change behavior of what is downloaded.
10Some supported arguments:
11 * cloud-daily: use daily stream [default]
12 * cloud-release: use release stream rather than daily stream.
13 * maas-release, maas-daily: download maas images instead of cloud-image
14 * hwe-N: download the hwe kernel from release 'N' instead of default
15 this is only respected if maas stream is used.
16 * YYYYMMDD[.X] : download the specific build version
17
18example:
19 ${0##*/} xenial_dir xenial cloud-daily
20EOF
21}
22TEMP_D=""
23
24NO_IMAGE_AVAILABLE_RC=3
25
26cleanup() {
27 [ ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
28}
29VERBOSITY=1
30inargs() {
31 local n=$1 x="";
32 shift;
33 for x in "$@"; do [ "$n" = "$x" ] && return 0; done;
34 return 1
35}
36debug() { [ $1 -ge $VERBOSITY ] || return 0; shift; echo "$@" 1>&2; }
37error() { echo "$@" 1>&2; }
38fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
39
40VERBOSITY=0
41TEMP_D=$(mktemp -d ${TMPDIR:-/tmp}/${0##*/}.XXXXXX) || exit 1
42trap cleanup EXIT
43
44arches=( ppc64el i386 amd64 )
45releases=( $(ubuntu-distro-info --all) )
46mbase="http://maas.ubuntu.com/images/ephemeral-v2"
47cbase="http://cloud-images.ubuntu.com"
48def_stream_type="cloud"
49stream_src=""
50curbase="$mbase"
51def_rel="xenial"
52vername=""
53
54[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; }
55[ $# -lt 2 ] && { Usage 1>&2; exit 1; }
56out_d="$1"
57shift
58
59myarch=$(uname -m)
60case "$myarch" in
61 ppc64*) def_arch="ppc64el";;
62 i?86) def_arch="i386";;
63 x86_64) def_arch="amd64";;
64 arm*) def_arch="armel";;
65esac
66
67pt=( )
68for x in "$@"; do
69 inargs "$x" "${arches[@]}" && pt[${#pt[@]}]=arch=$x && arch="$x" && continue
70 inargs "$x" "${releases[@]}" && pt[${#pt[@]}]="release=$x" && release=$x && continue
71 [ "$x" = "released" -o "$x" = "release" ] && x="releases"
72 case "$x" in
73 cloud-released|cloud-release) x="cloud-releases";;
74 maas-released|maas-release) x="maas-releases";;
75 esac
76
77 case "$x" in
78 maas|cloud) stream_type="$x";;
79 cloud-daily|maas-daily|cloud-releases|maas-releases)
80 stream_type="${x%-*}"
81 stream_sub=${x#*-};;
82 http://*) stream=$x;;
83 hwe-*) subarch="$x";;
84 subarch=*) subarch=${x#*=};;
85 *=*) pt[${#pt[@]}]="$x";;
86 *~*) pt[${#pt[@]}]="$x";;
87 [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])
88 pt[${#pt[@]}]="version_name=$x"
89 vername="$x";;
90 *) fail "Confused by input token '$x'";;
91 esac
92done
93
94[ -n "$stream_type" ] || stream_type="${def_stream_type}"
95if [ -z "$stream" ]; then
96 stream_sub=${stream_sub:-daily}
97 case "$stream_type" in
98 maas) stream="$mbase/$stream_sub";;
99 cloud) stream="$cbase/$stream_sub";;
100 *) fail "unknown stream_type '$stream_type'";;
101 esac
102fi
103
104[ -n "$arch" ] || pt[${#pt[@]}]="arch=$def_arch"
105
106if [ "$stream_type" = "maas" ]; then
107 if [ -z "$subarch" ]; then
108 t=${release#?}
109 first_letter=${release%${t}}
110 subarch="hwe-${first_letter}"
111 error "selected subarch=${subarch} for $release"
112 fi
113 pt[${#pt[@]}]="subarch=$subarch"
114 ofmt="%(sha256)s %(ftype)s %(subarch)s %(item_url)s"
115else
116 ofmt="%(sha256)s %(ftype)s %(item_url)s"
117fi
118
119OIFS="$IFS"
120mkdir -p "$out_d"
121case "$stream" in
122 *.json) :;;
123 *) keyring="/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg";;
124esac
125
126needs=""
127[ -n "$keyring" -a ! -f "$keyring" ] &&
128 needs="${needs} ubuntu-cloudimage-keyring"
129
130for pair in sstream-query:simplestreams tgt-admin:tgt; do
131 cmd=${pair%:*}
132 pkg=${pair#*:}
133 command -v "$cmd" >/dev/null 2>&1 || needs="$needs $pkg"
134done
135
136if [ -n "${needs# }" ]; then
137 error "missing dependencies"
138 fail "sudo apt-get install -qy ${needs# }"
139fi
140
141qcmd=( sstream-query ${keyring:+"--keyring=$keyring"} ${vername:---max=1}
142 --output-format="$ofmt" "${stream}" datatype="image-downloads"
143 "${pt[@]}" )
144echo "${qcmd[@]}"
145"${qcmd[@]}" > "${TEMP_D}/qout"
146roots=$(awk '$2 == "root-image.gz" || $2 == "disk1.img" { print $2 }' \
147 "${TEMP_D}/qout" | sort -u | wc -l)
148if [ "$roots" = "0" ]; then
149 error "No image available for $release in $stream${pt:+ (${pt[*]})}"
150 exit ${NO_IMAGE_AVAILABLE_RC}
151elif [ "$roots" != "1" ]; then
152 error "query resulted in '$roots' root images. expect 1 and only 1"
153 error "cmd was ${qcmd[*]}"
154 cat "${TEMP_D}/qout"
155 fail
156fi
157
158set -f
159while read line; do
160 set -- $line
161 if [ "$stream_type" = "maas" ]; then
162 sha256="$1"; ftype="$2"; subarch="$3"; url="$4"
163 else
164 sha256="$1"; ftype="$2"; url="$3"
165 fi
166 case "$ftype" in
167 boot-kernel|boot-initrd|root-image.gz|disk1.img) :;;
168 *) continue
169 esac
170 if [ "$ftype" = "root-image.gz" ]; then
171 fname="$ftype"
172 image_src="$out_d/$fname"
173 image="$out_d/root-image"
174 elif [ "$ftype" = "disk1.img" ]; then
175 fname="disk.img.dist"
176 image_src="$out_d/$fname"
177 image="$out_d/disk.img"
178 else
179 fname="$subarch/$ftype"
180 fi
181 out_f="${out_d}/$fname"
182 if [ -f "$out_f" ]; then
183 debug 1 "reusing existing '$out_f' rather than downloading $url."
184 continue
185 fi
186 [ -d "${out_f%/*}" ] || mkdir -p "${out_f%/*}"
187 tmp="${out_f}.tmp"
188 wget --progress=dot:mega -O "$tmp" "$url" || {
189 error "Failed to download $url to $tmp."
190 rm -f "$tmp"
191 exit 3
192 }
193 debug 1 "checksumming $tmp from $url"
194 out=$(sha256sum "$tmp") || {
195 error "Failed to checksum $tmp"
196 rm -f "$tmp"
197 exit 3;
198 }
199 found=${out% *}
200 if [ "$found" != "$sha256" ]; then
201 error "$tmp from $url found sha256 of $found. expected $sha256."
202 ls -l "$tmp" 1>&2
203 rm -f "$tmp"
204 exit 3
205 fi
206 mv "$tmp" "$out_f" || fail "failed renaming $tmp to $out_f"
207 echo "$fname" "$url" >> "$out_d/contents"
208done < "${TEMP_D}/qout"
209
210if [ ! -f "$image" ]; then
211 case "$image_src" in
212 */root-image.gz)
213 debug 1 "decompressing $image_src"
214 zcat "$image_src" > "$image.tmp" &&
215 mv "$image.tmp" "$image" ||
216 { rm -f "$image.tmp"; exit 1; }
217 ;;
218 */disk.img.dist)
219 debug 1 "converting qcow2 in $image_src -> raw in $image"
220 qemu-img convert -O raw "$image_src" "$image.tmp" &&
221 mv "$image.tmp" "$image" ||
222 { rm -f "$image.tmp"; exit 1; }
223 ;;
224 esac
225fi
226
227# vi: ts=4 expandtab
diff --git a/debian/tests/install b/debian/tests/install
index ae2fe79..5077b7b 100755
--- a/debian/tests/install
+++ b/debian/tests/install
@@ -28,5 +28,8 @@ grep -vq '^GenerateName=yes' /etc/iscsi/initiatorname.iscsi || die_with_file /et
28grep -q '^InitiatorName=' /etc/iscsi/initiatorname.iscsi || die_with_file /etc/iscsi/initiatorname.iscsi "InitiatorName is not set"28grep -q '^InitiatorName=' /etc/iscsi/initiatorname.iscsi || die_with_file /etc/iscsi/initiatorname.iscsi "InitiatorName is not set"
2929
30# Make sure the daemon is started30# Make sure the daemon is started
31service iscsid status || die "iscsid not running"31systemctl is-active iscsid.socket || die "iscsid socket not running"
32pgrep -c iscsid >/dev/null || die "iscsid not running"32# no-op discovery to socket activate service
33iscsiadm -m discovery -t sendtargets -p 127.0.0.1 >/dev/null 2>&1|| /bin/true
34systemctl is-active iscsid.service || die "iscsid service not running"
35pgrep -c iscsid >/dev/null || die "iscsid process not running"
diff --git a/debian/tests/patch-image b/debian/tests/patch-image
33new file mode 10075536new file mode 100755
index 0000000..0688912
--- /dev/null
+++ b/debian/tests/patch-image
@@ -0,0 +1,374 @@
1#!/bin/bash
2
3VERBOSITY=1
4TEMP_D=""
5
6error() { echo "$@" 1>&2; }
7fail() { local r=$?; [ $r -eq 0 ] && r=1; failrc "$r" "$@"; }
8failrc() { local r=$1; shift; [ $# -eq 0 ] || error "$@"; exit $r; }
9
10Usage() {
11 cat <<EOF
12Usage: ${0##*/} [options] image [packages]
13 Patch image, upgrading [packages].
14 --kernel FILE copy kernel out to FILE
15 --initrd FILE copy initrd out to FILE
16
17 --krd-only only copy out kernel/initrd do not change image.
18 this is incompatible with 'packages'
19 it is a short-cut to specifying all the '--no-*'
20 options below.
21
22 --no-copy-apt do not copy host's apt repos in.
23
24 image modifications:
25 --no-update-fstab do not modify fstab (LP: #1732028)
26
27 if no packages are provided, and ADT_TEST_TRIGGERS is set
28 in environment, then it will be read for the list of packages.
29 to override that behavior pass package 'none'.
30EOF
31
32}
33
34bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return 1; }
35cleanup() {
36 [ -z "${TEMP_D}" -o ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
37}
38
39debug() {
40 local level=${1}; shift;
41 [ "${level}" -gt "${VERBOSITY}" ] && return
42 error "${@}"
43}
44
45adt_test_triggers_to_bin_pkgs() {
46 # ADT_TEST_TRIGGERS is space delimited <src>/version
47 # returns a scalar '_RET', caller has to expand
48 local tok src="" ver="" binpkgs=""
49 for tok in "$@"; do
50 src=${tok%/*}
51 ver=${tok#*/}
52 bin_packages_from_source_pkg "$src" "$ver" || return
53 if [ -z "${_RET}" ]; then
54 error "$tok: (source=$src ver=$ver) No packages available!"
55 return 1
56 fi
57 binpkgs="${binpkgs} ${_RET}"
58 done
59 _RET=${binpkgs# }
60}
61
62bin_packages_from_source_pkg() {
63 local pkg=$1 ver=${2} cmd="" out="" p="" ret=""
64 if ! command -v grep-aptavail >/dev/null; then
65 error "No command grep-aptavail: apt-get install dctrl-tools"
66 return 1
67 fi
68 cmd=( grep-aptavail --show-field=Package
69 --exact-match --field=Source:Package "$pkg" )
70 if [ -n "$ver" ]; then
71 cmd=( "${cmd[@]}" --and --field=Version "$ver" )
72 fi
73 out=$("${cmd[@]}" | sed 's,Package: ,,')
74 ret=""
75 for p in $out; do
76 ret="$ret ${p#Package: }${ver:+=${ver}}"
77 done
78 # if no version was provided, we could have multiple results
79 _RET=$(set -f; for i in ${ret}; do echo "$i"; done | sort -u)
80}
81
82update_fstab() {
83 # update_fstab(path) modify the fstab at path
84 # to remove problematic entries (LP: #1732028)
85 local fstab="$1"
86 if [ ! -e "$fstab.patch-image-dist" ]; then
87 cp "$fstab" "$fstab.patch-image-dist" ||
88 { error "failed backing up $fstab to $fstab.dist"; return 1; }
89 fi
90 sed -i '/^LABEL=UEFI/s/^/#/' "$fstab"
91}
92
93cat_debug_script() {
94 cat <<"EOF"
95#!/bin/sh
96set -f
97NAME=${1:-debug-pid-$$}
98[ "$(id -u)" = "0" ] && log="/run/${NAME}.log" || log="/tmp/${NAME}.log"
99
100msg() {
101 echo "===" "$@" "===" 1>&2
102}
103showcmd() {
104 msg "showcmd$" "$@"
105 "$@"
106}
107
108main() {
109 issues=$(journalctl | egrep "[.]mount: ")
110 if [ -z "$issues" ]; then
111 msg "$NAME:" "MOUNT ISSUES FOUND: NO"
112 else
113 msg "$NAME:" "MOUNT ISSUES FOUND: YES"
114 fi
115 showcmd systemctl list-units --no-pager --all --full "*.mount"
116 showcmd systemctl cat --no-pager --all --full "*.mount"
117 showcmd systemctl status --no-pager --all --full "*.mount"
118 showcmd cat /etc/fstab
119 showcmd cat /proc/1/mountinfo
120}
121
122main > "$log" 2>&1
123echo "============ $NAME ============="
124cat "$log"
125EOF
126}
127
128add_systemd_job() {
129 local target="$1" name="$2" after="$3" start="$4"
130 local spath="lib/systemd/system/xdebug-$name.service"
131 debug 1 "writing $name to $target/$spath"
132 cat > "$target/$spath" <<EOF
133[Unit]
134Description=Execute xdebug ${name}
135After=${after}
136
137[Service]
138Type=oneshot
139ExecStart=${start} ${name}
140RemainAfterExit=yes
141StandardOutput=journal+console
142
143[Install]
144WantedBy=multi-user.target
145EOF
146 [ $? -eq 0 ] || { error "failed writing $target/$spath"; return 1; }
147 local wantsdir="$target/etc/systemd/system/multi-user.target.wants"
148 ln -s "/$spath" "$wantsdir/" ||
149 { error "failed ln -s '/$spath' '$wantsdir/'"; return 1; }
150}
151
152insert_debug_1788188() {
153 # This is an attempt to collect more debug information in the
154 # event that the tests trigger LP: #1788188.
155 local target="$1"
156 [ "$target" = "/" -o -z "$target" ] &&
157 { error "target was / in insert_debug"; return 1; }
158 local script="usr/local/bin/debug-mounts"
159 cat_debug_script > "$target/$script" &&
160 chmod 755 "$target/$script" ||
161 { error "failed writing $target/script"; return 1; }
162 local name=""
163 ( set +f;
164 rm -f "$target/lib/systemd/system/xdebug"-*.service \
165 "$target/etc/systemd/system/"*.wants/xdebug*.service )
166 add_systemd_job "$target" network network-online.target "/$script" &&
167 add_systemd_job "$target" local-fs local-fs.target "/$script" ||
168 { error "failed adding systemd jobs"; return 1; }
169}
170
171main() {
172 local short_opts="hv"
173 local long_opts="help,no-copy-apt,initrd:,kernel:,verbose"
174 local getopt_out="" orig_args=""
175 orig_args=( "$@" )
176 getopt_out=$(getopt --name "${0##*/}" \
177 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
178 eval set -- "${getopt_out}" ||
179 { bad_Usage; return; }
180
181 local cur="" next=""
182 local kernel="" initrd="" copy_apt=true krd_only=false
183 local update_fstab=true
184
185 while [ $# -ne 0 ]; do
186 cur="$1"; next="$2";
187 case "$cur" in
188 -h|--help) Usage ; exit 0;;
189 --krd-only) krd_only=true; shift;;
190 --no-copy-apt) copy_apt=false; shift;;
191 --no-update-fstab) update_fstab=false; shift;;
192 --kernel) kernel=$next; shift;;
193 --initrd) initrd=$next; shift;;
194 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
195 --) shift; break;;
196 esac
197 shift;
198 done
199
200 [ $# -ne 0 ] || { bad_Usage "must provide at least image"; return; }
201
202 [ "$(id -u)" = "0" ] || fail "not root"
203 target="$1"
204 shift
205 if [ -f "$target" ]; then
206 local nargs=""
207 nargs=( "${orig_args[@]}" )
208 # replace the first occurance of target in orig args with _MOUNTPOINT_
209 for((i=0;i<${#nargs[@]};i++)); do
210 [ "${nargs[$i]}" = "$target" ] && nargs[$i]=_MOUNTPOINT_ && break
211 done
212 debug 1 "mic $target -- $0 ${nargs[*]}"
213 IMAGE="$target" exec mount-image-callback \
214 --system-resolvconf "$target" -- "$0" "${nargs[@]}"
215 fi
216
217 if [ ! -d "$target" ]; then
218 fail "$target: not a directory or file"
219 fi
220
221 local tsrc=${IMAGE:-${target}}
222 local packages=( )
223 packages=( "$@" )
224
225 if $krd_only; then
226 if [ "${#packages[@]}" != 0 -a "${packages[*]}" != "none" ]; then
227 error "--krd-only is incompatible with packages."
228 return 1
229 fi
230 debug 1 "--krd-only provided no changes will be done."
231 copy_apt=false
232 update_fstab=false
233 packages=( "none" )
234 fi
235
236 if [ "${#packages[@]}" = "1" -a "${packages[0]}" = "none" ]; then
237 packages=( )
238 elif [ "${#packages[@]}" -eq 0 -a -n "${ADT_TEST_TRIGGERS}" ]; then
239 adt_test_triggers_to_bin_pkgs ${ADT_TEST_TRIGGERS} ||
240 fail "failed to find binary packages " \
241 "from ADT_TEST_TRIGGERS=$ADT_TEST_TRIGGERS"
242 packages=( $_RET )
243 debug 1 "read ADT_TEST_TRIGGERS=$ADT_TEST_TRIGGERS to set" \
244 "packages=${packages[*]}"
245 else
246 local opackages="" debs="" pkg=""
247 opackages=( "${packages[@]}" )
248 packages=( )
249 debs=( )
250 for pkg in "${opackages[@]}"; do
251 [ -f "${pkg}" ] && debs[${#debs[@]}]="$pkg" ||
252 packages[${packages[@]}]="$pkg"
253 done
254 if [ "${#packages[@]}" -eq 0 -a "${#debs[@]}" -eq 0 ]; then
255 packages=( open-iscsi )
256 debug 1 "no packages or debs given, using packages=${packages[*]}"
257 fi
258 fi
259
260 # if open-iscsi is not in the packages list above, we handle it specifically
261 # so that even if the image did not have open-iscsi, it will get it.
262 local pkg="" mypkg="open-iscsi"
263 for pkg in "${packages[@]}"; do
264 case "$pkg" in
265 open-iscsi|open-iscsi/*) mypkg="none";;
266 esac
267 done
268
269 TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") ||
270 fail "failed to make tempdir"
271 trap cleanup EXIT
272
273 if $copy_apt; then
274 local distdir="${target}/etc/apt.dist.${0##*/}"
275 if [ ! -d "$distdir" ]; then
276 mv "$target/etc/apt" "$distdir" ||
277 fail "failed to backup /etc/apt in $tsrc"
278 fi
279 cp -a /etc/apt "$target/etc/" ||
280 fail "failed to replace /etc/apt in $tsrc"
281
282 # find file:// repos in apt sources and copy them in
283 local file_repos=""
284 file_repos=$(
285 fm='s,.*[[:space:]]file:///*\([^[[:space:]]*\).*,/\1,p'
286 shopt -s nullglob
287 for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do
288 sed -n -e 's/#.*//' -e "$fm" "$f"
289 done
290 )
291 local dir="" bdir="" tdir=""
292 for dir in ${file_repos}; do
293 tdir="${target}$(dirname $dir)/$(basename ${dir})"
294 if [ -d "$dir" ]; then
295 debug 1 "copying $dir -> $tdir"
296 mkdir -p "$tdir" ||
297 fail "failed to create $tdir"
298 rsync --delete -a "$dir/" "$tdir" ||
299 fail "failed copy from $dir/ to $tdir"
300 fi
301 done
302 fi
303
304 if $update_fstab; then
305 update_fstab "$target/etc/fstab" ||
306 { error "failed updating /etc/fstab in target"; return 1; }
307 fi
308
309 insert_debug_1788188 "$target" || return 1
310
311 mount -o bind /sys "$target"/sys || :
312 mount -o bind /proc "$target"/proc || :
313 mount -o bind /dev "$target"/dev || :
314 mount -o bind /dev/pts "$target"/dev/pts || :
315
316 debug 1 "${#packages[@]} packages: ${packages[*]}"
317 if [ "${#packages[@]}" != "0" ]; then
318 DEBIAN_FRONTEND=noninteractive chroot "$target" sh -exc '
319 mypkg=$1
320 shift
321 apt-get update -q
322 if [ "$mypkg" != "none" ]; then
323 apt-get install -qy "$mypkg"
324 fi
325 apt-get install -qy --only-upgrade "$@"' \
326 chroot-inst "$mypkg" "${packages[@]}" ||
327 fail "failed to install ${packages[*]} in $target"
328 fi
329
330 debug 1 "${#debs[@]} debs: ${debs[*]}"
331 if [ "${#debs[@]}" != "0" ]; then
332 local tmpd=""
333 tmpd=$(mktemp -d "${target}/tmp/${0##*/}.XXXXXX")
334 cp "${debs[@]}" "$tmpd"
335 DEBIAN_FRONTEND=noninteractive chroot "$target" sh -exc \
336 'cd "$1"; shift; dpkg -i *.deb' debinstalls "${tmpd#${target}}"
337 rm -Rf "${tmpd}"
338 fi
339
340 umount "$target"/dev/pts || :
341 umount "$target"/dev || :
342 umount "$target"/proc || :
343 umount "$target"/sys || :
344
345 local kpath="" ipath=""
346 for f in "$target/boot/"*; do
347 case "${f##*/}" in
348 *.signed) continue;;
349 vmlinu?-*) kpath="$f";;
350 initrd.img-*) ipath="$f";;
351 esac
352 done
353
354 if [ -n "$kernel" ]; then
355 [ -n "$kpath" ] || fail "unable to find kernel in $tsrc"
356 debug 1 "using kernel ${kpath#${target}}"
357 cp "$kpath" "$kernel" ||
358 fail "failed copy $kpath to $kernel"
359 [ -z "$IMAGE" ] || chown "--reference=$IMAGE" "$kernel"
360 fi
361
362 if [ -n "$initrd" ]; then
363 [ -n "$ipath" ] || fail "unable to find initrd in $tsrc"
364 debug 1 "using initrd ${ipath#${target}}"
365 cp "$ipath" "$initrd" ||
366 fail "failed copy $ipath to $initrd"
367 [ -z "$IMAGE" ] || chown "--reference=$IMAGE" "$initrd"
368 fi
369
370}
371
372main "$@"
373
374# vi: ts=4 expandtab
diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
0new file mode 100644375new file mode 100644
index 0000000..1ad8b4f
--- /dev/null
+++ b/debian/tests/test-open-iscsi.py
@@ -0,0 +1,427 @@
1#!/usr/bin/python3
2#
3# test-open-iscsi.py quality assurance test script for open-iscsi
4# Copyright (C) 2011 Canonical Ltd.
5# Author: Jamie Strandboge <jamie@canonical.com>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19# packages required for test to run:
20# QRT-Packages: open-iscsi
21# packages where more than one package can satisfy a runtime requirement:
22# QRT-Alternates:
23# files and directories required for the test to run:
24# QRT-Depends:
25# privilege required for the test to run (remove line if running as user is okay):
26# QRT-Privilege: root
27
28'''
29 In general, this test should be run in a virtual machine (VM) or possibly
30 a chroot and not on a production machine. While efforts are made to make
31 these tests non-destructive, there is no guarantee this script will not
32 alter the machine. You have been warned.
33
34 How to run in a clean VM:
35 $ sudo apt-get -y install <QRT-Packages> && sudo ./test-PKG.py -v'
36
37 How to run in a clean schroot named 'lucid':
38 $ schroot -c lucid -u root -- sh -c 'apt-get -y install <QRT-Packages> && ./test-PKG.py -v'
39
40
41 NOTES:
42 - currently only tested on Ubuntu 8.04
43'''
44
45from __future__ import print_function
46
47from netifaces import gateways, AF_INET
48import unittest, subprocess, sys, os, glob
49import shutil
50import testlib
51import textwrap
52from tempfile import mkdtemp
53import time
54
55# There are setup based on README.multipurpose-vm. Feel free to override.
56remote_server = ''
57username = 'ubuntu'
58password = 'passwd'
59username_in = 'ubuntu'
60password_in = 'ubuntupasswd'
61initiatorname = 'iqn.2009-10.com.example.hardy-multi:iscsi-01'
62
63COLLECT_USER_DATA = """\
64#cloud-config
65bukket:
66 - &get_resolved_status |
67 if [ "${1:--}" != "-" ]; then
68 exec >"$1" 2>&1
69 fi
70 if ! command -v systemd-resolve >/dev/null 2>&1; then
71 echo "systemd-resolve: not available."
72 exit
73 fi
74 if ! ( systemd-resolve --help | grep -q -- --status ); then
75 echo "systemd-resolve: no --status."
76 exit
77 fi
78 systemd-resolve --status --no-pager
79
80 - &get_iscsid_status |
81 [ "${1:--}" != "-" ] && exec >"$1" 2>&1
82 udevadm settle
83 systemctl is-active iscsid.service
84 systemctl status --no-pager --full iscsid.service
85
86 - &add_and_remove_tuntap |
87 #!/bin/sh
88 # LP: #1785108 would break dns when any device was removed.
89 tapdev="mytap0"
90 echo ==== Adding $tapdev ====
91 ip tuntap add mode tap user root $tapdev
92 udevadm settle
93 echo ==== Removing $tapdev ====
94 ip tuntap del mode tap $tapdev
95 udevadm settle
96
97 - &collect_debug_mounts |
98 [ "${1:--}" != "-" ] && exec >"$1" 2>&1
99 [ -x /usr/local/bin/debug-mounts ] || exit 0
100 /usr/local/bin/debug-mounts
101
102runcmd:
103 - [ sh, -c, *add_and_remove_tuntap ]
104 - [ mkdir, -p, /output ]
105 - [ cp, /etc/resolv.conf, /output ]
106 - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt ]
107 - [ sh, -c, *get_iscsid_status, --, /output/iscsid-status.txt ]
108 - [ sh, -c, *collect_debug_mounts, --, /output/debug-mounts.txt ]
109 - [ sh, -c, 'journalctl --boot=0 --output=short-monotonic > /output/journal.txt' ]
110 - [ sh, -c, 'dpkg-query --show > /output/manifest.txt' ]
111 - [ tar, -C, /output, -cf, /dev/disk/by-id/virtio-output-disk, . ]
112
113power_state:
114 mode: poweroff
115 message: cloud-init finished. Shutting down.
116 timeout: 60
117"""
118
119try:
120 from private.qrt.OpenIscsi import PrivateOpenIscsiTest
121except ImportError:
122 class PrivateOpenIscsiTest(object):
123 '''Empty class'''
124 print("Skipping private tests", file=sys.stdout)
125
126class OpenIscsiTest(testlib.TestlibCase, PrivateOpenIscsiTest):
127 '''Test my thing.'''
128
129 def setUp(self):
130 '''Set up prior to each test_* function'''
131 self.pidfile = "/var/run/iscsid.pid"
132 self.exe = "/sbin/iscsid"
133 self.daemon = testlib.TestDaemon("open-iscsi")
134 self.initiatorname_iscsi = '/etc/iscsi/initiatorname.iscsi'
135 self.iscsid_conf = '/etc/iscsi/iscsid.conf'
136
137 def tearDown(self):
138 '''Clean up after each test_* function'''
139 global remote_server
140 global initiatorname
141
142 # If remote server is setup, convert back to manual, logout, remove
143 # testlib configs and restart (in that order)
144 if remote_server != '':
145 testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--op=update', '--name', 'node.startup', '--value=manual'])
146 testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--op=update', '--name', 'node.conn[0].startup', '--value=manual'])
147 testlib.cmd(['iscsiadm', '-m', 'node', '--targetname', initiatorname, '-p', '%s:3260' % remote_server, '--logout'])
148
149 testlib.config_restore(self.initiatorname_iscsi)
150 testlib.config_restore(self.iscsid_conf)
151 self.daemon.restart()
152
153 def test_discovery_with_server(self):
154 '''Test iscsi_discovery to remote server'''
155 global remote_server
156 global username
157 global password
158 global username_in
159 global password_in
160 global initiatorname
161
162 if remote_server == '':
163 return self._skipped("--remote-server not specified")
164
165 contents = '''
166InitiatorName=%s
167InitiatorAlias=ubuntu
168''' % (initiatorname)
169 testlib.config_replace(self.initiatorname_iscsi, contents, True)
170
171 contents = '''
172node.session.auth.authmethod = CHAP
173node.session.auth.username = %s
174node.session.auth.password = %s
175node.session.auth.username_in = %s
176node.session.auth.password_in = %s
177
178discovery.sendtargets.auth.authmethod = CHAP
179discovery.sendtargets.auth.username = %s
180discovery.sendtargets.auth.password = %s
181discovery.sendtargets.auth.username_in = %s
182discovery.sendtargets.auth.password_in = %s
183''' % (username, password, username_in, password_in, username, password, username_in, password_in)
184 testlib.config_replace(self.iscsid_conf, contents, True)
185
186 self.assertTrue(self.daemon.restart())
187 time.sleep(2)
188 self.assertTrue(self.daemon.status()[0])
189
190 rc, report = testlib.cmd(["/sbin/iscsi_discovery", remote_server])
191 expected = 0
192 result = 'Got exit code %d, expected %d\n' % (rc, expected)
193 self.assertEqual(expected, rc, result + report)
194 for i in ['starting discovery to %s' % remote_server,
195 'Testing iser-login to target %s portal %s' % (initiatorname, remote_server),
196 'starting to test tcp-login to target %s portal %s' % (initiatorname, remote_server),
197 'discovered 1 targets at %s, connected to 1' % remote_server]:
198 result = "Could not find '%s' in report:\n" % i
199 self.assertTrue(i in report, result + report)
200
201 def test_net_interface_handler_execute_bit(self):
202 '''Test /lib/open-iscsi/net-interface-handler is executable.'''
203 nih_path = '/lib/open-iscsi/net-interface-handler'
204 self.assertTrue(os.access(nih_path, os.X_OK))
205
206class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
207 '''Test the cloud image can boot on iscsi root.
208
209 See README-boot-test.md for more information.
210 '''
211
212 @classmethod
213 def setUpClass(cls):
214 reason = (
215 "Skipped Cloud Image test on {arch}. whitelisted are: {whitelist}")
216 whitelisted = os.environ.get('WHITELIST_ARCHES', 'amd64').split(",")
217 curarch = testlib.manager.dpkg_arch
218 if testlib.manager.dpkg_arch not in whitelisted:
219 raise unittest.SkipTest(
220 reason.format(arch=curarch, whitelist=whitelisted))
221
222 here = os.path.dirname(os.path.abspath(__file__))
223 os.environ['PATH'] = "%s:%s" % (here, os.environ['PATH'])
224 release = os.environ.get(
225 "ISCSI_TEST_RELEASE", testlib.ubuntu_release())
226 image_d = os.path.join(here, '{}.d'.format(release))
227 # Download MAAS ephemeral image.
228 info = {'release': release,
229 'image_d': image_d,
230 'root_image': os.path.join(image_d, 'disk.img'),
231 'kernel': os.path.join(image_d, 'kernel'),
232 'initrd': os.path.join(image_d, 'initrd')}
233 try:
234 get_image(info['image_d'], release)
235 except subprocess.CalledProcessError as e:
236 if e.return_code != 3:
237 raise e
238 raise unittest.SkipTest(
239 "Cloud Image not available for release '%s'." % release)
240 if os.environ.get("NO_PATCH_IMAGE", "0") == "0":
241 patch_image(info['root_image'],
242 kernel=info['kernel'], initrd=info['initrd'])
243 cls.info = info
244 cls.here = here
245
246 def tearDown(self):
247 super(CloudImageTest, self).tearDown()
248 if os.path.exists(self.tmpdir):
249 shutil.rmtree(self.tmpdir)
250
251 def setUp(self):
252 super(CloudImageTest, self).setUp()
253 self.tmpdir = mkdtemp()
254 udp = os.path.join(self.tmpdir, 'user-data')
255 with open(udp, "w") as fp:
256 fp.write(COLLECT_USER_DATA)
257 self.info['user-data'] = udp
258
259 def create_output_disk(self):
260 path = os.path.join(self.tmpdir, 'output-disk.img')
261 subprocess.check_call([
262 'qemu-img', 'create', '-f', 'raw', path, '10M'])
263 return path
264
265 def extract_files(self, path):
266 # get contents in a dictionary of tarball at 'path'
267 tmpdir = mkdtemp()
268 try:
269 subprocess.check_call(['tar', '-C', tmpdir, '-xf', path])
270 flist = {}
271 prefix = len(tmpdir) + 1
272 for root, dirs, files in os.walk(tmpdir):
273 for fname in files:
274 fpath = os.path.join(root, fname)
275 key = fpath[prefix:]
276 with open(fpath, "r") as fp:
277 flist[key] = fp.read()
278 return flist
279 finally:
280 shutil.rmtree(tmpdir)
281
282 def test_tgt_boot(self):
283 tgt_boot_cmd = os.path.join(self.here, 'tgt-boot-test')
284 # Add self.here to PATH so xkvm will be available to tgt-boot-test
285 dns_addr = '10.1.1.4'
286 rel_dir = '{}.d'.format(self.info['release'])
287 dns_search = 'example.com'
288 info = {'host': '10.1.1.2', 'dns': dns_addr,
289 'dnssearch': dns_search, 'network': '10.1.1.0/24'}
290 netdev = ("--netdev=user,net={network},host={host},dns={dns},"
291 "dnssearch={dnssearch}").format(**info)
292
293 artifacts_dir = os.environ.get('AUTOPKGTEST_ARTIFACTS')
294 if artifacts_dir and not os.path.isdir(artifacts_dir):
295 os.makedirs(artifacts_dir)
296
297 output_disk = self.create_output_disk()
298 cmd = [
299 tgt_boot_cmd, '-v', netdev,
300 '--disk=%s,serial=output-disk' % output_disk,
301 '--user-data-add=%s' % self.info['user-data'],
302 self.info['root_image'], self.info['kernel'],
303 self.info['initrd']]
304 sys.stderr.write(' '.join(cmd) + "\n")
305
306 env = os.environ.copy()
307 env['BOOT_TIMEOUT'] = env.get('BOOT_TIMEOUT', '60m')
308 subprocess.check_call(cmd, env=env)
309
310 if artifacts_dir:
311 tgz = os.path.join(artifacts_dir, "tgt-collected.tar.gz")
312 shutil.copy(output_disk, tgz)
313 print("Copied output_disk '%s' to artifacts dir '%s'" %
314 (output_disk, tgz))
315
316 files = self.extract_files(output_disk)
317 print("collected files: %s" % files.keys())
318 resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
319 resolve_status = files.get('systemd-resolve-status.txt')
320
321 resolvconf_id = 'generated by resolvconf'
322 resolved_addr = "127.0.0.53"
323 if resolvconf_id in resolvconf:
324 print("resolvconf manages resolvconf.\n")
325 self.assertIn(
326 dns_addr, resolvconf,
327 msg = ("%s not in resolvconf contents: \n%s" %
328 (dns_addr, resolvconf)))
329 if dns_search in resolvconf:
330 print("%s was found in resolv.conf." % dns_search)
331 elif resolved_addr in resolvconf and dns_search in resolve_status:
332 # zesty has resolvconf and systemd-resolved.
333 print("%s was in resolve_status and %s in resolv.conf" %
334 (resolved_addr, dns_search))
335 else:
336 raise AssertionError(
337 "%s domain is not being searched." % dns_search)
338
339 else:
340 print("systemd-resolved managing resolve.conf\n")
341 self.assertIn(
342 resolved_addr, resolvconf,
343 msg="%s not in resolved resolv.conf: %s" % (resolved_addr,
344 resolvconf))
345 self.assertIn(dns_addr, resolve_status,
346 msg=("%s not in systemd-resolve status: %s" %
347 (dns_addr, resolve_status)))
348 self.assertIn(dns_search, resolve_status,
349 msg=("search addr '%s' not in systemd-resolve status: %s" %
350 (dns_search, resolve_status)))
351
352 # iscsid-status.txt has first line output from
353 # 'systemctl is-active iscsid.service' and then 'systemcl status'
354 iscsid_status = files.get('iscsid-status.txt')
355 is_active = iscsid_status.splitlines()[0]
356 self.assertEqual(
357 "active", is_active,
358 msg=("Expected iscsid.service active, found '%s'.\n%s\n" %
359 (is_active, iscsid_status)))
360
361
362def get_image(top_d, release):
363 cmd = ['get-image', top_d, 'cloud-daily', release]
364 subprocess.check_call(cmd)
365
366
367def patch_image(image, packages=None, kernel=None, initrd=None):
368 '''Patch root-image with dep8 built open-iscsi package.'''
369
370 if packages is None:
371 # an empty 'packages' to patch-image still installs open-iscsi
372 packages = []
373
374 cmd = ['patch-image', image]
375 if kernel:
376 cmd.append('--kernel=%s' % kernel)
377 if initrd:
378 cmd.append('--initrd=%s' % initrd)
379 cmd.extend(packages)
380
381 subprocess.check_call(cmd)
382
383
384if __name__ == '__main__':
385 import optparse
386 parser = optparse.OptionParser()
387 parser.add_option("-v", "--verbose", dest="verbose", help="Verbose", action="store_true")
388 parser.add_option("-s", "--remote-server", dest="remote_server", help="Specify host with available iSCSI volumes", metavar="HOST")
389
390 parser.add_option("-n", "--initiatorname", dest="initiatorname", help="Specify initiatorname for use with --remote-server", metavar="NAME")
391
392 parser.add_option("--password", dest="password", help="Specify password for use with --remote-server", metavar="PASS")
393 parser.add_option("--password-in", dest="password_in", help="Specify password_in for use with --remote-server", metavar="PASS")
394
395 parser.add_option("--username", dest="username", help="Specify username for use with --remote-server", metavar="USER")
396 parser.add_option("--username-in", dest="username_in", help="Specify username_in for use with --remote-server", metavar="USER")
397
398 (options, args) = parser.parse_args()
399
400 if options.remote_server:
401 remote_server = options.remote_server
402
403 if options.username:
404 username = options.username
405 if options.password:
406 password = options.password
407 if options.username_in:
408 username_in = options.username_in
409 if options.password_in:
410 password_in = options.password_in
411 if options.initiatorname:
412 initiatorname = options.initiatorname
413 print("Connecting to remote server with:")
414 print(" host = %s " % remote_server)
415 print(' initiatorname = %s' % initiatorname)
416 print(' username = %s' % username)
417 print(' password = %s' % password)
418 print(' username_in = %s' % username_in)
419 print(' password_in = %s' % password_in)
420
421 suite = unittest.TestSuite()
422 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(OpenIscsiTest))
423 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
424 CloudImageTest))
425 rc = unittest.TextTestRunner(verbosity=2).run(suite)
426 if not rc.wasSuccessful():
427 sys.exit(1)
diff --git a/debian/tests/testlib.py b/debian/tests/testlib.py
0new file mode 100644428new file mode 100644
index 0000000..dce4252
--- /dev/null
+++ b/debian/tests/testlib.py
@@ -0,0 +1,1488 @@
1from __future__ import print_function
2#
3# testlib.py quality assurance test script
4# Copyright (C) 2008-2016 Canonical Ltd.
5#
6# This library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Library General Public
8# License as published by the Free Software Foundation; either
9# version 2 of the License.
10#
11# This library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Library General Public License for more details.
15#
16# You should have received a copy of the GNU Library General Public
17# License along with this program. If not, see
18# <http://www.gnu.org/licenses/>.
19#
20
21'''Common classes and functions for package tests.'''
22
23import crypt
24import glob
25import grp
26import gzip
27import os
28import os.path
29import platform
30import pwd
31import random
32import re
33import shutil
34import socket
35import string
36import subprocess
37import sys
38import tempfile
39import time
40import unittest
41
42from stat import ST_SIZE
43
44# Don't make python-pexpect mandatory
45try:
46 import pexpect
47except ImportError:
48 pass
49
50import warnings
51warnings.filterwarnings('ignore', message=r'.*apt_pkg\.TagFile.*', category=DeprecationWarning)
52try:
53 import apt_pkg
54 # cope with apt_pkg api changes.
55 if 'init_system' in dir(apt_pkg):
56 apt_pkg.init_system()
57 else:
58 apt_pkg.InitSystem()
59except:
60 # On non-Debian system, fall back to simple comparison without debianisms
61 class apt_pkg(object):
62 @staticmethod
63 def version_compare(one, two):
64 list_one = one.split('.')
65 list_two = two.split('.')
66 while len(list_one) > 0 and len(list_two) > 0:
67 try:
68 if int(list_one[0]) > int(list_two[0]):
69 return 1
70 if int(list_one[0]) < int(list_two[0]):
71 return -1
72 except:
73 # ugh, non-numerics in the version, fall back to
74 # string comparison, which will be wrong for e.g.
75 # 3.2 vs 3.16rc1
76 if list_one[0] > list_two[0]:
77 return 1
78 if list_one[0] < list_two[0]:
79 return -1
80 list_one.pop(0)
81 list_two.pop(0)
82 return 0
83
84 @staticmethod
85 def VersionCompare(one, two):
86 return apt_pkg.version_compare(one, two)
87
88bogus_nxdomain = "208.69.32.132"
89
90# http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html
91# This is needed so that the subprocesses that produce endless output
92# actually quit when the reader goes away.
93import signal
94def subprocess_setup():
95 # Python installs a SIGPIPE handler by default. This is usually not what
96 # non-Python subprocesses expect.
97 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
98
99
100class TimedOutException(Exception):
101 def __init__(self, value="Timed Out"):
102 self.value = value
103
104 def __str__(self):
105 return repr(self.value)
106
107
108def _restore_backup(path):
109 pathbackup = path + '.autotest'
110 if os.path.exists(pathbackup):
111 shutil.move(pathbackup, path)
112
113
114def _save_backup(path):
115 pathbackup = path + '.autotest'
116 if os.path.exists(path) and not os.path.exists(pathbackup):
117 shutil.copy2(path, pathbackup)
118 # copy2 does not copy ownership, so do it here.
119 # Reference: http://docs.python.org/library/shutil.html
120 a = os.stat(path)
121 os.chown(pathbackup, a[4], a[5])
122
123
124def config_copydir(path):
125 if os.path.exists(path) and not os.path.isdir(path):
126 raise OSError("'%s' is not a directory" % (path))
127 _restore_backup(path)
128
129 pathbackup = path + '.autotest'
130 if os.path.exists(path):
131 shutil.copytree(path, pathbackup, symlinks=True)
132
133
134def config_replace(path, contents, append=False):
135 '''Replace (or append) to a config file'''
136 _restore_backup(path)
137 if os.path.exists(path):
138 _save_backup(path)
139 if append:
140 with open(path) as fh:
141 contents = fh.read() + contents
142 with open(path, 'w') as fh:
143 fh.write(contents)
144
145
146def config_comment(path, field):
147 _save_backup(path)
148 contents = ""
149 with open(path) as fh:
150 for line in fh:
151 if re.search("^\s*%s\s*=" % (field), line):
152 line = "#" + line
153 contents += line
154
155 with open(path + '.new', 'w') as new_fh:
156 new_fh.write(contents)
157 os.rename(path + '.new', path)
158
159
160def config_set(path, field, value, spaces=True):
161 _save_backup(path)
162 contents = ""
163 if spaces:
164 setting = '%s = %s\n' % (field, value)
165 else:
166 setting = '%s=%s\n' % (field, value)
167 found = False
168 with open(path) as fh:
169 for line in fh:
170 if re.search("^\s*%s\s*=" % (field), line):
171 found = True
172 line = setting
173 contents += line
174 if not found:
175 contents += setting
176
177 with open(path + '.new', 'w') as new_config:
178 new_config.write(contents)
179 os.rename(path + '.new', path)
180
181
182def config_patch(path, patch, depth=1):
183 '''Patch a config file'''
184 _restore_backup(path)
185 _save_backup(path)
186
187 handle, name = mkstemp_fill(patch)
188 rc = subprocess.call(['/usr/bin/patch', '-p%s' % depth, path], stdin=handle, stdout=subprocess.PIPE)
189 os.unlink(name)
190 if rc != 0:
191 raise Exception("Patch failed")
192
193
194def config_restore(path):
195 '''Rename a replaced config file back to its initial state'''
196 _restore_backup(path)
197
198
199def timeout(secs, f, *args):
200 def handler(signum, frame):
201 raise TimedOutException()
202
203 old = signal.signal(signal.SIGALRM, handler)
204 result = None
205 signal.alarm(secs)
206 try:
207 result = f(*args)
208 finally:
209 signal.alarm(0)
210 signal.signal(signal.SIGALRM, old)
211
212 return result
213
214
215def require_nonroot():
216 if os.geteuid() == 0:
217 print("This series of tests should be run as a regular user with sudo access, not as root.", file=sys.stderr)
218 sys.exit(1)
219
220
221def require_root():
222 if os.geteuid() != 0:
223 print("This series of tests should be run with root privileges (e.g. via sudo).", file=sys.stderr)
224 sys.exit(1)
225
226
227def require_sudo():
228 if os.geteuid() != 0 or os.environ.get('SUDO_USER', None) is None:
229 print("This series of tests must be run under sudo.", file=sys.stderr)
230 sys.exit(1)
231 if os.environ['SUDO_USER'] == 'root':
232 print('Please run this test using sudo from a regular user. (You ran sudo from root.)', file=sys.stderr)
233 sys.exit(1)
234
235
236def random_string(length, lower=False):
237 '''Return a random string, consisting of ASCII letters, with given
238 length.'''
239
240 s = ''
241 selection = string.ascii_letters
242 if lower:
243 selection = string.ascii_lowercase
244 maxind = len(selection) - 1
245 for l in range(length):
246 s += selection[random.randint(0, maxind)]
247 return s
248
249
250def mkstemp_fill(contents, suffix='', prefix='testlib-', dir=None):
251 '''As tempfile.mkstemp does, return a (file, name) pair, but with
252 prefilled contents.'''
253
254 handle, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)
255 os.close(handle)
256 handle = open(name, "w+")
257 handle.write(contents)
258 handle.flush()
259 handle.seek(0)
260
261 return handle, name
262
263
264def create_fill(path, contents, mode=0o644):
265 '''Safely create a page'''
266 # make the temp file in the same dir as the destination file so we
267 # don't get invalid cross-device link errors when we rename
268 handle, name = mkstemp_fill(contents, dir=os.path.dirname(path))
269 handle.close()
270 os.rename(name, path)
271 os.chmod(path, mode)
272
273
274def login_exists(login):
275 '''Checks whether the given login exists on the system.'''
276
277 try:
278 pwd.getpwnam(login)
279 return True
280 except KeyError:
281 return False
282
283
284def group_exists(group):
285 '''Checks whether the given login exists on the system.'''
286
287 try:
288 grp.getgrnam(group)
289 return True
290 except KeyError:
291 return False
292
293
294def is_empty_file(path):
295 '''test if file is empty, returns True if so'''
296 with open(path) as fh:
297 return (len(fh.read()) == 0)
298
299
300def recursive_rm(dirPath, contents_only=False):
301 '''recursively remove directory'''
302 names = os.listdir(dirPath)
303 for name in names:
304 path = os.path.join(dirPath, name)
305 if os.path.islink(path) or not os.path.isdir(path):
306 os.unlink(path)
307 else:
308 recursive_rm(path)
309 if not contents_only:
310 os.rmdir(dirPath)
311
312
313def check_pidfile(exe, pidfile):
314 '''Checks if pid in pidfile is running'''
315 if not os.path.exists(pidfile):
316 return False
317
318 # get the pid
319 try:
320 with open(pidfile, 'r') as fd:
321 pid = fd.readline().rstrip('\n')
322 except:
323 return False
324
325 return check_pid(exe, pid)
326
327
328def check_pid(exe, pid):
329 '''Checks if pid is running'''
330 cmdline = "/proc/%s/cmdline" % (str(pid))
331 if not os.path.exists(cmdline):
332 return False
333
334 # get the command line
335 try:
336 with open(cmdline, 'r') as fd:
337 tmp = fd.readline().split('\0')
338 except:
339 return False
340
341 # this allows us to match absolute paths or just the executable name
342 if re.match('^' + exe + '$', tmp[0]) or \
343 re.match('.*/' + exe + '$', tmp[0]) or \
344 re.match('^' + exe + ': ', tmp[0]) or \
345 re.match('^\(' + exe + '\)', tmp[0]):
346 return True
347
348 return False
349
350
351def check_port(port, proto, ver=4):
352 '''Check if something is listening on the specified port.
353 WARNING: for some reason this does not work with a bind mounted /proc
354 '''
355 assert (port >= 1)
356 assert (port <= 65535)
357 assert (proto.lower() == "tcp" or proto.lower() == "udp")
358 assert (ver == 4 or ver == 6)
359
360 fn = "/proc/net/%s" % (proto)
361 if ver == 6:
362 fn += str(ver)
363
364 rc, report = cmd(['cat', fn])
365 assert (rc == 0)
366
367 hport = "%0.4x" % port
368
369 if re.search(': [0-9a-f]{8}:%s [0-9a-f]' % str(hport).lower(), report.lower()):
370 return True
371 return False
372
373
374def get_arch():
375 '''Get the current architecture'''
376 rc, report = cmd(['uname', '-m'])
377 assert (rc == 0)
378 return report.strip()
379
380
381def get_multiarch_tuple():
382 '''Get the current debian multiarch tuple'''
383
384 # XXX dpkg-architecture on Ubuntu 12.04 requires -q be adjacent to
385 # the variable name
386 rc, report = cmd(['dpkg-architecture', '-qDEB_HOST_MULTIARCH'])
387 assert (rc == 0)
388 return report.strip()
389
390
391def get_bits():
392 '''return the default architecture number of bits (32 or 64, usually)'''
393 return platform.architecture()[0][0:2]
394
395
396def get_memory():
397 '''Gets total ram and swap'''
398 meminfo = "/proc/meminfo"
399 memtotal = 0
400 swaptotal = 0
401 if not os.path.exists(meminfo):
402 return (False, False)
403
404 try:
405 fd = open(meminfo, 'r')
406 for line in fd.readlines():
407 splitline = line.split()
408 if splitline[0] == 'MemTotal:':
409 memtotal = int(splitline[1])
410 elif splitline[0] == 'SwapTotal:':
411 swaptotal = int(splitline[1])
412 fd.close()
413 except:
414 return (False, False)
415
416 return (memtotal, swaptotal)
417
418
419def is_running_in_vm():
420 '''Check if running under a VM'''
421 # add other virtualization environments here
422 for search in ['QEMU Virtual CPU']:
423 rc, report = cmd_pipe(['dmesg'], ['grep', search])
424 if rc == 0:
425 return True
426 return False
427
428
429def ubuntu_release():
430 '''Get the Ubuntu release'''
431 f = "/etc/lsb-release"
432 try:
433 size = os.stat(f)[ST_SIZE]
434 except:
435 return "UNKNOWN"
436
437 if size > 1024 * 1024:
438 raise IOError('Could not open "%s" (too big)' % f)
439
440 with open("/etc/lsb-release", 'r') as fh:
441 lines = fh.readlines()
442
443 pat = re.compile(r'DISTRIB_CODENAME')
444 for line in lines:
445 if pat.search(line):
446 return line.split('=')[1].rstrip('\n').rstrip('\r')
447
448 return "UNKNOWN"
449
450
451def cmd(command, input=None, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, stdin=None, timeout=None, env=None, shell=False, text=True):
452 '''Try to execute given command (array) and return its stdout, or return
453 a textual error if it failed.'''
454
455 try:
456 sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, preexec_fn=subprocess_setup, env=env, universal_newlines=text, shell=shell)
457 if sys.version_info[0] >= 3 and sys.version_info[1] > 3:
458 out, outerr = sp.communicate(input, timeout=timeout)
459 else:
460 out, outerr = sp.communicate(input)
461 except OSError as e:
462 return [127, str(e)]
463
464 # Handle redirection of stdout
465 if out is None:
466 out = ''
467 # Handle redirection of stderr
468 if outerr is None:
469 outerr = ''
470 if text == False:
471 out = str(out)
472 return [sp.returncode, out + outerr]
473
474
475def cmd_pipe(command1, command2, input=None, stderr=subprocess.STDOUT, stdin=None):
476 '''Try to pipe command1 into command2.'''
477 try:
478 sp1 = subprocess.Popen(command1, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, close_fds=True)
479 sp2 = subprocess.Popen(command2, stdin=sp1.stdout, stdout=subprocess.PIPE, stderr=stderr, close_fds=True, universal_newlines=True)
480 except OSError as e:
481 return [127, str(e)]
482
483 out = sp2.communicate(input)[0]
484 # ensure we don't leak open files and that sp1 is stopped
485 sp1.stdout.close()
486 sp1.wait()
487 return [sp2.returncode, out]
488
489
490def cwd_has_enough_space(cdir, total_bytes):
491 '''Determine if the partition of the current working directory has 'bytes'
492 free.'''
493 rc, df_output = cmd(['df'])
494 if rc != 0:
495 result = 'df failed, got exit code %d, expected %d\n' % (rc, 0)
496 raise OSError(result)
497 if rc != 0:
498 return False
499
500 kb = total_bytes / 1024
501
502 mounts = dict()
503 for line in df_output.splitlines():
504 if '/' not in line:
505 continue
506 tmp = line.split()
507 mounts[tmp[5]] = int(tmp[3])
508
509 cdir = os.getcwd()
510 while cdir != '/':
511 if cdir not in mounts:
512 cdir = os.path.dirname(cdir)
513 continue
514 return kb < mounts[cdir]
515
516 return kb < mounts['/']
517
518
519def get_md5(filename):
520 '''Gets the md5sum of the file specified'''
521
522 (rc, report) = cmd(["/usr/bin/md5sum", "-b", filename])
523 expected = 0
524 assert (expected == rc)
525
526 return report.split(' ')[0]
527
528
529def dpkg_compare_installed_version(pkg, check, version):
530 '''Gets the version for the installed package, and compares it to the
531 specified version.
532 '''
533 (rc, report) = cmd(["/usr/bin/dpkg", "-s", pkg])
534 assert (rc == 0)
535 assert ("Status: install ok installed" in report)
536 installed_version = ""
537 for line in report.splitlines():
538 if line.startswith("Version: "):
539 installed_version = line.split()[1]
540
541 assert (installed_version != "")
542
543 (rc, report) = cmd(["/usr/bin/dpkg", "--compare-versions", installed_version, check, version])
544 assert (rc == 0 or rc == 1)
545 if rc == 0:
546 return True
547 return False
548
549
550def _run_apt_command(pkg_list, apt_cmd='install'):
551 env = os.environ.copy()
552 env['DEBIAN_FRONTEND'] = 'noninteractive'
553 # debugging version, but on precise doesn't actually run dpkg
554 # command = ['apt-get', '-y', '--force-yes', '-o', 'Dpkg::Options::=--force-confold', '-o', 'Debug::pkgDPkgPM=true', apt_cmd]
555 command = ['apt-get', '-y', '--force-yes', '-o', 'Dpkg::Options::=--force-confold', apt_cmd]
556 command.extend(pkg_list)
557 rc, report = cmd(command)
558 return rc, report
559
560
561# note: for the following install_* functions, you probably want the
562# versions in the TestlibCase class (see below)
563def install_builddeps(src_pkg):
564 rc, report = _run_apt_command([src_pkg], 'build-dep')
565 assert(rc == 0)
566
567
568def install_package(package):
569 rc, report = _run_apt_command([package], 'install')
570 assert(rc == 0)
571
572
573def install_packages(pkg_list):
574 rc, report = _run_apt_command(pkg_list, 'install')
575 assert(rc == 0)
576
577
578def prepare_source(source, builder, cached_src, build_src, patch_system):
579 '''Download and unpack source package, installing necessary build depends,
580 adjusting the permissions for the 'builder' user, and returning the
581 directory of the unpacked source. Patch system can be one of:
582 - cdbs
583 - dpatch
584 - quilt
585 - quiltv3
586 - None (not the string)
587
588 This is normally used like this:
589
590 def setUp(self):
591 ...
592 self.topdir = os.getcwd()
593 self.cached_src = os.path.join(os.getcwd(), "source")
594 self.tmpdir = tempfile.mkdtemp(prefix='testlib', dir='/tmp')
595 self.builder = testlib.TestUser()
596 testlib.cmd(['chgrp', self.builder.login, self.tmpdir])
597 os.chmod(self.tmpdir, 0o775)
598
599 def tearDown(self):
600 ...
601 self.builder = None
602 self.topdir = os.getcwd()
603 if os.path.exists(self.tmpdir):
604 testlib.recursive_rm(self.tmpdir)
605
606 def test_suite_build(self):
607 ...
608 build_dir = testlib.prepare_source('foo', \
609 self.builder, \
610 self.cached_src, \
611 os.path.join(self.tmpdir, \
612 os.path.basename(self.cached_src)),
613 "quilt")
614 os.chdir(build_dir)
615
616 # Example for typical build, adjust as necessary
617 print("")
618 print(" make clean")
619 rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'clean'])
620
621 print(" configure")
622 rc, report = testlib.cmd(['sudo', '-u', self.builder.login, './configure', '--prefix=%s' % self.tmpdir, '--enable-debug'])
623
624 print(" make (will take a while)")
625 rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make'])
626
627 print(" make check (will take a while)",)
628 rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'check'])
629 expected = 0
630 result = 'Got exit code %d, expected %d\n' % (rc, expected)
631 self.assertEqual(expected, rc, result + report)
632
633 def test_suite_cleanup(self):
634 ...
635 if os.path.exists(self.cached_src):
636 testlib.recursive_rm(self.cached_src)
637
638 It is up to the caller to clean up cached_src and build_src (as in the
639 above example, often the build_src is in a tmpdir that is cleaned in
640 tearDown() and the cached_src is cleaned in a one time clean-up
641 operation (eg 'test_suite_cleanup()) which must be run after the build
642 suite test (obviously).
643 '''
644
645 # Make sure we have a clean slate
646 assert (os.path.exists(os.path.dirname(build_src)))
647 assert (not os.path.exists(build_src))
648
649 cdir = os.getcwd()
650 if os.path.exists(cached_src):
651 shutil.copytree(cached_src, build_src)
652 os.chdir(build_src)
653 else:
654 # Only install the build dependencies on the initial setup
655 install_builddeps(source)
656 os.makedirs(build_src)
657 os.chdir(build_src)
658
659 # These are always needed
660 pkgs = ['build-essential', 'dpkg-dev', 'fakeroot']
661 install_packages(pkgs)
662
663 rc, report = cmd(['apt-get', 'source', source])
664 assert (rc == 0)
665 shutil.copytree(build_src, cached_src)
666 print("(unpacked %s)" % os.path.basename(glob.glob('%s_*.dsc' % source)[0]), end=' ')
667
668 unpacked_dir = os.path.join(build_src, glob.glob('%s-*' % source)[0])
669
670 # Now apply the patches. Do it here so that we don't mess up our cached
671 # sources.
672 os.chdir(unpacked_dir)
673 assert (patch_system in ['cdbs', 'dpatch', 'quilt', 'quiltv3', None])
674 if patch_system is not None and patch_system != "quiltv3":
675 if patch_system == "quilt":
676 os.environ.setdefault('QUILT_PATCHES', 'debian/patches')
677 rc, report = cmd(['quilt', 'push', '-a'])
678 assert (rc == 0)
679 elif patch_system == "cdbs":
680 rc, report = cmd(['./debian/rules', 'apply-patches'])
681 assert (rc == 0)
682 elif patch_system == "dpatch":
683 rc, report = cmd(['dpatch', 'apply-all'])
684 assert (rc == 0)
685
686 cmd(['chown', '-R', '%s:%s' % (builder.uid, builder.gid), build_src])
687 os.chdir(cdir)
688
689 return unpacked_dir
690
691
692def get_changelog_version(source_dir):
693 '''Extract a package version from a changelog'''
694 package_version = ""
695
696 changelog_file = os.path.join(source_dir, "debian/changelog")
697
698 if os.path.exists(changelog_file):
699 changelog = open(changelog_file, 'r')
700 header = changelog.readline().split()
701 package_version = header[1].strip('()')
702
703 return package_version
704
705
706def _aa_status():
707 '''Get aa-status output'''
708 exe = "/usr/sbin/aa-status"
709 assert (os.path.exists(exe))
710 if os.geteuid() == 0:
711 return cmd([exe])
712 return cmd(['sudo', exe])
713
714
715def is_apparmor_loaded(path):
716 '''Check if profile is loaded'''
717 rc, report = _aa_status()
718 if rc != 0:
719 return False
720
721 for line in report.splitlines():
722 if line.endswith(path):
723 return True
724 return False
725
726
727def is_apparmor_confined(path):
728 '''Check if application is confined'''
729 rc, report = _aa_status()
730 if rc != 0:
731 return False
732
733 for line in report.splitlines():
734 if re.search('%s \(' % path, line):
735 return True
736 return False
737
738
739def check_apparmor(path, first_ubuntu_release, is_running=True):
740 '''Check if path is loaded and confined for everything higher than the
741 first Ubuntu release specified.
742
743 Usage:
744 rc, report = testlib.check_apparmor('/usr/sbin/foo', 8.04, is_running=True)
745 if rc < 0:
746 return self._skipped(report)
747
748 expected = 0
749 result = 'Got exit code %d, expected %d\n' % (rc, expected)
750 self.assertEqual(expected, rc, result + report)
751 '''
752 global manager
753 rc = -1
754
755 if manager.lsb_release["Release"] < first_ubuntu_release:
756 return (rc, "Skipped apparmor check")
757
758 if not os.path.exists('/sbin/apparmor_parser'):
759 return (rc, "Skipped (couldn't find apparmor_parser)")
760
761 rc = 0
762 msg = ""
763 if not is_apparmor_loaded(path):
764 rc = 1
765 msg = "Profile not loaded for '%s'" % path
766
767 # this check only makes sense it the 'path' is currently executing
768 if is_running and rc == 0 and not is_apparmor_confined(path):
769 rc = 1
770 msg = "'%s' is not running in enforce mode" % path
771
772 return (rc, msg)
773
774
775def get_gcc_version(gcc, full=True):
776 gcc_version = 'none'
777 if not gcc.startswith('/'):
778 gcc = '/usr/bin/%s' % (gcc)
779 if os.path.exists(gcc):
780 gcc_version = 'unknown'
781 lines = cmd([gcc, '-v'])[1].strip().splitlines()
782 version_lines = [x for x in lines if x.startswith('gcc version')]
783 if len(version_lines) == 1:
784 gcc_version = " ".join(version_lines[0].split()[2:])
785 if not full:
786 return gcc_version.split()[0]
787 return gcc_version
788
789
790def is_kdeinit_running():
791 '''Test if kdeinit is running'''
792 # applications that use kdeinit will spawn it if it isn't running in the
793 # test. This is a problem because it does not exit. This is a helper to
794 # check for it.
795 rc, report = cmd(['ps', 'x'])
796 if 'kdeinit4 Running' not in report:
797 print("kdeinit not running (you may start/stop any KDE application then run this script again)", file=sys.stderr)
798 return False
799 return True
800
801
802def get_pkgconfig_flags(libs=[]):
803 '''Find pkg-config flags for libraries'''
804 assert (len(libs) > 0)
805 rc, pkg_config = cmd(['pkg-config', '--cflags', '--libs'] + libs)
806 expected = 0
807 if rc != expected:
808 print('Got exit code %d, expected %d\n' % (rc, expected), file=sys.stderr)
809 assert(rc == expected)
810 return pkg_config.split()
811
812
813def cap_to_name(cap_num):
814 '''given an integer, return the capability name'''
815 rc, output = cmd(['capsh', '--decode=%x' % cap_num])
816 expected = 0
817 if rc != expected:
818 print('capsh: got exit code %d, expected %d\n' % (rc, expected), file=sys.stderr)
819 cap_name = output.strip().split('=')[1]
820 return cap_name
821
822
823def enumerate_capabilities():
824 i = 0
825 cap_list = []
826 done = False
827 while not done:
828 cap_name = cap_to_name(pow(2, i))
829 if cap_name == str(i):
830 done = True
831 else:
832 cap_list.append(cap_name)
833 i += 1
834 if i > 64:
835 done = True
836 return cap_list
837
838
839def _run_snap_install(snapname, track="latest/stable", classic=False):
840 # crude, but effective
841 if os.path.exists(os.path.join("/snap", snapname)):
842 return 0, ""
843
844 command = ["snap", "install", "--channel=%s" % track, snapname]
845 if classic:
846 command.append("--classic")
847 rc, report = cmd(command)
848 return rc, report
849
850
851def _run_snap_remove(snapname):
852 # crude, but effective
853 if not os.path.exists(os.path.join("/snap", snapname)):
854 return 0, ""
855
856 command = ["snap", "remove", "--purge", snapname]
857 rc, report = cmd(command)
858 return rc, report
859
860
861def install_snap(self, snapname, track="latest/stable", classic=False):
862 rc, report = _run_snap_install(snapname, track, classic)
863 self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
864 (snapname, report))
865
866
867def remove_snap(self, snapname):
868 rc, report = _run_snap_remove(snapname)
869 self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
870 (snapname, report))
871
872
873class TestDaemon:
874 '''Helper class to manage daemons consistently'''
875 def __init__(self, service_name):
876 '''Setup daemon attributes'''
877 if os.path.isfile('/usr/sbin/service') or os.path.islink('/usr/sbin/service'):
878 self.test_daemon_commands = ['service', service_name]
879 else:
880 self.test_daemon_commands = ['/etc/init.d/' + service_name]
881
882 def _run_command(self, action, seconds_to_wait=2):
883 command = list(self.test_daemon_commands)
884 command.append(action)
885 rc, report = cmd(command)
886 expected = 0
887 result = 'Got exit code %d, expected %d\n' % (rc, expected)
888 time.sleep(seconds_to_wait)
889 if expected != rc:
890 return False, result + report
891
892 if "fail" in report:
893 return False, "Found 'fail' in report\n" + report
894
895 return True, ""
896
897 def start(self):
898 '''Start daemon'''
899 return self._run_command('start')
900
901 def stop(self):
902 '''Stop daemon'''
903 return self._run_command('stop')
904
905 def reload(self):
906 '''Reload daemon'''
907 return self._run_command('force-reload')
908
909 def restart(self):
910 if self.test_daemon_commands[0] == 'service':
911 return self._run_command('restart')
912 else:
913 '''Restart daemon'''
914 (res, str) = self.stop()
915 if not res:
916 return res, str
917
918 (res, str) = self.start()
919 if not res:
920 return res, str
921
922 return True, ""
923
924 def force_restart(self):
925 '''Restart daemon even if already stopped'''
926 self.stop()
927
928 (res, str) = self.start()
929 if not res:
930 return res, str
931
932 return True, ""
933
934 def status(self):
935 '''Check daemon status'''
936 return self._run_command('status')
937
938
939class TestlibManager(object):
940 '''Singleton class used to set up per-test-run information'''
941 def __init__(self):
942 # Set glibc aborts to dump to stderr instead of the tty so test output
943 # is more sane.
944 os.environ.setdefault('LIBC_FATAL_STDERR_', '1')
945
946 # check verbosity
947 self.verbosity = False
948 if (len(sys.argv) > 1 and '-v' in sys.argv[1:]):
949 self.verbosity = True
950
951 # Load LSB release file
952 self.lsb_release = dict()
953 if not os.path.exists('/usr/bin/lsb_release') and not os.path.exists('/bin/lsb_release'):
954 raise OSError("Please install 'lsb-release'")
955 for line in subprocess.Popen(['lsb_release', '-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate()[0].splitlines():
956 field, value = line.split(':', 1)
957 value = value.strip()
958 field = field.strip()
959 # Convert numerics
960 try:
961 value = float(value)
962 except:
963 pass
964 self.lsb_release.setdefault(field, value)
965
966 # FIXME: hack OEM releases into known-Ubuntu versions
967 if self.lsb_release['Distributor ID'] == "HP MIE (Mobile Internet Experience)":
968 if self.lsb_release['Release'] == 1.0:
969 self.lsb_release['Distributor ID'] = "Ubuntu"
970 self.lsb_release['Release'] = 8.04
971 else:
972 raise OSError("Unknown version of HP MIE")
973
974 # FIXME: hack to assume a most-recent release if we're not
975 # running under Ubuntu.
976 if self.lsb_release['Distributor ID'] not in ["Ubuntu", "Linaro"]:
977 self.lsb_release['Release'] = 10000
978 # Adjust Linaro release to pretend to be Ubuntu
979 if self.lsb_release['Distributor ID'] in ["Linaro"]:
980 self.lsb_release['Distributor ID'] = "Ubuntu"
981 self.lsb_release['Release'] -= 0.01
982
983 # Load arch
984 if not os.path.exists('/usr/bin/dpkg'):
985 machine = cmd(['uname', '-m'])[1].strip()
986 if machine.endswith('86'):
987 self.dpkg_arch = 'i386'
988 elif machine.endswith('_64'):
989 self.dpkg_arch = 'amd64'
990 elif machine.startswith('arm'):
991 self.dpkg_arch = 'armel'
992 else:
993 raise ValueError("Unknown machine type '%s'" % (machine))
994 else:
995 self.dpkg_arch = cmd(['dpkg', '--print-architecture'])[1].strip()
996
997 # Find kernel version
998 self.kernel_is_ubuntu = False
999 self.kernel_version_signature = None
1000 self.kernel_version = cmd(["uname", "-r"])[1].strip()
1001 versig = '/proc/version_signature'
1002 if os.path.exists(versig):
1003 self.kernel_is_ubuntu = True
1004 self.kernel_version_signature = open(versig).read().strip()
1005 self.kernel_version_ubuntu = self.kernel_version
1006 elif os.path.exists('/usr/bin/dpkg'):
1007 # this can easily be inaccurate but is only an issue for Dapper
1008 rc, out = cmd(['dpkg', '-l', 'linux-image-%s' % (self.kernel_version)])
1009 if rc == 0:
1010 self.kernel_version_signature = out.strip().split('\n').pop().split()[2]
1011 self.kernel_version_ubuntu = self.kernel_version_signature
1012 if self.kernel_version_signature is None:
1013 # Attempt to fall back to something for non-Debian-based
1014 self.kernel_version_signature = self.kernel_version
1015 self.kernel_version_ubuntu = self.kernel_version
1016 # Build ubuntu version without hardware suffix
1017 try:
1018 self.kernel_version_ubuntu = "-".join([x for x in self.kernel_version_signature.split(' ')[1].split('-') if re.search('^[0-9]', x)])
1019 except:
1020 pass
1021
1022 # Find gcc version
1023 self.gcc_version = get_gcc_version('gcc')
1024
1025 # Find libc
1026 self.path_libc = [x.split()[2] for x in cmd(['ldd', '/bin/ls'])[1].splitlines() if x.startswith('\tlibc.so.')][0]
1027
1028 # Report self
1029 if self.verbosity:
1030 kernel = self.kernel_version_ubuntu
1031 if kernel != self.kernel_version_signature:
1032 kernel += " (%s)" % (self.kernel_version_signature)
1033 print("Running test: '%s' distro: '%s %.2f' kernel: '%s' arch: '%s' uid: %d/%d SUDO_USER: '%s')" % (
1034 sys.argv[0],
1035 self.lsb_release['Distributor ID'],
1036 self.lsb_release['Release'],
1037 kernel,
1038 self.dpkg_arch,
1039 os.geteuid(), os.getuid(),
1040 os.environ.get('SUDO_USER', '')), file=sys.stdout)
1041 sys.stdout.flush()
1042
1043 # Additional heuristics
1044 # if os.environ.get('SUDO_USER', os.environ.get('USER', '')) in ['mdeslaur']:
1045 # sys.stdout.write("Replying to Marc Deslauriers in http://launchpad.net/bugs/%d: " % random.randint(600000, 980000))
1046 # sys.stdout.flush()
1047 # time.sleep(0.5)
1048 # sys.stdout.write("destroyed\n")
1049 # time.sleep(0.5)
1050
1051 def hello(self, msg):
1052 print("Hello from %s" % (msg), file=sys.stderr)
1053# The central instance
1054manager = TestlibManager()
1055
1056
1057class TestlibCase(unittest.TestCase):
1058 def __init__(self, *args):
1059 '''This is called for each TestCase test instance, which isn't much better
1060 than SetUp.'''
1061
1062 unittest.TestCase.__init__(self, *args)
1063
1064 # Attach to and duplicate dicts from manager singleton
1065 self.manager = manager
1066 # self.manager.hello(repr(self) + repr(*args))
1067 self.my_verbosity = self.manager.verbosity
1068 self.lsb_release = self.manager.lsb_release
1069 self.dpkg_arch = self.manager.dpkg_arch
1070 self.kernel_version = self.manager.kernel_version
1071 self.kernel_version_signature = self.manager.kernel_version_signature
1072 self.kernel_version_ubuntu = self.manager.kernel_version_ubuntu
1073 self.kernel_is_ubuntu = self.manager.kernel_is_ubuntu
1074 self.gcc_version = self.manager.gcc_version
1075 self.path_libc = self.manager.path_libc
1076
1077 def version_compare(self, one, two):
1078 if 'version_compare' in dir(apt_pkg):
1079 return apt_pkg.version_compare(one, two)
1080 else:
1081 return apt_pkg.VersionCompare(one, two)
1082
1083 def assertFileType(self, filename, filetype, strict=True):
1084 '''Checks the file type of the file specified'''
1085
1086 (rc, report, out) = self._testlib_shell_cmd(["/usr/bin/file", "-b", filename])
1087 out = out.strip()
1088 expected = 0
1089 # Absolutely no idea why this happens on Hardy
1090 if self.lsb_release['Release'] == 8.04 and rc == 255 and len(out) > 0:
1091 rc = 0
1092 result = 'Got exit code %d, expected %d:\n%s\n' % (rc, expected, report)
1093 self.assertEqual(expected, rc, result)
1094
1095 if strict:
1096 filetype = '^%s$' % (filetype)
1097 else:
1098 # accept if the beginning of the line matches
1099 filetype = '^%s' % (filetype)
1100 result = 'File type reported by file: [%s], expected regex: [%s]\n' % (out, filetype)
1101 self.assertNotEqual(None, re.search(filetype, out), result)
1102
1103 def yank_commonname_from_cert(self, certfile):
1104 '''Extract the commonName from a given PEM'''
1105 rc, out = cmd(['openssl', 'asn1parse', '-in', certfile])
1106 if rc == 0:
1107 ready = False
1108 for line in out.splitlines():
1109 if ready:
1110 return line.split(':')[-1]
1111 if ':commonName' in line:
1112 ready = True
1113 return socket.getfqdn()
1114
1115 def announce(self, text):
1116 if self.my_verbosity:
1117 print("(%s) " % (text), file=sys.stderr, end='')
1118 sys.stdout.flush()
1119
1120 def make_clean(self):
1121 rc, output = self.shell_cmd(['make', 'clean'])
1122 self.assertEqual(rc, 0, output)
1123
1124 def get_makefile_compiler(self):
1125 # Find potential compiler name
1126 compiler = 'gcc'
1127 if os.path.exists('Makefile'):
1128 for line in open('Makefile'):
1129 if line.startswith('CC') and '=' in line:
1130 items = [x.strip() for x in line.split('=')]
1131 if items[0] == 'CC':
1132 compiler = items[1]
1133 break
1134 return compiler
1135
1136 def make_target(self, target, expected=0):
1137 '''Compile a target and report output'''
1138
1139 compiler = self.get_makefile_compiler()
1140 rc, output = self.shell_cmd(['make', target])
1141 self.assertEqual(rc, expected, 'rc(%d)!=%d:\n' % (rc, expected) + output)
1142 self.assertTrue('%s ' % (compiler) in output, 'Expected "%s":' % (compiler) + output)
1143 return output
1144
1145 # call as return testlib.skipped()
1146 def _skipped(self, reason=""):
1147 '''Provide a visible way to indicate that a test was skipped'''
1148 if reason != "":
1149 reason = ': %s' % (reason)
1150 self.announce("skipped%s" % (reason))
1151 return False
1152
1153 def _testlib_shell_cmd(self, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=None):
1154 argstr = "'" + "', '".join(args).strip() + "'"
1155 rc, out = cmd(args, stdin=stdin, stdout=stdout, stderr=stderr, env=env)
1156 report = 'Command: ' + argstr + '\nOutput:\n' + out
1157 return rc, report, out
1158
1159 def shell_cmd(self, args, stdin=None):
1160 return cmd(args, stdin=stdin)
1161
1162 def assertShellExitEquals(self, expected, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=None, msg="", bare_report=False):
1163 '''Test a shell command matches a specific exit code'''
1164 rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr, env=env)
1165 result = 'Got exit code %d, expected %d\n' % (rc, expected)
1166 self.assertEqual(expected, rc, msg + result + report)
1167 if bare_report:
1168 return out
1169 else:
1170 return report
1171
1172 def assertShellExitSuccess(self, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=None, msg="", bare_report=False):
1173 '''Same as assertShellEquals but with an expected exit status of 0 (success).'''
1174 return self.assertShellExitEquals(0, args, stdin, stdout, stderr, env, msg, bare_report)
1175
1176 # make sure exit value is in a list of expected values
1177 def assertShellExitIn(self, expected, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""):
1178 '''Test a shell command matches a specific exit code'''
1179 rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
1180 result = 'Got exit code %d, expected one of %s\n' % (rc, ', '.join(map(str, expected)))
1181 self.assertIn(rc, expected, msg + result + report)
1182
1183 def assertShellExitNotEquals(self, unwanted, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""):
1184 '''Test a shell command doesn't match a specific exit code'''
1185 rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
1186 result = 'Got (unwanted) exit code %d\n' % rc
1187 self.assertNotEqual(unwanted, rc, msg + result + report)
1188
1189 def assertShellOutputContains(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False, expected=None):
1190 '''Test a shell command contains a specific output'''
1191 rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
1192 result = 'Got exit code %d. Looking for text "%s"\n' % (rc, text)
1193 if not invert:
1194 self.assertTrue(text in out, msg + result + report)
1195 else:
1196 self.assertFalse(text in out, msg + result + report)
1197 if expected is not None:
1198 result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args))
1199 self.assertEqual(rc, expected, msg + result + report)
1200
1201 def assertShellOutputEquals(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False, expected=None):
1202 '''Test a shell command matches a specific output'''
1203 rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
1204 result = 'Got exit code %d. Looking for exact text "%s" (%s)\n' % (rc, text, " ".join(args))
1205 if not invert:
1206 self.assertEqual(text, out, msg + result + report)
1207 else:
1208 self.assertNotEqual(text, out, msg + result + report)
1209 if expected is not None:
1210 result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args))
1211 self.assertEqual(rc, expected, msg + result + report)
1212
1213 def _word_find(self, report, content, invert=False):
1214 '''Check for a specific string'''
1215 if invert:
1216 warning = 'Found "%s"\n' % content
1217 self.assertTrue(content not in report, warning + report)
1218 else:
1219 warning = 'Could not find "%s"\n' % content
1220 self.assertTrue(content in report, warning + report)
1221
1222 def _test_sysctl_value(self, path, expected, msg=None, exists=True):
1223 sysctl = '/proc/sys/%s' % (path)
1224 self.assertEqual(exists, os.path.exists(sysctl), sysctl)
1225 value = None
1226 if exists:
1227 with open(sysctl) as sysctl_fd:
1228 value = int(sysctl_fd.read())
1229 report = "%s is not %d: %d" % (sysctl, expected, value)
1230 if msg:
1231 report += " (%s)" % (msg)
1232 self.assertEqual(value, expected, report)
1233 return value
1234
1235 def set_sysctl_value(self, path, desired):
1236 sysctl = '/proc/sys/%s' % (path)
1237 self.assertTrue(os.path.exists(sysctl), "%s does not exist" % (sysctl))
1238 with open(sysctl, 'w') as sysctl_fh:
1239 sysctl_fh.write(str(desired))
1240 self._test_sysctl_value(path, desired)
1241
1242 def kernel_at_least(self, introduced):
1243 return self.version_compare(self.kernel_version_ubuntu,
1244 introduced) >= 0
1245
1246 def kernel_claims_cve_fixed(self, cve):
1247 changelog = "/usr/share/doc/linux-image-%s/changelog.Debian.gz" % (self.kernel_version)
1248 if os.path.exists(changelog):
1249 for line in gzip.open(changelog):
1250 if cve in line and "revert" not in line and "Revert" not in line:
1251 return True
1252 return False
1253
1254 def install_builddeps(self, src_pkg):
1255 rc, report = _run_apt_command([src_pkg], 'build-dep')
1256 self.assertEqual(0, rc, 'Failed to install build-deps for %s\nOutput:\n%s' % (src_pkg, report))
1257
1258 def install_package(self, package):
1259 rc, report = _run_apt_command([package], 'install')
1260 self.assertEqual(0, rc, 'Failed to install package %s\nOutput:\n%s' % (package, report))
1261
1262 def install_packages(self, pkg_list):
1263 rc, report = _run_apt_command(pkg_list, 'install')
1264 self.assertEqual(0, rc, 'Failed to install packages %s\nOutput:\n%s' % (','.join(pkg_list), report))
1265
1266 def install_snap(self, snapname, track="latest/stable", classic=False):
1267 rc, report = _run_snap_install(snapname, track, classic)
1268 self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
1269 (snapname, report))
1270
1271 def remove_snap(self, snapname):
1272 rc, report = _run_snap_remove(snapname)
1273 self.assertEqual(0, rc, "Failed to install snap %s\nOutput:\n%s" %
1274 (snapname, report))
1275
1276
1277class TestGroup:
1278 '''Create a temporary test group and remove it again in the dtor.'''
1279
1280 def __init__(self, group=None, lower=False):
1281 '''Create a new group'''
1282
1283 self.group = None
1284 if group:
1285 if group_exists(group):
1286 raise ValueError('group name already exists')
1287 else:
1288 while(True):
1289 group = random_string(7, lower=lower)
1290 if not group_exists(group):
1291 break
1292
1293 assert subprocess.call(['groupadd', group]) == 0
1294 self.group = group
1295 g = grp.getgrnam(self.group)
1296 self.gid = g[2]
1297
1298 def __del__(self):
1299 '''Remove the created group.'''
1300
1301 if self.group:
1302 rc, report = cmd(['groupdel', self.group])
1303 assert rc == 0
1304
1305
1306class TestUser:
1307 '''Create a temporary test user and remove it again in the dtor.'''
1308
1309 def __init__(self, login=None, home=True, group=None, uidmin=None, lower=False, shell=None):
1310 '''Create a new user account with a random password.
1311
1312 By default, the login name is random, too, but can be explicitly
1313 specified with 'login'. By default, a home directory is created, this
1314 can be suppressed with 'home=False'.'''
1315
1316 self.login = None
1317
1318 if os.geteuid() != 0:
1319 raise ValueError("You must be root to run this test")
1320
1321 if login:
1322 if login_exists(login):
1323 raise ValueError('login name already exists')
1324 else:
1325 while(True):
1326 login = 't' + random_string(7, lower=lower)
1327 if not login_exists(login):
1328 break
1329
1330 # when fips is enabled, python2.7 crypt.crypt() returns None
1331 # for DES salts for being too weak. Force sha256 with "$5$" for
1332 # the salt. XXX in python3, the salt is optional and will
1333 # generate strong passwords automatically.
1334 self.salt = "$5$%s" % random_string(2)
1335 self.password = random_string(8, lower=lower)
1336 self.crypted = crypt.crypt(self.password, self.salt)
1337
1338 creation = ['useradd', '-p', self.crypted]
1339 if home:
1340 creation += ['-m']
1341 if group:
1342 creation += ['-G', group]
1343 if uidmin:
1344 creation += ['-K', 'UID_MIN=%d' % uidmin]
1345 if shell:
1346 creation += ['-s', shell]
1347 creation += [login]
1348 assert subprocess.call(creation) == 0
1349 # Set GECOS
1350 assert subprocess.call(['usermod', '-c', 'Buddy %s' % (login), login]) == 0
1351
1352 self.login = login
1353 p = pwd.getpwnam(self.login)
1354 self.uid = p[2]
1355 self.gid = p[3]
1356 self.gecos = p[4]
1357 self.home = p[5]
1358 self.shell = p[6]
1359
1360 def __del__(self):
1361 '''Remove the created user account.'''
1362
1363 if self.login:
1364 # sanity check the login name so we don't accidentally wipe too much
1365 if len(self.login) > 3 and '/' not in self.login:
1366 subprocess.call(['rm', '-rf', '/home/' + self.login, '/var/mail/' + self.login])
1367 rc, report = cmd(['userdel', '-f', self.login])
1368 assert rc == 0
1369
1370 def add_to_group(self, group):
1371 '''Add user to the specified group name'''
1372 rc, report = cmd(['usermod', '-G', group, self.login])
1373 if rc != 0:
1374 print(report)
1375 assert rc == 0
1376
1377
1378class AddUser:
1379 '''Create a temporary test user and remove it again in the dtor.'''
1380
1381 def __init__(self, login=None, home=True, encrypt_home=False, group=None, lower=False, shell=None):
1382 '''Create a new user account with a random password.
1383
1384 By default, the login name is random, too, but can be explicitly
1385 specified with 'login'. By default, a home directory is created, this
1386 can be suppressed with 'home=False'.
1387
1388 This class differs from the TestUser class in that the adduser/deluser
1389 tools are used rather than the useradd/user/del tools. The adduser
1390 program is the only commandline program that can be used to add a new
1391 user with an encrypted home directory. It is possible that the AddUser
1392 class may replace the TestUser class in the future.'''
1393
1394 self.login = None
1395
1396 if os.geteuid() != 0:
1397 raise ValueError("You must be root to run this test")
1398
1399 if login:
1400 if login_exists(login):
1401 raise ValueError('login name already exists')
1402 else:
1403 while(True):
1404 login = 't' + random_string(7, lower=True)
1405 if not login_exists(login):
1406 break
1407
1408 self.password = random_string(8, lower=lower)
1409
1410 creation = ['adduser', '--quiet']
1411
1412 if not home:
1413 creation += ['--no-create-home']
1414 elif encrypt_home:
1415 creation += ['--encrypt-home']
1416
1417 if shell:
1418 creation += ['--shell', shell]
1419
1420 creation += ['--gecos', 'Buddy %s' % (login), login]
1421
1422 child = pexpect.spawn(creation.pop(0), creation, timeout=5)
1423 assert child.expect(b'(Enter new UNIX|New) password:') == 0
1424 child.sendline(self.password)
1425 assert child.expect(b'Retype new (UNIX )?password:') == 0
1426 child.sendline(self.password)
1427
1428 child.wait()
1429 child.close()
1430 assert child.exitstatus == 0
1431 assert child.signalstatus is None
1432
1433 self.login = login
1434
1435 if group:
1436 assert self.add_to_group(group) == 0
1437
1438 p = pwd.getpwnam(self.login)
1439 self.uid = p[2]
1440 self.gid = p[3]
1441 self.gecos = p[4]
1442 self.home = p[5]
1443 self.shell = p[6]
1444
1445 def __del__(self):
1446 '''Remove the created user account.'''
1447
1448 if self.login:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches