From 777ee8ae75277c05fb72cc94f568ba4d2bfe15a6 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 25 Jun 2020 11:16:54 +0100 Subject: [PATCH] Lookups: Fix "subdir" filter on a dsearch. (cherry picked from commit e0e21929b7426b9b5bbf5e3747797043801b1151) --- 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 de11b4f09..bae9abb85 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -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 diff --git a/src/src/lookups/dsearch.c b/src/src/lookups/dsearch.c index 455273fb1..501293ac0 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 381ef2563..e436d7be3 100644 --- a/test/scripts/2500-dsearch/2500 +++ b/test/scripts/2500-dsearch/2500 @@ -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 diff --git a/test/stdout/2500 b/test/stdout/2500 index 7e413c0a3..5d4d8306d 100644 --- a/test/stdout/2500 +++ b/test/stdout/2500 @@ -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 > -- 2.30.2