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.
This commit is contained in:
google-labs-jules[bot]
2025-11-19 15:17:34 +00:00
parent eee1f9c307
commit 6038953ba4

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 "$(logname)")
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