From 2a53e2464bfa1a831f544ed44d3690e5c22259a5 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Wed, 6 May 2020 15:19:24 +0100 Subject: [PATCH] testcases for value return --- doc/doc-docbook/spec.xfpt | 5 +-- src/src/match.c | 2 +- test/confs/0624 | 23 ++++++++++++ test/log/0624 | 13 +++++++ test/rejectlog/0624 | 1 + test/scripts/0000-Basic/0624 | 69 ++++++++++++++++++++++++++++++++++++ test/stderr/0362 | 4 +-- test/stderr/5204 | 2 +- test/stdout/0624 | 45 +++++++++++++++++++++++ 9 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 test/confs/0624 create mode 100644 test/log/0624 create mode 100644 test/rejectlog/0624 create mode 100644 test/scripts/0000-Basic/0624 create mode 100644 test/stdout/0624 diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index a05ad6650..33e07db0a 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -8528,7 +8528,7 @@ possible to use the same configuration file on several different hosts that differ only in their names. .new -The value for a match will be the primary host name/ +The value for a match will be the primary host name. .wen @@ -8541,7 +8541,8 @@ in square brackets (as in an email address that contains a domain literal), but only if that IP address is recognized as local for email routing purposes. The &%local_interfaces%& and &%extra_local_interfaces%& options can be used to control which of a host's several IP addresses are treated as local. -In today's Internet, the use of domain literals is controversial. +In today's Internet, the use of domain literals is controversial; +see the &%allow_domain_literals%& main option. .new The value for a match will be the &`@[]`& string. diff --git a/src/src/match.c b/src/src/match.c index db02b37bd..f9b539d10 100644 --- a/src/src/match.c +++ b/src/src/match.c @@ -160,7 +160,7 @@ if (pattern[0] == '*') expand_nlength[expand_setup] = slen - patlen; expand_nmax = expand_setup; } - if (valueptr) *valueptr = pattern; /* "value" gets the pattern */ + if (valueptr) *valueptr = pattern - 1; /* "value" gets the (original) pattern */ return OK; } diff --git a/test/confs/0624 b/test/confs/0624 new file mode 100644 index 000000000..d6f00b345 --- /dev/null +++ b/test/confs/0624 @@ -0,0 +1,23 @@ +# Exim test configuration 0624 + +.include DIR/aux-var/std_conf_prefix + + +# ----- Main settings ----- + +primary_hostname = primaryhostname.ex +hosts_treat_as_local = 46.test.ex +allow_domain_literals + +acl_smtp_rcpt = chk_rcpt + +# ----- ACL ----- + +begin acl + +chk_rcpt: + accept domains = OPT + logwrite = domain $domain + logwrite = value $domain_data + +# End diff --git a/test/log/0624 b/test/log/0624 new file mode 100644 index 000000000..3622b9f42 --- /dev/null +++ b/test/log/0624 @@ -0,0 +1,13 @@ +1999-03-02 09:44:33 U=CALLER F= rejected RCPT +1999-03-02 09:44:33 domain plainstring.ex +1999-03-02 09:44:33 value plainstring.ex +1999-03-02 09:44:33 domain headtail.ex +1999-03-02 09:44:33 value *tail.ex +1999-03-02 09:44:33 domain headregextail.ex +1999-03-02 09:44:33 value ^.*regex +1999-03-02 09:44:33 domain primaryhostname.ex +1999-03-02 09:44:33 value primaryhostname.ex +1999-03-02 09:44:33 domain [127.0.0.1] +1999-03-02 09:44:33 value @[] +1999-03-02 09:44:33 domain mx46.test.ex +1999-03-02 09:44:33 value @mx_any/ignore=1.1.1.1 diff --git a/test/rejectlog/0624 b/test/rejectlog/0624 new file mode 100644 index 000000000..86b0ed7e6 --- /dev/null +++ b/test/rejectlog/0624 @@ -0,0 +1 @@ +1999-03-02 09:44:33 U=CALLER F= rejected RCPT diff --git a/test/scripts/0000-Basic/0624 b/test/scripts/0000-Basic/0624 new file mode 100644 index 000000000..d4e5acbbc --- /dev/null +++ b/test/scripts/0000-Basic/0624 @@ -0,0 +1,69 @@ +# domainlist match values +# +exim -bs -DOPT=: +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +exim -bs '-DOPT=notthis : plainstring.ex : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +exim -bs '-DOPT=notthis : *tail.ex : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +exim -bs '-DOPT=notthis : ^.*regex : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +exim -bs '-DOPT=notthis : @ : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +# +exim -bs '-DOPT=notthis : @[] : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +# malformed +exim -bs '-DOPT=notthis : @[] : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +# malformed +exim -bs '-DOPT=notthis : @[] : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# +# +exim -bs '-DOPT=notthis : @mx_any/ignore=1.1.1.1 : nothiseither' +HELO test +MAIL FROM: +RCPT TO: +QUIT +**** +# diff --git a/test/stderr/0362 b/test/stderr/0362 index 7433c9d04..79725a0fa 100644 --- a/test/stderr/0362 +++ b/test/stderr/0362 @@ -62,7 +62,7 @@ r1 router skipped: domains mismatch local_part=x domain=x.test.ex checking domains x.test.ex in "*.test.ex"? yes (matched "*.test.ex") -data from lookup saved for cache for +local_domains: key 'x.test.ex' value '.test.ex' +data from lookup saved for cache for +local_domains: key 'x.test.ex' value '*.test.ex' x.test.ex in "+local_domains"? yes (matched "+local_domains") calling r2 router r2 router called for x@x.test.ex @@ -71,7 +71,7 @@ set transport t2 queued for t2 transport: local_part = x domain = x.test.ex errors_to=NULL - domain_data=.test.ex localpart_data=NULL + domain_data=*.test.ex localpart_data=NULL routed by r2 router envelope to: x@x.test.ex transport: t2 diff --git a/test/stderr/5204 b/test/stderr/5204 index 81fede5b6..27b40de67 100644 --- a/test/stderr/5204 +++ b/test/stderr/5204 @@ -220,7 +220,7 @@ set transport null queued for null transport: local_part = postmaster domain = test.ex errors_to=NULL - domain_data=NULL localpart_data=NULL + domain_data=NULL localpart_data=postmaster routed by pm router envelope to: postmaster@test.ex transport: null diff --git a/test/stdout/0624 b/test/stdout/0624 new file mode 100644 index 000000000..c59ed78b2 --- /dev/null +++ b/test/stdout/0624 @@ -0,0 +1,45 @@ +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +550 Administrative prohibition +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +250 Accepted +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +250 Accepted +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +250 Accepted +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +250 Accepted +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +250 Accepted +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +501 : malformed address: ]> may not follow : malformed domain literal +221 primaryhostname.ex closing connection +220 primaryhostname.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 primaryhostname.ex Hello CALLER at test +250 OK +250 Accepted +221 primaryhostname.ex closing connection -- 2.30.2