[PATCH 03/12] Dereference symbolic links in kirkwood directory

Geert Stappers <[email protected]>
Newsgroups gmane.linux.debian.devel.embedded
Message-ID <[email protected]>
This done by
   tar cf temp.tar --dereference kirkwood/
   tar xf temp.tar
   rm temp.tar
   git add kirkwood/

Now "git" does see this as

	typechange: kirkwood/hooks/create_user
	typechange: kirkwood/hooks/empty_password
	typechange: kirkwood/hooks/firstboot
	typechange: kirkwood/hooks/serial_tty
	typechange: kirkwood/packages/base
	typechange: kirkwood/packages/net
	typechange: kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends
	typechange: kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs
	typechange: kirkwood/root/etc/ld.so.conf
	typechange: kirkwood/root/etc/ssh/ssh_host_dsa_key
	typechange: kirkwood/root/etc/ssh/ssh_host_ecdsa_key
	typechange: kirkwood/root/etc/ssh/ssh_host_rsa_key
	typechange: kirkwood/root/sbin/ldconfig
	typechange: kirkwood/root/usr/bin/ldd
	typechange: kirkwood/root/usr/sbin/policy-rc.d
---
 kirkwood/hooks/create_user                         |    3 +-
 kirkwood/hooks/empty_password                      |    3 +-
 kirkwood/hooks/firstboot                           |   24 +++-
 kirkwood/hooks/serial_tty                          |    2 +-
 kirkwood/packages/base                             |   13 ++-
 kirkwood/packages/net                              |   13 ++-
 .../etc/apt/apt.conf.d/99no-install-recommends     |    2 +-
 kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs       |    2 +-
 kirkwood/root/etc/ld.so.conf                       |    3 +-
 kirkwood/root/etc/ssh/ssh_host_dsa_key             |    1 -
 kirkwood/root/etc/ssh/ssh_host_ecdsa_key           |    1 -
 kirkwood/root/etc/ssh/ssh_host_rsa_key             |    1 -
 kirkwood/root/sbin/ldconfig                        |    4 +-
 kirkwood/root/usr/bin/ldd                          |  202 +++++++++++++++++++-
 kirkwood/root/usr/sbin/policy-rc.d                 |    4 +-
 15 files changed, 263 insertions(+), 15 deletions(-)
 mode change 120000 => 100644 kirkwood/hooks/create_user
 mode change 120000 => 100644 kirkwood/hooks/empty_password
 mode change 120000 => 100644 kirkwood/hooks/firstboot
 mode change 120000 => 100644 kirkwood/hooks/serial_tty
 mode change 120000 => 100644 kirkwood/packages/base
 mode change 120000 => 100644 kirkwood/packages/net
 mode change 120000 => 100644 kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends
 mode change 120000 => 100644 kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs
 mode change 120000 => 100644 kirkwood/root/etc/ld.so.conf
 mode change 120000 => 100644 kirkwood/root/etc/ssh/ssh_host_dsa_key
 mode change 120000 => 100644 kirkwood/root/etc/ssh/ssh_host_ecdsa_key
 mode change 120000 => 100644 kirkwood/root/etc/ssh/ssh_host_rsa_key
 mode change 120000 => 100755 kirkwood/root/sbin/ldconfig
 mode change 120000 => 100755 kirkwood/root/usr/bin/ldd
 mode change 120000 => 100755 kirkwood/root/usr/sbin/policy-rc.d

diff --git a/kirkwood/hooks/create_user b/kirkwood/hooks/create_user
deleted file mode 120000
index ae9b334..0000000
--- a/kirkwood/hooks/create_user
+++ /dev/null
@@ -1 +0,0 @@
-../../default/hooks/create_user
\ No newline at end of file
diff --git a/kirkwood/hooks/create_user b/kirkwood/hooks/create_user
new file mode 100644
index 0000000..0404ea2
--- /dev/null
+++ b/kirkwood/hooks/create_user
@@ -0,0 +1,2 @@
+fakechroot chroot $ROOTDIR useradd user -p `openssl passwd -crypt -salt // ""` -s /bin/bash --create-home
+fakechroot chroot $ROOTDIR usermod -a -G audio,dialout user
diff --git a/kirkwood/hooks/empty_password b/kirkwood/hooks/empty_password
deleted file mode 120000
index 613fec1..0000000
--- a/kirkwood/hooks/empty_password
+++ /dev/null
@@ -1 +0,0 @@
-../../default/hooks/empty_password
\ No newline at end of file
diff --git a/kirkwood/hooks/empty_password b/kirkwood/hooks/empty_password
new file mode 100644
index 0000000..1c48613
--- /dev/null
+++ b/kirkwood/hooks/empty_password
@@ -0,0 +1,2 @@
+sed -i 's/\(root:\)[^:]*\(:\)/\1'`openssl passwd -crypt -salt // "" | sed 's/\(\/\|\\\|&\)/\\\&/g'`'\2/' $ROOTDIR/etc/shadow
+sed -i 's/\(PermitEmptyPasswords\) no/\1 yes/' $ROOTDIR/etc/ssh/sshd_config
diff --git a/kirkwood/hooks/firstboot b/kirkwood/hooks/firstboot
deleted file mode 120000
index d978812..0000000
--- a/kirkwood/hooks/firstboot
+++ /dev/null
@@ -1 +0,0 @@
-../../default/hooks/firstboot
\ No newline at end of file
diff --git a/kirkwood/hooks/firstboot b/kirkwood/hooks/firstboot
new file mode 100644
index 0000000..7f1119e
--- /dev/null
+++ b/kirkwood/hooks/firstboot
@@ -0,0 +1,23 @@
+cat > $ROOTDIR/etc/init.d/firstboot << __END__
+#!/bin/sh -e
+### BEGIN INIT INFO
+# Provides: firstboot
+# Required-Start: \$all
+# Required-Stop:
+# Default-Start: S
+# Default-Stop:
+### END INIT INFO
+
+for f in rsa dsa ecdsa; do rm -rf /etc/ssh/ssh_host_\${f}_key; done
+echo "generating ssh rsa key..."
+ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C "" -N ""
+echo "generating ssh dsa key..."
+ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C "" -N ""
+echo "generating ssh ecdsa key..."
+ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C "" -N ""
+
+update-rc.d -f firstboot remove
+__END__
+
+chmod +x $ROOTDIR/etc/init.d/firstboot
+fakechroot chroot $ROOTDIR update-rc.d firstboot start 99 S
diff --git a/kirkwood/hooks/serial_tty b/kirkwood/hooks/serial_tty
deleted file mode 120000
index f77cf2e..0000000
--- a/kirkwood/hooks/serial_tty
+++ /dev/null
@@ -1 +0,0 @@
-../../default/hooks/serial_tty
\ No newline at end of file
diff --git a/kirkwood/hooks/serial_tty b/kirkwood/hooks/serial_tty
new file mode 100644
index 0000000..4066a73
--- /dev/null
+++ b/kirkwood/hooks/serial_tty
@@ -0,0 +1 @@
+echo "T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100" >> $ROOTDIR/etc/inittab
diff --git a/kirkwood/packages/base b/kirkwood/packages/base
deleted file mode 120000
index 5b0599a..0000000
--- a/kirkwood/packages/base
+++ /dev/null
@@ -1 +0,0 @@
-../../default/packages/base
\ No newline at end of file
diff --git a/kirkwood/packages/base b/kirkwood/packages/base
new file mode 100644
index 0000000..e866da9
--- /dev/null
+++ b/kirkwood/packages/base
@@ -0,0 +1,12 @@
+udev
+module-init-tools
+apt
+locales
+procps
+conspy 
+man-db
+fbset
+openssh-server
+screen
+less
+vim
diff --git a/kirkwood/packages/net b/kirkwood/packages/net
deleted file mode 120000
index 21c287e..0000000
--- a/kirkwood/packages/net
+++ /dev/null
@@ -1 +0,0 @@
-../../default/packages/net
\ No newline at end of file
diff --git a/kirkwood/packages/net b/kirkwood/packages/net
new file mode 100644
index 0000000..87d45ae
--- /dev/null
+++ b/kirkwood/packages/net
@@ -0,0 +1,12 @@
+curl
+wget
+ntpdate
+vpnc
+rsync
+dhcp3-client
+ifupdown
+net-tools
+iproute
+dnsutils
+iputils-ping
+ppp
diff --git a/kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends b/kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends
deleted file mode 120000
index 9cf79f1..0000000
--- a/kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../default/root/etc/apt/apt.conf.d/99no-install-recommends
\ No newline at end of file
diff --git a/kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends b/kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends
new file mode 100644
index 0000000..25ec2b3
--- /dev/null
+++ b/kirkwood/root/etc/apt/apt.conf.d/99no-install-recommends
@@ -0,0 +1 @@
+APT::Install-Recommends "0";
diff --git a/kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs b/kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs
deleted file mode 120000
index a8c3da6..0000000
--- a/kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../default/root/etc/apt/apt.conf.d/99no-pdiffs
\ No newline at end of file
diff --git a/kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs b/kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs
new file mode 100644
index 0000000..07d01de
--- /dev/null
+++ b/kirkwood/root/etc/apt/apt.conf.d/99no-pdiffs
@@ -0,0 +1 @@
+Acquire::PDiffs "0";
diff --git a/kirkwood/root/etc/ld.so.conf b/kirkwood/root/etc/ld.so.conf
deleted file mode 120000
index e8d9ce9..0000000
--- a/kirkwood/root/etc/ld.so.conf
+++ /dev/null
@@ -1 +0,0 @@
-../../../default/root/etc/ld.so.conf
\ No newline at end of file
diff --git a/kirkwood/root/etc/ld.so.conf b/kirkwood/root/etc/ld.so.conf
new file mode 100644
index 0000000..a9d3ffc
--- /dev/null
+++ b/kirkwood/root/etc/ld.so.conf
@@ -0,0 +1,2 @@
+# supply ld.so.conf for fake ldd (running libc6 postinst script will fail)
+include /etc/ld.so.conf.d/*.conf
diff --git a/kirkwood/root/etc/ssh/ssh_host_dsa_key b/kirkwood/root/etc/ssh/ssh_host_dsa_key
deleted file mode 120000
index 3c63728..0000000
--- a/kirkwood/root/etc/ssh/ssh_host_dsa_key
+++ /dev/null
@@ -1 +0,0 @@
-../../../../default/root/etc/ssh/ssh_host_dsa_key
\ No newline at end of file
diff --git a/kirkwood/root/etc/ssh/ssh_host_dsa_key b/kirkwood/root/etc/ssh/ssh_host_dsa_key
new file mode 100644
index 0000000..e69de29
diff --git a/kirkwood/root/etc/ssh/ssh_host_ecdsa_key b/kirkwood/root/etc/ssh/ssh_host_ecdsa_key
deleted file mode 120000
index f5f2e31..0000000
--- a/kirkwood/root/etc/ssh/ssh_host_ecdsa_key
+++ /dev/null
@@ -1 +0,0 @@
-../../../../default/root/etc/ssh/ssh_host_ecdsa_key
\ No newline at end of file
diff --git a/kirkwood/root/etc/ssh/ssh_host_ecdsa_key b/kirkwood/root/etc/ssh/ssh_host_ecdsa_key
new file mode 100644
index 0000000..e69de29
diff --git a/kirkwood/root/etc/ssh/ssh_host_rsa_key b/kirkwood/root/etc/ssh/ssh_host_rsa_key
deleted file mode 120000
index 9753b5a..0000000
--- a/kirkwood/root/etc/ssh/ssh_host_rsa_key
+++ /dev/null
@@ -1 +0,0 @@
-../../../../default/root/etc/ssh/ssh_host_rsa_key
\ No newline at end of file
diff --git a/kirkwood/root/etc/ssh/ssh_host_rsa_key b/kirkwood/root/etc/ssh/ssh_host_rsa_key
new file mode 100644
index 0000000..e69de29
diff --git a/kirkwood/root/sbin/ldconfig b/kirkwood/root/sbin/ldconfig
deleted file mode 120000
index ba3ff23..0000000
--- a/kirkwood/root/sbin/ldconfig
+++ /dev/null
@@ -1 +0,0 @@
-../../../default/root/sbin/ldconfig
\ No newline at end of file
diff --git a/kirkwood/root/sbin/ldconfig b/kirkwood/root/sbin/ldconfig
new file mode 100755
index 0000000..a7b8b6d
--- /dev/null
+++ b/kirkwood/root/sbin/ldconfig
@@ -0,0 +1,3 @@
+#!/bin/sh -e
+
+exit
diff --git a/kirkwood/root/usr/bin/ldd b/kirkwood/root/usr/bin/ldd
deleted file mode 120000
index adf2fbc..0000000
--- a/kirkwood/root/usr/bin/ldd
+++ /dev/null
@@ -1 +0,0 @@
-../../../../default/root/usr/bin/ldd
\ No newline at end of file
diff --git a/kirkwood/root/usr/bin/ldd b/kirkwood/root/usr/bin/ldd
new file mode 100755
index 0000000..53e9533
--- /dev/null
+++ b/kirkwood/root/usr/bin/ldd
@@ -0,0 +1,201 @@
+#!/usr/bin/perl
+
+# fakeldd
+#
+# Replacement for ldd with usage of objdump
+#
+# (c) 2003-2010 Piotr Roszatycki <[email protected]>, LGPL
+
+use strict;
+
+my @Libs = ();
+my %Libs = ();
+
+my $Status = 0;
+my $Dynamic = 0;
+my $Format = '';
+
+my $Ldsodir = "/lib";
+my @Ld_Library_Path = qw(/usr/lib /lib /usr/lib32 /lib32 /usr/lib64 /lib64);
+
+
+sub ldso {
+    my ($lib) = @_;
+
+    return if $Libs{$lib};
+
+    my $path;
+
+    if ($lib =~ /^\//) {
+        $path = $lib;
+    }
+    else {
+        foreach my $dir (@Ld_Library_Path) {
+            next unless -f "$dir/$lib";
+
+            my $badformat = 0;
+            local *PIPE;
+            open PIPE, "objdump -p '$dir/$lib' 2>/dev/null |";
+            while (my $line = <PIPE>) {
+                if ($line =~ /file format (\S*)$/) {
+                    $badformat = 1 unless $1 eq $Format;
+                    last;
+                }
+            }
+            close PIPE;
+
+            next if $badformat;
+
+            $path = "$dir/$lib";
+            last;
+        }
+    }
+
+    push @Libs, $lib;
+    if (-f $path) {
+        $Libs{$lib} = $path;
+        objdump($path);
+    }
+}
+
+
+sub objdump {
+    my (@files) = @_;
+
+    foreach my $file (@files) {
+        local *PIPE;
+        open PIPE, "objdump -p '$file' 2>/dev/null |";
+        while (my $line = <PIPE>) {
+            $line =~ s/^\s+//;
+
+            if ($line =~ /file format (\S*)$/) {
+                if (not $Format) {
+                    $Format = $1;
+
+                    if ($^O eq 'linux') {
+                        if ($Format =~ /^elf64-/) {
+                            push @Libs, 'linux-vdso.so.1';
+                            $Libs{'linux-vdso.so.1'} = '';
+                        }
+                        else {
+                            push @Libs, 'linux-gate.so.1';
+                            $Libs{'linux-gate.so.1'} = '';
+                        }
+                    }
+
+                    foreach my $lib (split /:/, $ENV{LD_PRELOAD}||'') {
+                        ldso($lib);
+                    }
+                }
+                else {
+                    next unless $Format eq $1;
+                }
+            }
+            if (not $Dynamic and $line =~ /^Dynamic Section:/) {
+                $Dynamic = 1;
+            }
+
+            next unless $line =~ /^ \s* NEEDED \s+ (.*) \s* $/x;
+
+            my $needed = $1;
+            if ($needed =~ /^ld(-linux)?(\.|-)/) {
+                $needed = "$Ldsodir/$needed";
+            }
+
+            ldso($needed);
+        }
+        close PIPE;
+    }
+}
+
+
+sub load_ldsoconf {
+    my ($file) = @_;
+
+    local *FH;
+    open FH, $file;
+    while (my $line = <FH>) {
+        chomp $line;
+        $line =~ s/#.*//;
+        next if $line =~ /^\s*$/;
+
+        if ($line =~ /^include\s+(.*)\s*/) {
+            my $include = $1;
+            foreach my $incfile (glob $include) {
+                load_ldsoconf($incfile);
+            }
+            next;
+        }
+
+        unshift @Ld_Library_Path, $line;
+    }
+    close FH;
+}
+
+
+MAIN: {
+    my @args = @ARGV;
+
+    if (not @args) {
+        print STDERR "fakeldd: missing file arguments\n";
+        exit 1;
+    }
+
+    if (not `which objdump`) {
+        print STDERR "fakeldd: objdump: command not found: install binutils package\n";
+        exit 1;
+    }
+
+    load_ldsoconf('/etc/ld.so.conf');
+    unshift @Ld_Library_Path, split(/:/, $ENV{LD_LIBRARY_PATH}||'');
+
+    while ($args[0] =~ /^-/) {
+        my $arg = $args[0];
+        shift @ARGV;
+        last if $arg eq "--";
+    }
+
+    foreach my $file (@args) {
+        %Libs = ();
+        $Dynamic = 0;
+
+        if (@args > 1) {
+            print "$file:\n";
+        }
+
+        if (not -f $file) {
+            print STDERR "ldd: $file: No such file or directory\n";
+            $Status = 1;
+            next;
+        }
+
+        objdump($file);
+
+        if ($Dynamic == 0) {
+            print "\tnot a dynamic executable\n";
+            $Status = 1;
+        }
+        elsif (scalar %Libs eq "0") {
+            print "\tstatically linked\n";
+        }
+
+        my $address = '0x' . '0' x ($Format =~ /^elf64-/ ? 16 : 8);
+
+        foreach my $lib (@Libs) {
+            if ($lib =~ /^\//) {
+                printf "\t%s (%s)\n", $lib, $address;
+            }
+            elsif (defined $Libs{$lib}) {
+                printf "\t%s => %s (%s)\n", $lib, $Libs{$lib}, $address;
+            }
+            else {
+                printf "\t%s => not found\n", $lib;
+            }
+        }
+
+    }
+}
+
+END {
+    $? = $Status;
+}
diff --git a/kirkwood/root/usr/sbin/policy-rc.d b/kirkwood/root/usr/sbin/policy-rc.d
deleted file mode 120000
index 93e300d..0000000
--- a/kirkwood/root/usr/sbin/policy-rc.d
+++ /dev/null
@@ -1 +0,0 @@
-../../../../default/root/usr/sbin/policy-rc.d
\ No newline at end of file
diff --git a/kirkwood/root/usr/sbin/policy-rc.d b/kirkwood/root/usr/sbin/policy-rc.d
new file mode 100755
index 0000000..85d823d
--- /dev/null
+++ b/kirkwood/root/usr/sbin/policy-rc.d
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "sysvinit: All runlevel operations denied by policy" >&2
+exit 101
-- 
1.7.2.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.