Fix error messages in dbfn_open
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sun, 14 Mar 2021 11:16:57 +0000 (12:16 +0100)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Mon, 15 Mar 2021 20:50:48 +0000 (21:50 +0100)
src/src/dbfn.c
test/stderr/0275
test/stderr/0278
test/stderr/0386
test/stderr/0388
test/stderr/0402
test/stderr/0403
test/stderr/0404
test/stderr/0408
test/stderr/0487

index 452e2ade6a0330fc96256188dbaf7086768806f6..be6a47afcd07ecaf12eded9d46cb7888528fa610 100644 (file)
@@ -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/<name> */
+#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);
          }
        }
 
index a39ab10b3bd0ca967b38b829d8e54d2a81e27b27..4e27129b2d0dce5a83e849331f65235be1e9526a 100644 (file)
@@ -172,7 +172,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index 634c3facc8df749716f179f89d7622de576c4913..4ea1cf371fe63bad1691f29882bf048ebb5da76c 100644 (file)
@@ -131,7 +131,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index fb7382b21c165f7c17758b1d9855dc71ead59daf..9f53887c728c3f6bf40da6efa5c95a3cca524e96 100644 (file)
@@ -273,7 +273,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index e23c903f1d0d97ae77e08238cdf8e2a087049f95..f65b6f6820c45244dc8a070fc48bcec61b8024a8 100644 (file)
@@ -11,7 +11,7 @@ set_process_info: pppp delivering 10HmaX-0005vi-00
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index 2fe542bb79fd0375d8d4e540bb414b2a5ac598d3..865bf34be270d1ad0d29991831d871203d58f975 100644 (file)
@@ -214,7 +214,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index c71e924fe7519520f139b749aedb54991077e95c..939c7f422a32e23c193367762f86e855527fabc0 100644 (file)
@@ -71,7 +71,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index 4d5aeaf3ea777e82a5dacb638d82f1a2271b355d..1240813dcc9a58d9b0d41065036ebcd39d2d43e2 100644 (file)
@@ -172,7 +172,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index 6320691f31ecee14cbf1743f339d0d874ea910f7..bd7e753c327ab933d693b245ec38ae0951160ca9 100644 (file)
@@ -71,7 +71,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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
index e8e9dcb75db45c26d51878f1074583c1e7034578..2a3446da4ef2b8e52be1a68a8dbb2365a66f0c55 100644 (file)
@@ -99,7 +99,7 @@ Delivery address list:
  EXIM_DBOPEN: file <TESTSUITE/spool/db/retry> dir <TESTSUITE/spool/db> 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