- (dtucker) [auth-pam.c monitor.c session.c sshd.c] Bug #926: Move
pam_open_session and pam_close_session into the privsep monitor, which will ensure that pam_session_close is called as root. Patch from Tomas Mraz.
This commit is contained in:
parent
fe1cf97ee8
commit
52358d6df3
|
@ -1,3 +1,9 @@
|
||||||
|
20080312
|
||||||
|
- (dtucker) [auth-pam.c monitor.c session.c sshd.c] Bug #926: Move
|
||||||
|
pam_open_session and pam_close_session into the privsep monitor, which
|
||||||
|
will ensure that pam_session_close is called as root. Patch from Tomas
|
||||||
|
Mraz.
|
||||||
|
|
||||||
20080309
|
20080309
|
||||||
- (dtucker) [configure.ac] It turns out gcc's -fstack-protector-all doesn't
|
- (dtucker) [configure.ac] It turns out gcc's -fstack-protector-all doesn't
|
||||||
always work for all platforms and versions, so test what we can and
|
always work for all platforms and versions, so test what we can and
|
||||||
|
@ -3712,4 +3718,4 @@
|
||||||
OpenServer 6 and add osr5bigcrypt support so when someone migrates
|
OpenServer 6 and add osr5bigcrypt support so when someone migrates
|
||||||
passwords between UnixWare and OpenServer they will still work. OK dtucker@
|
passwords between UnixWare and OpenServer they will still work. OK dtucker@
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.4864 2008/03/09 11:50:50 dtucker Exp $
|
$Id: ChangeLog,v 1.4865 2008/03/11 11:58:25 dtucker Exp $
|
||||||
|
|
|
@ -598,15 +598,17 @@ static struct pam_conv store_conv = { sshpam_store_conv, NULL };
|
||||||
void
|
void
|
||||||
sshpam_cleanup(void)
|
sshpam_cleanup(void)
|
||||||
{
|
{
|
||||||
debug("PAM: cleanup");
|
if (sshpam_handle == NULL || (use_privsep && !mm_is_monitor()))
|
||||||
if (sshpam_handle == NULL)
|
|
||||||
return;
|
return;
|
||||||
|
debug("PAM: cleanup");
|
||||||
pam_set_item(sshpam_handle, PAM_CONV, (const void *)&null_conv);
|
pam_set_item(sshpam_handle, PAM_CONV, (const void *)&null_conv);
|
||||||
if (sshpam_cred_established) {
|
if (sshpam_cred_established) {
|
||||||
|
debug("PAM: deleting credentials");
|
||||||
pam_setcred(sshpam_handle, PAM_DELETE_CRED);
|
pam_setcred(sshpam_handle, PAM_DELETE_CRED);
|
||||||
sshpam_cred_established = 0;
|
sshpam_cred_established = 0;
|
||||||
}
|
}
|
||||||
if (sshpam_session_open) {
|
if (sshpam_session_open) {
|
||||||
|
debug("PAM: closing session");
|
||||||
pam_close_session(sshpam_handle, PAM_SILENT);
|
pam_close_session(sshpam_handle, PAM_SILENT);
|
||||||
sshpam_session_open = 0;
|
sshpam_session_open = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1547,6 +1547,11 @@ mm_answer_term(int sock, Buffer *req)
|
||||||
/* The child is terminating */
|
/* The child is terminating */
|
||||||
session_destroy_all(&mm_session_close);
|
session_destroy_all(&mm_session_close);
|
||||||
|
|
||||||
|
#ifdef USE_PAM
|
||||||
|
if (options.use_pam)
|
||||||
|
sshpam_cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
while (waitpid(pmonitor->m_pid, &status, 0) == -1)
|
while (waitpid(pmonitor->m_pid, &status, 0) == -1)
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
29
session.c
29
session.c
|
@ -428,11 +428,6 @@ do_exec_no_pty(Session *s, const char *command)
|
||||||
|
|
||||||
session_proctitle(s);
|
session_proctitle(s);
|
||||||
|
|
||||||
#if defined(USE_PAM)
|
|
||||||
if (options.use_pam && !use_privsep)
|
|
||||||
do_pam_setcred(1);
|
|
||||||
#endif /* USE_PAM */
|
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
is_child = 1;
|
is_child = 1;
|
||||||
|
@ -563,14 +558,6 @@ do_exec_pty(Session *s, const char *command)
|
||||||
ptyfd = s->ptyfd;
|
ptyfd = s->ptyfd;
|
||||||
ttyfd = s->ttyfd;
|
ttyfd = s->ttyfd;
|
||||||
|
|
||||||
#if defined(USE_PAM)
|
|
||||||
if (options.use_pam) {
|
|
||||||
do_pam_set_tty(s->tty);
|
|
||||||
if (!use_privsep)
|
|
||||||
do_pam_setcred(1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
is_child = 1;
|
is_child = 1;
|
||||||
|
@ -1373,16 +1360,8 @@ do_setusercontext(struct passwd *pw)
|
||||||
# ifdef __bsdi__
|
# ifdef __bsdi__
|
||||||
setpgid(0, 0);
|
setpgid(0, 0);
|
||||||
# endif
|
# endif
|
||||||
#ifdef GSSAPI
|
|
||||||
if (options.gss_authentication) {
|
|
||||||
temporarily_use_uid(pw);
|
|
||||||
ssh_gssapi_storecreds();
|
|
||||||
restore_uid();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
# ifdef USE_PAM
|
# ifdef USE_PAM
|
||||||
if (options.use_pam) {
|
if (options.use_pam) {
|
||||||
do_pam_session();
|
|
||||||
do_pam_setcred(use_privsep);
|
do_pam_setcred(use_privsep);
|
||||||
}
|
}
|
||||||
# endif /* USE_PAM */
|
# endif /* USE_PAM */
|
||||||
|
@ -1410,13 +1389,6 @@ do_setusercontext(struct passwd *pw)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
endgrent();
|
endgrent();
|
||||||
# ifdef GSSAPI
|
|
||||||
if (options.gss_authentication) {
|
|
||||||
temporarily_use_uid(pw);
|
|
||||||
ssh_gssapi_storecreds();
|
|
||||||
restore_uid();
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
# ifdef USE_PAM
|
# ifdef USE_PAM
|
||||||
/*
|
/*
|
||||||
* PAM credentials may take the form of supplementary groups.
|
* PAM credentials may take the form of supplementary groups.
|
||||||
|
@ -1424,7 +1396,6 @@ do_setusercontext(struct passwd *pw)
|
||||||
* Reestablish them here.
|
* Reestablish them here.
|
||||||
*/
|
*/
|
||||||
if (options.use_pam) {
|
if (options.use_pam) {
|
||||||
do_pam_session();
|
|
||||||
do_pam_setcred(use_privsep);
|
do_pam_setcred(use_privsep);
|
||||||
}
|
}
|
||||||
# endif /* USE_PAM */
|
# endif /* USE_PAM */
|
||||||
|
|
14
sshd.c
14
sshd.c
|
@ -1847,6 +1847,20 @@ main(int ac, char **av)
|
||||||
audit_event(SSH_AUTH_SUCCESS);
|
audit_event(SSH_AUTH_SUCCESS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GSSAPI
|
||||||
|
if (options.gss_authentication) {
|
||||||
|
temporarily_use_uid(authctxt->pw);
|
||||||
|
ssh_gssapi_storecreds();
|
||||||
|
restore_uid();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef USE_PAM
|
||||||
|
if (options.use_pam) {
|
||||||
|
do_pam_setcred(1);
|
||||||
|
do_pam_session();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In privilege separation, we fork another child and prepare
|
* In privilege separation, we fork another child and prepare
|
||||||
* file descriptor passing.
|
* file descriptor passing.
|
||||||
|
|
Loading…
Reference in New Issue