From 3865d9a25853995474f9141a5fdfc6cfe4477186 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 30 May 2012 16:46:05 +1200 Subject: Include all the libnss libraries we can find --- clubber | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'clubber') diff --git a/clubber b/clubber index 0729d07..48bb5f4 100755 --- a/clubber +++ b/clubber @@ -21,6 +21,7 @@ use warnings; use Cwd qw(abs_path); use Digest::MD5; use File::Basename; +use File::Find; use Getopt::Long; # @@ -82,6 +83,30 @@ foreach my $binary (@$binaries) { } } +# +# Include all libnss libraries available, because even static binaries depend +# on these for reading files like /etc/passwd. I leave importing those files to +# you because it's entirely possible you actually intend to have a different +# /etc/passwd or /etc/resolv.conf in your chroot environment. Good practice, +# even. +# +# If two of the libraries have the exact same filename, use the one with the +# shortest complete path. +# +my $nsslibs = {}; +my $nssfind = sub { + my $basename = $_; + if ($File::Find::name =~ /libnss/) { + if (!exists $nsslibs->{$basename} or length($File::Find::name) < length($nsslibs->{$basename})) { + $nsslibs->{$basename} = $File::Find::name; + } + } +}; +find($nssfind, qw(/lib /usr/lib)); +foreach my $nsslib (keys(%$nsslibs)) { + $libraries->{$nsslibs->{$nsslib}} = 1; +} + # # If we have a chroot, we need to figure out what libraries require importing # and which directories require creating. -- cgit v1.2.3