Skip to content

Instantly share code, notes, and snippets.

@baudetail
Forked from TheConstructor/inetd.conf
Created June 7, 2016 08:52
Show Gist options
  • Save baudetail/b2f58ad2cb34d70453313c921712024b to your computer and use it in GitHub Desktop.
Save baudetail/b2f58ad2cb34d70453313c921712024b 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
#!/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