Skip to content

pam: lookup XDG_RUNTIME_DIR using get_any_env

The pam_gnome_keyring.so PAM module needs to find the daemon control file, which is stored in $XDG_RUNTIME_DIR/keyring/control. Unfortunately when commit 2ca51a0a ("daemon: Stop exporting the $GNOME_KEYRING_CONTROL env variable", 2014-03-06) switched to using XDG_RUNTIME_DIR preferentially over GNOME_KEYRING_CONTROL, it was looked up using getenv().

Unfortunately XDG_RUNTIME_DIR isn't always set in the environment, but may need to be looked up from pam_getenv. Indeed, the function get_any_env already exists for this purpose.

Because of the incorrect environment lookup, lookup_daemon will incorrectly report that the gnome-keyring-daemon is not running, even though it is. This results in starting the daemon multiple times, and potentially failing to shut it down, or start it correctly when changing the password.

To fix this, move the code for determining the control file path from gkr-pam-client.c into gkr-pam-module.c This will using get_any_env(), and avoids the need for passing the pam_handle_t variable into gkr-pam-client.c

It does mean that the control variable must be allocated with space, since we need to combine the environment value with a different suffix depending on if we use GNOME_KEYRING_CONTROL or XDG_RUNTIME_DIR.

Add a function get_control_file, so that the logic for determining the control file path remains in one location.

Signed-off-by: Jacob Keller jacob.keller@gmail.com

Merge request reports