]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: file_create_locked() - Improve EACCES error messages
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 22 Jan 2026 09:26:53 +0000 (11:26 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 22 Jan 2026 11:35:30 +0000 (13:35 +0200)
src/lib/file-create-locked.c

index 47fe7f9f339c437df849a941c5803f4594fdd282..8d9c55ad79de3ad3b4ed7a7a32906a1587d4d51b 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "str.h"
+#include "eacces-error.h"
 #include "safe-mkstemp.h"
 #include "mkdir-parents.h"
 #include "file-lock.h"
@@ -108,7 +109,12 @@ try_create_new(const char *path, const struct file_create_settings *set,
                errno = orig_errno;
        }
        if (fd == -1) {
-               *error_r = t_strdup_printf("safe_mkstemp(%s) failed: %m", path);
+               if (errno == EACCES)
+                       *error_r = eacces_error_get("safe_mkstemp", path);
+               else {
+                       *error_r = t_strdup_printf(
+                               "safe_mkstemp(%s) failed: %m", path);
+               }
                return -1;
        }
 
@@ -170,6 +176,9 @@ int file_create_locked(const char *path, const struct file_create_settings *set,
                        i_close_fd(&fd);
                        if (ret < 0)
                                return -1;
+               } else if (errno == EACCES) {
+                       *error_r = eacces_error_get("open", path);
+                       return -1;
                } else if (errno != ENOENT) {
                        *error_r = t_strdup_printf("open(%s) failed: %m", path);
                        return -1;