Skip to content

Instantly share code, notes, and snippets.

@TheConstructor
Last active May 22, 2020 10:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save TheConstructor/6163083 to your computer and use it in GitHub Desktop.
Save TheConstructor/6163083 to your computer and use it in GitHub Desktop.
Postfix SRS-support under Debian "Wheezy". Using http://packages.debian.org/wheezy/srs, http://packages.debian.org/wheezy/liburi-perl and http://packages.debian.org/wheezy/openbsd-inetd File paths are: - /opt/srs/srs-encode.sh - /opt/srs/srs-decode.sh - /etc/inetd.conf (should be appended to) - /etc/postfix/main.cf (should be appended to) - /etc…
# SRS
127.0.0.1:10001 stream tcp nowait root /opt/srs/srs-encode.sh /opt/srs/srs-encode.sh
127.0.0.1:10002 stream tcp nowait root /opt/srs/srs-decode.sh /opt/srs/srs-decode.sh
# SRS
recipient_canonical_maps = proxy:hash:/etc/postfix/pfix-srs.norewrite, proxy:tcp:127.0.0.1:10002
recipient_canonical_classes = envelope_recipient
sender_canonical_maps = proxy:hash:/etc/postfix/pfix-srs.norewrite, proxy:tcp:127.0.0.1:10001
sender_canonical_classes = envelope_sender
# We want to be shure not to rewrite these
# For vom.tc
postmaster@vom.tc postmaster@vom.tc
abuse@vom.tc abuse@vom.tc
webmaster@vom.tc webmaster@vom.tc
# For pinch.vom.tc
postmaster@pinch.vom.tc postmaster@pinch.vom.tc
abuse@pinch.vom.tc abuse@pinch.vom.tc
webmaster@pinch.vom.tc webmaster@pinch.vom.tc
#!/bin/bash
while read line; do
email="${line#get }"
email="$(perl -MURI::Escape -e 'print uri_unescape($ARGV[0]);' "${email}")"
if [[ "${line}" == "${email}" ]]; then
echo "400 Empty input"
else
unset t_std t_err t_ret
eval "$( srs --secretfile=/etc/postfix/srs.secrets --reverse "${email}" 2> >(t_err=$(cat); typeset -p t_err) > >(t_std=$(cat); typeset -p t_std); t_ret=$?; typeset -p t_ret )"
if [[ $t_ret -eq 0 ]]; then
echo "200 $(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "${t_std}")"
else
echo "500 $(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "${t_err}")"
fi
fi
done
#!/bin/bash
while read line; do
email="${line#get }"
email="$(perl -MURI::Escape -e 'print uri_unescape($ARGV[0]);' "${email}")"
if [[ "${line}" == "${email}" ]]; then
echo "400 Empty input"
else
unset t_std t_err t_ret
if [[ "${email}" =~ @(vom\.tc|pinch\.vom\.tc)$ ]]; then
t_err="${email}"
t_ret=1
else
eval "$( srs --alias=vom.tc --secretfile=/etc/postfix/srs.secrets "${email}" 2> >(t_err=$(cat); typeset -p t_err) > >(t_std=$(cat); typeset -p t_std); t_ret=$?; typeset -p t_ret )"
fi
if [[ $t_ret -eq 0 ]]; then
echo "200 $(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "${t_std}")"
else
echo "500 $(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "${t_err}")"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment