diff --git a/setup/management.sh b/setup/management.sh index 0f6e4d0a..7ea1332b 100755 --- a/setup/management.sh +++ b/setup/management.sh @@ -8,7 +8,7 @@ hide_output pip3 install rtyaml # Create a backup directory and a random key for encrypting backups. mkdir -p $STORAGE_ROOT/backup if [ ! -f $STORAGE_ROOT/backup/secret_key.txt ]; then - openssl rand -base64 2048 > $STORAGE_ROOT/backup/secret_key.txt + $(umask 077; openssl rand -base64 2048 > $STORAGE_ROOT/backup/secret_key.txt) fi # Link the management server daemon into a well known location. diff --git a/setup/migrate.py b/setup/migrate.py index 87c915ab..d2ecff24 100755 --- a/setup/migrate.py +++ b/setup/migrate.py @@ -56,6 +56,10 @@ def migration_4(env): db = os.path.join(env["STORAGE_ROOT"], 'mail/users.sqlite') shell("check_call", ["sqlite3", db, "ALTER TABLE users ADD privileges TEXT NOT NULL DEFAULT ''"]) +def migration_5(env): + # The secret key for encrypting backups was world readable. Fix here. + os.chmod(os.path.join(env["STORAGE_ROOT"], 'backup/secret_key.txt'), 0o600) + def get_current_migration(): ver = 0 while True: