Lookups: Fix "subdir" filter on a dsearch.
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 25 Jun 2020 10:16:54 +0000 (11:16 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 25 Jun 2020 10:16:54 +0000 (11:16 +0100)
doc/doc-txt/ChangeLog
src/src/lookups/dsearch.c
test/scripts/2500-dsearch/2500
test/stdout/2500

index 2c05706350d81afd80f39f802499c86d5f77ec53..83d027d0f6ba8fb24951816167b4b38e584d34b7 100644 (file)
@@ -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.
 
       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
 
 
 Exim version 4.94
index 455273fb11d5cf92f4c7f435e5a225bad201a0a4..501293ac0330c8f58f7778fe082efee6551f8bd1 100644 (file)
@@ -125,8 +125,7 @@ if (  Ulstat(filename, &statbuf) >= 0
                 && S_ISDIR(statbuf.st_mode)
         && (  flags & FILTER_DIR
            || keystring[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
    )  )  )  )
   {
   /* Since the filename exists in the filesystem, we can return a
@@ -135,10 +134,10 @@ if (  Ulstat(filename, &statbuf) >= 0
   return OK;
   }
 
   return OK;
   }
 
-if (errno == ENOENT) return FAIL;
+if (errno == ENOENT || errno == 0) return FAIL;
 
 save_errno = errno;
 
 save_errno = errno;
-*errmsg = string_sprintf("%s: lstat failed", filename);
+*errmsg = string_sprintf("%s: lstat: %s", filename, strerror(errno));
 errno = save_errno;
 return DEFER;
 }
 errno = save_errno;
 return DEFER;
 }
index 8677b7166233b0d48803035712fd695366193ce5..f3937ec9127f064de1ff08b3f7247e409c0df7d5 100644 (file)
@@ -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}}
 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}}
 
 cachelayer tests
 fail:       ${lookup{test-data}   dsearch               {DIR/}          {$value}{FAIL}}
index c6014d388a30a9af5512d4fa4182f371ef65c65d..6daaab658e1f626c6908832a372250d73f9957be 100644 (file)
@@ -12,8 +12,9 @@
 > ok,dir:     2500.dir
 > fail,dir:   FAIL
 > ok,subdir:  2500.dir
 > 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
 > 
 > cachelayer tests
 > fail:       FAIL