From 31af746f8270da9bfe6e16f9cd514c290902846d Mon Sep 17 00:00:00 2001 From: John Denker Date: Sat, 28 Mar 2015 22:00:25 -0700 Subject: fix bizarre bug: symptom: AUTH PLAIN authentication fails; reason: waitpid is tricky --- qmail-smtpd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/qmail-smtpd.c b/qmail-smtpd.c index aaf65e8..580be77 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -26,6 +26,12 @@ #include "wait.h" #include "fd.h" +#ifdef NASTY_DEBUG +# include +#endif /* NASTY_DEBUG */ + +void dummy() {} /* needed to make waitpid() work */ + // AUTHCRAM is not #defined for now, because: // 1) It requires cmd5checkpw (not just checkpassword), and // a) cmd5checkpw requires separate administration of the poppasswed file. @@ -577,7 +583,13 @@ int authenticate(void) close(pi[1]); byte_zero(pass.s,pass.len); byte_zero(upbuf,sizeof upbuf); - if (wait_pid(&wstat,child) == -1) return err_child(); + if (wait_pid(&wstat,child) == -1) { +#ifdef NASTY_DEBUG + fprintf(stderr, "kidpid: %d errno: %d : ", child, errno); + perror(0); +#endif /* NASTY_DEBUG */ + return err_child(); + } if (wait_crashed(wstat)) return err_child(); if (wait_exitcode(wstat)) { sleep(5); return 1; } /* no */ return 0; /* yes */ @@ -993,6 +1005,11 @@ void main(argc,argv) int argc; char **argv; { +/* waitpid() doesn't do what you expect + unless we do something nontrivial with SIGCHLD; + read the manpage. + */ + sig_childcatch(dummy); hostname = ""; if (argc > 1) hostname = argv[1]; childargs = 0; -- cgit v1.2.3