[exim/exim] [Bug]: Mishandled errno in exim_fchown(journal_fd) (Issue #3209)

maxg1 via Exim-dev <[email protected]> Mon, 23 Mar 2026 08:35:57 +0000
Newsgroups gmane.mail.exim.devel
Message-ID <exim/exim/issues/[email protected]>
What is the problem environment ?
---------------------------------

any

What happened?
--------------

Just a minor thing I noticed looking at the source in deliver.c , hash 8dc59b5 ( https://code.exim.org/exim/exim/commit/8dc59b5 )

8393     /* Set the close-on-exec flag, make the file owned by Exim, and ensure
8394     that the mode is correct - the group setting doesn't always seem to get
8395     set automatically. */
8396
8397     if(  exim_fchown(journal_fd, exim_uid, exim_gid, fname)
8398       || fchmod(journal_fd, SPOOL_MODE)
8399 #ifndef O_CLOEXEC
8400       || fcntl(journal_fd, F_SETFD, fcntl(journal_fd, F_GETFD) | FD_CLOEXEC)
8401 #endif
8402       )
8403       {
8404       int ret = Uunlink(fname);
8405       log_write(LOG_MAIN|LOG_PANIC, "Couldn't set perms on journal file %s: %s",
8406 >-------fname, strerror(errno));
8407       if(ret  &&  errno != ENOENT)
8408 >-------log_write_die(LOG_MAIN, "failed to unlink %s: %s",
8409 >-------  fname, strerror(errno));
8410       return DELIVER_NOT_ATTEMPTED;
8411       }
8412     }
* the printed out errno in 8406 is the errno after the unlink call, possibly clobbered.
* the printed out errno in 8409 -- could be from something inside preceeding log_write at 8405
* apart from that, it's unclear if it would be from fchown(), fchmod() or fcntl()

Relevant log output
-------------------

No response

---
View it on Exim Forgejo ( https://code.exim.org/exim/exim/issues/3209 ) or reply to this email directly.