From: Vincent Bernat Date: Sun, 18 Mar 2007 15:46:42 +0000 (+0000) Subject: Generate a 24 bytes key instead of using the default one X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ea6c00d95fb929f5ff1328f76fa10cc42cedcc06;p=roundcube.git Generate a 24 bytes key instead of using the default one --- diff --git a/debian/postinst b/debian/postinst index 9af208a..b7996ff 100644 --- a/debian/postinst +++ b/debian/postinst @@ -34,8 +34,24 @@ case "$1" in db_get roundcube/language || true language="$RET" + + # Get current 3DES key from /etc/roundcube/main.inc.php + [ -f /etc/roundcube/main.inc.php ] && { + deskey=$(sed -n "s+^\$rcmail_config\['des_key'\] = '\(.*\)';\$+\1+p" \ + /etc/roundcube/main.inc.php) + } + # If this is the default key, forget it ! + [ "$deskey" = "rcmail-!24ByteDESkey*Str" ] && unset deskey + # Generate a new one + while [ -z "$deskey" ]; do + deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | \ + tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') + done + + # Put hosts, language and key in main.inc.php zcat /usr/share/doc/roundcube/main.inc.php.dist.gz | \ sed -e "s+^\(\$rcmail_config\['default_host'\] = \)''\(;\)\$+\1${hosts}\2+" \ + -e "s+^\(\$rcmail_config\['des_key'\] = '\).*\(';\)\$+\1$deskey\2+" \ -e "s+^\(\$rcmail_config\['locale_string'\] = '\).*\(';\)\$+\1${language}\2+" >> $CONFFILE.ucftmp ucf --debconf-ok $CONFFILE.ucftmp $CONFFILE