Fix: Remove sudo usage from auth detection to avoid password prompts
All checks were successful
CI/CD / Test (push) Successful in 1m16s
CI/CD / Lint (push) Successful in 1m27s
CI/CD / Build & Release (push) Successful in 3m16s

- Remove sudo cat attempt for reading pg_hba.conf
- Prevents password prompts when running as postgres via 'su postgres'
- Auth detection now relies on connection attempts when file is unreadable
- Fixes issue where returning to menu after restore triggers sudo prompt
This commit is contained in:
2026-01-16 13:52:41 +01:00
parent 510175ff04
commit 62ddc57fb7
2 changed files with 7 additions and 13 deletions

View File

@@ -4,8 +4,8 @@ This directory contains pre-compiled binaries for the DB Backup Tool across mult
## Build Information ## Build Information
- **Version**: 3.42.34 - **Version**: 3.42.34
- **Build Time**: 2026-01-16_08:42:47_UTC - **Build Time**: 2026-01-16_12:38:18_UTC
- **Git Commit**: a85ad0c - **Git Commit**: 510175f
## Recent Updates (v1.1.0) ## Recent Updates (v1.1.0)
- ✅ Fixed TUI progress display with line-by-line output - ✅ Fixed TUI progress display with line-by-line output

View File

@@ -84,19 +84,13 @@ func findHbaFileViaPostgres() string {
// parsePgHbaConf parses pg_hba.conf and returns the authentication method // parsePgHbaConf parses pg_hba.conf and returns the authentication method
func parsePgHbaConf(path string, user string) AuthMethod { func parsePgHbaConf(path string, user string) AuthMethod {
// Try with sudo if we can't read directly // Try to read the file directly - do NOT use sudo as it triggers password prompts
// If we can't read pg_hba.conf, we'll rely on connection attempts to determine auth
file, err := os.Open(path) file, err := os.Open(path)
if err != nil { if err != nil {
// Try with sudo (with timeout) // If we can't read the file, return unknown and let the connection determine auth
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) // This avoids sudo password prompts when running as postgres via su
defer cancel() return AuthUnknown
cmd := exec.CommandContext(ctx, "sudo", "cat", path)
output, err := cmd.Output()
if err != nil {
return AuthUnknown
}
return parseHbaContent(string(output), user)
} }
defer file.Close() defer file.Close()