aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2002-02-04 17:15:44 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2002-02-04 17:15:44 +0000
commit12b6e9a089bb705fb2ed21b6aee0bb5ceb806d11 (patch)
tree507b8bf12741e578a6864720797b7935237b7dcb /lib
parent985e77de7babd0920348e887298250e52ef06ac9 (diff)
Notes
Diffstat (limited to 'lib')
-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 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);