]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: iostream-rawlog - Do not log errors for permissions
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 31 Jul 2025 09:23:37 +0000 (12:23 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 4 Aug 2025 11:57:13 +0000 (11:57 +0000)
If permissions are not sufficient, fail silently.

src/lib/iostream-rawlog.c

index 6939d1909238a6926b9bc9d82234ad16dc40b6b3..9b36939b7edebdafc85f8c77577c8c916e5e6022 100644 (file)
@@ -220,16 +220,10 @@ int iostream_rawlog_create(const char *dir, struct istream **input,
 {
        static unsigned int counter = 0;
        const char *timestamp, *prefix;
-       struct stat st;
        int ret;
 
        if ((ret = iostream_rawlog_try_create_tcp(dir, input, output)) != 0)
                return ret < 0 ? -1 : 0;
-       if (stat(dir, &st) < 0) {
-               if (errno != ENOENT && errno != EACCES)
-                       i_error("rawlog: stat(%s) failed: %m", dir);
-               return -1;
-       }
 
        timestamp = t_strflocaltime("%Y%m%d-%H%M%S", ioloop_time);
 
@@ -249,14 +243,16 @@ int iostream_rawlog_create_prefix(const char *prefix, struct istream **input,
        in_path = t_strdup_printf("%s.in", prefix);
        in_fd = open(in_path, O_CREAT | O_APPEND | O_WRONLY, 0600);
        if (in_fd == -1) {
-               i_error("creat(%s) failed: %m", in_path);
+               if (errno != ENOENT && !ENOACCESS(errno))
+                       i_error("rawlog: creat(%s) failed: %m", in_path);
                return -1;
        }
 
        out_path = t_strdup_printf("%s.out", prefix);
        out_fd = open(out_path, O_CREAT | O_APPEND | O_WRONLY, 0600);
        if (out_fd == -1) {
-               i_error("creat(%s) failed: %m", out_path);
+               if (errno != ENOENT && !ENOACCESS(errno))
+                       i_error("rawlog: creat(%s) failed: %m", out_path);
                i_close_fd(&in_fd);
                i_unlink(in_path);
                return -1;
@@ -285,7 +281,8 @@ int iostream_rawlog_create_path(const char *path, struct istream **input,
                return ret < 0 ? -1 : 0;
        fd = open(path, O_CREAT | O_APPEND | O_WRONLY, 0600);
        if (fd == -1) {
-               i_error("creat(%s) failed: %m", path);
+               if (errno != ENOENT && !ENOACCESS(errno))
+                       i_error("rawlog: creat(%s) failed: %m", path);
                return -1;
        }
        iostream_rawlog_create_fd(fd, path, input, output);