- (stevesk) [auth-pam.c auth-pam.h auth-passwd.c auth-sia.c auth-sia.h

auth1.c auth2.c] PAM, OSF_SIA password auth cleanup; from djm.
This commit is contained in:
Kevin Steves 2002-04-04 19:02:28 +00:00
parent af40bc6a72
commit e683e76439
8 changed files with 61 additions and 71 deletions

View File

@ -1,3 +1,7 @@
20020404
- (stevesk) [auth-pam.c auth-pam.h auth-passwd.c auth-sia.c auth-sia.h
auth1.c auth2.c] PAM, OSF_SIA password auth cleanup; from djm.
20020402 20020402
- (bal) Hand Sync of scp.c (reverted to upstream code) - (bal) Hand Sync of scp.c (reverted to upstream code)
- deraadt@cvs.openbsd.org 2002/03/30 17:45:46 - deraadt@cvs.openbsd.org 2002/03/30 17:45:46
@ -8147,4 +8151,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.2020 2002/04/03 03:36:54 mouring Exp $ $Id: ChangeLog,v 1.2021 2002/04/04 19:02:28 stevesk Exp $

View File

@ -28,6 +28,7 @@
#include "ssh.h" #include "ssh.h"
#include "xmalloc.h" #include "xmalloc.h"
#include "log.h" #include "log.h"
#include "auth.h"
#include "auth-pam.h" #include "auth-pam.h"
#include "servconf.h" #include "servconf.h"
#include "canohost.h" #include "canohost.h"
@ -35,7 +36,7 @@
extern char *__progname; extern char *__progname;
RCSID("$Id: auth-pam.c,v 1.42 2002/02/05 01:40:47 djm Exp $"); RCSID("$Id: auth-pam.c,v 1.43 2002/04/04 19:02:28 stevesk Exp $");
#define NEW_AUTHTOK_MSG \ #define NEW_AUTHTOK_MSG \
"Warning: Your password has expired, please change it now" "Warning: Your password has expired, please change it now"
@ -199,10 +200,11 @@ void do_pam_cleanup_proc(void *context)
} }
/* Attempt password authentation using PAM */ /* Attempt password authentation using PAM */
int auth_pam_password(struct passwd *pw, const char *password) int auth_pam_password(Authctxt *authctxt, const char *password)
{ {
extern ServerOptions options; extern ServerOptions options;
int pam_retval; int pam_retval;
struct passwd *pw = authctxt->pw;
do_pam_set_conv(&conv); do_pam_set_conv(&conv);

View File

@ -1,4 +1,4 @@
/* $Id: auth-pam.h,v 1.11 2001/03/27 06:12:24 djm Exp $ */ /* $Id: auth-pam.h,v 1.12 2002/04/04 19:02:28 stevesk Exp $ */
#include "includes.h" #include "includes.h"
#ifdef USE_PAM #ifdef USE_PAM
@ -7,7 +7,7 @@
void start_pam(const char *user); void start_pam(const char *user);
void finish_pam(void); void finish_pam(void);
int auth_pam_password(struct passwd *pw, const char *password); int auth_pam_password(Authctxt *authctxt, const char *password);
char **fetch_pam_environment(void); char **fetch_pam_environment(void);
int do_pam_authenticate(int flags); int do_pam_authenticate(int flags);
int do_pam_account(char *username, char *remote_user); int do_pam_account(char *username, char *remote_user);

View File

@ -38,13 +38,13 @@
#include "includes.h" #include "includes.h"
RCSID("$OpenBSD: auth-passwd.c,v 1.24 2002/03/04 12:43:06 markus Exp $"); RCSID("$OpenBSD: auth-passwd.c,v 1.24 2002/03/04 12:43:06 markus Exp $");
#if !defined(USE_PAM) && !defined(HAVE_OSF_SIA)
#include "packet.h" #include "packet.h"
#include "log.h" #include "log.h"
#include "servconf.h" #include "servconf.h"
#include "auth.h" #include "auth.h"
#if !defined(USE_PAM) && !defined(HAVE_OSF_SIA)
/* Don't need any of these headers for the PAM or SIA cases */
# ifdef HAVE_CRYPT_H # ifdef HAVE_CRYPT_H
# include <crypt.h> # include <crypt.h>
# endif # endif
@ -78,7 +78,7 @@ RCSID("$OpenBSD: auth-passwd.c,v 1.24 2002/03/04 12:43:06 markus Exp $");
# include <sys/cygwin.h> # include <sys/cygwin.h>
# define is_winnt (GetVersion() < 0x80000000) # define is_winnt (GetVersion() < 0x80000000)
# endif # endif
#endif /* !USE_PAM && !HAVE_OSF_SIA */
extern ServerOptions options; extern ServerOptions options;
@ -89,6 +89,15 @@ extern ServerOptions options;
int int
auth_password(Authctxt *authctxt, const char *password) auth_password(Authctxt *authctxt, const char *password)
{ {
#if defined(USE_PAM)
if (*password == '\0' && options.permit_empty_passwd == 0)
return 0;
return auth_pam_password(authctxt, password);
#elif defined(HAVE_OSF_SIA)
if (*password == '\0' && options.permit_empty_passwd == 0)
return 0;
return auth_sia_password(authctxt, password);
#else
struct passwd * pw = authctxt->pw; struct passwd * pw = authctxt->pw;
char *encrypted_password; char *encrypted_password;
char *pw_password; char *pw_password;
@ -221,5 +230,5 @@ auth_password(Authctxt *authctxt, const char *password)
/* Authentication is accepted if the encrypted passwords are identical. */ /* Authentication is accepted if the encrypted passwords are identical. */
return (strcmp(encrypted_password, pw_password) == 0); return (strcmp(encrypted_password, pw_password) == 0);
}
#endif /* !USE_PAM && !HAVE_OSF_SIA */ #endif /* !USE_PAM && !HAVE_OSF_SIA */
}

View File

@ -6,6 +6,7 @@
#include "log.h" #include "log.h"
#include "servconf.h" #include "servconf.h"
#include "canohost.h" #include "canohost.h"
#include "auth.h"
#include <sia.h> #include <sia.h>
#include <siad.h> #include <siad.h>
@ -23,15 +24,16 @@ extern char **saved_argv;
extern int errno; extern int errno;
int int
auth_sia_password(char *user, char *pass) auth_sia_password(Authctxt *authctxt, char *pass)
{ {
int ret; int ret;
SIAENTITY *ent = NULL; SIAENTITY *ent = NULL;
const char *host; const char *host;
char *user = authctxt->user;
host = get_canonical_hostname(options.verify_reverse_mapping); host = get_canonical_hostname(options.verify_reverse_mapping);
if (!user || !pass) if (!user || !pass || pass[0] == '\0')
return(0); return(0);
if (sia_ses_init(&ent, saved_argc, saved_argv, host, user, NULL, 0, if (sia_ses_init(&ent, saved_argc, saved_argv, host, user, NULL, 0,

View File

@ -2,7 +2,7 @@
#ifdef HAVE_OSF_SIA #ifdef HAVE_OSF_SIA
int auth_sia_password(char *user, char *pass); int auth_sia_password(Authctxt *authctxt, char *pass);
void session_setup_sia(char *user, char *tty); void session_setup_sia(char *user, char *tty);
#endif /* HAVE_OSF_SIA */ #endif /* HAVE_OSF_SIA */

15
auth1.c
View File

@ -84,13 +84,7 @@ do_authloop(Authctxt *authctxt)
#if defined(KRB4) || defined(KRB5) #if defined(KRB4) || defined(KRB5)
(!options.kerberos_authentication || options.kerberos_or_local_passwd) && (!options.kerberos_authentication || options.kerberos_or_local_passwd) &&
#endif #endif
#ifdef USE_PAM
auth_pam_password(pw, "")) {
#elif defined(HAVE_OSF_SIA)
0) {
#else
PRIVSEP(auth_password(authctxt, ""))) { PRIVSEP(auth_password(authctxt, ""))) {
#endif
auth_log(authctxt, 1, "without authentication", ""); auth_log(authctxt, 1, "without authentication", "");
return; return;
} }
@ -246,17 +240,8 @@ do_authloop(Authctxt *authctxt)
password = packet_get_string(&dlen); password = packet_get_string(&dlen);
packet_check_eom(); packet_check_eom();
#ifdef USE_PAM
/* Do PAM auth with password */
authenticated = auth_pam_password(pw, password);
#elif defined(HAVE_OSF_SIA)
/* Do SIA auth with password */
authenticated = auth_sia_password(authctxt->user,
password);
#else /* !USE_PAM && !HAVE_OSF_SIA */
/* Try authentication with the password. */ /* Try authentication with the password. */
authenticated = PRIVSEP(auth_password(authctxt, password)); authenticated = PRIVSEP(auth_password(authctxt, password));
#endif /* USE_PAM */
memset(password, 0, strlen(password)); memset(password, 0, strlen(password));
xfree(password); xfree(password);

12
auth2.c
View File

@ -329,13 +329,7 @@ userauth_none(Authctxt *authctxt)
if (check_nt_auth(1, authctxt->pw) == 0) if (check_nt_auth(1, authctxt->pw) == 0)
return(0); return(0);
#endif #endif
#ifdef USE_PAM
return auth_pam_password(authctxt->pw, "");
#elif defined(HAVE_OSF_SIA)
return 0;
#else /* !HAVE_OSF_SIA && !USE_PAM */
return PRIVSEP(auth_password(authctxt, "")); return PRIVSEP(auth_password(authctxt, ""));
#endif /* USE_PAM */
} }
static int static int
@ -354,13 +348,7 @@ userauth_passwd(Authctxt *authctxt)
#ifdef HAVE_CYGWIN #ifdef HAVE_CYGWIN
check_nt_auth(1, authctxt->pw) && check_nt_auth(1, authctxt->pw) &&
#endif #endif
#ifdef USE_PAM
auth_pam_password(authctxt->pw, password) == 1)
#elif defined(HAVE_OSF_SIA)
auth_sia_password(authctxt->user, password) == 1)
#else /* !USE_PAM && !HAVE_OSF_SIA */
PRIVSEP(auth_password(authctxt, password)) == 1) PRIVSEP(auth_password(authctxt, password)) == 1)
#endif /* USE_PAM */
authenticated = 1; authenticated = 1;
memset(password, 0, len); memset(password, 0, len);
xfree(password); xfree(password);