diff options
author | des <des@FreeBSD.org> | 2002-02-04 17:15:44 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2002-02-04 17:15:44 +0000 |
commit | 0b3772b62a8c3d89f2167505c61ed82c6c58d41e (patch) | |
tree | 507b8bf12741e578a6864720797b7935237b7dcb /lib | |
parent | 8f97296c6846096aef4ac41ae2520f6f1a9b9709 (diff) | |
download | FreeBSD-src-0b3772b62a8c3d89f2167505c61ed82c6c58d41e.zip FreeBSD-src-0b3772b62a8c3d89f2167505c61ed82c6c58d41e.tar.gz |
ssh_get_authentication_connection() gets its parameters from environment
variables, so temporarily switch to the PAM environment before calling it.
Submitted by: Takanori Saneto <sanewo@ba2.so-net.ne.jp>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libpam/modules/pam_ssh/pam_ssh.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.c b/lib/libpam/modules/pam_ssh/pam_ssh.c index d22c99f..f6bf022 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); |