mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-04-17 04:37:49 +00:00
- (dtucker) [auth-pam.c auth-pam.h session.c] Make PAM use the new static
cleanup functions. With & ok djm@
This commit is contained in:
parent
6f1f611a52
commit
8846a07639
@ -1,5 +1,7 @@
|
|||||||
20031007
|
20031007
|
||||||
- (djm) Delete autom4te.cache after autoreconf
|
- (djm) Delete autom4te.cache after autoreconf
|
||||||
|
- (dtucker) [auth-pam.c auth-pam.h session.c] Make PAM use the new static
|
||||||
|
cleanup functions. With & ok djm@
|
||||||
|
|
||||||
20031003
|
20031003
|
||||||
- OpenBSD CVS Sync
|
- OpenBSD CVS Sync
|
||||||
@ -1282,4 +1284,4 @@
|
|||||||
- Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
|
- Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
|
||||||
Report from murple@murple.net, diagnosis from dtucker@zip.com.au
|
Report from murple@murple.net, diagnosis from dtucker@zip.com.au
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.3057 2003/10/07 00:18:22 djm Exp $
|
$Id: ChangeLog,v 1.3058 2003/10/07 01:30:15 dtucker Exp $
|
||||||
|
38
auth-pam.c
38
auth-pam.c
@ -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 $ */
|
/* Based on $FreeBSD: src/crypto/openssh/auth2-pam-freebsd.c,v 1.11 2003/03/31 13:48:18 des Exp $ */
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$Id: auth-pam.c,v 1.74 2003/09/23 12:12:38 djm Exp $");
|
RCSID("$Id: auth-pam.c,v 1.75 2003/10/07 01:30:16 dtucker Exp $");
|
||||||
|
|
||||||
#ifdef USE_PAM
|
#ifdef USE_PAM
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
@ -126,6 +126,7 @@ struct pam_ctxt {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void sshpam_free_ctx(void *);
|
static void sshpam_free_ctx(void *);
|
||||||
|
static struct pam_ctxt *cleanup_ctxt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Conversation function for authentication thread.
|
* Conversation function for authentication thread.
|
||||||
@ -245,15 +246,19 @@ sshpam_thread(void *ctxtp)
|
|||||||
return (NULL); /* Avoid warning for non-pthread case */
|
return (NULL); /* Avoid warning for non-pthread case */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
sshpam_thread_cleanup(void *ctxtp)
|
sshpam_thread_cleanup(void)
|
||||||
{
|
{
|
||||||
struct pam_ctxt *ctxt = ctxtp;
|
struct pam_ctxt *ctxt = cleanup_ctxt;
|
||||||
|
|
||||||
pthread_cancel(ctxt->pam_thread);
|
if (ctxt != NULL && ctxt->pam_thread != 0) {
|
||||||
pthread_join(ctxt->pam_thread, NULL);
|
pthread_cancel(ctxt->pam_thread);
|
||||||
close(ctxt->pam_psock);
|
pthread_join(ctxt->pam_thread, NULL);
|
||||||
close(ctxt->pam_csock);
|
close(ctxt->pam_psock);
|
||||||
|
close(ctxt->pam_csock);
|
||||||
|
memset(ctxt, 0, sizeof(*ctxt));
|
||||||
|
cleanup_ctxt = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -265,10 +270,9 @@ sshpam_null_conv(int n, const struct pam_message **msg,
|
|||||||
|
|
||||||
static struct pam_conv null_conv = { sshpam_null_conv, NULL };
|
static struct pam_conv null_conv = { sshpam_null_conv, NULL };
|
||||||
|
|
||||||
static void
|
void
|
||||||
sshpam_cleanup(void *arg)
|
sshpam_cleanup(void)
|
||||||
{
|
{
|
||||||
(void)arg;
|
|
||||||
debug("PAM: cleanup");
|
debug("PAM: cleanup");
|
||||||
if (sshpam_handle == NULL)
|
if (sshpam_handle == NULL)
|
||||||
return;
|
return;
|
||||||
@ -299,7 +303,6 @@ sshpam_init(const char *user)
|
|||||||
PAM_USER, (const void **)&pam_user);
|
PAM_USER, (const void **)&pam_user);
|
||||||
if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0)
|
if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0)
|
||||||
return (0);
|
return (0);
|
||||||
fatal_remove_cleanup(sshpam_cleanup, NULL);
|
|
||||||
pam_end(sshpam_handle, sshpam_err);
|
pam_end(sshpam_handle, sshpam_err);
|
||||||
sshpam_handle = NULL;
|
sshpam_handle = NULL;
|
||||||
}
|
}
|
||||||
@ -333,7 +336,6 @@ sshpam_init(const char *user)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fatal_add_cleanup(sshpam_cleanup, NULL);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +356,7 @@ sshpam_init_ctx(Authctxt *authctxt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxt = xmalloc(sizeof *ctxt);
|
ctxt = xmalloc(sizeof *ctxt);
|
||||||
ctxt->pam_done = 0;
|
memset(ctxt, 0, sizeof(*ctxt));
|
||||||
|
|
||||||
/* Start the authentication thread */
|
/* Start the authentication thread */
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) {
|
||||||
@ -372,7 +374,7 @@ sshpam_init_ctx(Authctxt *authctxt)
|
|||||||
xfree(ctxt);
|
xfree(ctxt);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
fatal_add_cleanup(sshpam_thread_cleanup, ctxt);
|
cleanup_ctxt = ctxt;
|
||||||
return (ctxt);
|
return (ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,8 +483,7 @@ sshpam_free_ctx(void *ctxtp)
|
|||||||
{
|
{
|
||||||
struct pam_ctxt *ctxt = ctxtp;
|
struct pam_ctxt *ctxt = ctxtp;
|
||||||
|
|
||||||
fatal_remove_cleanup(sshpam_thread_cleanup, ctxt);
|
sshpam_thread_cleanup();
|
||||||
sshpam_thread_cleanup(ctxtp);
|
|
||||||
xfree(ctxt);
|
xfree(ctxt);
|
||||||
/*
|
/*
|
||||||
* We don't call sshpam_cleanup() here because we may need the PAM
|
* We don't call sshpam_cleanup() here because we may need the PAM
|
||||||
@ -524,8 +525,7 @@ start_pam(const char *user)
|
|||||||
void
|
void
|
||||||
finish_pam(void)
|
finish_pam(void)
|
||||||
{
|
{
|
||||||
fatal_remove_cleanup(sshpam_cleanup, NULL);
|
sshpam_cleanup();
|
||||||
sshpam_cleanup(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int
|
u_int
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: auth-pam.h,v 1.21 2003/09/02 13:18:53 djm Exp $ */
|
/* $Id: auth-pam.h,v 1.22 2003/10/07 01:30:16 dtucker Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000 Damien Miller. All rights reserved.
|
* Copyright (c) 2000 Damien Miller. All rights reserved.
|
||||||
@ -43,5 +43,7 @@ int do_pam_putenv(char *, char *);
|
|||||||
void print_pam_messages(void);
|
void print_pam_messages(void);
|
||||||
char ** fetch_pam_environment(void);
|
char ** fetch_pam_environment(void);
|
||||||
void free_pam_environment(char **);
|
void free_pam_environment(char **);
|
||||||
|
void sshpam_thread_cleanup(void);
|
||||||
|
void sshpam_cleanup(void);
|
||||||
|
|
||||||
#endif /* USE_PAM */
|
#endif /* USE_PAM */
|
||||||
|
@ -2165,6 +2165,13 @@ do_cleanup(Authctxt *authctxt)
|
|||||||
ssh_gssapi_cleanup_creds();
|
ssh_gssapi_cleanup_creds();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_PAM
|
||||||
|
if (options.use_pam) {
|
||||||
|
sshpam_cleanup();
|
||||||
|
sshpam_thread_cleanup();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* remove agent socket */
|
/* remove agent socket */
|
||||||
auth_sock_cleanup_proc(authctxt->pw);
|
auth_sock_cleanup_proc(authctxt->pw);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user