From 12b6e9a089bb705fb2ed21b6aee0bb5ceb806d11 Mon Sep 17 00:00:00 2001 From: Dag-Erling Smørgrav Date: Mon, 4 Feb 2002 17:15:44 +0000 Subject: ssh_get_authentication_connection() gets its parameters from environment variables, so temporarily switch to the PAM environment before calling it. Submitted by: Takanori Saneto --- lib/libpam/modules/pam_ssh/pam_ssh.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.c b/lib/libpam/modules/pam_ssh/pam_ssh.c index d22c99fa5414..f6bf0220c655 100644 --- a/lib/libpam/modules/pam_ssh/pam_ssh.c +++ b/lib/libpam/modules/pam_ssh/pam_ssh.c @@ -481,8 +481,30 @@ pam_sm_open_session(pam_handle_t *pamh, int flags __unused, int argc, const char PAM_LOG("Environment saved"); - /* connect to the agent */ - ac = ssh_get_authentication_connection(); + /* + * Connect to the agent. + * + * XXX Because ssh_get_authentication_connection() gets the + * XXX agent parameters from the environment, we have to + * XXX temporarily replace the environment with the PAM + * XXX environment list. This is a hack. + */ + { + extern char **environ; + char **saved, **evp; + + saved = environ; + if ((environ = pam_getenvlist(pamh)) == NULL) { + environ = saved; + syslog(LOG_ERR, "%s: %m", MODULE_NAME); + PAM_RETURN(PAM_BUF_ERR); + } + ac = ssh_get_authentication_connection(); + for (evp = environ; *evp; evp++) + free(*evp); + free(environ); + environ = saved; + } if (!ac) { syslog(LOG_ERR, "%s: %s: %m", MODULE_NAME, agent_socket); PAM_RETURN(PAM_SESSION_ERR); -- cgit v1.3