6767#include <pam/pam_appl.h>
6868#endif
6969
70- #if !defined(SSHD_PAM_SERVICE )
71- extern char * __progname ;
72- # define SSHD_PAM_SERVICE __progname
73- #endif
74-
7570/* OpenGroup RFC86.0 and XSSO specify no "const" on arguments */
7671#ifdef PAM_SUN_CODEBASE
7772# define sshpam_const /* Solaris, HP-UX, SunOS */
@@ -105,6 +100,7 @@ extern char *__progname;
105100#include "ssh-gss.h"
106101#endif
107102#include "monitor_wrap.h"
103+ #include "srclimit.h"
108104
109105extern ServerOptions options ;
110106extern struct sshbuf * loginmsg ;
@@ -171,13 +167,13 @@ sshpam_sigchld_handler(int sig)
171167 return ;
172168 }
173169 }
174- if (WIFSIGNALED ( sshpam_thread_status ) &&
175- WTERMSIG ( sshpam_thread_status ) == SIGTERM )
176- return ; /* terminated by pthread_cancel */
177- if (! WIFEXITED ( sshpam_thread_status ))
178- sigdie ( "PAM: authentication thread exited unexpectedly" );
179- if (WEXITSTATUS (sshpam_thread_status ) != 0 )
180- sigdie ( "PAM: authentication thread exited uncleanly" );
170+ if (sshpam_thread_status == -1 )
171+ return ;
172+ if ( WIFSIGNALED ( sshpam_thread_status )) {
173+ if (signal_is_crash ( WTERMSIG ( sshpam_thread_status ) ))
174+ _exit ( EXIT_CHILD_CRASH );
175+ } else if (! WIFEXITED (sshpam_thread_status ))
176+ _exit ( EXIT_CHILD_CRASH );
181177}
182178
183179/* ARGSUSED */
@@ -694,6 +690,8 @@ sshpam_init(struct ssh *ssh, Authctxt *authctxt)
694690 const char * * ptr_pam_user = & pam_user ;
695691 int r ;
696692
693+ if (options .pam_service_name == NULL )
694+ fatal_f ("internal error: NULL PAM service name" );
697695#if defined(PAM_SUN_CODEBASE ) && defined(PAM_MAX_RESP_SIZE )
698696 /* Protect buggy PAM implementations from excessively long usernames */
699697 if (strlen (user ) >= PAM_MAX_RESP_SIZE )
@@ -715,9 +713,10 @@ sshpam_init(struct ssh *ssh, Authctxt *authctxt)
715713 pam_end (sshpam_handle , sshpam_err );
716714 sshpam_handle = NULL ;
717715 }
718- debug ("PAM: initializing for \"%s\"" , user );
719- sshpam_err =
720- pam_start (SSHD_PAM_SERVICE , user , & store_conv , & sshpam_handle );
716+ debug ("PAM: initializing for \"%s\" with service \"%s\"" , user ,
717+ options .pam_service_name );
718+ sshpam_err = pam_start (options .pam_service_name , user ,
719+ & store_conv , & sshpam_handle );
721720 sshpam_authctxt = authctxt ;
722721
723722 if (sshpam_err != PAM_SUCCESS ) {
0 commit comments