[exim-cvs] Lookups: Fix "subdir" filter on a dsearch.

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] Lookups: Fix "subdir" filter on a dsearch.
Gitweb: https://git.exim.org/exim.git/commitdiff/e0e21929b7426b9b5bbf5e3747797043801b1151
Commit:     e0e21929b7426b9b5bbf5e3747797043801b1151
Parent:     1077d3c3f960c4e5a157c51815b8009f5114ab1a
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Jun 25 11:16:54 2020 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Thu Jun 25 11:16:54 2020 +0100


    Lookups: Fix "subdir" filter on a dsearch.
---
 doc/doc-txt/ChangeLog          | 2 ++
 src/src/lookups/dsearch.c      | 7 +++----
 test/scripts/2500-dsearch/2500 | 5 +++--
 test/stdout/2500               | 5 +++--
 4 files changed, 11 insertions(+), 8 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 2c05706..83d027d 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -63,6 +63,8 @@ JH/12 Bug 2607: Fix the ${srs_encode } expansion to handle quoted local_parts.
       needed, strip the quoting and quote the entire local_part.
       Also make the inbound_srs expansion condition handle quoting.


+JH/13 Fix dsearch "subdir" filter to ignore ".".  Previously only ".." was
+      excluded, not matching the documentation.



 Exim version 4.94
diff --git a/src/src/lookups/dsearch.c b/src/src/lookups/dsearch.c
index 455273f..501293a 100644
--- a/src/src/lookups/dsearch.c
+++ b/src/src/lookups/dsearch.c
@@ -125,8 +125,7 @@ if (  Ulstat(filename, &statbuf) >= 0
             && S_ISDIR(statbuf.st_mode)
      && (  flags & FILTER_DIR
         || keystring[0] != '.'
-        || keystring[1] != '.'
-        || keystring[1] && keystring[2]
+        || keystring[1] && keystring[1] != '.'
    )  )  )  )
   {
   /* Since the filename exists in the filesystem, we can return a
@@ -135,10 +134,10 @@ if (  Ulstat(filename, &statbuf) >= 0
   return OK;
   }


-if (errno == ENOENT) return FAIL;
+if (errno == ENOENT || errno == 0) return FAIL;

 save_errno = errno;
-*errmsg = string_sprintf("%s: lstat failed", filename);
+*errmsg = string_sprintf("%s: lstat: %s", filename, strerror(errno));
 errno = save_errno;
 return DEFER;
 }
diff --git a/test/scripts/2500-dsearch/2500 b/test/scripts/2500-dsearch/2500
index 8677b71..f3937ec 100644
--- a/test/scripts/2500-dsearch/2500
+++ b/test/scripts/2500-dsearch/2500
@@ -15,8 +15,9 @@ fail,file:  ${lookup{TESTNUM.dir} dsearch,filter=file   {DIR/aux-fixed}{$value}{
 ok,dir:     ${lookup{TESTNUM.dir} dsearch,filter=dir    {DIR/aux-fixed}{$value}{FAIL}}
 fail,dir:   ${lookup{TESTNUM.tst} dsearch,filter=dir    {DIR/aux-fixed}{$value}{FAIL}}
 ok,subdir:  ${lookup{TESTNUM.dir} dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
-fail,subdir:${lookup{..}          dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
-fail,subdir:${lookup{TESTNUM.tst} dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
+fail,subdir(..):${lookup{..}          dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
+fail,subdir(.) :${lookup{.}           dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}
+fail,subdir(f) :${lookup{TESTNUM.tst} dsearch,filter=subdir {DIR/aux-fixed}{$value}{FAIL}}


 cachelayer tests
 fail:       ${lookup{test-data}   dsearch               {DIR/}          {$value}{FAIL}}
diff --git a/test/stdout/2500 b/test/stdout/2500
index c6014d3..6daaab6 100644
--- a/test/stdout/2500
+++ b/test/stdout/2500
@@ -12,8 +12,9 @@

 > ok,dir:     2500.dir
 > fail,dir:   FAIL
 > ok,subdir:  2500.dir

-> fail,subdir:FAIL
-> fail,subdir:FAIL
+> fail,subdir(..):FAIL
+> fail,subdir(.) :FAIL
+> fail,subdir(f) :FAIL
>
 > cachelayer tests
 > fail:       FAIL