Fix ACL "condition =" for negative number values. Bug 1005
authorJeremy Harris <jgh146exb@wizmail.org>
Tue, 18 Mar 2014 16:17:56 +0000 (16:17 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Tue, 18 Mar 2014 16:17:56 +0000 (16:17 +0000)
Fix conditional "bool{<string>}" for negative number values, to match.

12 files changed:
doc/doc-docbook/spec.xfpt
doc/doc-txt/ChangeLog
src/src/acl.c
src/src/expand.c
test/log/0023
test/mail/0023.cond--1 [new file with mode: 0644]
test/mail/0023.cond-rhubarb
test/mail/0023.okbatch
test/scripts/0000-Basic/0002
test/scripts/0000-Basic/0023
test/stdout/0002
test/stdout/0023

index c412c1e1675e124f5c7909a77fe6eabf6a08837f..0f66180a23464b9c384c0e5464ada3bde724e061 100644 (file)
@@ -10247,7 +10247,7 @@ If the ACL returns defer the result is a forced-fail.
 .cindex "&%bool%& expansion condition"
 This condition turns a string holding a true or false representation into
 a boolean state.  It parses &"true"&, &"false"&, &"yes"& and &"no"&
 .cindex "&%bool%& expansion condition"
 This condition turns a string holding a true or false representation into
 a boolean state.  It parses &"true"&, &"false"&, &"yes"& and &"no"&
-(case-insensitively); also positive integer numbers map to true if non-zero,
+(case-insensitively); also integer numbers map to true if non-zero,
 false if zero.
 An empty string is treated as false.
 Leading and trailing whitespace is ignored;
 false if zero.
 An empty string is treated as false.
 Leading and trailing whitespace is ignored;
index 8a55ceea9d6eeea9e82f623f9fe409695e530e51..25e153e3613372e33d0b1eec814d0f2ed3444ca8 100644 (file)
@@ -62,6 +62,9 @@ JH/08 Bugzilla 1371: Add tls_{,try_}verify_hosts to smtp transport.
 JH/09 Bugzilla 1431: Support (with limitations) headers_add/headers_remove in
       routers/transports under cutthrough routing.
 
 JH/09 Bugzilla 1431: Support (with limitations) headers_add/headers_remove in
       routers/transports under cutthrough routing.
 
+JH/10 Bugzilla 1005: ACL "condition =" should accept values which are negative
+      numbers.  Touch up "bool" conditional to keep the same definition.
+
 
 Exim version 4.82
 -----------------
 
 Exim version 4.82
 -----------------
index fd958aa3951d62ed0e4de3e24c280769d9dc4313..4fda03b77b03e8b21e3931a4a704a69d5f814dac 100644 (file)
@@ -3103,7 +3103,9 @@ for (; cb != NULL; cb = cb->next)
     /* The true/false parsing here should be kept in sync with that used in
     expand.c when dealing with ECOND_BOOL so that we don't have too many
     different definitions of what can be a boolean. */
     /* The true/false parsing here should be kept in sync with that used in
     expand.c when dealing with ECOND_BOOL so that we don't have too many
     different definitions of what can be a boolean. */
-    if (Ustrspn(arg, "0123456789") == Ustrlen(arg))     /* Digits, or empty */
+    if (*arg == '-'
+       ? Ustrspn(arg+1, "0123456789") == Ustrlen(arg+1)    /* Negative number */
+       : Ustrspn(arg,   "0123456789") == Ustrlen(arg))     /* Digits, or empty */
       rc = (Uatoi(arg) == 0)? FAIL : OK;
     else
       rc = (strcmpic(arg, US"no") == 0 ||
       rc = (Uatoi(arg) == 0)? FAIL : OK;
     else
       rc = (strcmpic(arg, US"no") == 0 ||
index bd097db432f80f242b7bd641479931e497c2c312..64a3a86e6156a5b3282dc475f67fa0023de579d8 100644 (file)
@@ -2849,7 +2849,9 @@ switch(cond_type)
     be no maintenance burden from replicating it. */
     if (len == 0)
       boolvalue = FALSE;
     be no maintenance burden from replicating it. */
     if (len == 0)
       boolvalue = FALSE;
-    else if (Ustrspn(t, "0123456789") == len)
+    else if (*t == '-'
+            ? Ustrspn(t+1, "0123456789") == len-1
+            : Ustrspn(t,   "0123456789") == len)
       {
       boolvalue = (Uatoi(t) == 0) ? FALSE : TRUE;
       /* expand_check_condition only does a literal string "0" check */
       {
       boolvalue = (Uatoi(t) == 0) ? FALSE : TRUE;
       /* expand_check_condition only does a literal string "0" check */
index 9880fbd92e07b0ddf03a58720d1b3e229e4302a8..422944aeed57c514a7cdb5e24f288afbfd1cba57 100644 (file)
 1999-03-02 09:44:33 10HmbK-0005vi-00 => cond-yes <cond-yes@test.ex> R=r1 T=t1
 1999-03-02 09:44:33 10HmbK-0005vi-00 Completed
 1999-03-02 09:44:33 H=[56.56.57.57] U=CALLER F=<userx@test.ex> temporarily rejected RCPT <cond-rhubarb@test.ex>: invalid "condition" value "rhubarb"
 1999-03-02 09:44:33 10HmbK-0005vi-00 => cond-yes <cond-yes@test.ex> R=r1 T=t1
 1999-03-02 09:44:33 10HmbK-0005vi-00 Completed
 1999-03-02 09:44:33 H=[56.56.57.57] U=CALLER F=<userx@test.ex> temporarily rejected RCPT <cond-rhubarb@test.ex>: invalid "condition" value "rhubarb"
-1999-03-02 09:44:33 10HmbL-0005vi-00 <= userx@test.ex H=[56.56.56.56] U=CALLER P=smtp S=sss
-1999-03-02 09:44:33 10HmbL-0005vi-00 => cond-rhubarb <cond-rhubarb@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmbL-0005vi-00 <= userx@test.ex H=[56.56.57.57] U=CALLER P=smtp S=sss
+1999-03-02 09:44:33 10HmbL-0005vi-00 => cond--1 <cond--1@test.ex> R=r1 T=t1
 1999-03-02 09:44:33 10HmbL-0005vi-00 Completed
 1999-03-02 09:44:33 10HmbL-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbM-0005vi-00 <= userx@test.ex H=[56.56.56.56] U=CALLER P=smtp S=sss
+1999-03-02 09:44:33 10HmbM-0005vi-00 => cond-rhubarb <cond-rhubarb@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmbM-0005vi-00 Completed
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@test.ex> rejected RCPT <bad1@test.ex>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@test.ex> rejected RCPT <bad2@test.ex>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@test.ex> rejected RCPT <bad3@test.ex>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@test.ex> rejected RCPT <bad1@test.ex>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@test.ex> rejected RCPT <bad2@test.ex>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@test.ex> rejected RCPT <bad3@test.ex>
-1999-03-02 09:44:33 10HmbM-0005vi-00 <= rcpttest@test.ex H=[56.56.58.58] U=CALLER P=smtp S=sss
-1999-03-02 09:44:33 10HmbM-0005vi-00 => ok1 <ok1@test.ex> R=r0 T=t2
-1999-03-02 09:44:33 10HmbM-0005vi-00 -> ok2 <ok2@test.ex> R=r0 T=t2
-1999-03-02 09:44:33 10HmbM-0005vi-00 -> ok3 <ok3@test.ex> R=r0 T=t2
-1999-03-02 09:44:33 10HmbM-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbN-0005vi-00 <= rcpttest@test.ex H=[56.56.58.58] U=CALLER P=smtp S=sss
+1999-03-02 09:44:33 10HmbN-0005vi-00 => ok1 <ok1@test.ex> R=r0 T=t2
+1999-03-02 09:44:33 10HmbN-0005vi-00 -> ok2 <ok2@test.ex> R=r0 T=t2
+1999-03-02 09:44:33 10HmbN-0005vi-00 -> ok3 <ok3@test.ex> R=r0 T=t2
+1999-03-02 09:44:33 10HmbN-0005vi-00 Completed
 1999-03-02 09:44:33 H=[56.56.59.59] U=CALLER F=<rcpttest@test.ex> rejected RCPT <fail@test.ex>: here is a fail message
 1999-03-02 09:44:33 H=[V4NET.11.12.13] U=CALLER F=<x@y> rejected RCPT <x@y>: DNSLIST (rbl.test.ex: This is a test blacklisting message)
 1999-03-02 09:44:33 H=[V4NET.11.12.13] U=CALLER F=<x@y> rejected RCPT <x1@y>: DNSLIST (rbl.test.ex: This is a test blacklisting message)
 1999-03-02 09:44:33 H=[56.56.59.59] U=CALLER F=<rcpttest@test.ex> rejected RCPT <fail@test.ex>: here is a fail message
 1999-03-02 09:44:33 H=[V4NET.11.12.13] U=CALLER F=<x@y> rejected RCPT <x@y>: DNSLIST (rbl.test.ex: This is a test blacklisting message)
 1999-03-02 09:44:33 H=[V4NET.11.12.13] U=CALLER F=<x@y> rejected RCPT <x1@y>: DNSLIST (rbl.test.ex: This is a test blacklisting message)
diff --git a/test/mail/0023.cond--1 b/test/mail/0023.cond--1
new file mode 100644 (file)
index 0000000..ef08691
--- /dev/null
@@ -0,0 +1,9 @@
+From userx@test.ex Tue Mar 02 09:44:33 1999
+Received: from [56.56.57.57] (ident=CALLER)
+       by myhost.test.ex with smtp (Exim x.yz)
+       (envelope-from <userx@test.ex>)
+       id 10HmbL-0005vi-00
+       for cond--1@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
+X-message-body-size: 0
+
+
index c8b40c7307e3f007eb9b2722b59c76e6f551991a..798c40f0ec79937802bbb9057a5d519d23ec8a43 100644 (file)
@@ -11,7 +11,7 @@ From userx@test.ex Tue Mar 02 09:44:33 1999
 Received: from [56.56.56.56] (ident=CALLER)
        by myhost.test.ex with smtp (Exim x.yz)
        (envelope-from <userx@test.ex>)
 Received: from [56.56.56.56] (ident=CALLER)
        by myhost.test.ex with smtp (Exim x.yz)
        (envelope-from <userx@test.ex>)
-       id 10HmbL-0005vi-00
+       id 10HmbM-0005vi-00
        for cond-rhubarb@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
 X-message-body-size: 0
 
        for cond-rhubarb@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
 X-message-body-size: 0
 
index eae8de28b222929fba9f4e4dd0c38f531603c0ff..16b2f73883e49f982fe77b479fab4fb56a6743f5 100644 (file)
@@ -5,7 +5,7 @@ Envelope-to: ok1@test.ex,
 Received: from [56.56.58.58] (ident=CALLER)
        by myhost.test.ex with smtp (Exim x.yz)
        (envelope-from <rcpttest@test.ex>)
 Received: from [56.56.58.58] (ident=CALLER)
        by myhost.test.ex with smtp (Exim x.yz)
        (envelope-from <rcpttest@test.ex>)
-       id 10HmbM-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000
+       id 10HmbN-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000
 xx: rcpt_count = 1
     rcpt_defer_count = 0
     rcpt_fail_count  = 0
 xx: rcpt_count = 1
     rcpt_defer_count = 0
     rcpt_fail_count  = 0
index 367d558b3a98038a47993a4c38ca118d00fa60f4..7b6c34b3eca5c34dfdc0be0a9aa957b29b1bc89b 100644 (file)
@@ -602,7 +602,7 @@ abcdea abc z   ${tr{abcdea}{abc}{z}}
 " yes"                ${if bool{ yes}{true}{false}}      EXPECT: true
 " no"                 ${if bool{ no}{true}{false}}     EXPECT: false
 "yes "                ${if bool{yes }{true}{false}}      EXPECT: true
 " yes"                ${if bool{ yes}{true}{false}}      EXPECT: true
 " no"                 ${if bool{ no}{true}{false}}     EXPECT: false
 "yes "                ${if bool{yes }{true}{false}}      EXPECT: true
-"-1"                  ${if bool{-1}{true}{false}}     EXPECT: error
+"-1"                  ${if bool{-1}{true}{false}}     EXPECT: true
 "0"                   ${if bool{0}{true}{false}}     EXPECT: false
 "1"                   ${if bool{1}{true}{false}}      EXPECT: true
 " 0 "                 ${if bool{ 0 }{true}{false}}     EXPECT: false
 "0"                   ${if bool{0}{true}{false}}     EXPECT: false
 "1"                   ${if bool{1}{true}{false}}      EXPECT: true
 " 0 "                 ${if bool{ 0 }{true}{false}}     EXPECT: false
@@ -612,6 +612,7 @@ abcdea abc z   ${tr{abcdea}{abc}{z}}
 " "                   ${if bool{ }{true}{false}}     EXPECT: false
 "text"                ${if bool{text}{true}{false}}     EXPECT: error
 " text"               ${if bool{ text}{true}{false}}     EXPECT: error
 " "                   ${if bool{ }{true}{false}}     EXPECT: false
 "text"                ${if bool{text}{true}{false}}     EXPECT: error
 " text"               ${if bool{ text}{true}{false}}     EXPECT: error
+"-text"               ${if bool{-text}{true}{false}}     EXPECT: error
 "text "               ${if bool{text }{true}{false}}     EXPECT: error
 " text "              ${if bool{ text }{true}{false}}     EXPECT: error
 "00"                  ${if bool{00}{true}{false}}     EXPECT: false
 "text "               ${if bool{text }{true}{false}}     EXPECT: error
 " text "              ${if bool{ text }{true}{false}}     EXPECT: error
 "00"                  ${if bool{00}{true}{false}}     EXPECT: false
index 28c6ec97a8977b05ffa07d79cee0399740d4baba..51e7123d0d3cc535dcdf8d3622b36efbcf711ec7 100644 (file)
@@ -299,6 +299,11 @@ data
 .
 mail from:<userx@test.ex>
 rcpt to:<cond-rhubarb@test.ex>
 .
 mail from:<userx@test.ex>
 rcpt to:<cond-rhubarb@test.ex>
+rset
+mail from:<userx@test.ex>
+rcpt to:<cond--1@test.ex>
+data
+.
 quit
 ****
 exim -DLOG_SELECTOR=log_selector=-acl_warn_skipped -odi -bs -oMa 56.56.56.56
 quit
 ****
 exim -DLOG_SELECTOR=log_selector=-acl_warn_skipped -odi -bs -oMa 56.56.56.56
index e6270977b96ff2a9b3b1d510ae12309b8736a28e..64e5719444cb4875886330e02d0458f691c8c6b1 100644 (file)
 > " yes"                true      EXPECT: true
 > " no"                 false     EXPECT: false
 > "yes "                true      EXPECT: true
 > " yes"                true      EXPECT: true
 > " no"                 false     EXPECT: false
 > "yes "                true      EXPECT: true
-> Failed: unrecognised boolean value "-1"
+> "-1"                  true     EXPECT: true
 > "0"                   false     EXPECT: false
 > "1"                   true      EXPECT: true
 > " 0 "                 false     EXPECT: false
 > "0"                   false     EXPECT: false
 > "1"                   true      EXPECT: true
 > " 0 "                 false     EXPECT: false
 > " "                   false     EXPECT: false
 > Failed: unrecognised boolean value "text"
 > Failed: unrecognised boolean value "text"
 > " "                   false     EXPECT: false
 > Failed: unrecognised boolean value "text"
 > Failed: unrecognised boolean value "text"
+> Failed: unrecognised boolean value "-text"
 > Failed: unrecognised boolean value "text"
 > Failed: unrecognised boolean value "text"
 > "00"                  false     EXPECT: false
 > Failed: unrecognised boolean value "text"
 > Failed: unrecognised boolean value "text"
 > "00"                  false     EXPECT: false
index 74ef7a0f6a62436d3ee5d037427ef96dbf23a01e..b805f334bbfe2d9a87c03765041f8f83310d6fdb 100644 (file)
 250 OK id=10HmbK-0005vi-00\r
 250 OK\r
 451 Temporary local problem - please try later\r
 250 OK id=10HmbK-0005vi-00\r
 250 OK\r
 451 Temporary local problem - please try later\r
+250 Reset OK\r
+250 OK\r
+250 accepted by condition\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmbL-0005vi-00\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
-250 OK id=10HmbL-0005vi-00\r
+250 OK id=10HmbM-0005vi-00\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r
 550 Administrative prohibition\r
 550 Administrative prohibition\r
 354 Enter message, ending with "." on a line by itself\r
 550 Administrative prohibition\r
 550 Administrative prohibition\r
 354 Enter message, ending with "." on a line by itself\r
-250 OK id=10HmbM-0005vi-00\r
+250 OK id=10HmbN-0005vi-00\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r
 221 myhost.test.ex closing connection\r
 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
 250 OK\r