3 # Copyright (c) 1999-2001 Jason Gunthorpe <jgg@debian.org>
4 # Copyright (c) 2002-2003,2006 Ryan Murray <rmurray@debian.org>
5 # Copyright (c) 2004-2005 Joey Schulze <joey@infodrom.org>
6 # Copyright (c) 2008 Peter Palfrader <peter@palfrader.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 # Without effect on the commandline
25 if [ -z "$TERM" -o "$TERM" = "dumb" ]
28 sleep $(( $RANDOM % 120 ))
33 PATH=/sbin:/usr/sbin:/bin:/usr/bin
36 SYNCHOST=`ud-config synchost`;
37 LOCALSYNCON=`ud-config localsyncon`;
39 cd /var/lib/misc || cd /var/state/glibc/ || cd /var/db/
40 lockfile -r 1 -l 3600 lock
41 trap "rm -f lock" exit
48 udhost="sshdist@$SYNCHOST:"
52 rsync ${verbose} -e 'ssh -i /etc/ssh/ssh_host_rsa_key -o PreferredAuthentications=publickey' -rp "${udhost}/var/cache/userdir-ldap/hosts/$HOST" .
54 makedb "$HOST/passwd.tdb" -o passwd.db.t
55 if [ -s "$HOST/shadow.tdb" ]
57 (umask 027 && makedb "$HOST/shadow.tdb" -o shadow.db.t)
58 chown root.shadow shadow.db.t
59 chmod 0640 shadow.db.t
60 mv -f shadow.db.t shadow.db
62 makedb "$HOST/group.tdb" -o group.db.t
63 mv -f passwd.db.t passwd.db
64 mv -f group.db.t group.db
65 for a in $HOST/ssh-rsa-shadow $HOST/ssh_known_hosts; do
68 ln -sf `pwd -P`/ssh-rsa-shadow /etc/ssh
69 ln -sf `pwd -P`/ssh_known_hosts /etc/ssh
71 find $HOST -name "ssh-rsa-shadow-*" -type f | while read f
73 user=$(echo $f | sed s@.*-@@)
74 id ${user} 2>/dev/null >/dev/null
80 if [ -x /usr/bin/dchroot ]; then
81 CHROOTS=`dchroot --listpaths`
83 if [ -x "$c/usr/bin/makedb" ]
86 test ! -d "$c/var/lib/misc/$HOST" || mkdir -p "$c/var/lib/misc/$HOST"
88 rsync -a ${verbose} $HOST/group.tdb $HOST/passwd.tdb $HOST/ssh* "$c/var/lib/misc/$HOST"
90 test ! -f "$c/var/lib/misc/$HOST/shadow.tdb" || rm -f "$c/var/lib/misc/$HOST/shadow.tdb"
91 test ! -f "$c/var/lib/misc/shadow.db" || rm -f "$c/var/lib/misc/shadow.db"
93 chroot "$c" makedb "/var/lib/misc/$HOST/passwd.tdb" -o /var/lib/misc/passwd.db.t
94 chroot "$c" makedb "/var/lib/misc/$HOST/group.tdb" -o /var/lib/misc/group.db.t
95 mv -f "$c/var/lib/misc/passwd.db.t" "$c/var/lib/misc/passwd.db"
96 mv -f "$c/var/lib/misc/group.db.t" "$c/var/lib/misc/group.db"
97 ln -sf "$HOST/ssh_known_hosts" "$c/var/lib/misc/"
98 ln -sf ../../var/lib/misc/ssh_known_hosts "$c/etc/ssh"
103 if [ -d "/etc/exim4" -a -e "$HOST/bsmtp" ]; then
104 if perl -e 'exit !((stat "/etc/exim4/bsmtp")[9] < time()-3600)'; then
105 cp "$HOST/bsmtp" /etc/exim4/bsmtp
108 if [ -d "/etc/postfix" -a -f "$HOST/forward-alias" ]; then
109 sed -e 's/:/@debian.org/' $HOST/forward-alias > /etc/postfix/debian
110 /usr/sbin/postmap hash:/etc/postfix/debian < /etc/postfix/debian || true