From 649c209e19281edd67beee84e9e60b0849f84554 Mon Sep 17 00:00:00 2001 From: "Heiko Schlittermann (HS12-RIPE)" Date: Sun, 14 Mar 2021 12:16:57 +0100 Subject: [PATCH 1/1] Fix error messages in dbfn_open --- src/src/dbfn.c | 22 +++++++++++++++------- test/stderr/0275 | 2 +- test/stderr/0278 | 2 +- test/stderr/0386 | 2 +- test/stderr/0388 | 2 +- test/stderr/0402 | 2 +- test/stderr/0403 | 2 +- test/stderr/0404 | 2 +- test/stderr/0408 | 2 +- test/stderr/0487 | 2 +- 10 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/src/dbfn.c b/src/src/dbfn.c index 452e2ade6..be6a47afc 100644 --- a/src/src/dbfn.c +++ b/src/src/dbfn.c @@ -9,6 +9,11 @@ #include "exim.h" +/* We have buffers holding path names for database files. +PATH_MAX could be used here, but would be wasting memory, as we deal +with database files like $spooldirectory/db/ */ +#define PATHLEN 256 + /* Functions for accessing Exim's hints database, which consists of a number of different DBM files. This module does not contain code for reading DBM files @@ -93,7 +98,7 @@ int rc, save_errno; BOOL read_only = flags == O_RDONLY; BOOL created = FALSE; flock_t lock_data; -uschar dirname[256], filename[256]; +uschar dirname[PATHLEN], filename[PATHLEN]; DEBUG(D_hints_lookup) acl_level++; @@ -196,12 +201,15 @@ but creation of the database file failed. */ if (created && geteuid() == root_uid) { DIR * dd; - uschar *lastname = Ustrrchr(filename, '/') + 1; + uschar path[PATHLEN]; + uschar *lastname; int namelen = Ustrlen(name); + Ustrcpy(path, filename); + lastname = Ustrrchr(path, '/') + 1; *lastname = 0; - if ((dd = exim_opendir(filename))) + if ((dd = exim_opendir(path))) for (struct dirent *ent; ent = readdir(dd); ) if (Ustrncmp(ent->d_name, name, namelen) == 0) { @@ -209,13 +217,13 @@ if (created && geteuid() == root_uid) /* Filenames from readdir() are trusted, so use a taint-nonchecking copy */ strcpy(CS lastname, CCS ent->d_name); - if (Ustat(filename, &statbuf) >= 0 && statbuf.st_uid != exim_uid) + if (Ustat(path, &statbuf) >= 0 && statbuf.st_uid != exim_uid) { DEBUG(D_hints_lookup) - debug_printf_indent("ensuring %s is owned by exim\n", filename); - if (exim_chown(filename, exim_uid, exim_gid)) + debug_printf_indent("ensuring %s is owned by exim\n", path); + if (exim_chown(path, exim_uid, exim_gid)) DEBUG(D_hints_lookup) - debug_printf_indent("failed setting %s to owned by exim\n", filename); + debug_printf_indent("failed setting %s to owned by exim\n", path); } } diff --git a/test/stderr/0275 b/test/stderr/0275 index a39ab10b3..4e27129b2 100644 --- a/test/stderr/0275 +++ b/test/stderr/0275 @@ -172,7 +172,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: userx@test.ex diff --git a/test/stderr/0278 b/test/stderr/0278 index 634c3facc..4ea1cf371 100644 --- a/test/stderr/0278 +++ b/test/stderr/0278 @@ -131,7 +131,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: CALLER@test.ex diff --git a/test/stderr/0386 b/test/stderr/0386 index fb7382b21..9f53887c7 100644 --- a/test/stderr/0386 +++ b/test/stderr/0386 @@ -273,7 +273,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: 2@b diff --git a/test/stderr/0388 b/test/stderr/0388 index e23c903f1..f65b6f682 100644 --- a/test/stderr/0388 +++ b/test/stderr/0388 @@ -11,7 +11,7 @@ set_process_info: pppp delivering 10HmaX-0005vi-00 EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: x@y diff --git a/test/stderr/0402 b/test/stderr/0402 index 2fe542bb7..865bf34be 100644 --- a/test/stderr/0402 +++ b/test/stderr/0402 @@ -214,7 +214,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: CALLER@test.ex diff --git a/test/stderr/0403 b/test/stderr/0403 index c71e924fe..939c7f422 100644 --- a/test/stderr/0403 +++ b/test/stderr/0403 @@ -71,7 +71,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: userx@test.ex diff --git a/test/stderr/0404 b/test/stderr/0404 index 4d5aeaf3e..1240813dc 100644 --- a/test/stderr/0404 +++ b/test/stderr/0404 @@ -172,7 +172,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: userx@test.ex diff --git a/test/stderr/0408 b/test/stderr/0408 index 6320691f3..bd7e753c3 100644 --- a/test/stderr/0408 +++ b/test/stderr/0408 @@ -71,7 +71,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: userx@test.ex diff --git a/test/stderr/0487 b/test/stderr/0487 index e8e9dcb75..2a3446da4 100644 --- a/test/stderr/0487 +++ b/test/stderr/0487 @@ -99,7 +99,7 @@ Delivery address list: EXIM_DBOPEN: file dir flags=O_RDONLY returned from EXIM_DBOPEN: (nil) ensuring TESTSUITE/spool/db/retry.lockfile is owned by exim - failed to open DB file TESTSUITE/spool/db/retry.lockfile: No such file or directory + failed to open DB file TESTSUITE/spool/db/retry: No such file or directory no retry data available >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: userx@test.ex -- 2.30.2