# # This patches catmail in Listproc 6.0c so that mail that fails # to be delivered by catmail will return an exit code of 75 to # the sending MTA, which should cause it to requeue the message # for later delivery attempts # Usage: # cd src # patch -p0 < catmail.patch # Then recompile listproc # # By Alan Schwartz, 1997 *** catmail.c.old Thu May 2 20:44:03 1996 --- catmail.c Thu May 2 20:47:20 1996 *************** *** 103,108 **** --- 103,109 ---- int get_tag_id (void); void usage (void); int gexit (int); + int exit_and_queue (int); void main (int argc, char **argv, char **envp) { *************** *** 143,149 **** mask = "066", umask (S_IRWXG|S_IRWXO); /* 600 */ ! signal (SIGALRM, (void (*)()) gexit); alarm (120); /* Timeout after 2 mins */ #ifdef SYSLOG openlog ("ListProcessor: catmail", LOG_NDELAY --- 144,150 ---- mask = "066", umask (S_IRWXG|S_IRWXO); /* 600 */ ! signal (SIGALRM, (void (*)()) exit_and_queue); alarm (120); /* Timeout after 2 mins */ #ifdef SYSLOG openlog ("ListProcessor: catmail", LOG_NDELAY *************** *** 189,201 **** setup_string (list_mail_f, list_alias, LIST_MAIL_FILE); } #ifndef NO_LOCKS ! signal (SIGINT, (void (*)()) gexit); if ((lfd = lock_file (file, O_RDWR | O_CREAT, 0640, TRUE)) < 0) switch (lfd) { case CANT_OPEN: report_progress (report, tsprintf ("\\nCould not stat file %s", file), TRUE); ! exit (1); case CANT_LOCK: if (requests) strcpy (file, LOST_REQUESTS); --- 190,202 ---- setup_string (list_mail_f, list_alias, LIST_MAIL_FILE); } #ifndef NO_LOCKS ! signal (SIGINT, (void (*)()) exit_and_queue); if ((lfd = lock_file (file, O_RDWR | O_CREAT, 0640, TRUE)) < 0) switch (lfd) { case CANT_OPEN: report_progress (report, tsprintf ("\\nCould not stat file %s", file), TRUE); ! exit_and_queue (1); case CANT_LOCK: if (requests) strcpy (file, LOST_REQUESTS); *************** *** 210,216 **** case CANT_OPEN: report_progress (report, tsprintf ("\\nCould not stat file %s", SERVER_MAIL_FILE), TRUE); ! gexit (1); case CANT_LOCK: report_progress (report, tsprintf ("\\nCANNOT LOCK FILE %s: TAKING MY CHANCES", --- 211,217 ---- case CANT_OPEN: report_progress (report, tsprintf ("\\nCould not stat file %s", SERVER_MAIL_FILE), TRUE); ! exit_and_queue (1); case CANT_LOCK: report_progress (report, tsprintf ("\\nCANNOT LOCK FILE %s: TAKING MY CHANCES", *************** *** 221,227 **** case CANT_OPEN: report_progress (report, tsprintf ("\\nCould not stat file %s", list_mail_f), TRUE); ! gexit (1); case CANT_LOCK: report_progress (report, tsprintf ("\\nCANNOT LOCK FILE %s: TAKING MY CHANCES", --- 222,228 ---- case CANT_OPEN: report_progress (report, tsprintf ("\\nCould not stat file %s", list_mail_f), TRUE); ! exit_and_queue (1); case CANT_LOCK: report_progress (report, tsprintf ("\\nCANNOT LOCK FILE %s: TAKING MY CHANCES", *************** *** 356,359 **** --- 357,374 ---- unlock_file (lfd3); #endif exit (exitcode); + } + + + /* Graceful exit but give exit code 75 so sendmail will requeue + * mail and try to deliver later. + */ + int exit_and_queue (int exitcode) + { + #ifndef NO_LOCKS + unlock_file (lfd); + unlock_file (lfd2); + unlock_file (lfd3); + #endif + exit (75); }