summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-07-09 11:50:53 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-07-09 11:50:53 +0200
commit71a7b2919d040048b61ecccefbbb208bfe90c806 (patch)
tree14fc498edbc516926ce841c6ea756d395f01ede6
parent2523835aaccc6663f9884b82c778abcccaddbd82 (diff)
downloadfemtomail-71a7b2919d040048b61ecccefbbb208bfe90c806.tar.gz
Fix-up macro expansion of USERNAME and MAILBOX_PATH
-rw-r--r--Makefile4
-rw-r--r--femtomail.c12
2 files changed, 7 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 8fe0fc5..0066b05 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ SETCAP ?= setcap
CFLAGS ?= -Wall -Wextra -O2 -g
ifneq ($(MAILBOX_PATH),)
- override CFLAGS += -DMAILBOX_PATH="$(MAILBOX_PATH)"
+ override CFLAGS += -DMAILBOX_PATH=\"$(MAILBOX_PATH)\"
endif
all: $(OBJDIR)/femtomail
@@ -19,7 +19,7 @@ $(OBJDIR)/femtomail: femtomail.c
ifeq ($(USERNAME),)
$(error USERNAME must be set and non-empty)
endif
- $(CC) -DUSERNAME="$(USERNAME)" $(CFLAGS) -o $(DESTDIR)$@ $<
+ $(CC) -DUSERNAME=\"$(USERNAME)\" $(CFLAGS) -o $(DESTDIR)$@ $<
clean:
$(RM) $(OBJDIR)/femtomail
diff --git a/femtomail.c b/femtomail.c
index 6bc1fb8..4442b93 100644
--- a/femtomail.c
+++ b/femtomail.c
@@ -3,8 +3,8 @@
* Maildir box. Note: this program does not try to implement sendmail.
*
* Installation commands:
- * $ cc -DUSERNAME=$USER femtomail.c -o femtomail
- * (Optional override: -DMAILBOX_PATH=.Maildir/inbox)
+ * $ cc -DUSERNAME=\"$USER\" femtomail.c -o femtomail
+ * (Optional override: -DMAILBOX_PATH=\".Maildir/inbox\")
* # install -m 755 femtomail /usr/bin/sendmail
* # setcap cap_setuid,cap_setgid=ep /usr/bin/sendmail
*
@@ -38,15 +38,13 @@
#include <pwd.h>
#include <sys/prctl.h>
-#define STRINGIFY(str) #str
-
#ifndef USERNAME
# error Please define the user to deliver mail to with USERNAME
#endif
/* Maildir directory relative to home dir of USERNAME (see above) */
#ifndef MAILBOX_PATH
-# define MAILBOX_PATH .local/share/local-mail/inbox
+# define MAILBOX_PATH ".local/share/local-mail/inbox"
#endif
/* change user/group context to username and fill in maildir path */
@@ -69,7 +67,7 @@ init_user(const char *username, char *maildir, size_t maildir_len) {
return 1;
}
- snprintf(maildir, maildir_len, "%s/" STRINGIFY(MAILBOX_PATH) "/new", pwd->pw_dir);
+ snprintf(maildir, maildir_len, "%s/" MAILBOX_PATH "/new", pwd->pw_dir);
return 0;
}
@@ -199,7 +197,7 @@ main(int argc, char **argv) {
return (EXIT_FAILURE);
}
- if (init_user(STRINGIFY(USERNAME), maildir, sizeof(maildir))) {
+ if (init_user((USERNAME), maildir, sizeof(maildir))) {
return (EXIT_FAILURE);
}