diff --git a/README.md b/README.md index b90a498..de6be1e 100644 --- a/README.md +++ b/README.md @@ -371,13 +371,14 @@ On Windows and Linux, use `--config FILE` to select another file. Command-line v - When `agent.upstream` is empty, `UPSTREAM_SSH_AUTH_SOCK` takes precedence over `SSH_AUTH_SOCK`. If neither is set, the GUI uses the native OpenSSH agent endpoint: `\\.\pipe\openssh-ssh-agent` on Windows and `~/.ssh/ssh-agent.sock` on macOS and Linux. - To keep the upstream endpoint tied to a changing environment variable, set `agent.upstream = "env:SSH_AUTH_SOCK"`, or choose Environment variable in GUI Settings and enter its name. The GUI resolves this reference at startup and when Settings are applied, while saving the `env:NAME` reference in the config file. The variable must be set and non-empty. - Environment variables in ordinary paths and a leading `~` are expanded using the GUI process environment. +- `[agent].allow_unbound_signing_on_bind_failure` defaults to `false`; GUI Settings omits it from the configuration file unless it is enabled. - `[history].path` selects the selection-history database when set. If omitted or empty, the GUI uses `history.sqlite` in the application data folder. Relative paths are resolved from that folder. GUI Settings leaves the field blank and shows the resolved default path as its placeholder. It saves `history.path` only when you enter or choose a path. - `[history].enabled` controls whether the GUI records and shows selection history. `[history].remember_selection` controls whether it remembers the last selected key for each verified target host. Both default to `true`, can be changed in GUI Settings, and are written to the config only when set to `false`. When both are `false`, the GUI does not create or open the SQLite database. - If the configured Listen endpoint is active or blocked by a non-socket file, the GUI starts with the proxy `Not configured`. A stale socket owned by the current user is replaced when KeySelect confirms that it is no longer listening. -The configuration loader rejects unknown keys. Logging is off by default. Set `log.level` to enable it and optionally set `log.file` to append logs to a file. When `log.file` is empty, logs go to standard error. +The configuration loader rejects unknown keys. Logging is off by default. Set `log.level` to enable it and optionally set `log.file` to choose a log destination. When `log.file` is empty, the GUI uses `ssh-keyselect.log` in its application data directory. Settings shows this default as a placeholder and leaves it out of the configuration file. -The key selection timeout defaults to 120 seconds. In GUI Settings, set `agent.selection_timeout`. For `ssh-keyselect ssh`, pass `--selection-timeout SECONDS`. +The key selection timeout defaults to 120 seconds. GUI Settings shows `120` as a placeholder; leave the field blank to use the default and omit `agent.selection_timeout` from the configuration file. Enter a value from 1 to 86,399 to override it. For `ssh-keyselect ssh`, pass `--selection-timeout SECONDS`. If, after a timeout, the SSH client prints the errors below and the server's `/var/log/secure` contains `penalty: exceeded LoginGraceTime`, set the Key selection Timeout to match that server's `LoginGraceTime` value in seconds. @@ -400,12 +401,11 @@ listen = 'C:\Users\USERNAME\.ssh\ssh-keyselect-agent.sock' upstream_mode = "auto" listen_mode = "cygwin" -selection_timeout = 120 # seconds (1 to 86399) +# selection_timeout = 120 # seconds (1 to 86399) # Allows signing without upstream destination binding after an explicit refusal. -allow_unbound_signing_on_bind_failure = false +# allow_unbound_signing_on_bind_failure = true [log] -file = "" level = "off" [history] diff --git a/cmd/ssh-keyselect-gui/endpoint_display_unix.go b/cmd/ssh-keyselect-gui/endpoint_display_unix.go index 9d66eac..8da486b 100644 --- a/cmd/ssh-keyselect-gui/endpoint_display_unix.go +++ b/cmd/ssh-keyselect-gui/endpoint_display_unix.go @@ -33,6 +33,6 @@ func guiFormatPathInput(path string) string { return path } func guiFilePathFromDisplay(path string) string { return path } -func guiListenPathForConfig(endpoint string) string { return endpoint } +func guiEndpointPathForConfig(endpoint string) string { return endpoint } func guiNormalizeListenPathForMode(endpoint string, _ transport.Mode) string { return endpoint } diff --git a/cmd/ssh-keyselect-gui/endpoint_display_windows.go b/cmd/ssh-keyselect-gui/endpoint_display_windows.go index 4926101..da27f6a 100644 --- a/cmd/ssh-keyselect-gui/endpoint_display_windows.go +++ b/cmd/ssh-keyselect-gui/endpoint_display_windows.go @@ -60,8 +60,8 @@ func guiFilePathFromDisplay(path string) string { return strings.ReplaceAll(path, "¥", `\`) } -// guiListenPathForConfig writes filesystem endpoints in native Windows form while preserving named pipes. -func guiListenPathForConfig(endpoint string) string { +// guiEndpointPathForConfig writes filesystem endpoints in native Windows form while preserving named pipes. +func guiEndpointPathForConfig(endpoint string) string { if endpoint == "" || winpath.IsNamedPipe(endpoint) { return endpoint } diff --git a/cmd/ssh-keyselect-gui/gui.go b/cmd/ssh-keyselect-gui/gui.go index 4f491cb..29b46ff 100644 --- a/cmd/ssh-keyselect-gui/gui.go +++ b/cmd/ssh-keyselect-gui/gui.go @@ -89,10 +89,10 @@ type guiApp struct { type guiOptions struct { Config *string `help:"TOML configuration file." placeholder:"FILE"` - Listen *string `help:"Frontend endpoint (default: HOME socket, or the fixed Windows OpenSSH named-pipe endpoint)." placeholder:"ENDPOINT"` - ListenMode *string `help:"Frontend protocol mode (auto, cygwin, unix, named-pipe, wsl1)." placeholder:"MODE"` Upstream *string `help:"Upstream endpoint (default: UPSTREAM_SSH_AUTH_SOCK, then SSH_AUTH_SOCK)." placeholder:"ENDPOINT"` UpstreamMode *string `help:"Upstream protocol mode (auto, cygwin, unix, named-pipe, wsl1)." placeholder:"MODE"` + Listen *string `help:"Frontend endpoint (default: HOME socket, or the fixed Windows OpenSSH named-pipe endpoint)." placeholder:"ENDPOINT"` + ListenMode *string `help:"Frontend protocol mode (auto, cygwin, unix, named-pipe, wsl1)." placeholder:"MODE"` AllowUnboundSigningOnBindFailure *bool `help:"Allow signing without upstream session binding after an explicit upstream refusal (weakens upstream restrictions)."` LogLevel *string `help:"Log level (off, debug, info, warn, error)." placeholder:"LEVEL"` Version kong.VersionFlag `help:"Print version information and quit."` @@ -132,16 +132,6 @@ func executeGUI(args []string, stdout, stderr io.Writer) int { if err != nil { return cmdutil.ReportError(stderr, guiCommandName, err) } - if options.Listen != nil { - cfg.Agent.Listen = config.ExpandPath(*options.Listen) - } - if options.ListenMode != nil { - mode, modeErr := transport.ParseMode(*options.ListenMode) - if modeErr != nil { - return cmdutil.ReportError(stderr, guiCommandName, modeErr) - } - cfg.Agent.ListenMode = mode - } if options.Upstream != nil { cfg.Agent.Upstream = config.ExpandPath(*options.Upstream) } @@ -152,6 +142,16 @@ func executeGUI(args []string, stdout, stderr io.Writer) int { } cfg.Agent.UpstreamMode = mode } + if options.Listen != nil { + cfg.Agent.Listen = config.ExpandPath(*options.Listen) + } + if options.ListenMode != nil { + mode, modeErr := transport.ParseMode(*options.ListenMode) + if modeErr != nil { + return cmdutil.ReportError(stderr, guiCommandName, modeErr) + } + cfg.Agent.ListenMode = mode + } if options.LogLevel != nil { cfg.Log.Level = *options.LogLevel } @@ -187,8 +187,18 @@ func executeGUI(args []string, stdout, stderr io.Writer) int { return cmdutil.ReportError(stderr, guiCommandName, err) } } + mygo.App.SetName("SSH KeySelect") + mygo.App.SetVersion(version) + userDataPath, err := setGUIUserDataPath() + if err != nil { + return cmdutil.ReportError(stderr, guiCommandName, err) + } + logFilePath := cfg.Log.File + if logFilePath == "" { + logFilePath = guiDefaultLogFilePath(userDataPath) + } - logOutput, err := newGUILogOutput(stderr, cfg.Log.File) + logOutput, err := newGUILogOutput(stderr, logFilePath) if err != nil { return cmdutil.ReportError(stderr, guiCommandName, err) } @@ -207,7 +217,8 @@ func executeGUI(args []string, stdout, stderr io.Writer) int { server.SetAllowUnboundSigningOnBindFailure(cfg.Agent.AllowUnboundSigningOnBindFailure) app := &guiApp{ ctx: ctx, stop: stop, logger: logger, loggerOutput: logOutput, cfg: cfg, - configPath: configPath, actualListen: listenPath, listenMode: effectiveListenMode, + userDataPath: userDataPath, + configPath: configPath, actualListen: listenPath, listenMode: effectiveListenMode, endpointAgent: endpointAgent, server: server, selector: guiSelector, selectedIdentity: -1, } @@ -220,8 +231,9 @@ func executeGUI(args []string, stdout, stderr io.Writer) int { }) app.runtime = &guiRuntime{ ctx: ctx, server: server, agent: endpointAgent, loggerOutput: logOutput, logOutput: logOutput, logLevel: &logLevel, - listenPath: listenPath, listenMode: effectiveListenMode, currentLogLevel: cfg.Log.Level, - currentLogFile: cfg.Log.File, + defaultLogFilePath: guiDefaultLogFilePath(userDataPath), + listenPath: listenPath, listenMode: effectiveListenMode, currentLogLevel: cfg.Log.Level, + currentLogFile: logFilePath, } app.runtime.onServeError = func(serveErr error) { if window := app.mainWindow.Load(); window != nil { @@ -236,13 +248,6 @@ func executeGUI(args []string, stdout, stderr io.Writer) int { } } - mygo.App.SetName("SSH KeySelect") - mygo.App.SetVersion(version) - userDataPath, err := setGUIUserDataPath() - if err != nil { - return cmdutil.ReportError(stderr, guiCommandName, err) - } - app.userDataPath = userDataPath if cfg.History.Enabled || cfg.History.RememberSelection { historyPath, pathErr := guiHistoryDatabasePath(userDataPath, cfg.History.Path) if pathErr != nil { diff --git a/cmd/ssh-keyselect-gui/gui_config.go b/cmd/ssh-keyselect-gui/gui_config.go index 4792e00..a001bce 100644 --- a/cmd/ssh-keyselect-gui/gui_config.go +++ b/cmd/ssh-keyselect-gui/gui_config.go @@ -8,10 +8,10 @@ package main import ( "errors" "fmt" - "math" "os" "path/filepath" "runtime" + "strconv" "strings" "github.com/egoist/mygo" @@ -27,7 +27,10 @@ import ( // guiConfigForDisk stores endpoint paths in the native format for this OS. func guiConfigForDisk(cfg config.Config) config.Config { - cfg.Agent.Listen = guiListenPathForConfig(cfg.Agent.Listen) + if _, environmentBacked := config.UpstreamEnvironmentVariable(cfg.Agent.Upstream); !environmentBacked { + cfg.Agent.Upstream = guiEndpointPathForConfig(cfg.Agent.Upstream) + } + cfg.Agent.Listen = guiEndpointPathForConfig(cfg.Agent.Listen) return cfg } @@ -600,7 +603,7 @@ type guiSettingsValues struct { listenMode string logLevel string theme string - selectionTimeout float64 + selectionTimeout string allowUnboundSigningOnBindFailure bool } @@ -615,6 +618,7 @@ type guiSettingsState struct { resolvedUpstream string listenPath string logFile string + logPlaceholder string historyFile string historyPlaceholder string historyEnabled bool @@ -623,7 +627,7 @@ type guiSettingsState struct { listenMode string logLevel string theme string - selectionTimeout float64 + selectionTimeout string allowUnboundSigningOnBindFailure bool initialListenMode transport.Mode previousListenMode string @@ -665,7 +669,7 @@ func (a *guiApp) openSettings() { } window := mygo.NewWindow(mygo.WindowOptions{ Title: "Settings", Parent: a.window, Modal: true, - Width: 600, Height: height, MinWidth: 580, MinHeight: minHeight, + Width: 620, Height: height, MinWidth: 580, MinHeight: minHeight, Content: ui.View(state.view), }) state.window = window @@ -715,17 +719,18 @@ func newGUISettingsState(app *guiApp, cfg config.Config) (*guiSettingsState, err if err != nil { return nil, err } + logPlaceholder := guiDisplayFilePath(guiDefaultLogFilePath(app.userDataPath)) state := &guiSettingsState{ app: app, cfg: cfg, upstreamSource: upstreamSource, upstreamPath: guiDisplayEndpointPath(upstreamEndpoint), upstreamEnvName: upstreamEnvName, resolvedUpstream: upstreamEndpoint, listenPath: guiDisplayEndpointPath(listenEndpoint), logFile: guiDisplayFilePath(cfg.Log.File), - historyFile: guiDisplayFilePath(strings.TrimSpace(cfg.History.Path)), + logPlaceholder: logPlaceholder, historyFile: guiDisplayFilePath(strings.TrimSpace(cfg.History.Path)), historyPlaceholder: guiDisplayFilePath(historyPlaceholder), historyEnabled: cfg.History.Enabled, rememberSelection: cfg.History.RememberSelection, upstreamMode: upstreamMode, listenMode: listenMode, logLevel: strings.ToLower(cfg.Log.Level), theme: guiThemeLabel(cfg.GUI.Theme), - selectionTimeout: float64(cfg.Agent.SelectionTimeout), + selectionTimeout: guiSelectionTimeoutForDisplay(cfg.Agent.SelectionTimeout), allowUnboundSigningOnBindFailure: cfg.Agent.AllowUnboundSigningOnBindFailure, initialListenMode: initialListenMode, previousListenMode: listenMode, lastFilesystemPath: func() string { @@ -834,13 +839,21 @@ func (s *guiSettingsState) selectionSection(c *ui.Context, theme *ui.Theme) { ui.Text(c, "Key selection").FontWeight(500) ui.Row(c).Gap(theme.Space(2)).AlignItems(ui.Center).Children(func() { ui.Text(c, "Timeout").Width(theme.Space(26)).Shrink(0) - // Keep 86400 editable so Apply can report the invalid endpoint instead of reverting it. - ui.NumberInput(c, &s.selectionTimeout, 1, 86400, 1).Label("Key selection timeout") + ui.TextInput(c, &s.selectionTimeout). + Label("Key selection timeout").Placeholder(strconv.Itoa(config.Default().Agent.SelectionTimeout)).Grow(1) ui.Text(c, "seconds").TextColor(theme.TextMuted) }) }) } +// guiSelectionTimeoutForDisplay leaves the default visible as an input placeholder. +func guiSelectionTimeoutForDisplay(seconds int) string { + if seconds == config.Default().Agent.SelectionTimeout { + return "" + } + return strconv.Itoa(seconds) +} + // endpointSection keeps each socket path and transport choice in a compact group. func (s *guiSettingsState) endpointSection(c *ui.Context, theme *ui.Theme, title string, upstream bool) { path, mode := &s.listenPath, &s.listenMode @@ -919,7 +932,7 @@ func (s *guiSettingsState) loggingSection(c *ui.Context, theme *ui.Theme) { ui.Text(c, "Logging").FontWeight(500) ui.Row(c).Gap(theme.Space(2)).AlignItems(ui.Center).Children(func() { ui.Text(c, "Log file").Width(theme.Space(26)).Shrink(0) - input := ui.TextInput(c, &s.logFile).Label("Log file").Placeholder("Leave blank to log to standard error").Grow(1) + input := ui.TextInput(c, &s.logFile).Label("Log file").Placeholder(s.logPlaceholder).Grow(1) if input.Changed() { s.logFile = guiFormatPathInput(s.logFile) } @@ -1056,9 +1069,6 @@ func (s *guiSettingsState) upstreamEndpoint() (string, error) { } func (s *guiSettingsState) buildConfig() (config.Config, error) { - if math.Trunc(s.selectionTimeout) != s.selectionTimeout { - return config.Config{}, fmt.Errorf("key selection timeout must be a whole number of seconds") - } cfg := s.cfg upstreamMode := guiModeFromDisplay(s.upstreamMode) upstreamEndpoint := "" @@ -1112,7 +1122,15 @@ func (s *guiSettingsState) buildConfig() (config.Config, error) { cfg.Agent.UpstreamMode = upstreamMode cfg.Agent.Listen = listenEndpoint cfg.Agent.ListenMode = listenMode - cfg.Agent.SelectionTimeout = int(s.selectionTimeout) + selectionTimeout := config.Default().Agent.SelectionTimeout + if value := strings.TrimSpace(s.selectionTimeout); value != "" { + parsed, err := strconv.Atoi(value) + if err != nil { + return config.Config{}, fmt.Errorf("key selection timeout must be a whole number of seconds") + } + selectionTimeout = parsed + } + cfg.Agent.SelectionTimeout = selectionTimeout cfg.Agent.AllowUnboundSigningOnBindFailure = s.allowUnboundSigningOnBindFailure cfg.Log.File = config.ExpandPath(guiFilePathFromDisplay(s.logFile)) cfg.Log.Level = s.logLevel @@ -1131,6 +1149,9 @@ func (s *guiSettingsState) browseLogFile() { s.browsingLog = true window := s.window current := guiFilePathFromDisplay(s.logFile) + if current == "" { + current = guiFilePathFromDisplay(s.logPlaceholder) + } go func() { path, err := guiChooseLogFile(window, current) if window == nil || window.IsDestroyed() { diff --git a/cmd/ssh-keyselect-gui/gui_log.go b/cmd/ssh-keyselect-gui/gui_log.go index 4f3fc53..90e3f0a 100644 --- a/cmd/ssh-keyselect-gui/gui_log.go +++ b/cmd/ssh-keyselect-gui/gui_log.go @@ -34,6 +34,11 @@ func newGUILogOutput(fallback io.Writer, path string) (*guiLogOutput, error) { return output, nil } +// guiDefaultLogFilePath keeps the default log beside the GUI's other application data. +func guiDefaultLogFilePath(userDataPath string) string { + return filepath.Join(userDataPath, "ssh-keyselect.log") +} + // newGUILogger shares a live level with the proxy and UI while keeping one destination writer. func newGUILogger(output io.Writer, level *slog.LevelVar, configured string) *slog.Logger { level.Set(guiSlogLevel(configured)) diff --git a/cmd/ssh-keyselect-gui/gui_runtime.go b/cmd/ssh-keyselect-gui/gui_runtime.go index 4d730d0..f144afa 100644 --- a/cmd/ssh-keyselect-gui/gui_runtime.go +++ b/cmd/ssh-keyselect-gui/gui_runtime.go @@ -101,19 +101,20 @@ type guiListenerState struct { // guiRuntime restarts serving at a changed endpoint and invalidates old client selections. type guiRuntime struct { - mu sync.Mutex - ctx context.Context - server *agentproxy.Server - agent *guiEndpointAgent - loggerOutput io.Writer - onServeError func(error) - listenerState *guiListenerState - listenPath string - listenMode transport.Mode - currentLogLevel string - currentLogFile string - logOutput *guiLogOutput - logLevel *slog.LevelVar + mu sync.Mutex + ctx context.Context + server *agentproxy.Server + agent *guiEndpointAgent + loggerOutput io.Writer + onServeError func(error) + listenerState *guiListenerState + listenPath string + listenMode transport.Mode + currentLogLevel string + currentLogFile string + defaultLogFilePath string + logOutput *guiLogOutput + logLevel *slog.LevelVar } func (r *guiRuntime) Apply(cfg config.Config) (string, transport.Mode, error) { @@ -130,15 +131,18 @@ func (r *guiRuntime) Apply(cfg config.Config) (string, transport.Mode, error) { if err != nil { return "", "", err } - cfg.Log.File = config.ExpandPath(cfg.Log.File) - logFileChanged := r.currentLogFile != cfg.Log.File + logFilePath := config.ExpandPath(cfg.Log.File) + if logFilePath == "" { + logFilePath = r.defaultLogFilePath + } + logFileChanged := r.currentLogFile != logFilePath var preparedLogFile *os.File if logFileChanged { if r.logOutput == nil { return "", "", errors.New("GUI log output is unavailable") } var err error - preparedLogFile, err = r.logOutput.open(cfg.Log.File) + preparedLogFile, err = r.logOutput.open(logFilePath) if err != nil { return "", "", err } @@ -155,7 +159,7 @@ func (r *guiRuntime) Apply(cfg config.Config) (string, transport.Mode, error) { if logFileChanged { r.logOutput.replace(preparedLogFile) preparedLogFile = nil - r.currentLogFile = cfg.Log.File + r.currentLogFile = logFilePath } if r.currentLogLevel != cfg.Log.Level { if r.logLevel != nil { diff --git a/internal/config/config.go b/internal/config/config.go index e4971bc..bce7d4f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -43,9 +43,9 @@ type HistoryConfig struct { } type AgentConfig struct { - Listen string `toml:"listen"` Upstream string `toml:"upstream"` UpstreamMode transport.Mode `toml:"upstream_mode"` + Listen string `toml:"listen"` ListenMode transport.Mode `toml:"listen_mode"` SelectionTimeout int `toml:"selection_timeout"` AllowUnboundSigningOnBindFailure bool `toml:"allow_unbound_signing_on_bind_failure"` @@ -63,11 +63,17 @@ type GUIConfig struct { type saveConfig struct { Agent saveAgentConfig `toml:"agent"` - Log LogConfig `toml:"log"` + Log saveLogConfig `toml:"log"` History *saveHistoryConfig `toml:"history,omitempty"` GUI GUIConfig `toml:"gui"` } +// saveLogConfig writes the log path with the same TOML path formatting as other paths. +type saveLogConfig struct { + File tomlPath `toml:"file,omitempty"` + Level string `toml:"level"` +} + type saveHistoryConfig struct { Enabled *bool `toml:"enabled,omitempty"` Path tomlPath `toml:"path,omitempty"` @@ -75,12 +81,12 @@ type saveHistoryConfig struct { } type saveAgentConfig struct { - Listen tomlPath `toml:"listen"` Upstream tomlPath `toml:"upstream"` UpstreamMode transport.Mode `toml:"upstream_mode"` + Listen tomlPath `toml:"listen"` ListenMode transport.Mode `toml:"listen_mode"` - SelectionTimeout int `toml:"selection_timeout"` - AllowUnboundSigningOnBindFailure bool `toml:"allow_unbound_signing_on_bind_failure"` + SelectionTimeout *int `toml:"selection_timeout,omitempty"` + AllowUnboundSigningOnBindFailure *bool `toml:"allow_unbound_signing_on_bind_failure,omitempty"` } type tomlPath string @@ -110,16 +116,25 @@ func isTOMLLiteralString(value string) bool { func configForSave(cfg Config) saveConfig { encoded := saveConfig{ Agent: saveAgentConfig{ - Listen: tomlPath(cfg.Agent.Listen), - Upstream: tomlPath(cfg.Agent.Upstream), - UpstreamMode: cfg.Agent.UpstreamMode, - ListenMode: cfg.Agent.ListenMode, - SelectionTimeout: cfg.Agent.SelectionTimeout, - AllowUnboundSigningOnBindFailure: cfg.Agent.AllowUnboundSigningOnBindFailure, + Upstream: tomlPath(cfg.Agent.Upstream), + UpstreamMode: cfg.Agent.UpstreamMode, + Listen: tomlPath(cfg.Agent.Listen), + ListenMode: cfg.Agent.ListenMode, + }, + Log: saveLogConfig{ + File: tomlPath(cfg.Log.File), + Level: cfg.Log.Level, }, - Log: cfg.Log, GUI: cfg.GUI, } + if cfg.Agent.SelectionTimeout != defaultSelectionTimeoutSeconds { + selectionTimeout := cfg.Agent.SelectionTimeout + encoded.Agent.SelectionTimeout = &selectionTimeout + } + if cfg.Agent.AllowUnboundSigningOnBindFailure { + enabled := true + encoded.Agent.AllowUnboundSigningOnBindFailure = &enabled + } if cfg.History.Path != "" || !cfg.History.Enabled || !cfg.History.RememberSelection { history := &saveHistoryConfig{Path: tomlPath(cfg.History.Path)} if !cfg.History.Enabled { @@ -240,14 +255,14 @@ func Load(path string) (Config, error) { } } - if value := os.Getenv("SSH_KEYSELECT_LISTEN"); value != "" { - cfg.Agent.Listen = value - } if cfg.Agent.Upstream == "" { cfg.Agent.Upstream = UpstreamFromEnvironment() } - cfg.Agent.Listen = ExpandPath(cfg.Agent.Listen) cfg.Agent.Upstream = ExpandPath(cfg.Agent.Upstream) + if value := os.Getenv("SSH_KEYSELECT_LISTEN"); value != "" { + cfg.Agent.Listen = value + } + cfg.Agent.Listen = ExpandPath(cfg.Agent.Listen) cfg.Log.File = ExpandPath(cfg.Log.File) cfg.History.Path = ExpandPath(cfg.History.Path) if err := cfg.Validate(); err != nil {