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`.
This commit is contained in:
google-labs-jules[bot]
2025-11-19 15:05:41 +00:00
parent dbe9bbe4ca
commit 4dee6d48e4

View File

@@ -45,13 +45,19 @@ EOF
log_info "GNOME Keyring ya estaba en ejecución." log_info "GNOME Keyring ya estaba en ejecución."
fi 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 if [[ ! -S "$keyring_socket" ]]; then
log_warning "No se encontró el socket de GNOME Keyring en ${keyring_socket}." log_warning "No se encontró el socket de GNOME Keyring en la ruta esperada."
if [[ -S "/run/user/$UID/keyring/ssh" ]]; then # Como fallback, intentamos la ruta con el UID del proceso actual.
keyring_socket="/run/user/$UID/keyring/ssh" 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 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 return 1
fi fi
fi fi