aboutsummaryrefslogtreecommitdiff
path: root/clubber
diff options
context:
space:
mode:
Diffstat (limited to 'clubber')
-rwxr-xr-xclubber25
1 files changed, 25 insertions, 0 deletions
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;
#
@@ -83,6 +84,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.
#