From 93dde12ee2e255aba328b73ac02ff473b76bf50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Tue, 4 Aug 2009 19:29:01 +0000 Subject: [PATCH] fix alternc-slaves detection and warn the user if there's no key to authorize --- debian/alternc.postinst | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/debian/alternc.postinst b/debian/alternc.postinst index 0b5374ac..bba346d9 100644 --- a/debian/alternc.postinst +++ b/debian/alternc.postinst @@ -158,19 +158,26 @@ EOF # multi-server configuration: we create an alternc account with # authorized keys. since this is the master, we do not give him a # valid shell, but we still need the user for proper perms - if [ ! -z "$ALTERNC_SLAVES" && "$ALTERNC_SLAVES" != "localhost" ] ; then + if [ ! -z "$ALTERNC_SLAVES" ] && [ "$ALTERNC_SLAVES" != "localhost" ] ; then if ! grep -q alternc /etc/passwd ; then echo "Creating alternc account" adduser --quiet --system --uid 342 --home $ALTERNC_LOC --shell /bin/false --ingroup adm alternc fi - key=`cat ~root/.ssh/id_dsa.pub` - if ! grep -q "$key" $ALTERNC_LOC/.ssh/authorized_keys ; then - echo "Authorizing root ssh key to access the common alternc account" - mkdir -p $ALTERNC_LOC/.ssh - echo "$key" >> $ALTERNC_LOC/.ssh/authorized_keys - chown -R alternc:adm $ALTERNC_LOC/.ssh - chmod -R og-rwx $ALTERNC_LOC/.ssh + if [ -r ~root/.ssh/id_dsa.pub ]; then + key=`cat ~root/.ssh/id_dsa.pub` + if ! grep -q "$key" $ALTERNC_LOC/.ssh/authorized_keys ; then + echo "Authorizing root ssh key to access the common alternc account" + mkdir -p $ALTERNC_LOC/.ssh + echo "$key" >> $ALTERNC_LOC/.ssh/authorized_keys + chown -R alternc:adm $ALTERNC_LOC/.ssh + chmod -R og-rwx $ALTERNC_LOC/.ssh + fi + else + echo "No SSH key in "~root/.ssh/id_dsa.pub + echo "create one and reconfigure alternc to propagate SSH keys" fi + else + echo "AlternC slaves not configured ($ALTERNC_SLAVES)" fi # /var/alternc/dns/d/www.example.com