geestion contraseñas correcto
This commit is contained in:
@@ -76,6 +76,26 @@ prompt_password() {
|
|||||||
htpasswd_update() {
|
htpasswd_update() {
|
||||||
local user="$1" password="$2"
|
local user="$1" password="$2"
|
||||||
htpasswd -B -C "$DEFAULT_COST" -b "$USERS_FILE" "$user" "$password" >/dev/null
|
htpasswd -B -C "$DEFAULT_COST" -b "$USERS_FILE" "$user" "$password" >/dev/null
|
||||||
|
normalize_bcrypt_prefix "$user"
|
||||||
|
}
|
||||||
|
|
||||||
|
normalize_bcrypt_prefix() {
|
||||||
|
local user="$1"
|
||||||
|
if ! command -v python3 >/dev/null 2>&1; then
|
||||||
|
echo "⚠️ python3 no disponible: no se pudo normalizar el hash bcrypt de '$user' (prefijo \$2y\$)." >&2
|
||||||
|
echo " Radicale solo acepta hashes \$2b\$, por lo que este usuario podría fallar." >&2
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
python3 - "$USERS_FILE" "$user" <<'PY'
|
||||||
|
import pathlib, re, sys
|
||||||
|
path = pathlib.Path(sys.argv[1])
|
||||||
|
user = sys.argv[2]
|
||||||
|
data = path.read_text()
|
||||||
|
pattern = re.compile(rf'^({re.escape(user)}:\$)2y', re.M)
|
||||||
|
updated, count = pattern.subn(r'\g<1>2b', data)
|
||||||
|
if count:
|
||||||
|
path.write_text(updated)
|
||||||
|
PY
|
||||||
}
|
}
|
||||||
|
|
||||||
list_users() {
|
list_users() {
|
||||||
|
|||||||
Reference in New Issue
Block a user