From: Jeremy Harris Date: Thu, 25 Jun 2020 10:16:54 +0000 (+0100) Subject: Lookups: Fix "subdir" filter on a dsearch. X-Git-Url: https://git.exim.org/users/heiko/exim.git/commitdiff_plain/e0e21929b7426b9b5bbf5e3747797043801b1151?hp=1077d3c3f960c4e5a157c51815b8009f5114ab1a Lookups: Fix "subdir" filter on a dsearch. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 2c0570635..83d027d0f 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 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 8677b7166..f3937ec91 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 c6014d388..6daaab658 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