]> git.donarmstrong.com Git - roundcube.git/commitdiff
Generate a 24 bytes key instead of using the default one
authorVincent Bernat <bernat@luffy.cx>
Sun, 18 Mar 2007 15:46:42 +0000 (15:46 +0000)
committerVincent Bernat <bernat@luffy.cx>
Sun, 18 Mar 2007 15:46:42 +0000 (15:46 +0000)
debian/postinst

index 9af208a87b911c1334b449244a84375a566bf90e..b7996ffe1a728d09e08f6e806649b7b718b7ddb3 100644 (file)
@@ -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