From 6038953ba4b3f9183aaaa160a6e284153b6657cc 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:17:34 +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 uses the `logname` command to reliably determine the user's UID and construct the correct path to the socket, instead of relying on environment variables that can be unreliable when the script is run with `sudo`. This makes the socket detection more robust. --- 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..2c218e5 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 "$(logname)") + 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