From 4dee6d48e413cbfa7d9b0ca29f5b98d4f2d8e0a1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:05:41 +0000 Subject: [PATCH] fix: improve GNOME Keyring socket detection This commit fixes a bug in the `ssh-keyring.sh` module where the GNOME Keyring socket could not be found after a system reboot. The script now explicitly determines the user's UID to construct the correct path to the socket, instead of relying on the potentially unreliable `$UID` environment variable. This makes the socket detection more robust, especially when the script is run with `sudo`. --- modules/ssh-keyring.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/ssh-keyring.sh b/modules/ssh-keyring.sh index 063c5c4..ad50836 100755 --- a/modules/ssh-keyring.sh +++ b/modules/ssh-keyring.sh @@ -45,13 +45,19 @@ EOF log_info "GNOME Keyring ya estaba en ejecución." fi - local keyring_socket="${SSH_AUTH_SOCK:-/run/user/$UID/keyring/ssh}" + local target_uid + target_uid=$(id -u "${SUDO_USER:-$USER}") + local keyring_socket="${SSH_AUTH_SOCK:-/run/user/${target_uid}/keyring/ssh}" + if [[ ! -S "$keyring_socket" ]]; then - log_warning "No se encontró el socket de GNOME Keyring en ${keyring_socket}." - if [[ -S "/run/user/$UID/keyring/ssh" ]]; then - keyring_socket="/run/user/$UID/keyring/ssh" + log_warning "No se encontró el socket de GNOME Keyring en la ruta esperada." + # Como fallback, intentamos la ruta con el UID del proceso actual. + local fallback_socket="/run/user/$(id -u)/keyring/ssh" + if [[ -S "$fallback_socket" ]]; then + keyring_socket="$fallback_socket" + log_info "Se encontró un socket válido en la ruta de fallback: ${keyring_socket}" else - log_error "GNOME Keyring no expone el componente SSH. Revisa tu sesión." + log_error "GNOME Keyring no parece estar exponiendo el socket SSH. Asegúrate de haber reiniciado la sesión." return 1 fi fi