From 7c6e845bc7443d3222c9e363b9cc5436bb5b36ae Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 9 Sep 2015 00:03:39 +0200 Subject: Support absolute paths for MAILBOX_PATH And in case somebody decides to put a format specifier in MAILBOX_PATH, pass it as argument. Suggestion made by an anonymous user by email. --- README.md | 5 +++++ femtomail.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69b6366..380d807 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,11 @@ be changed to `~/.Maildir/inbox` as follows: make USERNAME=peter MAILBOX_PATH=.Maildir/inbox +Absolute paths are also supported. The following configuration will put mail in +`/var/mail/new/(filename)`: + + make USERNAME=nobody MAILBOX_PATH=/var/mail + To install femtomail on your system with the appropriate capabilities: make install install-link-sendmail setcap diff --git a/femtomail.c b/femtomail.c index b07d7a7..2838463 100644 --- a/femtomail.c +++ b/femtomail.c @@ -42,7 +42,8 @@ # error Please define the user to deliver mail to with USERNAME #endif -/* Maildir directory relative to home dir of USERNAME (see above) */ +/* Maildir; either absolute (starting with a forward slash) or + * a directory relative to home dir of USERNAME (see above) */ #ifndef MAILBOX_PATH # define MAILBOX_PATH ".local/share/local-mail/inbox" #endif @@ -67,7 +68,11 @@ init_user(const char *username, char *maildir, size_t maildir_len) { return 1; } - snprintf(maildir, maildir_len, "%s/" MAILBOX_PATH "/new", pwd->pw_dir); + if ((MAILBOX_PATH)[0] == '/') { + snprintf(maildir, maildir_len, "%s/new", MAILBOX_PATH); + } else { + snprintf(maildir, maildir_len, "%s/%s/new", pwd->pw_dir, MAILBOX_PATH); + } return 0; } -- cgit v1.2.1