QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
SshAuthSock Class Reference

SSH_AUTH_SOCK discovery and validation for child processes. More...

#include <sshauthsock.h>

Public Types

enum class  OverrideStatus : std::uint8_t { Valid , DoesNotExist , NotReadable , NotUnixDomainSocket }
 Classify a non-empty SSH_AUTH_SOCK override path supplied by the user. More...

Static Public Member Functions

static auto overrideStatus (const QString &path) -> OverrideStatus
 Validate an SSH_AUTH_SOCK override path. Caller is expected to skip validation when the input is empty / whitespace-only.
static void initialise (const QString &override={})
 Ensure SSH_AUTH_SOCK is set for child processes.

Detailed Description

SSH_AUTH_SOCK discovery and validation for child processes.

Extracted from Util. GUI-launched applications don't inherit shell-set environment variables, so users with gpg-agent's SSH support or another external SSH agent see git push/pull fail. See initialise(). Issue #543.

Definition at line 23 of file sshauthsock.h.

Member Enumeration Documentation

◆ OverrideStatus

enum class SshAuthSock::OverrideStatus : std::uint8_t
strong

Classify a non-empty SSH_AUTH_SOCK override path supplied by the user.

Empty / unset input is handled by the caller (no warning when the field is blank). On Windows the socket check is skipped — ssh-agent uses a named pipe there.

Enumerator
Valid 

Exists, readable, and on Unix a Unix domain socket.

DoesNotExist 

QFileInfo::exists() returned false.

NotReadable 

Exists, but QFileInfo::isReadable() returned false.

NotUnixDomainSocket 

Unix only: stat() says the path is not S_ISSOCK.

Definition at line 33 of file sshauthsock.h.

Member Function Documentation

◆ initialise()

void SshAuthSock::initialise ( const QString & override = {})
static

Ensure SSH_AUTH_SOCK is set for child processes.

GUI-launched applications don't inherit shell-set environment variables (.bashrc/.zshrc/etc.), so users with gpg-agent's SSH support or other external SSH agents see git push/git pull fail when QtPass launches from a desktop launcher rather than a terminal. Issue #543.

Resolution order:

  1. If SSH_AUTH_SOCK is already set (terminal launch, .desktop override, parent process), do nothing.
  2. If a sshAuthSockOverride setting is configured in QtPass, use it verbatim as an explicit user choice (no validation is performed here). Users should ensure this path points to a valid, accessible SSH agent socket; otherwise SSH operations may fail for child processes. The Settings dialog shows a non-blocking warning at save time when the override path looks bogus (missing, unreadable, or not a socket).
  3. Probe gpgconf --list-dirs agent-ssh-socket (canonical for gpg-agent), then validate the candidate with ssh-add -l (must exit 0 or 1) before adopting. Validation prevents silently switching users from a working external SSH agent to an empty gpg-agent SSH socket.
  4. On macOS, fall back to launchctl getenv SSH_AUTH_SOCK, with the same ssh-add -l validation.

Sets the variable via qputenv so child processes inherit it.

Parameters
overrideManual override path from settings (empty → auto-probe).

Definition at line 110 of file sshauthsock.cpp.

Here is the caller graph for this function:

◆ overrideStatus()

auto SshAuthSock::overrideStatus ( const QString & path) -> OverrideStatus
static

Validate an SSH_AUTH_SOCK override path. Caller is expected to skip validation when the input is empty / whitespace-only.

Parameters
pathNon-empty candidate path.
Returns
Classification per OverrideStatus.

Definition at line 84 of file sshauthsock.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: