--- INSTALL.ORIG 2004-12-02 19:54:33.000000000 +0100 +++ INSTALL 2012-04-13 18:04:40.000000000 +0200 @@ -5,13 +5,13 @@ srs-socketmapd.m4 to sendmail cf/hack/ dir srs-socketmapd to /etc/init.d/srs-socketmapd -srs-socketmapd.0.32rc3.pl to /usr/local/sbin/srs-socketmapd.0.32rc3.pl -srs-socketmapd.conf to /usr/local/srs-socketmapd.conf +srs-socketmapd.0.32rc3.pl to /usr/local/sbin/srs-socketmapd.pl +srs-socketmapd.conf to /usr/local/etc/srs-socketmapd.conf -Make sure /usr/local/sbin/srs-socketmapd.0.32rc3.pl is executeable and that perl +Make sure /usr/local/sbin/srs-socketmapd.pl is executeable and that perl is available in /usr/local/bin -Edit /usr/local/srs-socketmapd.conf to set your options as necessary. +Edit /usr/local/etc/srs-socketmapd.conf to set your options as necessary. you must supply a valid user, secret and alias NOTE : This file should be accessible only to root. It contains your secret! @@ -21,6 +21,12 @@ Run /etc/init.d/srs-socketmapd start +To make the service run permanently do something like (works at least +for Fedora, RH, CentOS environments) + +chkconfig --add srs-socketmapd +chkconfig --list srs-socketmapd + check /var/log/syslog for errors/warnings and make sure the daemon is running. @@ -48,7 +54,7 @@ HACK(srs-socketmapd, local:/var/run/socket.sock, SRS_ALL) : - srs rewrite everything (including the aliasing doamain. + srs rewrite everything (including the aliasing doamain). HACK(srs-socketmapd, local:/var/run/socket.sock, SRS_LOCAL_SELF) : @@ -64,3 +70,4 @@ before the hack will cause that file to be used to look up the destination mailer and if its listed then no forward srs rewrite occurs. Can be used to exclude srs rewrites to certain domains. + --- srs-socketmapd.0.32rc3.pl.ORIG 2004-12-02 19:54:34.000000000 +0100 +++ srs-socketmapd.0.32rc3.pl 2019-05-15 00:18:32.000000000 +0200 @@ -23,6 +23,12 @@ # http://spf.pobox.com/ # # This version requires at least Sendmail 8.13.0 + Mail::SRS 0.30 +# +# Revisions: +# 2012-04-02 jk@zid.tuwien.ac.at +# Fixed: make_srs may receive blanks in address, retain quoting. +# Fixed: exit read-in loop if some error condition arises. +# use IO::Socket; use POSIX qw (:sys_wait_h); @@ -52,6 +58,8 @@ # startup +init_syslog (); + write_syslog ("srs-socketmapd starting up"); parse_config (); @@ -130,13 +138,20 @@ $fwdomain = $Config_Params{"ALIAS"}; $max_age = $Config_Params{"MAXAGE"} || 8; $hash_length = $Config_Params{"HASHLENGTH"} || 8; + init_syslog($Config_Params{"LOGFACILITY"}) if $Config_Params{"LOGFACILITY"}; } -sub write_syslog { +sub init_syslog { + my $facility = shift; + $facility = "mail" if ! defined $facility; + + closelog (); setlogsock ('unix'); - openlog ('srs-socketmapd', 'pid,cons', 'lpr') or exit 1; + openlog ('srs-socketmapd', 'pid,cons', $facility) or exit 1; +} + +sub write_syslog { syslog ('info', @_); - closelog (); } sub log_error_and_exit { @@ -172,7 +187,7 @@ my $client = shift; while (not eval {eof ($client)}) { if (eval {$data = netstringRead ($client)}) { - if ($data =~ /^(\S+) (\S+)$/) { + if ($data =~ /^(\S+)\s(.+)$/) { $socket_map = $1; $old_address = $2; ($use_address = $old_address) =~ s/[<>]//g; @@ -182,6 +197,7 @@ $use_address = $_ while (eval {$_ = $srs -> reverse ($use_address)}); $use_address .= '.>'; $use_address =~ s/\@/<@/; + $use_address =~ s/^([^<@]* .*?)<@/"$1"<@/; # quote if blank inside! netstringWrite ($client, $use_address); } elsif ($use_address =~ /^\|/) { netstringWrite ($client, "\"$old_address\""); @@ -194,6 +210,7 @@ } elsif (eval {$new_address = $srs -> forward ($use_address, $fwdomain)}) { $new_address .= '.>'; $new_address =~ s/\@/<@/; + $new_address =~ s/^([^<@]* .*?)<@/"$1"<@/; # quote if blank inside! netstringWrite ($client, $new_address); } else { netstringWrite ($client, $old_address); @@ -204,6 +221,7 @@ } elsif (eval {$new_address = $srs_all -> forward ($use_address, $fwdomain)}) { $new_address .= '.>'; $new_address =~ s/\@/<@/; + $new_address =~ s/^([^<@]* .*?)<@/"$1"<@/; # quote if blank inside! netstringWrite ($client, $new_address); } else { netstringWrite ($client, $old_address); @@ -211,14 +229,17 @@ } else { write_syslog ("WARNING: unknown socketmap, '$socket_map'"); + return; } } else { write_syslog ("WARNING: incomplete data, '$data'"); + return; } } else { write_syslog ("WARNING: unable to read from client"); + return; } - } + } # while } # So far so good, lets fire her up @@ -299,4 +320,5 @@ eval {$sock -> close ()}; -exit 0; \ No newline at end of file +exit 0; + --- srs-socketmapd.ORIG 2004-12-02 19:54:33.000000000 +0100 +++ srs-socketmapd 2012-04-13 17:46:28.000000000 +0200 @@ -1,14 +1,24 @@ #!/bin/sh # -# socketmapd This script starts and stops the sendmail SRS socketmap daemon +# srs-socketmapd This script starts and stops the sendmail SRS socketmap daemon # # Version 0.32rc3 # # chkconfig: 2345 91 30 # -# description: socketmapd is a daemon which servers as a sendmail lookup map via a socket +# description: srs-socketmapd is a daemon which serves as a sendmail lookup map via a socket # to allow forward and reverse SRS rewriting -# processname: clamav-milter +# processname: srs-socketmapd +# config: /etc/srs-socketmapd.conf +# pidfile: /var/run/srs-socketmapd.pid + +# this ist name refering to in subsys, sysconfig and how the process names itself +# after it is running ... +prog=srs-socketmapd + +# this is the "binary" or program name which will be started +bin=srs-socketmapd.pl + # Source function library. . /etc/rc.d/init.d/functions @@ -16,28 +26,30 @@ # Source networking configuration. . /etc/sysconfig/network -[ -x /usr/local/sbin/srs-socketmapd.pl ] || exit 0 + PATH=$PATH:/usr/bin:/usr/local/sbin:/usr/local/bin +( which $bin > /dev/null 2>&1 || (echo "program $bin missing"; false) ) || exit 0 RETVAL=0 start() { - echo -n "Starting socketmapd: " - daemon srs-socketmapd.pl + echo -n "Starting $prog: " + daemon --pidfile /var/run/$prog.pid $OPTARG $bin RETVAL=$? echo - test $RETVAL -eq 0 && touch /var/lock/subsys/srs-socketmapd + test $RETVAL -eq 0 && touch /var/lock/subsys/$prog return $RETVAL } stop() { - echo -n "Shutting down socketmapd: " - killproc srs-socketmapd.pl + echo -n "Shutting down $prog: " + # daemon renames itself to $prog (even if it is started as $bin) + killproc -p /var/run/$prog.pid $prog RETVAL=$? echo - test $RETVAL -eq 0 && rm -f /var/lock/subsys/srs-socketmapd - test -f /var/lock/subsys/srs-socketmapd || rm -f /var/run/srs-socketmapd.pid - test -f /var/lock/subsys/srs-socketmapd || rm -f /var/run/srs-socketmapd.sock + test $RETVAL -eq 0 && rm -f /var/lock/subsys/$prog + test -f /var/lock/subsys/$prog || rm -f /var/run/$prog.pid + test -f /var/lock/subsys/$prog || rm -f /var/run/$prog.sock } restart() { @@ -45,6 +57,7 @@ start } + # See how we were called. case "$1" in start) @@ -55,16 +68,22 @@ # Stop daemon. stop ;; - restart|reload) + restart|force-reload|reload) stop start ;; - condrestart) - test -f /var/lock/subsys/srs-socketmapd && $0 restart || : + condrestart|try-restart) + test -f /var/lock/subsys/$prog && $0 restart || : ;; + status) + echo -n $prog; status -p /var/run/$prog.pid $prog + RETVAL=$? + [ $RETVAL -eq 0 ] && RETVAL=$? + ;; *) - echo "Usage: $0 {start|stop|reload|restart|condrestart}" - exit 1 + echo "Usage: $0 {start|stop|reload|restart|reload|condrestart|status}" + RETVAL=2 esac -exit $? +exit $RETVAL + --- srs-socketmapd.conf.ORIG 2004-12-02 19:54:33.000000000 +0100 +++ srs-socketmapd.conf 2012-04-13 15:48:53.000000000 +0200 @@ -39,3 +39,10 @@ # HASHLENGTH = 6 # (Default = 8 ) + +# LOGFACILITY = mail + +# (Default = mail, usually available: auth, authpriv (for security information of a sensitive nature), cron, +# daemon, ftp, kern, lpr, mail, news, security (deprecated synonym for auth), syslog, user, uucp, +# and local0 to local7). +