Fix critical password newline bug causing backup authentication failure

CRITICAL BUG FIX: The prompt_password() function was capturing a newline
character along with the password/token, causing the config file to have
malformed multi-line password values.

The Problem:
- prompt_password() used `echo` to print a newline after password input
- This echo was captured by command substitution: PBS_PASSWORD=$(prompt_password ...)
- Config file ended up with:
  PBS_PASSWORD="
  actual-token-here"
- PBS client couldn't authenticate with the malformed password
- Error: "authentication failed - invalid credentials"

The Fix:
- Changed `echo` to `echo >&2` (output to stderr)
- Stderr is not captured by command substitution
- Only the actual password is captured and stored
- Config file now correctly has: PBS_PASSWORD="actual-token-here"

File Changed: pbs-client-installer.sh
- Line 54: echo >&2  # Output newline to stderr so it doesn't get captured

CHANGELOG.md Updated:
- Documented as CRITICAL fix
- Explains the authentication failure in backup service
- Notes config file formatting fix

Impact:
- Connection test passed but backup service failed with auth error
- This affected both password and API token authentication
- Backups would fail silently on scheduled runs
- Now fixed: backups will authenticate correctly

Testing:
User should run installer again and the backup service will now work.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zaphod-black 2025-11-01 18:08:18 -05:00
parent ac2480bc24
commit 748e735e5d
2 changed files with 5 additions and 1 deletions

View file

@ -45,6 +45,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **CRITICAL**: SSL fingerprint prompt no longer causes authentication timeout
- Script now automatically accepts SSL fingerprints by piping 'y' to login
- This was the root cause of "authentication hanging" issues
- **CRITICAL**: Password/token capture no longer includes newline character
- `prompt_password()` function now outputs formatting to stderr
- Fixes "authentication failed - invalid credentials" in backup service
- Config file now has properly formatted single-line passwords
- Script no longer hangs indefinitely when PBS server is unreachable
- Block device auto-detection now correctly handles btrfs subvolumes
- Invalid device paths like `/dev/mapper/root[/@]` are now properly cleaned

View file

@ -51,7 +51,7 @@ prompt_password() {
local prompt_text="$1"
local user_input
read -sp "$(echo -e ${BLUE}${prompt_text}${NC}: )" user_input
echo
echo >&2 # Output newline to stderr so it doesn't get captured
echo "$user_input"
}