summaryrefslogtreecommitdiffstats
path: root/lib/libpam
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-02-04 17:15:44 +0000
committerdes <des@FreeBSD.org>2002-02-04 17:15:44 +0000
commit0b3772b62a8c3d89f2167505c61ed82c6c58d41e (patch)
tree507b8bf12741e578a6864720797b7935237b7dcb /lib/libpam
parent8f97296c6846096aef4ac41ae2520f6f1a9b9709 (diff)
downloadFreeBSD-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/libpam')
-rw-r--r--lib/libpam/modules/pam_ssh/pam_ssh.c26
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);
OpenPOWER on IntegriCloud