diff --git a/src/initramfs-tools/hooks/clevis.in b/src/initramfs-tools/hooks/clevis.in index 2c8473c3..3d4eb67f 100755 --- a/src/initramfs-tools/hooks/clevis.in +++ b/src/initramfs-tools/hooks/clevis.in @@ -95,3 +95,11 @@ bash_bin=$(find_binary "bash") copy_exec "${curl_bin}" || die 2 "Unable to copy ${curl_bin} to initrd image" copy_exec "${awk_bin}" || die 2 "Unable to copy ${awk_bin} to initrd image" copy_exec "${bash_bin}" || die 2 "Unable to copy ${bash_bin} to initrd image" + +# Copy latest versions of shared objects needed for DNS resolution +for so in $(ldconfig -p | sed -nr 's/^\s*libnss_files\.so\.[0-9]+\s.*=>\s*//p'); do + copy_exec "${so}" +done +for so in $(ldconfig -p | sed -nr 's/^\s*libnss_dns\.so\.[0-9]+\s.*=>\s*//p'); do + copy_exec "${so}" +done diff --git a/src/initramfs-tools/scripts/local-top/clevis.in b/src/initramfs-tools/scripts/local-top/clevis.in index 7c08a724..14872647 100755 --- a/src/initramfs-tools/scripts/local-top/clevis.in +++ b/src/initramfs-tools/scripts/local-top/clevis.in @@ -263,6 +263,23 @@ do_configure_networking() { echo "clevis: Warning: multiple network interfaces available but no ip= parameter provided." fi configure_networking + + # Add DNS servers from configure_networking to /etc/resolv.conf + if [ ! -e /etc/resolv.conf ]; then + touch /etc/resolv.conf + for intf in /run/net-*.conf; do + . "${intf}" + if [ ! -z "${IPV4DNS0}" ] && [ "${IPV4DNS0}" != "0.0.0.0" ]; then + echo nameserver "${IPV4DNS0}" >> /etc/resolv.conf + fi + if [ ! -z "${IPV4DNS1}" ] && [ "${IPV4DNS1}" != "0.0.0.0" ]; then + echo nameserver "${IPV4DNS1}" >> /etc/resolv.conf + fi + if [ ! -z "${IPV6DNS0}" ]; then + echo nameserver "${IPV6DNS0}" >> /etc/resolv.conf + fi + done + fi fi }