/*
+ * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
* Copyright (c) 2008 The DragonFly Project. All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
- * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
+ * by Simon Schubert <2@0x2c.org>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include <fcntl.h>
#include <limits.h>
#include <paths.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <syslog.h>
execl(LIBEXEC_PATH "/dma-mbox-create", "dma-mbox-create", name, NULL);
syslog(LOG_ERR, "cannot execute "LIBEXEC_PATH"/dma-mbox-create: %m");
- exit(1);
+ exit(EX_SOFTWARE);
default:
/* parent */
goto out;
}
- error = snprintf(line, sizeof(line), "%sFrom %s\t%s", newline, sender, ctime(&now));
+ error = snprintf(line, sizeof(line), "%sFrom %s %s", newline, sender, ctime(&now));
if (error < 0 || (size_t)error >= sizeof(line)) {
syslog(LOG_NOTICE, "local delivery deferred: can not write header: %m");
goto out;
goto chop;
}
- if (hadnl && strncmp(line, "From ", 5) == 0) {
+ /*
+ * mboxro processing:
+ * - escape lines that start with "From " with a > sign.
+ * - be reversable by escaping lines that contain an arbitrary
+ * number of > signs, followed by "From ", i.e. />*From / in regexp.
+ * - strict mbox processing only requires escaping after empty lines,
+ * yet most MUAs seem to relax this requirement and will treat any
+ * line starting with "From " as the beginning of a new mail.
+ */
+ if ((!MBOX_STRICT || hadnl) &&
+ strncmp(&line[strspn(line, ">")], "From ", 5) == 0) {
const char *gt = ">";
if (write(mbox, gt, 1) != 1)