Browse Source

Log the MTA from mailmunge-multiplexor.c instead of the filter

This means it's only logged once per mailmunge-multiplexor invocation
rather than each time a scanning worker starts up.
master
Dianne Skoll 4 weeks ago
parent
commit
af7031176b
Signed by: dianne GPG Key ID: 685A5A5E511D30E2
  1. 1
      c/Makefile.in
  2. 55
      c/mailmunge-multiplexor.c
  3. 8
      perl/lib/Mailmunge/Filter.pm

1
c/Makefile.in

@ -25,6 +25,7 @@ DEFS=-D_POSIX_PTHREAD_SEMANTICS \
-DVERSION=\"@PACKAGE_VERSION@\" \
-DSPOOLDIR=\"@SPOOLDIR@\" \
-DQDIR=\"@QDIR@\" \
-DSENDMAIL=\"@SENDMAILPROG@\" \
-DCONFDIR=\"${CONFDIR}\"
CC=@CC@

55
c/mailmunge-multiplexor.c

@ -389,6 +389,58 @@ state_name(int state)
return "Unknown";
}
/**********************************************************************
* %FUNCTION: log_mta
* %ARGUMENTS:
* None
* %RETURNS:
* Nothing
* %DESCRIPTION:
* Tries to determine whether we're running Sendmail or Postfix, and
* logs the result
***********************************************************************/
static void log_mta(void)
{
int mta_is_postfix = 0;
int mta_is_sendmail = 0;
/* Look for config files */
if (access("/etc/postfix/main.cf", R_OK) >= 0 &&
access("/etc/mail/sendmail.cf", R_OK) < 0) {
mta_is_postfix = 1;
mta_is_sendmail = 0;
} else if (access("/etc/postfix/main.cf", R_OK) < 0 &&
access("/etc/mail/sendmail.cf", R_OK) >= 0) {
mta_is_postfix = 0;
mta_is_sendmail = 1;
} else {
FILE *sm = popen(SENDMAIL " -bt < /dev/null 2>&1", "r");
if (sm) {
char buf[1024];
while(fgets(buf, sizeof(buf), sm)) {
if (strstr(buf, "unsupported: -bt")) {
mta_is_postfix = 1;
mta_is_sendmail = 0;
break;
} else if (strstr(buf, "ADDRESS TEST MODE")) {
mta_is_postfix = 0;
mta_is_sendmail = 1;
break;
}
}
pclose(sm);
}
}
if (mta_is_postfix) {
syslog(LOG_INFO, "MTA appears to be: Postfix");
} else if (mta_is_sendmail) {
syslog(LOG_INFO, "MTA appears to be: Sendmail");
} else {
syslog(LOG_INFO, "MTA could not be identified");
}
}
/**********************************************************************
* %FUNCTION: state_name_lc
* %ARGUMENTS:
@ -1409,6 +1461,9 @@ main(int argc, char *argv[], char **env)
write(kidpipe[1], "X", 1);
close(kidpipe[1]);
/* Detect and log the mta */
log_mta();
/* And loop... */
while(!Terminate) {
if (Event_HandleEvent(es) < 0) {

8
perl/lib/Mailmunge/Filter.pm

@ -877,14 +877,6 @@ sub _main_loop
$self->initialize();
if ($self->mta_is_postfix) {
$self->log('NOQUEUE', 'info', 'MTA appears to be: Postfix');
} elsif ($self->mta_is_sendmail) {
$self->log('NOQUEUE', 'info', 'MTA appears to be: Sendmail');
} else {
$self->log('NOQUEUE', 'info', 'MTA could not be identified');
}
while (my $line = <STDIN>) {
$self->_cd_to_spooldir();
chomp($line);

Loading…
Cancel
Save