Skip to content

Commit b003314

Browse files
committed
propagate PAM crashes to PerSourcePenalties
If the PAM subprocess crashes, exit with a crash status that will be picked up by the sshd(8) listener process where it can be used by PerSourcePenalties to block the client. This is similar handling to the privsep preauth process.
1 parent 1c207f4 commit b003314

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: auth-pam.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
#include "ssh-gss.h"
101101
#endif
102102
#include "monitor_wrap.h"
103+
#include "srclimit.h"
103104

104105
extern ServerOptions options;
105106
extern struct sshbuf *loginmsg;
@@ -166,13 +167,13 @@ sshpam_sigchld_handler(int sig)
166167
return;
167168
}
168169
}
169-
if (WIFSIGNALED(sshpam_thread_status) &&
170-
WTERMSIG(sshpam_thread_status) == SIGTERM)
171-
return; /* terminated by pthread_cancel */
172-
if (!WIFEXITED(sshpam_thread_status))
173-
sigdie("PAM: authentication thread exited unexpectedly");
174-
if (WEXITSTATUS(sshpam_thread_status) != 0)
175-
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);
176177
}
177178

178179
/* ARGSUSED */

0 commit comments

Comments
 (0)