diff -Nru initramfs-tools-0.122ubuntu8.2/debian/changelog initramfs-tools-0.122ubuntu8.3/debian/changelog --- initramfs-tools-0.122ubuntu8.2/debian/changelog 2016-09-23 22:01:48.000000000 +0000 +++ initramfs-tools-0.122ubuntu8.3/debian/changelog 2016-09-27 20:27:38.000000000 +0000 @@ -1,3 +1,13 @@ +initramfs-tools (0.122ubuntu8.3) xenial; urgency=medium + + * scripts/functions: make sure we can try to start all available and suitable + interfaces if ip= isn't set when setting up the network, and exit as soon + as we get an IP address. This retains the old behavior from ipconfig when + ip= is unset, for really simple remote-root scenarios. (LP: #1628306) + * scripts/functions: retain bootp/rarp behavior using ipconfig. + + -- Mathieu Trudel-Lapierre Tue, 27 Sep 2016 16:27:38 -0400 + initramfs-tools (0.122ubuntu8.2) xenial; urgency=medium [ Mathieu Trudel-Lapierre ] diff -Nru initramfs-tools-0.122ubuntu8.2/scripts/functions initramfs-tools-0.122ubuntu8.3/scripts/functions --- initramfs-tools-0.122ubuntu8.2/scripts/functions 2016-09-23 22:01:48.000000000 +0000 +++ initramfs-tools-0.122ubuntu8.3/scripts/functions 2016-09-27 20:25:48.000000000 +0000 @@ -194,6 +194,34 @@ return ${RET} } +all_netbootable_devices() +{ + for device in /sys/class/net/* ; do + if [ ! -e $device/flags ]; then + continue + fi + + loop=$(($(cat $device/flags) & 0x8 && 1 || 0)) + bc=$(($(cat $device/flags) & 0x2 && 1 || 0)) + ptp=$(($(cat $device/flags) & 0x10 && 1 || 0)) + + # Skip any device that is a loopback + if [ $loop = 1 ]; then + continue + fi + + # Skip any device that isn't a broadcast + # or point-to-point. + if [ $bc = 0 ] && [ $ptp = 0 ]; then + continue + fi + + DEVICE="$DEVICE $(basename $device)" + done + + echo $DEVICE +} + configure_networking() { if [ -n "${BOOTIF}" ]; then @@ -254,16 +282,38 @@ none|off) # Do nothing ;; - ""|::::*|on|any|dhcp|bootp|rarp|both) + ""|::::*|on|any|dhcp) # if IP contains something other than BOOTIF; use that # interface to bring up the network. if ! echo "${IP}" | grep -qc 'BOOTIF'; then DEVICE="${IP#*:*:*:*:*:*}"; fi + # if we don't have a device specified, try to bring up + # any eligible device. + if [ -z "${DEVICE}" ]; then + DEVICE=$(all_netbootable_devices) + fi + # Bring up device - dhclient -4 -1 -v "${DEVICE}" - dhclient -6 -1 -v "${DEVICE}" + for dev in "${DEVICE}"; do + dhclient -4 -1 -v "${dev}" + dhclient -6 -1 -v "${dev}" + + # If we reach BOUND or BOUND6, break out -- we + # got an interface configured. + if grep -qc BOUND /run/net-${dev}.conf; then + break + fi + done + + # At this point we should have configured an interface + # properly, or none were suitable. Keep track of the + # last device we reached to source the results later. + DEVICE=$dev + ;; + bootp|rarp|both) + ipconfig -t ${ROUNDTTT} -c ${IP} -d "${DEVICE}" ;; *) ipconfig -t ${ROUNDTTT} -d $IP