On fork, fds are shared between children. If two processes work on
different recipients, but on the same queue file, they might get
confused when the fd (and thus the offset) is shared. Prevent this by
re-opening the queue file after fork.
Reported-by: Daniel Roethlisberger <daniel@roe.ch>
{
struct sigaction sa;
struct qitem *it;
+ FILE *newqf;
pid_t pid;
if (daemonize && daemon(0, 0) != 0) {
*
* return and deliver mail
*/
+ /*
+ * We have to prevent sharing of fds between children, so
+ * we have to re-open the queue file.
+ */
+ newqf = fopen(it->queuefn, "r");
+ if (newqf == NULL) {
+ syslog(LOG_ERR, "can not re-open queue file `%s': %m",
+ it->queuefn);
+ exit(1);
+ }
+ fclose(it->queuef);
+ it->queuef = newqf;
return (it);
default: