-#if [ -x /usr/bin/dchroot ]; then
-# CHROOTS=`dchroot --listpaths`
-# for c in $CHROOTS; do
-# if [ -e "$c/var/lib/misc/$HOST" ]; then
-# chroot "$c" makedb "/var/lib/misc/$HOST/passwd.tdb" -o /var/lib/misc/passwd.db.t
-# (umask 027 && chroot "$c" makedb "/var/lib/misc/$HOST/shadow.tdb" -o /var/lib/misc/shadow.db.t)
-# chown root.shadow "$c/var/lib/misc/shadow.db.t"
-# chmod 0640 "$c/var/lib/misc/shadow.db.t"
-# chroot "$c" makedb "/var/lib/misc/$HOST/group.tdb" -o /var/lib/misc/group.db.t
-# mv -f "$c/var/lib/misc/passwd.db.t" "$c/var/lib/misc/passwd.db"
-# mv -f "$c/var/lib/misc/shadow.db.t" "$c/var/lib/misc/shadow.db"
-# mv -f "$c/var/lib/misc/group.db.t" "$c/var/lib/misc/group.db"
-# fi
-# done
-#fi
-ln -sf "$HOST/ssh-rsa-shadow" .
-ln -sf "$HOST/ssh_known_hosts" .
-if [ -d "/etc/exim" -a -e "$HOST/bsmtp" ]; then
- if perl -e 'exit !((stat "/etc/exim/bsmtp")[9] < time()-3600)'; then
- cp "$HOST/bsmtp" /etc/exim/bsmtp
+if [ -e "$HOST/ssh-rsa-shadow" ]; then
+ ln -sf $HOST/ssh-rsa-shadow .
+ ln -sf `pwd -P`/ssh-rsa-shadow /etc/ssh
+else
+ rm -f ssh-rsa-shadow /etc/ssh/ssh-rsa-shadow
+fi
+ln -sf $HOST/ssh_known_hosts .
+ln -sf `pwd -P`/ssh_known_hosts /etc/ssh
+
+if [ -e ${HOST}/ssh-keys.tar.gz ]; then
+ export TMPDIR='/tmp/'
+ tempdir=$(mktemp -d)
+ tar -C "$tempdir" -xf ${HOST}/ssh-keys.tar.gz
+ mkdir -p userkeys
+ chmod 755 $tempdir
+ rsync -a --delete-after $tempdir/ userkeys/
+fi
+
+CHROOTS=""
+if [ -x /usr/bin/dchroot ]; then
+ CHROOTS=`dchroot --listpaths`
+elif [ -x /usr/bin/dchroot-dsa ]; then
+ CHROOTS=$(dchroot-dsa -i | grep Location | awk '{print $2}')
+fi
+if [ -n "$CHROOTS" ]; then
+ for c in $CHROOTS; do
+ if [ "$c" = "/" ] || [ "$c" = "" ]; then
+ echo "$0 WTF: \$c is '' or '/' here." 2>&1
+ exit 1
+ fi
+ if [ -x "$c/usr/bin/makedb" ]
+ then
+ mkdir -p "$c/var/lib/misc/$HOST"
+
+ # remove extra stuff from earlier times and so
+ find "$c/var/lib/misc/$HOST" -mindepth 1 \
+ ! -name group.tdb -a \
+ ! -name passwd.tdb -a \
+ ! -name ssh_known_hosts \
+ -print0 | xargs --no-run-if-empty -0 rm -f
+ rsync -a ${verbose} $HOST/group.tdb $HOST/passwd.tdb $HOST/ssh_known_hosts "$c/var/lib/misc/$HOST"
+
+ # clean up from the times we supposedly did shadow stuff in chroots
+ rm -f "$c/var/lib/misc/shadow.db"
+
+ # from failed makedb runs earlier.
+ rm -f "$c/var/lib/misc/passwd.db.t" \
+ "$c/var/lib/misc/group.db.t"
+ # build passwd information
+ chroot "$c" makedb "/var/lib/misc/$HOST/passwd.tdb" -o /var/lib/misc/passwd.db.t
+ chroot "$c" makedb "/var/lib/misc/$HOST/group.tdb" -o /var/lib/misc/group.db.t
+ mv -f "$c/var/lib/misc/passwd.db.t" "$c/var/lib/misc/passwd.db"
+ mv -f "$c/var/lib/misc/group.db.t" "$c/var/lib/misc/group.db"
+
+ ln -sf "$HOST/ssh_known_hosts" "$c/var/lib/misc/"
+ if [ -d "$c/etc/ssh" ]; then
+ ln -sf ../../var/lib/misc/ssh_known_hosts "$c/etc/ssh"
+ elif [ -L "$c/etc/ssh" ] && [ "`readlink \"$c/etc/ssh\"`" = "../../var/lib/misc/ssh_known_hosts" ]; then
+ # clean up past mistakes
+ rm -f "$c/etc/ssh"
+ fi
+ fi
+ done
+fi
+
+if [ -d "/etc/exim4" -a -e "$HOST/bsmtp" ]; then
+ if perl -e 'exit !((stat "/etc/exim4/bsmtp")[9] < time()-3600)'; then
+ cp "$HOST/bsmtp" /etc/exim4/bsmtp