mpaperno / spampd

SpamPD - Spam Proxy Daemon. A spam-filtering SMTP/LMTP proxy server using SpamAssassin in Perl. Since 2002.
GNU General Public License v3.0
34 stars 10 forks source link

Logs end up in different place when running 2.60 with --nodetach than with older versions. #31

Closed realsimix closed 3 years ago

realsimix commented 3 years ago

Hi Maxim,

While working on my spampd-2.60 RPMs for RHEL7 and later, I wondering how to get the logging the same way than it was with older versions up to 2.53.

On these system, systemd is starting spampd with the option --nodetach so that spampd doesn't daemonize and systemd can to the baby sitting. Unfortunately starting with 2.60, I don't get the log messages in /var/log/maillog anymore but they go to /var/log/messages instead.

The reason seems to be that with --nodetach on 2.60, messages are not going to syslog anymore but to STDERR, while with older versions, they still went to syslog.

Is this wanted or can it be changed to how it has worked before?

Thanks, Simon

mpaperno commented 3 years ago

I wasn't aware that the default behavior changed (line 702), but I can look into that. Meanwhile I think the option you're looking for is --logfile, which is probably good to specify explicitly anyway. In fact there are more log destination options now...

--logfile or -o <dest>     Destination for logs (syslog|stderr|<filename>).
--logsock or -ls <sock>    Allows specifying the syslog socket type.
--logident or -li <name>   Specify syslog identity name.
--logfacility or -lf <nm>  Specify syslog facility (log name).

If you're already using --logfile then the mystery deepens.

BTW don't miss the new config file option :)

realsimix commented 3 years ago

If you're already using --logfile then the mystery deepens.

I can confirm that I'm not using any --logfile option.

BTW don't miss the new config file option :)

I saw the new config file option, will see how to use it best.

I guess the good thing is that one can change the config file and send SIGHUP to reload it, while doing the same with command line options is not possible, right?

Simon

mpaperno commented 3 years ago

No, it will reload the whole original command line, including config file(s), if any. The files are just for convenience really.

mpaperno commented 3 years ago

PS. Looks like I could have been clearer about that in the change log!

realsimix commented 3 years ago

PS. Looks like I could have been clearer about that in the change log!

What I meant is this: if I specify --relayhost=127.0.0.1:10026 on the command line, I can not change the port without restarting spampd.

If I specify the same in a config file, it will pick up the new port when HUPed, right?

Simon

mpaperno commented 3 years ago

Oh, yes, absolutely right, of course. Sorry, I missed they key word "change" in your original question.

mpaperno commented 3 years ago

Commenting out/removing lines 704-707 should revert back to old behavior (default logging to syslog). Could you confirm?

  # set up logging specs based on options ($logspec is only an array if --logfile option(s) existed)
  if (ref($spd_p->{logspec}) eq 'ARRAY') {
    $spd_p->{logtype} &= ~LOG_TYPE_MASK;  # reset the low byte containing LOG_<type> constant
    ($spd_p->{logtype}, $srv_p->{log_file}) = logfile2logtype($spd_p->{logspec}, $spd_p->{logtype});
  }
  # elsif (!$srv_p->{background}) {
  #   # set default logging to stderr if not daemonizing and user didn't specify.
  #   $spd_p->{logtype} = $spd_p->{logtype} & (~LOG_TYPE_MASK) | LOG_SYSLOG;
  # }

I guess I should revert it.... it was just convenient when running "interactively" from a command line, but I don't suppose many people will be doing that on a regular basis anyway.

Thanks again! -Max

realsimix commented 3 years ago

Hi Maxim,

Yes, that's the solution. Tested it and it reverses the behavior to how it was with older releases.

Thanks, Simon

mpaperno commented 3 years ago

Thanks again Simon. I just pushed a new version with all the fixes in one place. I'll give this a day or few and if you don't find any other issues I will do a new tag/release (or I can do one sooner if you prefer).

Cheers, -Max