copy_binaries: utility function to pick up a binary and needed libs

The existing multipath functionality manually picks up a binary and lots
of needed libraries manually, and sometimes misses libraries if the
binary was linked against something else.

Use lddtree from app-misc/pax-utils to get all libraries with the
binary. The only ones that will be missed are those that are dlopen()ed.
cpio is used for copying to preserve directory structure.

lddtree usage replaces a larger manual function from calling ldd, that
was also vulnerable to injections.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
(commit message rewritten)
cleanup-cruft
Richard Yao 13 years ago committed by Robin H. Johnson
parent af26e433cb
commit 1079122ea0

@ -5,6 +5,10 @@
# Distributed under the GPL v2 # Distributed under the GPL v2
# $Id$ # $Id$
06 Feb 2012: Richard Yao <ryao@cs.stonybrook.edu> gen_initramfs.sh:
copy_binaries utility function for putting binaries and librares into
initramfs (see git commit for full details).
06 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> defaults/initrd.scripts: 06 Feb 2012; Robin H. Johnson <robbat2@gentoo.org> defaults/initrd.scripts:
Support virtio devices, and provide fallback of all remaining devices. Support virtio devices, and provide fallback of all remaining devices.

@ -3,6 +3,15 @@
CPIO_ARGS="--quiet -o -H newc" CPIO_ARGS="--quiet -o -H newc"
copy_binaries() {
local destdir=$1 files=$2
# Copy files
lddtree $files | tr ')(' '\n' |awk '/=>/{ if($3 ~ /^\//){print $3}}' | sort | uniq | cpio -p --make-directories --dereference --quiet $destdir
}
append_base_layout() { append_base_layout() {
if [ -d "${TEMP}/initramfs-base-temp" ] if [ -d "${TEMP}/initramfs-base-temp" ]
then then

Loading…
Cancel
Save