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:21:47 +0000 (11:21 +0100)
(cherry picked from commit e0e21929b7426b9b5bbf5e3747797043801b1151)

doc/doc-txt/ChangeLog
src/src/lookups/dsearch.c
test/scripts/2500-dsearch/2500
test/stdout/2500

index de11b4f097b396298961d27eea23ae195715864d..bae9abb85e432568743552578f820a88939b2d51 100644 (file)
@@ -49,6 +49,8 @@ JH/11 Bug 2604: Fix request to cutthrough-deliver when a connection is already
       held open for a verify callout.  Previously this wan not accounted for
       and a corrupt onward SMTP conversation resulted.
 
+JH/13 Fix dsearch "subdir" filter to ignore ".".  Previously only ".." was
+      excluded, not matching the documentation.
 
 
 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] != '.'
-           || 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;
 }
index 381ef25632f5de0a6cdd4a9ed1229b4dd5d1fc59..e436d7be396c0eb54f2db5098a612943358c6670 100644 (file)
@@ -14,8 +14,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}}
 ****
 #
 1
index 7e413c0a3ba562e9f4cd0a39b07ef47f4fd7a803..5d4d8306dd42d4f7d4b0182d19e19c66a5ea6233 100644 (file)
@@ -11,6 +11,7 @@
 > 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
 >