Skip to content

Commit

Permalink
propagate PAM crashes to PerSourcePenalties
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
djmdjm committed Jun 17, 2024
1 parent 1c207f4 commit b003314
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions auth-pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
#include "ssh-gss.h"
#endif
#include "monitor_wrap.h"
#include "srclimit.h"

extern ServerOptions options;
extern struct sshbuf *loginmsg;
Expand Down Expand Up @@ -166,13 +167,13 @@ sshpam_sigchld_handler(int sig)
return;
}
}
if (WIFSIGNALED(sshpam_thread_status) &&
WTERMSIG(sshpam_thread_status) == SIGTERM)
return; /* terminated by pthread_cancel */
if (!WIFEXITED(sshpam_thread_status))
sigdie("PAM: authentication thread exited unexpectedly");
if (WEXITSTATUS(sshpam_thread_status) != 0)
sigdie("PAM: authentication thread exited uncleanly");
if (sshpam_thread_status == -1)
return;
if (WIFSIGNALED(sshpam_thread_status)) {
if (signal_is_crash(WTERMSIG(sshpam_thread_status)))
_exit(EXIT_CHILD_CRASH);
} else if (!WIFEXITED(sshpam_thread_status))
_exit(EXIT_CHILD_CRASH);
}

/* ARGSUSED */
Expand Down

0 comments on commit b003314

Please sign in to comment.