Compare commits

...
8 Commits
Author SHA1 Message Date
Darren Tucker ad52178a4d - (dtucker) [openbsd-compat/fake-rfc2553.h] Bug #812: #undef getaddrinfo
before redefining it, silences warnings on Tru64.
2004-03-10 21:05:42 +11:00
Darren Tucker 08bb3628a9 - (dtucker) [auth-pam.c auth-pam.h auth1.c auth2.c monitor.c monitor_wrap.c
monitor_wrap.h] Bug #808: Ensure force_pwchange is correctly initialized
   even if keyboard-interactive is not used by the client.  Prevents segfaults
   in some cases where the user's password is expired (note this is not
   considered a security exposure).  ok djm@
2004-03-08 23:02:13 +11:00
Darren Tucker 2d4d0f62a6 - (dtucker) [configure.ac sshd.c openbsd-compat/bsd-misc.h
openbsd-compat/setenv.c] Unset KRB5CCNAME on AIX to prevent it from being
   inherited by the child.  ok djm@
2004-03-08 22:21:58 +11:00
Darren Tucker ebe1cb87c4 - (dtucker) [sshd.c] Back out rev 1.270 as it caused problems on some
platforms (eg SCO, HP-UX) with logging in the wrong TZ.
2004-03-08 22:20:16 +11:00
Darren Tucker 59e2e6a19d - (dtucker) [auth-passwd.c auth-sia.c auth-sia.h defines.h
openbsd-compat/xcrypt.c] Bug #802: Fix build error on Tru64 when
   configured --with-osfsia.  ok djm@
2004-03-04 22:56:57 +11:00
Darren Tucker 3b6da42000 - (dtucker) [auth-pam.c] Reset signal status when starting pam auth thread,
prevent hanging during PAM keyboard-interactive authentications.  ok djm@
2004-03-04 20:03:17 +11:00
Darren Tucker 08e3d1e686 - (dtucker) [auth-pam.c] Don't try to export PAM when compiled with
-DUSE_POSIX_THREADS.  From antoine.verheijen at ualbert ca.  ok djm@
2004-03-04 19:53:16 +11:00
Tim Rice b3a5a95b03 - (tim) [configure.ac] Put back bits mistakenly removed from Rev 1.188 2004-02-29 15:54:27 -08:00
18 changed files with 1226 additions and 102 deletions
+1161 -45
View File
File diff suppressed because it is too large Load Diff
+20 -12
View File
@@ -31,7 +31,7 @@
/* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */
#include "includes.h"
RCSID("$Id: auth-pam.c,v 1.95 2004/02/17 12:20:08 dtucker Exp $");
RCSID("$Id: auth-pam.c,v 1.95.2.3 2004/03/08 12:02:13 dtucker Exp $");
#ifdef USE_PAM
#if defined(HAVE_SECURITY_PAM_APPL_H)
@@ -117,6 +117,7 @@ pthread_create(sp_pthread_t *thread, const void *attr __unused,
{
pid_t pid;
sshpam_thread_status = -1;
switch ((pid = fork())) {
case -1:
error("fork(): %s", strerror(errno));
@@ -159,7 +160,7 @@ static int sshpam_session_open = 0;
static int sshpam_cred_established = 0;
static int sshpam_account_status = -1;
static char **sshpam_env = NULL;
static int *force_pwchange;
static Authctxt *the_authctxt = NULL;
/* Some PAM implementations don't implement this */
#ifndef HAVE_PAM_GETENVLIST
@@ -179,7 +180,9 @@ void
pam_password_change_required(int reqd)
{
debug3("%s %d", __func__, reqd);
*force_pwchange = reqd;
if (the_authctxt == NULL)
fatal("%s: PAM authctxt not initialized", __func__);
the_authctxt->force_pwchange = reqd;
if (reqd) {
no_port_forwarding_flag |= 2;
no_agent_forwarding_flag |= 2;
@@ -201,6 +204,7 @@ import_environments(Buffer *b)
debug3("PAM: %s entering", __func__);
#ifndef USE_POSIX_THREADS
/* Import variables set by do_pam_account */
sshpam_account_status = buffer_get_int(b);
pam_password_change_required(buffer_get_int(b));
@@ -228,6 +232,7 @@ import_environments(Buffer *b)
}
#endif
}
#endif
}
/*
@@ -336,6 +341,9 @@ sshpam_thread(void *ctxtp)
sshpam_conv.conv = sshpam_thread_conv;
sshpam_conv.appdata_ptr = ctxt;
if (the_authctxt == NULL)
fatal("%s: PAM authctxt not initialized", __func__);
buffer_init(&buffer);
sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
(const void *)&sshpam_conv);
@@ -348,7 +356,7 @@ sshpam_thread(void *ctxtp)
if (compat20) {
if (!do_pam_account())
goto auth_fail;
if (*force_pwchange) {
if (the_authctxt->force_pwchange) {
sshpam_err = pam_chauthtok(sshpam_handle,
PAM_CHANGE_EXPIRED_AUTHTOK);
if (sshpam_err != PAM_SUCCESS)
@@ -362,7 +370,7 @@ sshpam_thread(void *ctxtp)
#ifndef USE_POSIX_THREADS
/* Export variables set by do_pam_account */
buffer_put_int(&buffer, sshpam_account_status);
buffer_put_int(&buffer, *force_pwchange);
buffer_put_int(&buffer, the_authctxt->force_pwchange);
/* Export any environment strings set in child */
for(i = 0; environ[i] != NULL; i++)
@@ -443,11 +451,11 @@ sshpam_cleanup(void)
}
static int
sshpam_init(const char *user)
sshpam_init(Authctxt *authctxt)
{
extern u_int utmp_len;
extern char *__progname;
const char *pam_rhost, *pam_user;
const char *pam_rhost, *pam_user, *user = authctxt->user;
if (sshpam_handle != NULL) {
/* We already have a PAM context; check if the user matches */
@@ -461,6 +469,8 @@ sshpam_init(const char *user)
debug("PAM: initializing for \"%s\"", user);
sshpam_err =
pam_start(SSHD_PAM_SERVICE, user, &null_conv, &sshpam_handle);
the_authctxt = authctxt;
if (sshpam_err != PAM_SUCCESS) {
pam_end(sshpam_handle, sshpam_err);
sshpam_handle = NULL;
@@ -503,7 +513,7 @@ sshpam_init_ctx(Authctxt *authctxt)
return NULL;
/* Initialize PAM */
if (sshpam_init(authctxt->user) == -1) {
if (sshpam_init(authctxt) == -1) {
error("PAM: initialization failed");
return (NULL);
}
@@ -511,8 +521,6 @@ sshpam_init_ctx(Authctxt *authctxt)
ctxt = xmalloc(sizeof *ctxt);
memset(ctxt, 0, sizeof(*ctxt));
force_pwchange = &(authctxt->force_pwchange);
/* Start the authentication thread */
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
error("PAM: failed create sockets: %s", strerror(errno));
@@ -671,12 +679,12 @@ KbdintDevice mm_sshpam_device = {
* This replaces auth-pam.c
*/
void
start_pam(const char *user)
start_pam(Authctxt *authctxt)
{
if (!options.use_pam)
fatal("PAM: initialisation requested when UsePAM=no");
if (sshpam_init(user) == -1)
if (sshpam_init(authctxt) == -1)
fatal("PAM: initialisation failed");
}
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: auth-pam.h,v 1.24 2004/02/10 02:23:29 dtucker Exp $ */
/* $Id: auth-pam.h,v 1.24.2.1 2004/03/08 12:02:13 dtucker Exp $ */
/*
* Copyright (c) 2000 Damien Miller. All rights reserved.
@@ -31,7 +31,7 @@
# define SSHD_PAM_SERVICE __progname
#endif
void start_pam(const char *);
void start_pam(Authctxt *);
void finish_pam(void);
u_int do_pam_account(void);
void do_pam_session(void);
-7
View File
@@ -73,13 +73,6 @@ auth_password(Authctxt *authctxt, const char *password)
if (*password == '\0' && options.permit_empty_passwd == 0)
return 0;
#if defined(HAVE_OSF_SIA)
/*
* XXX: any reason this is before krb? could be moved to
* sys_auth_passwd()? -dt
*/
return auth_sia_password(authctxt, password) && ok;
#endif
#ifdef KRB5
if (options.kerberos_authentication == 1) {
int ret = auth_krb5_password(authctxt, password);
+1 -1
View File
@@ -47,7 +47,7 @@ extern int saved_argc;
extern char **saved_argv;
int
auth_sia_password(Authctxt *authctxt, char *pass)
sys_auth_passwd(Authctxt *authctxt, char *pass)
{
int ret;
SIAENTITY *ent = NULL;
+1 -1
View File
@@ -26,7 +26,7 @@
#ifdef HAVE_OSF_SIA
int auth_sia_password(Authctxt *, char *);
int sys_auth_passwd(Authctxt *, char *);
void session_setup_sia(struct passwd *, char *);
#endif /* HAVE_OSF_SIA */
+1 -1
View File
@@ -307,7 +307,7 @@ do_authentication(Authctxt *authctxt)
#ifdef USE_PAM
if (options.use_pam)
PRIVSEP(start_pam(user));
PRIVSEP(start_pam(authctxt));
#endif
/*
+3 -3
View File
@@ -150,24 +150,24 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
if (authctxt->attempt++ == 0) {
/* setup auth context */
authctxt->pw = PRIVSEP(getpwnamallow(user));
authctxt->user = xstrdup(user);
if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
authctxt->valid = 1;
debug2("input_userauth_request: setting up authctxt for %s", user);
#ifdef USE_PAM
if (options.use_pam)
PRIVSEP(start_pam(authctxt->pw->pw_name));
PRIVSEP(start_pam(authctxt));
#endif
} else {
logit("input_userauth_request: illegal user %s", user);
authctxt->pw = fakepw();
#ifdef USE_PAM
if (options.use_pam)
PRIVSEP(start_pam(user));
PRIVSEP(start_pam(authctxt));
#endif
}
setproctitle("%s%s", authctxt->pw ? user : "unknown",
use_privsep ? " [net]" : "");
authctxt->user = xstrdup(user);
authctxt->service = xstrdup(service);
authctxt->style = style ? xstrdup(style) : NULL;
if (use_privsep)
+2 -2
View File
@@ -1,4 +1,4 @@
# $Id: configure.ac,v 1.203 2004/02/29 23:53:37 tim Exp $
# $Id: configure.ac,v 1.202.2.2 2004/03/08 11:21:59 dtucker Exp $
AC_INIT
AC_CONFIG_SRCDIR([ssh.c])
@@ -802,7 +802,7 @@ AC_CHECK_FUNCS(\
setproctitle setregid setreuid setrlimit \
setsid setvbuf sigaction sigvec snprintf socketpair strerror \
strlcat strlcpy strmode strnvis strtoul sysconf tcgetpgrp \
truncate updwtmpx utimes vhangup vsnprintf waitpid \
truncate unsetenv updwtmpx utimes vhangup vsnprintf waitpid \
)
# IRIX has a const char return value for gai_strerror()
+8 -1
View File
@@ -25,7 +25,7 @@
#ifndef _DEFINES_H
#define _DEFINES_H
/* $Id: defines.h,v 1.110 2004/02/10 02:01:14 dtucker Exp $ */
/* $Id: defines.h,v 1.110.2.1 2004/03/04 11:56:57 dtucker Exp $ */
/* Constants */
@@ -616,6 +616,13 @@ struct winsize {
# define USE_LASTLOG
#endif
#ifdef HAVE_OSF_SIA
# ifdef USE_SHADOW
# undef USE_SHADOW
# endif
# define CUSTOM_SYS_AUTH_PASSWD 1
#endif
/** end of login recorder definitions */
#endif /* _DEFINES_H */
+1 -7
View File
@@ -782,16 +782,10 @@ mm_answer_skeyrespond(int socket, Buffer *m)
int
mm_answer_pam_start(int socket, Buffer *m)
{
char *user;
if (!options.use_pam)
fatal("UsePAM not set, but ended up in %s anyway", __func__);
user = buffer_get_string(m, NULL);
start_pam(user);
xfree(user);
start_pam(authctxt);
monitor_permit(mon_dispatch, MONITOR_REQ_PAM_ACCOUNT, 1);
+1 -3
View File
@@ -686,7 +686,7 @@ mm_session_pty_cleanup2(Session *s)
#ifdef USE_PAM
void
mm_start_pam(char *user)
mm_start_pam(Authctxt *authctxt)
{
Buffer m;
@@ -695,8 +695,6 @@ mm_start_pam(char *user)
fatal("UsePAM=no, but ended up in %s anyway", __func__);
buffer_init(&m);
buffer_put_cstring(&m, user);
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PAM_START, &m);
buffer_free(&m);
+1 -1
View File
@@ -66,7 +66,7 @@ OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
#endif
#ifdef USE_PAM
void mm_start_pam(char *);
void mm_start_pam(struct Authctxt *);
u_int mm_do_pam_account(void);
void *mm_sshpam_init_ctx(struct Authctxt *);
int mm_sshpam_query(void *, char **, char **, u_int *, char ***, u_int **);
+5 -1
View File
@@ -1,4 +1,4 @@
/* $Id: bsd-misc.h,v 1.14 2004/02/17 05:49:55 djm Exp $ */
/* $Id: bsd-misc.h,v 1.14.2.1 2004/03/08 11:21:59 dtucker Exp $ */
/*
* Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
@@ -89,6 +89,10 @@ pid_t tcgetpgrp(int);
int tcsendbreak(int, int);
#endif
#ifndef HAVE_UNSETENV
void unsetenv(const char *);
#endif
/* wrapper for signal interface */
typedef void (*mysig_t)(int);
mysig_t mysignal(int sig, mysig_t act);
+4 -1
View File
@@ -1,4 +1,4 @@
/* $Id: fake-rfc2553.h,v 1.8 2004/02/10 02:05:41 dtucker Exp $ */
/* $Id: fake-rfc2553.h,v 1.8.2.1 2004/03/10 10:05:43 dtucker Exp $ */
/*
* Copyright (C) 2000-2003 Damien Miller. All rights reserved.
@@ -133,6 +133,9 @@ struct addrinfo {
#endif /* !HAVE_STRUCT_ADDRINFO */
#ifndef HAVE_GETADDRINFO
#ifdef getaddrinfo
# undef getaddrinfo
#endif
#define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d))
int getaddrinfo(const char *, const char *,
const struct addrinfo *, struct addrinfo **);
+6 -2
View File
@@ -30,7 +30,7 @@
*/
#include "includes.h"
#ifndef HAVE_SETENV
#if !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV)
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$OpenBSD: setenv.c,v 1.6 2003/06/02 20:18:38 millert Exp $";
@@ -77,6 +77,7 @@ __findenv(name, offset)
return (NULL);
}
#ifndef HAVE_SETENV
/*
* setenv --
* Set the value of the environmental variable "name" to be
@@ -138,7 +139,9 @@ setenv(name, value, rewrite)
;
return (0);
}
#endif /* HAVE_SETENV */
#ifndef HAVE_UNSETENV
/*
* unsetenv(name) --
* Delete environmental variable "name".
@@ -157,5 +160,6 @@ unsetenv(name)
if (!(*P = *(P + 1)))
break;
}
#endif /* HAVE_UNSETENV */
#endif /* HAVE_SETENV */
#endif /* !defined(HAVE_SETENV) || !defined(HAVE_UNSETENV) */
-4
View File
@@ -24,8 +24,6 @@
#include "includes.h"
#if !defined(HAVE_OSF_SIA)
# ifdef HAVE_CRYPT_H
# include <crypt.h>
# endif
@@ -108,5 +106,3 @@ shadow_pw(struct passwd *pw)
return pw_password;
}
#endif /* !defined(HAVE_OSF_SIA) */
+9 -8
View File
@@ -42,7 +42,7 @@
*/
#include "includes.h"
RCSID("$OpenBSD: sshd.c,v 1.287 2004/02/25 00:22:45 djm Exp $");
RCSID("$OpenBSD: sshd.c,v 1.286 2004/02/23 12:02:33 markus Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -101,7 +101,6 @@ extern char *__progname;
#else
char *__progname;
#endif
extern char **environ;
/* Server configuration options. */
ServerOptions options;
@@ -568,7 +567,7 @@ privsep_preauth_child(void)
debug3("privsep user:group %u:%u", (u_int)pw->pw_uid,
(u_int)pw->pw_gid);
#if 0
/* XXX not ready, too heavy after chroot */
/* XXX not ready, to heavy after chroot */
do_setusercontext(pw);
#else
gidset[0] = pw->pw_gid;
@@ -940,6 +939,13 @@ main(int ac, char **av)
SYSLOG_FACILITY_AUTH : options.log_facility,
log_stderr || !inetd_flag);
#ifdef _AIX
/*
* Unset KRB5CCNAME, otherwise the user's session may inherit it from
* root's environment
*/
unsetenv("KRB5CCNAME");
#endif /* _AIX */
#ifdef _UNICOS
/* Cray can define user privs drop all prives now!
* Not needed on PRIV_SU systems!
@@ -1106,11 +1112,6 @@ main(int ac, char **av)
unmounted if desired. */
chdir("/");
#ifndef HAVE_CYGWIN
/* Clear environment */
environ[0] = NULL;
#endif
/* ignore SIGPIPE */
signal(SIGPIPE, SIG_IGN);