Ubuntu Pastebin

Paste from smoser at Thu, 19 Mar 2015 13:00:03 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff --git a/debian/changelog b/debian/changelog
index 5271baa..12963ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,22 @@
+systemd (219-4ubuntu7~ppa0) vivid; urgency=medium
+
+  * use systemd-ifupdown-helper script to handle ifup and ifdown
+    of auto or hotplug devices.  This allows iscsi root volumes
+    to work again. (LP: #1432829)
+  * debian/control/tests: disable running of upstart tests until
+    upstart packaging bug 1434058 is resolved.
+
+ -- Scott Moser <smoser@ubuntu.com>  Wed, 18 Mar 2015 20:08:41 -0400
+
+systemd (219-4ubuntu6) vivid; urgency=medium
+
+  * d/extra/units/ifup@.service, d/extra/tmpfiles.d/debian.conf:
+    use tmpfiles.d population of /run/network rather than
+    'RuntimeDirectory' in the ifup service.  This way files created
+    in initramfs are not deleted. (LP: #1432821)
+
+ -- Scott Moser <smoser@ubuntu.com>  Tue, 17 Mar 2015 19:40:45 -0400
+
 systemd (219-4ubuntu5) vivid; urgency=medium
 
   * Merge from experimental branch:
diff --git a/debian/extra/systemd-ifupdown-helper b/debian/extra/systemd-ifupdown-helper
new file mode 100644
index 0000000..ee21958
--- /dev/null
+++ b/debian/extra/systemd-ifupdown-helper
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+CR="
+"
+IFSTATE_FILE="/run/network/ifstate"
+
+do_ifup() {
+    local ifname="$1"
+    ifquery --list --allow=hotplug | grep -q "^$ifname$" ||
+        ifquery --list --allow=auto | grep -q "^$ifname$" ||
+        return 0
+    ifup "$ifname"
+}
+
+is_persistent_initramfs_iface() {
+    # open-iscsi.interface is written by open-iscsi when booting from
+    # an iscsi volume, when you can't bounce the interface that the root
+    # device is on.  The other file, is meant as a more generic location
+    # for an initramfs job to write "persistent" network devices.
+    grep -qs "^$1$" /run/initramfs/open-iscsi.interface \
+        "/run/network/initramfs-persistent-iface"
+}
+
+adjust_resolvconf() {
+    local ifname="$1" data=""
+    command -v resolvconf >/dev/null 2>&1 || return 0
+
+    # /run/net-eth0.conf is written by 'ipconfig' in klibc
+    [ -f "/run/net-$ifname.conf" ] || return 0
+    . "/run/net-$ifname.conf"
+    data=""
+    [ -n "$DOMAINSEARCH" ] && data="$data${CR}domainsearch $DOMAINSEARCH"
+    for ns in "$IPV4DNS0" "$IPV4DNS1"; do
+        [ -n "$ns" -a "$ns" != "0.0.0.0" ] && data="$data${CR}nameserver $ns"
+    done
+    data=${data#${CR}}
+    [ -z "$data" ] && return 0
+    echo "$data" | resolvconf -a "$ifname.initramfs"
+}
+
+do_ifup_persistent() {
+    local ifname="$1"
+    # already done
+    grep -qs "$ifname=" $IFSTATE_FILE && return 0
+
+    adjust_resolvconf "$ifname" || return
+    # write to the ifstate file, so ifupdown thinks its up.
+    echo "$ifname=$ifname" >> $IFSTATE_FILE
+}
+
+start_main() {
+    local ifname=$1
+    shift
+    if is_persistent_initramfs_iface "$ifname"; then
+         do_ifup_persistent "$ifname" "$@" || return
+    fi
+    do_ifup "$ifname" "$@"
+}
+
+stop_main() {
+    local ifname="$1" fail=0
+    shift
+    if ! is_persistent_initramfs_iface "$ifname"; then
+        /sbin/ifdown "$ifname"
+        return
+    fi
+    # we only pretend to bring the interface down
+    # if interface is not present, we're already done
+    grep -qs "^$ifname=" $IFSTATE_FILE || return 0
+
+    sed -i "/^$ifname=/d" "$IFSTATE_FILE" || fail=1
+    resolvconf -d "$ifname.initramfs" || fail=1
+    return $fail
+}
+
+mode="$1"
+shift;
+case "$mode" in
+    start) start_main "$@";;
+    stop) stop_main "$@";;
+    *) echo "$0: unknown mode '$mode'" 1>&2; exit 1;;
+esac
+exit
diff --git a/debian/extra/tmpfiles.d/debian.conf b/debian/extra/tmpfiles.d/debian.conf
index 83f7586..02612dc 100644
--- a/debian/extra/tmpfiles.d/debian.conf
+++ b/debian/extra/tmpfiles.d/debian.conf
@@ -11,3 +11,4 @@
 L /run/initctl -    -    -    -   /run/systemd/initctl/fifo
 L /run/shm     -    -    -    -   /dev/shm
 d /run/sendsigs.omit.d 0755 root root -
+d /run/network         0755 root root -
diff --git a/debian/extra/units/ifup@.service b/debian/extra/units/ifup@.service
index d6dd1b0..d87749b 100644
--- a/debian/extra/units/ifup@.service
+++ b/debian/extra/units/ifup@.service
@@ -7,10 +7,6 @@ DefaultDependencies=no
 
 [Service]
 Type=oneshot
-RuntimeDirectory=network
-ExecStart=/sbin/ifup --allow=hotplug %I
-ExecStartPost=/sbin/ifup --allow=auto %I
-# only fail if ifupdown knows about the iface AND it's not up
-ExecStartPost=/bin/sh -c 'if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi'
-ExecStop=/sbin/ifdown %I
+ExecStart=/lib/systemd/systemd-ifupdown-helper start %I
+ExecStop=/lib/systemd/systemd-ifupdown-helper stop %I
 RemainAfterExit=true
diff --git a/debian/systemd.install b/debian/systemd.install
index e0eaed5..cff3719 100644
--- a/debian/systemd.install
+++ b/debian/systemd.install
@@ -53,3 +53,4 @@ usr/share/locale/
 ../../extra/tmpfiles.d/*.conf usr/lib/tmpfiles.d/
 ../../extra/debian-fixup lib/systemd/
 ../../extra/units/* lib/systemd/system/
+../../extra/systemd-ifupdown-helper lib/systemd/
diff --git a/debian/tests/control b/debian/tests/control
index 4945c83..de8ab12 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -22,6 +22,7 @@ Depends: systemd-sysv, lightdm, cron, network-manager, busybox-static, apparmor
 Restrictions: needs-root, isolation-machine, needs-recommends, breaks-testbed
 
 Tests: cmdline-upstart-boot
+Disabled-until-bug-fixed: http://pad.lv/1434058
 Depends: systemd-sysv, cron, network-manager, python3
 Restrictions: needs-root, isolation-machine, breaks-testbed
 
Download as text