Fix: Trim all user input to prevent whitespace breaking config
Added defensive whitespace trimming (| xargs) to ALL prompted variables,
not just PBS_PASSWORD. This prevents trailing/leading spaces or newlines
from breaking the PBS_REPOSITORY string and causing authentication failures.
ISSUE:
User reported permission error despite having correct PBS permissions.
Root cause: Input variables contained trailing whitespace, causing the
repository string to be malformed:
Expected: root@pam!backupAutomations@192.168.1.181:8007:backups
Actual: root@pam !backupAutomations@192.168.1.181:8007:backups
^ extra space breaks authentication
SOLUTION:
Added `| xargs` to trim whitespace from all inputs:
- PBS_SERVER, PBS_PORT, PBS_DATASTORE
- PBS_USERNAME, PBS_REALM
- PBS_TOKEN_NAME, PBS_TOKEN_SECRET/PBS_PASSWORD
Applied to both functions:
- interactive_config_for_target() (lines 1006-1027)
- reconfigure_connection_for_target() (lines 613-634)
The `xargs` command without arguments reads stdin and outputs it with
leading/trailing whitespace removed - a common shell trimming idiom.
This complements the existing PBS_PASSWORD_CLEAN newline stripping
and provides comprehensive input sanitization.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
157265e3f9
commit
10534da9a6
2 changed files with 28 additions and 22 deletions
|
|
@ -136,6 +136,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- More intuitive for users familiar with numbered menus
|
||||
|
||||
### Fixed
|
||||
- **CRITICAL: All input fields now trimmed to prevent whitespace issues**
|
||||
- Added `| xargs` to all prompted variables (server, port, datastore, username, realm, token name, etc.)
|
||||
- Prevents trailing/leading whitespace from breaking PBS_REPOSITORY string
|
||||
- Fixes authentication failures caused by malformed repository strings
|
||||
- Example: `"root@pam "` (with space) now becomes `"root@pam"` automatically
|
||||
- Applied to both interactive_config_for_target() and reconfigure_connection_for_target()
|
||||
- **Main menu now loops properly after actions**
|
||||
- Removed `exit 0` calls from all menu options except Exit
|
||||
- Menu now continues after listing targets, running backups, or other actions
|
||||
|
|
|
|||
|
|
@ -610,9 +610,9 @@ reconfigure_connection() {
|
|||
echo
|
||||
|
||||
# PBS Server details
|
||||
PBS_SERVER=$(prompt "Enter PBS server IP/hostname" "192.168.1.181")
|
||||
PBS_PORT=$(prompt "Enter PBS server port" "8007")
|
||||
PBS_DATASTORE=$(prompt "Enter datastore name" "backups")
|
||||
PBS_SERVER=$(prompt "Enter PBS server IP/hostname" "192.168.1.181" | xargs)
|
||||
PBS_PORT=$(prompt "Enter PBS server port" "8007" | xargs)
|
||||
PBS_DATASTORE=$(prompt "Enter datastore name" "backups" | xargs)
|
||||
|
||||
echo
|
||||
info "Authentication Method:"
|
||||
|
|
@ -621,15 +621,15 @@ reconfigure_connection() {
|
|||
AUTH_METHOD=$(prompt "Select authentication method [1/2]" "2")
|
||||
|
||||
if [ "$AUTH_METHOD" = "1" ]; then
|
||||
PBS_USERNAME=$(prompt "Enter username" "root")
|
||||
PBS_REALM=$(prompt "Enter realm" "pam")
|
||||
PBS_PASSWORD=$(prompt_password "Enter password")
|
||||
PBS_USERNAME=$(prompt "Enter username" "root" | xargs)
|
||||
PBS_REALM=$(prompt "Enter realm" "pam" | xargs)
|
||||
PBS_PASSWORD=$(prompt_password "Enter password" | xargs)
|
||||
PBS_REPOSITORY="${PBS_USERNAME}@${PBS_REALM}@${PBS_SERVER}:${PBS_PORT}:${PBS_DATASTORE}"
|
||||
else
|
||||
PBS_USERNAME=$(prompt "Enter username" "backup")
|
||||
PBS_REALM=$(prompt "Enter realm" "pam")
|
||||
PBS_TOKEN_NAME=$(prompt "Enter token name" "backup-token")
|
||||
PBS_TOKEN_SECRET=$(prompt_password "Enter token secret")
|
||||
PBS_USERNAME=$(prompt "Enter username" "backup" | xargs)
|
||||
PBS_REALM=$(prompt "Enter realm" "pam" | xargs)
|
||||
PBS_TOKEN_NAME=$(prompt "Enter token name" "backup-token" | xargs)
|
||||
PBS_TOKEN_SECRET=$(prompt_password "Enter token secret" | xargs)
|
||||
PBS_REPOSITORY="${PBS_USERNAME}@${PBS_REALM}!${PBS_TOKEN_NAME}@${PBS_SERVER}:${PBS_PORT}:${PBS_DATASTORE}"
|
||||
PBS_PASSWORD="$PBS_TOKEN_SECRET"
|
||||
fi
|
||||
|
|
@ -1003,26 +1003,26 @@ interactive_config() {
|
|||
echo
|
||||
|
||||
# PBS Server details
|
||||
PBS_SERVER=$(prompt "Enter PBS server IP/hostname" "192.168.1.181")
|
||||
PBS_PORT=$(prompt "Enter PBS server port" "8007")
|
||||
PBS_DATASTORE=$(prompt "Enter datastore name" "backups")
|
||||
|
||||
PBS_SERVER=$(prompt "Enter PBS server IP/hostname" "192.168.1.181" | xargs)
|
||||
PBS_PORT=$(prompt "Enter PBS server port" "8007" | xargs)
|
||||
PBS_DATASTORE=$(prompt "Enter datastore name" "backups" | xargs)
|
||||
|
||||
echo
|
||||
info "Authentication Method:"
|
||||
echo " 1) Username + Password"
|
||||
echo " 2) API Token (recommended for automation)"
|
||||
AUTH_METHOD=$(prompt "Select authentication method [1/2]" "2")
|
||||
|
||||
|
||||
if [ "$AUTH_METHOD" = "1" ]; then
|
||||
PBS_USERNAME=$(prompt "Enter username" "root")
|
||||
PBS_REALM=$(prompt "Enter realm" "pam")
|
||||
PBS_PASSWORD=$(prompt_password "Enter password")
|
||||
PBS_USERNAME=$(prompt "Enter username" "root" | xargs)
|
||||
PBS_REALM=$(prompt "Enter realm" "pam" | xargs)
|
||||
PBS_PASSWORD=$(prompt_password "Enter password" | xargs)
|
||||
PBS_REPOSITORY="${PBS_USERNAME}@${PBS_REALM}@${PBS_SERVER}:${PBS_PORT}:${PBS_DATASTORE}"
|
||||
else
|
||||
PBS_USERNAME=$(prompt "Enter username" "backup")
|
||||
PBS_REALM=$(prompt "Enter realm" "pam")
|
||||
PBS_TOKEN_NAME=$(prompt "Enter token name" "backup-token")
|
||||
PBS_TOKEN_SECRET=$(prompt_password "Enter token secret")
|
||||
PBS_USERNAME=$(prompt "Enter username" "backup" | xargs)
|
||||
PBS_REALM=$(prompt "Enter realm" "pam" | xargs)
|
||||
PBS_TOKEN_NAME=$(prompt "Enter token name" "backup-token" | xargs)
|
||||
PBS_TOKEN_SECRET=$(prompt_password "Enter token secret" | xargs)
|
||||
PBS_REPOSITORY="${PBS_USERNAME}@${PBS_REALM}!${PBS_TOKEN_NAME}@${PBS_SERVER}:${PBS_PORT}:${PBS_DATASTORE}"
|
||||
PBS_PASSWORD="$PBS_TOKEN_SECRET"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue