Small cleanup of PAM code

This commit is contained in:
Damien Miller 1999-12-04 20:24:48 +11:00
parent 1f7833deba
commit dc33fc3910
2 changed files with 14 additions and 14 deletions

View File

@ -1,3 +1,6 @@
19991204
- Small cleanup of PAM code in sshd.c
19991126 19991126
- Add definition for __P() - Add definition for __P()
- Added [v]snprintf() replacement for systems that lack it - Added [v]snprintf() replacement for systems that lack it

25
sshd.c
View File

@ -11,7 +11,7 @@
*/ */
#include "includes.h" #include "includes.h"
RCSID("$Id: sshd.c,v 1.32 1999/11/25 00:54:59 damien Exp $"); RCSID("$Id: sshd.c,v 1.33 1999/12/04 09:24:48 damien Exp $");
#include "xmalloc.h" #include "xmalloc.h"
#include "rsa.h" #include "rsa.h"
@ -138,8 +138,7 @@ void do_child(const char *command, struct passwd * pw, const char *term,
#ifdef HAVE_LIBPAM #ifdef HAVE_LIBPAM
static int pamconv(int num_msg, const struct pam_message **msg, static int pamconv(int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr); struct pam_response **resp, void *appdata_ptr);
void do_pam_account_and_session(char *username, char *remote_user, void do_pam_account_and_session(char *username, char *remote_user);
const char *remote_host);
void pam_cleanup_proc(void *context); void pam_cleanup_proc(void *context);
static struct pam_conv conv = { static struct pam_conv conv = {
@ -229,18 +228,16 @@ void pam_cleanup_proc(void *context)
} }
} }
void do_pam_account_and_session(char *username, char *remote_user, void do_pam_account_and_session(char *username, char *remote_user)
const char *remote_host)
{ {
int pam_retval; int pam_retval;
if (remote_host != NULL) { debug("PAM setting rhost to \"%.200s\"", get_canonical_hostname());
debug("PAM setting rhost to \"%.200s\"", remote_host); pam_retval = pam_set_item((pam_handle_t *)pamh, PAM_RHOST,
pam_retval = pam_set_item((pam_handle_t *)pamh, PAM_RHOST, remote_host); get_canonical_hostname());
if (pam_retval != PAM_SUCCESS) { if (pam_retval != PAM_SUCCESS) {
log("PAM set rhost failed: %.200s", PAM_STRERROR((pam_handle_t *)pamh, pam_retval)); log("PAM set rhost failed: %.200s", PAM_STRERROR((pam_handle_t *)pamh, pam_retval));
do_fake_authloop(username); do_fake_authloop(username);
}
} }
if (remote_user != NULL) { if (remote_user != NULL) {
@ -1555,8 +1552,7 @@ do_authloop(struct passwd * pw)
user); user);
#ifdef HAVE_LIBPAM #ifdef HAVE_LIBPAM
do_pam_account_and_session(pw->pw_name, client_user, do_pam_account_and_session(pw->pw_name, client_user);
get_canonical_hostname());
/* Clean up */ /* Clean up */
if (client_user != NULL) if (client_user != NULL)
@ -2449,6 +2445,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
equals = strstr(pam_env[i], "="); equals = strstr(pam_env[i], "=");
if ((strlen(pam_env[i]) < (sizeof(var_name) - 1)) && (equals != NULL)) if ((strlen(pam_env[i]) < (sizeof(var_name) - 1)) && (equals != NULL))
{ {
debug("PAM environment: %s=%s", var_name, var_val);
memset(var_name, '\0', sizeof(var_name)); memset(var_name, '\0', sizeof(var_name));
memset(var_val, '\0', sizeof(var_val)); memset(var_val, '\0', sizeof(var_val));
strncpy(var_name, pam_env[i], equals - pam_env[i]); strncpy(var_name, pam_env[i], equals - pam_env[i]);