Skip to content

Commit

Permalink
- Fix listening to IP address (8cdc4c6 broke this, leading to error […
Browse files Browse the repository at this point in the history
…0])... (#18)

* - Fix listening to IP address (8cdc4c6 broke this, leading to error [0]) by
  making sure $(relay)socket is only defined if passed.
- Bump version to upcoming release 2.51 (wasn't bumbed on 2.50)
- Add --setsid option to start server with setsid if running in background (--nodetach isn't set).

[0]
Could not determine port number from host [*]:unix    at line 78 in
file /usr/local/lib/perl5/site_perl/Net/Server/Proto.pm
  • Loading branch information
grembo authored and mpaperno committed May 1, 2018
1 parent 47d2f78 commit ee66b26
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions spampd.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
######################
# SpamPD - spam proxy daemon
#
# v2.51 - 01-May-18
# v2.50 - 30-Apr-18
# v2.42 - 08-Dec-13
# v2.41 - 11-Aug-10
# v2.40 - 10-Jan-09
Expand Down Expand Up @@ -433,7 +435,7 @@ BEGIN

use vars qw(@ISA $VERSION);
our @ISA = qw(Net::Server::PreForkSimple);
our $VERSION = '2.42';
our $VERSION = '2.51';

sub process_message {
my ($self, $fh) = @_;
Expand Down Expand Up @@ -826,6 +828,7 @@ ($$$)
my $background = 1; # specifies whether to 'daemonize' and fork into background;
# apparently useful under Win32/cygwin to disable this via
# --nodetach option;
my $setsid = 0; # specifies wheter to use POSIX::setsid() command to truly daemonize.
my $envelopeheaders = 0; # Set X-Envelope-To and X-Envelope-From headers in the mail before
# passing it to spamassassin. Set to 1 to enable this.
my $setenvelopefrom = 0; # Set X-Envelope-From header only
Expand Down Expand Up @@ -887,6 +890,7 @@ ($$$)
'hostname=s', # deprecated
'logsock=s',
'nodetach',
'setsid',
'set-envelope-headers|seh',
'set-envelope-from|sef',
'saconfig=s',
Expand All @@ -909,22 +913,23 @@ ($$$)

$relayport = $1 if $relayport =~ /^(.*)$/;

$relaysocket = $1 if $relaysocket =~ /^(.*)$/;
$relaysocket = $1 if defined($relaysocket) && $relaysocket =~ /^(.*)$/;

$host = $1 if $host =~ /^(.*)$/;

$port = $1 if $port =~ /^(.*)$/;

$socket = $1 if $socket =~ /^(.*)$/;
$socket = $1 if defined($socket) && $socket =~ /^(.*)$/;

$socket_perms = $1 if $socket_perms =~ /^(.*)$/;
$socket_perms = $1 if defined($socket_perms) && $socket_perms =~ /^(.*)$/;
#

if ( $options{tagall} ) { $tagall = 1; }
if ( $options{'log-rules-hit'} ) { $rh = 1; }
if ( $options{debug} ) { $debug = 1; $nsloglevel = 4; }
if ( $options{dose} ) { $dose = 1; }
if ( $options{'nodetach'} ) { $background = undef; }
if ( $options{'setsid'} && defined($background)) { $setsid = 1; }
if ( $options{'set-envelope-headers'} ) { $envelopeheaders = 1; }
if ( $options{'set-envelope-from'} ) { $setenvelopefrom = 1; }
if ( $options{'saconfig'} ) { $saconfigfile = $options{'saconfig'}; }
Expand Down Expand Up @@ -1006,7 +1011,7 @@ ($$$)
syslog_ident => 'spampd',
syslog_facility => 'mail',
background => $background,
# setsid => 1,
setsid => $setsid,
pid_file => $pidfile,
user => $user,
group => $group,
Expand Down Expand Up @@ -1080,6 +1085,10 @@ sub usage {
background. Useful for some daemon control
tools or when running as a win32 service
under cygwin.
--setsid Fork after the bind method to release itself
from the command line and then run the
POSIX::setsid() command to truly daemonize.
Only used if --nodetach isn't specified.
--logsock=inet or unix Allows specifying the syslog socket type. Default is
'unix' except on HPUX and SunOS which prefer 'inet'.
Expand Down Expand Up @@ -1176,6 +1185,7 @@ =head1 Synopsis
[B<--satimeout=n>]
[B<--pid|p=filename>]
[B<--nodetach>]
[B<--setsid>]
[B<--logsock=inet|unix>]
[B<--maxsize=n>]
[B<--dose>]
Expand Down Expand Up @@ -1469,6 +1479,12 @@ =head1 Options
management tools or when configured as a win32 service under cygrunsrv's
control.
=item B<--setsid> C<(new in v2.51)>
If this option is given spampd will fork after the bind method to release
itself from the command line and then run the POSIX::setsid() command to truly
daemonize. Only used if --nodetach isn't specified.
=item B<--maxsize=n>
The maximum message size to send to SpamAssassin, in KBytes. By default messages
Expand Down

0 comments on commit ee66b26

Please sign in to comment.