From 71a7b2919d040048b61ecccefbbb208bfe90c806 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 9 Jul 2013 11:50:53 +0200 Subject: Fix-up macro expansion of USERNAME and MAILBOX_PATH --- Makefile | 4 ++-- femtomail.c | 12 +++++------- 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 #include -#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); } -- cgit v1.2.1