diff --git a/src/usr/share/initramfs-tools/hooks/early_ssh b/src/usr/share/initramfs-tools/hooks/early_ssh index b84d782..4b401d9 100755 --- a/src/usr/share/initramfs-tools/hooks/early_ssh +++ b/src/usr/share/initramfs-tools/hooks/early_ssh @@ -1,5 +1,9 @@ #!/bin/bash +# Adjusted for slackware's initrd +# Andrew Clemons +# August 2016 + PREREQ="" prereqs() { @@ -13,39 +17,30 @@ prereqs) ;; esac -# load initramfs' hook functions -source /usr/share/initramfs-tools/hook-functions +if [ -z "$DESTDIR" ] ; then + echo "Missing destination directory. Use DESTDIR= to pass the destination directory." + exit 1 +fi # create the needed directories for i in /etc/dropbear /etc/early-ssh /root /root/.ssh /sbin /bin /usr/bin /var /var/log; do [ ! -e "${DESTDIR}${i}" ] && mkdir -p "${DESTDIR}${i}" done +if [ ! -e "${DESTDIR}/tmp" ] ; then + mkdir "${DESTDIR}/tmp" + chmod 1777 "${DESTDIR}/tmp" +fi + # copy the needed executables -copy_exec /usr/sbin/dropbear sbin/ -copy_exec /sbin/ifconfig sbin/ -copy_exec /sbin/route sbin/ -[ -f /usr/bin/scp ] && copy_exec /usr/bin/scp bin/ +cp -a /usr/bin/dropbearmulti $DESTDIR/sbin/dropbear +cp -a /usr/share/mkinitrd/scripts/early_ssh $DESTDIR/ # copy the configs cp -rp /etc/localtime $DESTDIR/etc/ cp -rp /etc/login.defs $DESTDIR/etc/ cp -rp /etc/early-ssh/early-ssh.conf $DESTDIR/etc/early-ssh/ -ls -1 /lib/libnss_files* 2>/dev/null >/dev/null -if [ $? == 0 ]; then - cp -rp /lib/libnss_files* $DESTDIR/lib/ -else - cp -rp `dpkg -L libc6 | grep '/libnss_files' | tr '\n' ' '` $DESTDIR/lib/ -fi - -ln -s /usr/lib/libz.so.1 $DESTDIR/usr/libz.so.1 - -echo "passwd: files -group: files -shadow: files -" > $DESTDIR/etc/nsswitch.conf - . /etc/early-ssh/early-ssh.conf if [ "$AUTHKEY_OVERRIDE" != "" ]; then @@ -62,18 +57,14 @@ fi if [ "$PASSWD_OVERRIDE" != "" ]; then cat $PASSWD_OVERRIDE >> $DESTDIR/etc/passwd -else - cat /etc/passwd | grep -E '^root:' | sed -e 's/:\/bin\/bash/:\/bin\/sh/' >> $DESTDIR/etc/passwd fi if [ "$SHADOW_OVERRIDE" != "" ]; then cat $SHADOW_OVERRIDE >> $DESTDIR/etc/shadow -else - cat /etc/shadow | grep -E '^root:' >> $DESTDIR/etc/shadow fi if [ "$GROUP_OVERRIDE" != "" ]; then cat $GROUP_OVERRIDE >> $DESTDIR/etc/group -else - cat /etc/group | grep -E '^root:' >> $DESTDIR/etc/group fi + +sed -i 's#/bin/bash#/bin/sh#g' $DESTDIR/etc/passwd diff --git a/src/usr/share/initramfs-tools/scripts/local-top/early_ssh b/src/usr/share/initramfs-tools/scripts/local-top/early_ssh index 83fad25..1078801 100755 --- a/src/usr/share/initramfs-tools/scripts/local-top/early_ssh +++ b/src/usr/share/initramfs-tools/scripts/local-top/early_ssh @@ -97,7 +97,7 @@ mv /dev/random /dev/random.old ln -s /dev/urandom /dev/random # start the dropbear in the background -/sbin/dropbear -d /etc/dropbear/dropbear_dss_host_key -r /etc/dropbear/dropbear_rsa_host_key -E -F -p $PORT & +/sbin/dropbear -F -p $PORT & dropbear_pid=$! # give a notice to the user he/she can log in over SSH now