diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-09-09 00:03:39 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-09-09 00:11:23 +0200 |
commit | 7c6e845bc7443d3222c9e363b9cc5436bb5b36ae (patch) | |
tree | e608c5a48a0fcfb7966a0737beb8a19f2334a942 | |
parent | a646eb75a5639d942865ad402983f27ded1eac70 (diff) | |
download | femtomail-7c6e845bc7443d3222c9e363b9cc5436bb5b36ae.tar.gz |
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.
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | femtomail.c | 9 |
2 files changed, 12 insertions, 2 deletions
@@ -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; } |