Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add sanity-checks to config writes
Leendert de Borst3e29a352d3a9
diff --git a/install.sh b/install.shindex 64f9decf1..bef30e743 100755--- a/install.sh+++ b/install.sh@@ -1362,13 +1362,19 @@ write_secret_to_file() {# Create secrets directory if it doesn't existif [ ! -d "$SECRETS_DIR" ]; then- mkdir -p "$SECRETS_DIR"- chmod 700 "$SECRETS_DIR"+ if ! mkdir -p "$SECRETS_DIR"; then+ printf " ${RED}> Failed to create secrets directory $SECRETS_DIR (permission denied?)${NC}\n" >&2+ return 1+ fi+ chmod 700 "$SECRETS_DIR" 2>/dev/null || truefi- # Write secret to file- echo -n "$secret_value" > "$secret_file"- chmod 600 "$secret_file"+ # Write secret to file.+ if ! echo -n "$secret_value" > "$secret_file"; then+ printf " ${RED}> Failed to write secret $secret_name to $secret_file (permission denied?)${NC}\n" >&2+ return 1+ fi+ chmod 600 "$secret_file" 2>/dev/null || trueprintf " ${GREEN}> Secret $secret_name has been written to $secret_file${NC}\n"}@@ -2785,9 +2791,6 @@ handle_install_version() {printf "${GREEN}✓ Docker image pulling completed${NC}\n"- # Save version to .env- update_env_var "ALIASVAULT_VERSION" "$target_version"-# Start containersprintf "\n${YELLOW}+++ Starting services +++${NC}\n"@@ -2824,6 +2827,10 @@ handle_install_version() {exit 1fi+ # Save new version to .env only after all checks have passed, so we don't end up with a+ # partially installed version in case of an error.+ update_env_var "ALIASVAULT_VERSION" "$target_version"+# Clean up old Docker imagescleanup_docker_images "$target_version"@@ -3516,19 +3523,19 @@ check_and_populate_env() {# JWT_KEYif [ ! -f "${SECRETS_DIR}/jwt_key" ] || [ -z "$(cat "${SECRETS_DIR}/jwt_key" 2>/dev/null)" ]; thenJWT_KEY=$(openssl rand -base64 32)- write_secret_to_file "jwt_key" "$JWT_KEY"+ write_secret_to_file "jwt_key" "$JWT_KEY" || exit 1fi# DATA_PROTECTION_CERT_PASSif [ ! -f "${SECRETS_DIR}/data_protection_cert_pass" ] || [ -z "$(cat "${SECRETS_DIR}/data_protection_cert_pass" 2>/dev/null)" ]; thenCERT_PASS=$(openssl rand -base64 32)- write_secret_to_file "data_protection_cert_pass" "$CERT_PASS"+ write_secret_to_file "data_protection_cert_pass" "$CERT_PASS" || exit 1fi# POSTGRES_PASSWORDif [ ! -f "${SECRETS_DIR}/postgres_password" ] || [ -z "$(cat "${SECRETS_DIR}/postgres_password" 2>/dev/null)" ]; thenPOSTGRES_PASS=$(openssl rand -base64 32)- write_secret_to_file "postgres_password" "$POSTGRES_PASS"+ write_secret_to_file "postgres_password" "$POSTGRES_PASS" || exit 1fi# PRIVATE_EMAIL_DOMAINS