Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address 'TEMP cannot use a string pattern on a bytes-like object' and make logging use syslog #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pckizer
Copy link

@pckizer pckizer commented Sep 16, 2020

Before this patch, reverse_srs would work but I would consistently get an error when calling make_srs:

% ./smapc unix:///tmp/pysrs make_srs 'infooo<@example.org.>'
TEMP cannot use a string pattern on a bytes-like object
% ./smapc unix:///tmp/pysrs reverse_srs 'SRS0=J6Lly=CZ=example.org=infooo<@example.com.>'
OK infooo<@example.org.>

After the patch both directions seem to work just fine:

% ./smapc unix:///tmp/pysrs make_srs 'infooo<@example.org.>'
OK SRS0=J6Lly=CZ=example.org=infooo<@example.com.>
% ./smapc unix:///tmp/pysrs reverse_srs 'SRS0=J6Lly=CZ=example.org=infooo<@example.com.>'
OK infooo<@example.org.>

To help debugging I also made the logging go to syslog rather than STDOUT.

@sdgathman
Copy link
Owner

Hmm. The logging should use the log method, which should be the only place you would add a syslog option. Stderr works well with systemd. I'll have to see what happens if you do syslog twice - may get two timestamps.

It needs a test case to reproduce the problem before the fix can be committed. Was the problem appearing with SES?

@sdgathman
Copy link
Owner

Your example does not fail:

2020Sep29 22:13:58 b'make-srs example.com\x9binfooo<@example.org.>' 
2020Sep29 22:13:58 h = example.com 
2020Sep29 22:13:58 OK SRS0=Mh29IKeV=DH=example.org=infooo<@example.org.> 
2020Sep29 22:13:58 b'reverse-srs SRS0=Mh29IKeV=DH=example.org=infooo<@example.org.>' 
2020Sep29 22:13:58 OK infooo<@example.org.> 

Are you using sendmail? Or another MTA?

@pckizer
Copy link
Author

pckizer commented Sep 30, 2020

I was using the smapc test utility client from the Gnu smap package (ftp://download.gnu.org.ua/pub/release/smap/smap-1.1.tar.gz), but I was indeed getting a similar failure from sendmail (8.16.1). I'm curious why yours does not show a similar failure.

I was using a fresh git clone from this repo with Python 3.7.9 (on FreeBSD 12.1) with a simple 'python3 ./pysrs.py test-pysrs.cfg' using a test-pysrs.cfg containing:

[srs]
secret="[secret]"
maxage=21
hashlength=5
database=/var/db/milter/srsdata
ses = example.com
fwdomain = example.com

Let me know if you want me to repeat with a sharable secret, though that shouldn't matter for exercising the code paths that led to me seeing the "TEMP cannot use a string pattern on a bytes-like object".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants