From 3f9fdc0f61e6fef9799c8347e7fa6f412d1fec68 Mon Sep 17 00:00:00 2001 From: Simon Schubert <2@0x2c.org> Date: Thu, 25 Jul 2013 23:22:24 +0200 Subject: [PATCH] flushspool: use O_TRUNC instead of utimes(2) utimes(2) only works if the file is owned by the current user. Use open(..., O_TRUNC|...) instead, together with a group writable flush file. --- Makefile | 1 + spool.c | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 0262718..aed2ef7 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,7 @@ install-spool-dirs: permissions: -${CHGRP} mail ${DESTDIR}${VARMAIL}/* -${CHMOD} g+w ${DESTDIR}${VARMAIL}/* + -${CHMOD} 660 ${DESTDIR}${DMASPOOL}/flush install-etc: ${INSTALL} -d ${DESTDIR}${CONFDIR} diff --git a/spool.c b/spool.c index fa42654..416b5fa 100644 --- a/spool.c +++ b/spool.c @@ -429,18 +429,12 @@ flushqueue_signal(void) if (asprintf(&flushfn, "%s/%s", config.spooldir, SPOOL_FLUSHFILE) < 0) return (-1); - fd = open(flushfn, O_CREAT|O_RDONLY, 0440); + fd = open(flushfn, O_CREAT|O_WRONLY|O_TRUNC, 0660); + free(flushfn); if (fd < 0) { syslog(LOG_ERR, "could not open flush file: %m"); - free(flushfn); return (-1); } close(fd); - if (utimes(flushfn, NULL) < 0) { - syslog(LOG_ERR, "could not touch flush file: %m"); - free(flushfn); - return (-1); - } - free (flushfn); return (0); } -- 2.47.3