[client] Fall back to getent/id for SSH user lookup in static builds (#5510)

This commit is contained in:
Viktor Liu
2026-03-13 22:22:02 +08:00
committed by GitHub
parent d86875aeac
commit 529c0314f8
9 changed files with 848 additions and 18 deletions

View File

@@ -49,10 +49,14 @@ func getWindowsUserShell() string {
return `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`
}
// getUnixUserShell returns the shell for Unix-like systems
// getUnixUserShell returns the shell for Unix-like systems.
// Tries /etc/passwd first (fast, no subprocess), falls back to getent for NSS users.
func getUnixUserShell(userID string) string {
shell := getShellFromPasswd(userID)
if shell != "" {
if shell := getShellFromPasswd(userID); shell != "" {
return shell
}
if shell := getShellFromGetent(userID); shell != "" {
return shell
}