summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-12-04 20:24:48 +1100
committerDamien Miller <djm@mindrot.org>1999-12-04 20:24:48 +1100
commitdc33fc3910552c82518503b581efc1a51192fa76 (patch)
treea0ee3dde21a3cb813cfea1d9629a5ab0fbd72efb /sshd.c
parent1f7833deba0c9b4fa7872d7b01e31e4cbd540ad4 (diff)
Small cleanup of PAM code
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/sshd.c b/sshd.c
index c4b1d1dfe..fa9eab74f 100644
--- a/sshd.c
+++ b/sshd.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include "includes.h" 13#include "includes.h"
14RCSID("$Id: sshd.c,v 1.32 1999/11/25 00:54:59 damien Exp $"); 14RCSID("$Id: sshd.c,v 1.33 1999/12/04 09:24:48 damien Exp $");
15 15
16#include "xmalloc.h" 16#include "xmalloc.h"
17#include "rsa.h" 17#include "rsa.h"
@@ -138,8 +138,7 @@ void do_child(const char *command, struct passwd * pw, const char *term,
138#ifdef HAVE_LIBPAM 138#ifdef HAVE_LIBPAM
139static int pamconv(int num_msg, const struct pam_message **msg, 139static int pamconv(int num_msg, const struct pam_message **msg,
140 struct pam_response **resp, void *appdata_ptr); 140 struct pam_response **resp, void *appdata_ptr);
141void do_pam_account_and_session(char *username, char *remote_user, 141void do_pam_account_and_session(char *username, char *remote_user);
142 const char *remote_host);
143void pam_cleanup_proc(void *context); 142void pam_cleanup_proc(void *context);
144 143
145static struct pam_conv conv = { 144static struct pam_conv conv = {
@@ -229,18 +228,16 @@ void pam_cleanup_proc(void *context)
229 } 228 }
230} 229}
231 230
232void do_pam_account_and_session(char *username, char *remote_user, 231void do_pam_account_and_session(char *username, char *remote_user)
233 const char *remote_host)
234{ 232{
235 int pam_retval; 233 int pam_retval;
236 234
237 if (remote_host != NULL) { 235 debug("PAM setting rhost to \"%.200s\"", get_canonical_hostname());
238 debug("PAM setting rhost to \"%.200s\"", remote_host); 236 pam_retval = pam_set_item((pam_handle_t *)pamh, PAM_RHOST,
239 pam_retval = pam_set_item((pam_handle_t *)pamh, PAM_RHOST, remote_host); 237 get_canonical_hostname());
240 if (pam_retval != PAM_SUCCESS) { 238 if (pam_retval != PAM_SUCCESS) {
241 log("PAM set rhost failed: %.200s", PAM_STRERROR((pam_handle_t *)pamh, pam_retval)); 239 log("PAM set rhost failed: %.200s", PAM_STRERROR((pam_handle_t *)pamh, pam_retval));
242 do_fake_authloop(username); 240 do_fake_authloop(username);
243 }
244 } 241 }
245 242
246 if (remote_user != NULL) { 243 if (remote_user != NULL) {
@@ -1555,8 +1552,7 @@ do_authloop(struct passwd * pw)
1555 user); 1552 user);
1556 1553
1557#ifdef HAVE_LIBPAM 1554#ifdef HAVE_LIBPAM
1558 do_pam_account_and_session(pw->pw_name, client_user, 1555 do_pam_account_and_session(pw->pw_name, client_user);
1559 get_canonical_hostname());
1560 1556
1561 /* Clean up */ 1557 /* Clean up */
1562 if (client_user != NULL) 1558 if (client_user != NULL)
@@ -2449,6 +2445,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
2449 equals = strstr(pam_env[i], "="); 2445 equals = strstr(pam_env[i], "=");
2450 if ((strlen(pam_env[i]) < (sizeof(var_name) - 1)) && (equals != NULL)) 2446 if ((strlen(pam_env[i]) < (sizeof(var_name) - 1)) && (equals != NULL))
2451 { 2447 {
2448 debug("PAM environment: %s=%s", var_name, var_val);
2452 memset(var_name, '\0', sizeof(var_name)); 2449 memset(var_name, '\0', sizeof(var_name));
2453 memset(var_val, '\0', sizeof(var_val)); 2450 memset(var_val, '\0', sizeof(var_val));
2454 strncpy(var_name, pam_env[i], equals - pam_env[i]); 2451 strncpy(var_name, pam_env[i], equals - pam_env[i]);