Переглянути джерело

fix(install): generate the initial password without ambiguous characters (#895) (#919)

The base64-derived alphabet included 0/O and 1/l/I, which are nearly
indistinguishable in common terminal fonts - in the reported case the
user could not log in at all despite copying the password. Draw from
an unambiguous alphabet (57 symbols, no 0/O, no 1/l/I); 16 chars stays
~94 bits of entropy.
Nacho 2 місяців тому
батько
коміт
699459f390
1 змінених файлів з 4 додано та 1 видалено
  1. 4 1
      install.sh

+ 4 - 1
install.sh

@@ -334,7 +334,10 @@ fi
 
 # Initial config ONLY on fresh install (upgrades never touch .env or data)
 if [ ! -f "$STATE_DIR/.env" ]; then
-    ADMIN_PASS=$(head -c 18 /dev/urandom | base64 | tr -d '/+=' | head -c 16)
+    # #895: alfabeto sin caracteres ambiguos (sin 0/O ni 1/l/I) para que la
+    # password inicial no se confunda en fuentes de terminal. 57 símbolos ×
+    # 16 caracteres ≈ 94 bits de entropía.
+    ADMIN_PASS=$(LC_ALL=C tr -dc 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789' < /dev/urandom | head -c 16)
     if [ "$DRY_RUN" -eq 1 ]; then info "[dry-run] would generate $STATE_DIR/.env (0600, random admin password, PORT=$PORT, DEMO_MODE=$DEMO)"; else
         $SUDO tee "$STATE_DIR/.env" >/dev/null <<EOF
 PORT=$PORT