[exim-cvs] Fix ACL "condition =" for negative number values.…

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Exim Git Commits Mailing List
日付:  
To: exim-cvs
題目: [exim-cvs] Fix ACL "condition =" for negative number values. Bug 1005
Gitweb: http://git.exim.org/exim.git/commitdiff/51c7471d48efd62b2d4f5647782ba1e849d4c35a
Commit:     51c7471d48efd62b2d4f5647782ba1e849d4c35a
Parent:     6681531ad79b73f4e811037481a0055ace41e46d
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Tue Mar 18 16:17:56 2014 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Mar 18 16:17:56 2014 +0000


    Fix ACL "condition =" for negative number values.  Bug 1005
    Fix conditional "bool{<string>}" for negative number values, to match.
---
 doc/doc-docbook/spec.xfpt    |    2 +-
 doc/doc-txt/ChangeLog        |    3 +++
 src/src/acl.c                |    4 +++-
 src/src/expand.c             |    4 +++-
 test/log/0023                |   17 ++++++++++-------
 test/mail/0023.cond--1       |    9 +++++++++
 test/mail/0023.cond-rhubarb  |    2 +-
 test/mail/0023.okbatch       |    2 +-
 test/scripts/0000-Basic/0002 |    3 ++-
 test/scripts/0000-Basic/0023 |    5 +++++
 test/stdout/0002             |    3 ++-
 test/stdout/0023             |    9 +++++++--
 12 files changed, 47 insertions(+), 16 deletions(-)


diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index c412c1e..0f66180 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -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"&
-(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;
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 8a55cee..25e153e 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -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/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
 -----------------
diff --git a/src/src/acl.c b/src/src/acl.c
index fd958aa..4fda03b 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -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. */
-    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 ||
diff --git a/src/src/expand.c b/src/src/expand.c
index bd097db..64a3a86 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -2849,7 +2849,9 @@ switch(cond_type)
     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 */
diff --git a/test/log/0023 b/test/log/0023
index 9880fbd..422944a 100644
--- a/test/log/0023
+++ b/test/log/0023
@@ -42,17 +42,20 @@
 1999-03-02 09:44:33 10HmbK-0005vi-00 => cond-yes <cond-yes@???> 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@???> temporarily rejected RCPT <cond-rhubarb@???>: invalid "condition" value "rhubarb"
-1999-03-02 09:44:33 10HmbL-0005vi-00 <= userx@??? H=[56.56.56.56] U=CALLER P=smtp S=sss
-1999-03-02 09:44:33 10HmbL-0005vi-00 => cond-rhubarb <cond-rhubarb@???> R=r1 T=t1
+1999-03-02 09:44:33 10HmbL-0005vi-00 <= userx@??? H=[56.56.57.57] U=CALLER P=smtp S=sss
+1999-03-02 09:44:33 10HmbL-0005vi-00 => cond--1 <cond--1@???> R=r1 T=t1
 1999-03-02 09:44:33 10HmbL-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbM-0005vi-00 <= userx@??? H=[56.56.56.56] U=CALLER P=smtp S=sss
+1999-03-02 09:44:33 10HmbM-0005vi-00 => cond-rhubarb <cond-rhubarb@???> 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@???> rejected RCPT <bad1@???>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@???> rejected RCPT <bad2@???>
 1999-03-02 09:44:33 H=[56.56.58.58] U=CALLER F=<rcpttest@???> rejected RCPT <bad3@???>
-1999-03-02 09:44:33 10HmbM-0005vi-00 <= rcpttest@??? H=[56.56.58.58] U=CALLER P=smtp S=sss
-1999-03-02 09:44:33 10HmbM-0005vi-00 => ok1 <ok1@???> R=r0 T=t2
-1999-03-02 09:44:33 10HmbM-0005vi-00 -> ok2 <ok2@???> R=r0 T=t2
-1999-03-02 09:44:33 10HmbM-0005vi-00 -> ok3 <ok3@???> R=r0 T=t2
-1999-03-02 09:44:33 10HmbM-0005vi-00 Completed
+1999-03-02 09:44:33 10HmbN-0005vi-00 <= rcpttest@??? H=[56.56.58.58] U=CALLER P=smtp S=sss
+1999-03-02 09:44:33 10HmbN-0005vi-00 => ok1 <ok1@???> R=r0 T=t2
+1999-03-02 09:44:33 10HmbN-0005vi-00 -> ok2 <ok2@???> R=r0 T=t2
+1999-03-02 09:44:33 10HmbN-0005vi-00 -> ok3 <ok3@???> 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@???> rejected RCPT <fail@???>: 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
index 0000000..ef08691
--- /dev/null
+++ b/test/mail/0023.cond--1
@@ -0,0 +1,9 @@
+From userx@??? 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@???>)
+    id 10HmbL-0005vi-00
+    for cond--1@???; Tue, 2 Mar 1999 09:44:33 +0000
+X-message-body-size: 0
+
+
diff --git a/test/mail/0023.cond-rhubarb b/test/mail/0023.cond-rhubarb
index c8b40c7..798c40f 100644
--- a/test/mail/0023.cond-rhubarb
+++ b/test/mail/0023.cond-rhubarb
@@ -11,7 +11,7 @@ From userx@??? 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@???>)
-    id 10HmbL-0005vi-00
+    id 10HmbM-0005vi-00
     for cond-rhubarb@???; Tue, 2 Mar 1999 09:44:33 +0000
 X-message-body-size: 0


diff --git a/test/mail/0023.okbatch b/test/mail/0023.okbatch
index eae8de2..16b2f73 100644
--- a/test/mail/0023.okbatch
+++ b/test/mail/0023.okbatch
@@ -5,7 +5,7 @@ Envelope-to: ok1@???,
 Received: from [56.56.58.58] (ident=CALLER)
     by myhost.test.ex with smtp (Exim x.yz)
     (envelope-from <rcpttest@???>)
-    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
diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002
index 367d558..7b6c34b 100644
--- a/test/scripts/0000-Basic/0002
+++ b/test/scripts/0000-Basic/0002
@@ -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
-"-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
@@ -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
+"-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
diff --git a/test/scripts/0000-Basic/0023 b/test/scripts/0000-Basic/0023
index 28c6ec9..51e7123 100644
--- a/test/scripts/0000-Basic/0023
+++ b/test/scripts/0000-Basic/0023
@@ -299,6 +299,11 @@ data
 .
 mail from:<userx@???>
 rcpt to:<cond-rhubarb@???>
+rset
+mail from:<userx@???>
+rcpt to:<cond--1@???>
+data
+.
 quit
 ****
 exim -DLOG_SELECTOR=log_selector=-acl_warn_skipped -odi -bs -oMa 56.56.56.56
diff --git a/test/stdout/0002 b/test/stdout/0002
index e627097..64e5719 100644
--- a/test/stdout/0002
+++ b/test/stdout/0002
@@ -563,7 +563,7 @@

 > " 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

@@ -573,6 +573,7 @@
 > " "                   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

diff --git a/test/stdout/0023 b/test/stdout/0023
index 74ef7a0..b805f33 100644
--- a/test/stdout/0023
+++ b/test/stdout/0023
@@ -429,12 +429,17 @@
250 OK id=10HmbK-0005vi-00
250 OK
451 Temporary local problem - please try later
+250 Reset OK
+250 OK
+250 accepted by condition
+354 Enter message, ending with "." on a line by itself
+250 OK id=10HmbL-0005vi-00
221 myhost.test.ex closing connection
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250 OK
250 Accepted
354 Enter message, ending with "." on a line by itself
-250 OK id=10HmbL-0005vi-00
+250 OK id=10HmbM-0005vi-00
221 myhost.test.ex closing connection
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250 OK
@@ -445,7 +450,7 @@
550 Administrative prohibition
550 Administrative prohibition
354 Enter message, ending with "." on a line by itself
-250 OK id=10HmbM-0005vi-00
+250 OK id=10HmbN-0005vi-00
221 myhost.test.ex closing connection
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250 OK