Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: SPF: SRS

[srs-discuss] Implementing Mail::SRS in MIMEDefang

 

 

SPF srs RSS feed   Index | Next | Previous | View Threaded


mfaurot at atww

Oct 3, 2004, 9:28 AM

Post #1 of 4 (3225 views)
Permalink
[srs-discuss] Implementing Mail::SRS in MIMEDefang

After successfully implementing Mail::SPF::Query in MIMEDefang[1] and
getting SPF TXT records implemented in the zone files for the various
domains I administer, I'm now looking to implement Mail::SRS for some
of the domains I forward.

So far, I believe I've got the sender envelope re-writing bits worked
out. As I'm experimenting with getting the receiving/verification part
implemented I've run into a problem. In particular, I've been testing
$srs->reverse($srsaddress). When the rewritten SRS address is valid,
there's no problems. But if I deliberately use a malformed SRS address
(as a spammer would presumably do), then Mail::SRS causes my MIMEDefang
slave process to die with the following error:

Oct 2 17:50:49 mail mimedefang-multiplexor[393]: Slave 1
stderr: Parse error in `SRS0+YYpR7b=MV=atww.org=mfaurot':
Invalid hash at /usr/local/share/perl/5.6.1/Mail/SRS/Shortcut.pm
line 86.

Upon inspection of Shortcut.pm at line 86, I see the problem is this:

unless ($self->hash_verify($hash,$timestamp,$sendhost,$senduser)) {
die "Invalid hash";
}

Looking around further, I see lots of use of 'die' in these modules.
This presents a problem when trying to integrate Mail::SRS into a
larger system. I need a return code of some type to tell me whether a
particular address is invalid--not have the module terminate my program.

Please advise how I should implement validation and address reversal
using $srs->reverse(), without it terminating my programs.

Thanks.

[1]: http://www.mimedefang.org/

-------
To unsubscribe, change your address, or temporarily deactivate your subscription,
please go to http://v2.listbox.com/member/?listname=srs-discuss [at] v2


admin at asarian-host

Oct 3, 2004, 10:48 AM

Post #2 of 4 (3002 views)
Permalink
Re: [srs-discuss] Implementing Mail::SRS in MIMEDefang [In reply to]

Michael Faurot wrote:

> But if I deliberately use a malformed SRS address (as a spammer would
> presumably do), then Mail::SRS causes my MIMEDefang slave process
> to die with the following error:
>
> Oct 2 17:50:49 mail mimedefang-multiplexor[393]: Slave 1
> stderr: Parse error in `SRS0+YYpR7b=MV=atww.org=mfaurot':
> Invalid hash at /usr/local/share/perl/5.6.1/Mail/SRS/Shortcut.pm
> line 86.
>
> Looking around further, I see lots of use of 'die' in these modules.
> This presents a problem when trying to integrate Mail::SRS into a
> larger system. I need a return code of some type to tell me whether a
> particular address is invalid--not have the module terminate my
> program.
>
> Please advise how I should implement validation and address reversal
> using $srs->reverse(), without it terminating my programs.

The "die" statements are quite the standard way of doing things in Perl
modules. So this is actually really a Perl question.

At any rate, you should enclose SRS calls in an 'eval' function, which will
return undef upon die. Like so:

if (eval {$_ = $srs -> reverse ($to)}) {
print "Reversed SRS address is $_\n";
}

Watch out for pitfalls like these:

if (eval {my $address = $srs -> reverse ($to)}) {

As the lexical scope of "my $address" is limited to within the eval
construct. What you want then, is this:

my $address;
if (eval {$address = $srs -> reverse ($to)}) {

And you'll be fine.

- Mark

System Administrator Asarian-host.org

---
"If you were supposed to understand it,
we wouldn't call it code." - FedEx

-------
To unsubscribe, change your address, or temporarily deactivate your subscription,
please go to http://v2.listbox.com/member/?listname=srs-discuss [at] v2


mfaurot at atww

Oct 3, 2004, 2:56 PM

Post #3 of 4 (2994 views)
Permalink
Re: [srs-discuss] Implementing Mail::SRS in MIMEDefang [In reply to]

In article <200410031748.I93HMMDZ089517 [at] asarian-host> you wrote:

> The "die" statements are quite the standard way of doing things in Perl
> modules. So this is actually really a Perl question.

I thought my difficulty might involve something like this as I haven't
had much reason to use modules, until now.

> At any rate, you should enclose SRS calls in an 'eval' function, which will
> return undef upon die. Like so:
[...]
> my $address;
> if (eval {$address = $srs -> reverse ($to)}) {

This does indeed solve my difficulties. Thanks!

Perhaps example code using eval could be incorporated into the POD
documentation? Presumably someone that does enough of this stuff, probably
already knows that they should use eval, but for folks like me that are
looking at the docs for example code just to get something working,
would appreciate it. :)

-------
To unsubscribe, change your address, or temporarily deactivate your subscription,
please go to http://v2.listbox.com/member/?listname=srs-discuss [at] v2


spf at anarres

Oct 19, 2004, 8:51 AM

Post #4 of 4 (2976 views)
Permalink
Re: [srs-discuss] Implementing Mail::SRS in MIMEDefang [In reply to]

On Sun, 3 Oct 2004, Michael Faurot wrote:

>
> In article <200410031748.I93HMMDZ089517 [at] asarian-host> you wrote:
>
> > The "die" statements are quite the standard way of doing things in Perl
> > modules. So this is actually really a Perl question.
>
> I thought my difficulty might involve something like this as I haven't
> had much reason to use modules, until now.
>
> > At any rate, you should enclose SRS calls in an 'eval' function, which will
> > return undef upon die. Like so:
> [...]
> > my $address;
> > if (eval {$address = $srs -> reverse ($to)}) {
>
> This does indeed solve my difficulties. Thanks!
>
> Perhaps example code using eval could be incorporated into the POD
> documentation? Presumably someone that does enough of this stuff, probably
> already knows that they should use eval, but for folks like me that are
> looking at the docs for example code just to get something working,
> would appreciate it. :)

Strictly speaking, you should inspect $@ and not rely on the returned
value.

my $address = eval { $srs->reverse($to); };
unless ($@) {
...
}

However, if the code ever returns undef (which I don't think it can), that
would also be an error, so your code is fine.

I will some examples in the documentation forthwith. Perhaps the code in
Daemon.pm offers the best examples.

S.

--
Shevek http://www.anarres.org/
Robust Sender Policy Framework (SPF) http://www.libspf2.org/
SRS for the next generation http://www.libsrs2.org/

-------
To unsubscribe, change your address, or temporarily deactivate your subscription,
please go to http://v2.listbox.com/member/?listname=srs-discuss [at] v2

SPF srs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.