Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/etc/initramfs-tools/hooks/networking.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}

case $1 in
prereqs)
prereqs
exit 0
;;
esac


. /usr/share/initramfs-tools/hook-functions

# include a module dynamically loaded by a library
# $1 - directory to search for the library (may be / to search all of initramfs)
# $2 - library to search for
# $3 - module to include relative to library found
# example: lib_module /lib 'libc.so.*' 'libnss_dns.so.*'
# lib_module /usr/lib 'libpango-*.so.*' 'pango/*/modules/pango-basic-fc.so'
# Does not handle spaces in directory or module names and .. in module names.
# Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=636697
lib_module()
{
dir="$1"
lib="$2"
mod="$3"
{ find "${DESTDIR}${dir}" -name "${lib}" -type l
find "${DESTDIR}${dir}" -name "${lib}" -type f ; } | { while read i ; do
lib_dir="$(dirname "$i" | sed -e "s ^${DESTDIR} " )"
ls "${lib_dir}"/"${mod}" | { while read j ; do
copy_exec "$j"
done ; }
done ; }
}

# sys-libs/glibc loads additional libraries reqired for domain name lookups dynamically,
# they doesn't get picked up by initramfs installation scripts. Let's include them manually.
# For more information, see https://wiki.gentoo.org/wiki/Custom_Initramfs#DNS
lib_module /lib 'libc.so.*' 'libnss_dns.*'
lib_module /lib 'libc.so.*' 'libnss_files.so.*'
lib_module /lib 'libc.so.*' 'libresolv.so.*'
lib_module /usr/lib 'libc.so.*' 'libnss_dns.*'
lib_module /usr/lib 'libc.so.*' 'libnss_files.so.*'
lib_module /usr/lib 'libc.so.*' 'libresolv.so.*'
39 changes: 13 additions & 26 deletions src/etc/initramfs-tools/hooks/wget.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
#!/bin/sh -e
PREREQS=""
case $1 in
prereqs) echo "${PREREQS}"; exit 0;;
esac
. /usr/share/initramfs-tools/hook-functions

copy_exec /usr/bin/wget /usr/bin/real_wget

strace_and_copy_libs_for_url ()
#!/bin/sh
PREREQ="networking"
prereqs()
{
LIB_PAT="\".*/lib/.*\""
STRACED_LIBS=$(strace /usr/bin/wget --no-iri -q -O - "$1" 2>&1 | grep -o "$LIB_PAT")
echo "$PREREQ"
}

echo "$STRACED_LIBS" | while IFS= read -r line
do
# Strip the quotation marks
line="${line%\"}"
line="${line#\"}"
case $1 in
prereqs)
prereqs
exit 0
;;
esac

if [ -f "$line" ]
then
copy_exec "$line"
fi
done
}

strace_and_copy_libs_for_url "https://www.debian.org"
strace_and_copy_libs_for_url "https://raw.githubusercontent.com/stupidpupil/https-keyscript/master/tests/fixtures/encrypted_keyfile"
strace_and_copy_libs_for_url "https://mozilla-modern.badssl.com"
. /usr/share/initramfs-tools/hook-functions

copy_exec /usr/bin/wget /usr/bin/real_wget
copy_exec /etc/ssl/certs/ca-certificates.crt