diff options
| author | perry <perry@NetBSD.org> | 2002-02-02 23:10:24 +0000 |
|---|---|---|
| committer | perry <perry@NetBSD.org> | 2002-02-02 23:10:24 +0000 |
| commit | 6f59dc7aebbf705da79e61ef3fd24b48ed99d327 (patch) | |
| tree | c6e9fd356c8aac78b966a9dd53f5d0d14d5e62cd /gnu/dist/postfix/src/virtual | |
| parent | ecf43984517b4cfb837e78958769cc8207ea5288 (diff) | |
Postfix 1.1.2
(Postfix releases are now numbered -- 1.1.2 means 1.1, patchlevel 2.)
Lots of new features, same great security.
Diffstat (limited to 'gnu/dist/postfix/src/virtual')
| -rw-r--r-- | gnu/dist/postfix/src/virtual/.printfck | 25 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/Makefile.in | 166 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/deliver_attr.c | 74 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/mailbox.c | 246 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/maildir.c | 176 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/recipient.c | 93 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/unknown.c | 64 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/virtual.c | 414 | ||||
| -rw-r--r-- | gnu/dist/postfix/src/virtual/virtual.h | 134 |
9 files changed, 1392 insertions, 0 deletions
diff --git a/gnu/dist/postfix/src/virtual/.printfck b/gnu/dist/postfix/src/virtual/.printfck new file mode 100644 index 00000000000..66016ed453c --- /dev/null +++ b/gnu/dist/postfix/src/virtual/.printfck @@ -0,0 +1,25 @@ +been_here_xt 2 0 +bounce_append 5 0 +cleanup_out_format 1 0 +defer_append 5 0 +mail_command 1 0 +mail_print 1 0 +msg_error 0 0 +msg_fatal 0 0 +msg_info 0 0 +msg_panic 0 0 +msg_warn 0 0 +opened 4 0 +post_mail_fprintf 1 0 +qmgr_message_bounce 2 0 +rec_fprintf 2 0 +sent 4 0 +smtp_cmd 1 0 +smtp_mesg_fail 2 0 +smtp_printf 1 0 +smtp_rcpt_fail 3 0 +smtp_site_fail 2 0 +udp_syslog 1 0 +vstream_fprintf 1 0 +vstream_printf 0 0 +vstring_sprintf 1 0 diff --git a/gnu/dist/postfix/src/virtual/Makefile.in b/gnu/dist/postfix/src/virtual/Makefile.in new file mode 100644 index 00000000000..8bf523ed3f8 --- /dev/null +++ b/gnu/dist/postfix/src/virtual/Makefile.in @@ -0,0 +1,166 @@ +SHELL = /bin/sh +SRCS = virtual.c mailbox.c recipient.c deliver_attr.c maildir.c unknown.c +OBJS = virtual.o mailbox.o recipient.o deliver_attr.o maildir.o unknown.o +HDRS = virtual.h +TESTSRC = +WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ + -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \ + -Wunused +DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE) -I.. +CFLAGS = $(DEBUG) $(OPT) $(DEFS) +PROG = virtual +TESTPROG= +INC_DIR = ../../include +LIBS = ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libutil.a $(AUXLIBS) + +.c.o:; $(CC) $(CFLAGS) -c $*.c + +$(PROG): $(OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(SYSLIBS) + +Makefile: Makefile.in + (set -e; echo "# DO NOT EDIT"; $(OPTS) $(SHELL) ../../makedefs; cat $?) >$@ + +test: $(TESTPROG) + +update: ../../libexec/$(PROG) + +../../libexec/$(PROG): $(PROG) + cp $(PROG) ../../libexec + +printfck: $(OBJS) $(PROG) + rm -rf printfck + mkdir printfck + cp *.h printfck + sed '1,/^# do not edit/!d' Makefile >printfck/Makefile + set -e; for i in *.c; do printfck -f .printfck $$i >printfck/$$i; done + cd printfck; make "INC_DIR=../../../include" `cd ..; ls *.o` + +lint: + lint $(DEFS) $(SRCS) $(LINTFIX) + +clean: + rm -f *.o *core $(PROG) $(TESTPROG) junk + rm -rf printfck + +tidy: clean + +depend: $(MAKES) + (sed '1,/^# do not edit/!d' Makefile.in; \ + set -e; for i in [a-z][a-z0-9]*.c; do \ + $(CC) -E $(DEFS) $(INCL) $$i | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \ + -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' -e 'p' -e '}'; \ + done) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in + @make -f Makefile.in Makefile + +# do not edit below this line - it is generated by 'make depend' +deliver_attr.o: deliver_attr.c +deliver_attr.o: ../../include/sys_defs.h +deliver_attr.o: ../../include/msg.h +deliver_attr.o: ../../include/vstream.h +deliver_attr.o: ../../include/vbuf.h +deliver_attr.o: virtual.h +deliver_attr.o: ../../include/vstring.h +deliver_attr.o: ../../include/deliver_request.h +deliver_attr.o: ../../include/recipient_list.h +deliver_attr.o: ../../include/maps.h +deliver_attr.o: ../../include/dict.h +deliver_attr.o: ../../include/argv.h +deliver_attr.o: ../../include/mbox_conf.h +mailbox.o: mailbox.c +mailbox.o: ../../include/sys_defs.h +mailbox.o: ../../include/msg.h +mailbox.o: ../../include/vstring.h +mailbox.o: ../../include/vbuf.h +mailbox.o: ../../include/vstream.h +mailbox.o: ../../include/mymalloc.h +mailbox.o: ../../include/stringops.h +mailbox.o: ../../include/set_eugid.h +mailbox.o: ../../include/mail_copy.h +mailbox.o: ../../include/mbox_open.h +mailbox.o: ../../include/safe_open.h +mailbox.o: ../../include/defer.h +mailbox.o: ../../include/bounce.h +mailbox.o: ../../include/sent.h +mailbox.o: ../../include/mail_params.h +mailbox.o: virtual.h +mailbox.o: ../../include/deliver_request.h +mailbox.o: ../../include/recipient_list.h +mailbox.o: ../../include/maps.h +mailbox.o: ../../include/dict.h +mailbox.o: ../../include/argv.h +mailbox.o: ../../include/mbox_conf.h +maildir.o: maildir.c +maildir.o: ../../include/sys_defs.h +maildir.o: ../../include/msg.h +maildir.o: ../../include/mymalloc.h +maildir.o: ../../include/stringops.h +maildir.o: ../../include/vstring.h +maildir.o: ../../include/vbuf.h +maildir.o: ../../include/vstream.h +maildir.o: ../../include/make_dirs.h +maildir.o: ../../include/set_eugid.h +maildir.o: ../../include/get_hostname.h +maildir.o: ../../include/sane_fsops.h +maildir.o: ../../include/mail_copy.h +maildir.o: ../../include/bounce.h +maildir.o: ../../include/defer.h +maildir.o: ../../include/sent.h +maildir.o: ../../include/mail_params.h +maildir.o: virtual.h +maildir.o: ../../include/deliver_request.h +maildir.o: ../../include/recipient_list.h +maildir.o: ../../include/maps.h +maildir.o: ../../include/dict.h +maildir.o: ../../include/argv.h +maildir.o: ../../include/mbox_conf.h +recipient.o: recipient.c +recipient.o: ../../include/sys_defs.h +recipient.o: ../../include/msg.h +recipient.o: ../../include/mymalloc.h +recipient.o: ../../include/stringops.h +recipient.o: ../../include/vstring.h +recipient.o: ../../include/vbuf.h +recipient.o: ../../include/bounce.h +recipient.o: virtual.h +recipient.o: ../../include/vstream.h +recipient.o: ../../include/deliver_request.h +recipient.o: ../../include/recipient_list.h +recipient.o: ../../include/maps.h +recipient.o: ../../include/dict.h +recipient.o: ../../include/argv.h +recipient.o: ../../include/mbox_conf.h +unknown.o: unknown.c +unknown.o: ../../include/sys_defs.h +unknown.o: ../../include/msg.h +unknown.o: ../../include/bounce.h +unknown.o: virtual.h +unknown.o: ../../include/vstream.h +unknown.o: ../../include/vbuf.h +unknown.o: ../../include/vstring.h +unknown.o: ../../include/deliver_request.h +unknown.o: ../../include/recipient_list.h +unknown.o: ../../include/maps.h +unknown.o: ../../include/dict.h +unknown.o: ../../include/argv.h +unknown.o: ../../include/mbox_conf.h +virtual.o: virtual.c +virtual.o: ../../include/sys_defs.h +virtual.o: ../../include/msg.h +virtual.o: ../../include/vstring.h +virtual.o: ../../include/vbuf.h +virtual.o: ../../include/vstream.h +virtual.o: ../../include/iostuff.h +virtual.o: ../../include/set_eugid.h +virtual.o: ../../include/dict.h +virtual.o: ../../include/argv.h +virtual.o: ../../include/mail_queue.h +virtual.o: ../../include/recipient_list.h +virtual.o: ../../include/deliver_request.h +virtual.o: ../../include/deliver_completed.h +virtual.o: ../../include/mail_params.h +virtual.o: ../../include/mail_conf.h +virtual.o: ../../include/mail_server.h +virtual.o: virtual.h +virtual.o: ../../include/maps.h +virtual.o: ../../include/mbox_conf.h diff --git a/gnu/dist/postfix/src/virtual/deliver_attr.c b/gnu/dist/postfix/src/virtual/deliver_attr.c new file mode 100644 index 00000000000..63b15580fcf --- /dev/null +++ b/gnu/dist/postfix/src/virtual/deliver_attr.c @@ -0,0 +1,74 @@ +/*++ +/* NAME +/* deliver_attr 3 +/* SUMMARY +/* initialize message delivery attributes +/* SYNOPSIS +/* #include "virtual.h" +/* +/* void deliver_attr_init(attrp) +/* DELIVER_ATTR *attrp; +/* +/* void deliver_attr_dump(attrp) +/* DELIVER_ATTR *attrp; +/* DESCRIPTION +/* deliver_attr_init() initializes a structure with message delivery +/* attributes to a known initial state (all zeros). +/* +/* deliver_attr_dump() logs the contents of the given attribute list. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include <sys_defs.h> + +/* Utility library. */ + +#include <msg.h> +#include <vstream.h> + +/* Application-specific. */ + +#include "virtual.h" + +/* deliver_attr_init - set message delivery attributes to all-zero state */ + +void deliver_attr_init(DELIVER_ATTR *attrp) +{ + attrp->level = 0; + attrp->fp = 0; + attrp->queue_name = 0; + attrp->queue_id = 0; + attrp->offset = 0; + attrp->sender = 0; + attrp->recipient = 0; + attrp->user = 0; + attrp->delivered = 0; + attrp->relay = 0; +} + +/* deliver_attr_dump - log message delivery attributes */ + +void deliver_attr_dump(DELIVER_ATTR *attrp) +{ + msg_info("level: %d", attrp->level); + msg_info("path: %s", VSTREAM_PATH(attrp->fp)); + msg_info("fp: 0x%lx", (long) attrp->fp); + msg_info("queue_name: %s", attrp->queue_name ? attrp->queue_name : "null"); + msg_info("queue_id: %s", attrp->queue_id ? attrp->queue_id : "null"); + msg_info("offset: %ld", attrp->offset); + msg_info("sender: %s", attrp->sender ? attrp->sender : "null"); + msg_info("recipient: %s", attrp->recipient ? attrp->recipient : "null"); + msg_info("user: %s", attrp->user ? attrp->user : "null"); + msg_info("delivered: %s", attrp->delivered ? attrp->delivered : "null"); + msg_info("relay: %s", attrp->relay ? attrp->relay : "null"); +} diff --git a/gnu/dist/postfix/src/virtual/mailbox.c b/gnu/dist/postfix/src/virtual/mailbox.c new file mode 100644 index 00000000000..21782404b62 --- /dev/null +++ b/gnu/dist/postfix/src/virtual/mailbox.c @@ -0,0 +1,246 @@ +/*++ +/* NAME +/* mailbox 3 +/* SUMMARY +/* mailbox delivery +/* SYNOPSIS +/* #include "virtual.h" +/* +/* int deliver_mailbox(state, usr_attr, statusp) +/* LOCAL_STATE state; +/* USER_ATTR usr_attr; +/* int *statusp; +/* DESCRIPTION +/* deliver_mailbox() delivers to UNIX-style mailbox or to maildir. +/* +/* A zero result means that the named user was not found. +/* +/* Arguments: +/* .IP state +/* The attributes that specify the message, recipient and more. +/* .IP usr_attr +/* Attributes describing user rights and mailbox location. +/* .IP statusp +/* Delivery status: see below. +/* DIAGNOSTICS +/* The message delivery status is non-zero when delivery should be tried +/* again. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include <sys_defs.h> +#include <sys/stat.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> + +/* Utility library. */ + +#include <msg.h> +#include <vstring.h> +#include <vstream.h> +#include <mymalloc.h> +#include <stringops.h> +#include <set_eugid.h> + +/* Global library. */ + +#include <mail_copy.h> +#include <mbox_open.h> +#include <defer.h> +#include <sent.h> +#include <mail_params.h> + +#ifndef EDQUOT +#define EDQUOT EFBIG +#endif + +/* Application-specific. */ + +#include "virtual.h" + +#define YES 1 +#define NO 0 + +/* deliver_mailbox_file - deliver to recipient mailbox */ + +static int deliver_mailbox_file(LOCAL_STATE state, USER_ATTR usr_attr) +{ + char *myname = "deliver_mailbox_file"; + VSTRING *why; + MBOX *mp; + int mail_copy_status; + int deliver_status; + int copy_flags; + long end; + struct stat st; + + /* + * Make verbose logging easier to understand. + */ + state.level++; + if (msg_verbose) + MSG_LOG_STATE(myname, state); + + /* + * Initialize. Assume the operation will fail. Set the delivered + * attribute to reflect the final recipient. + */ + if (vstream_fseek(state.msg_attr.fp, state.msg_attr.offset, SEEK_SET) < 0) + msg_fatal("seek message file %s: %m", VSTREAM_PATH(state.msg_attr.fp)); + state.msg_attr.delivered = state.msg_attr.recipient; + mail_copy_status = MAIL_COPY_STAT_WRITE; + why = vstring_alloc(100); + + /* + * Lock the mailbox and open/create the mailbox file. + * + * Write the file as the recipient, so that file quota work. + */ + copy_flags = MAIL_COPY_MBOX; + + set_eugid(usr_attr.uid, usr_attr.gid); + mp = mbox_open(usr_attr.mailbox, O_APPEND | O_WRONLY | O_CREAT, + S_IRUSR | S_IWUSR, &st, -1, -1, + virtual_mbox_lock_mask, why); + if (mp != 0) { + if (S_ISREG(st.st_mode) == 0) { + vstream_fclose(mp->fp); + vstring_sprintf(why, "destination is not a regular file"); + errno = 0; + } else { + end = vstream_fseek(mp->fp, (off_t) 0, SEEK_END); + mail_copy_status = mail_copy(COPY_ATTR(state.msg_attr), mp->fp, + copy_flags, "\n", why); + } + mbox_release(mp); + } + set_eugid(var_owner_uid, var_owner_gid); + + /* + * As the mail system, bounce, defer delivery, or report success. + */ + if (mail_copy_status & MAIL_COPY_STAT_CORRUPT) { + deliver_status = DEL_STAT_DEFER; + } else if (mail_copy_status != 0) { + deliver_status = (errno == EDQUOT || errno == EFBIG ? + bounce_append : defer_append) + (BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "mailbox %s: %s", usr_attr.mailbox, vstring_str(why)); + } else { + deliver_status = sent(SENT_ATTR(state.msg_attr), "mailbox"); + } + vstring_free(why); + return (deliver_status); +} + +/* deliver_mailbox - deliver to recipient mailbox */ + +int deliver_mailbox(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp) +{ + char *myname = "deliver_mailbox"; + const char *mailbox_res; + const char *uid_res; + const char *gid_res; + long n; + + /* + * Make verbose logging easier to understand. + */ + state.level++; + if (msg_verbose) + MSG_LOG_STATE(myname, state); + + /* + * Sanity check. + */ + if (*var_virt_mailbox_base != '/') + msg_fatal("do not specify relative pathname: %s = %s", + VAR_VIRT_MAILBOX_BASE, var_virt_mailbox_base); + + /* + * Look up the mailbox location. Bounce if not found, defer in case of + * trouble. + */ + mailbox_res = maps_find(virtual_mailbox_maps, state.msg_attr.user, + DICT_FLAG_FIXED); + if (mailbox_res == 0) { + if (dict_errno == 0) + return (NO); + + *statusp = defer_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "%s: lookup %s: %m", + virtual_mailbox_maps->title, state.msg_attr.user); + return (YES); + } + usr_attr.mailbox = concatenate(var_virt_mailbox_base, "/", + mailbox_res, (char *) 0); + +#define RETURN(res) { myfree(usr_attr.mailbox); return (res); } + + /* + * Look up the mailbox owner rights. Defer in case of trouble. + */ + if ((uid_res = maps_find(virtual_uid_maps, state.msg_attr.user, + DICT_FLAG_FIXED)) == 0) { + *statusp = defer_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "recipient %s: uid not found in %s", + state.msg_attr.user, virtual_uid_maps->title); + RETURN(YES); + } + if ((n = atol(uid_res)) < var_virt_minimum_uid) { + *statusp = defer_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "recipient %s: bad uid %s in %s", + state.msg_attr.user, uid_res, virtual_uid_maps->title); + RETURN(YES); + } + usr_attr.uid = (uid_t) n; + + /* + * Look up the mailbox group rights. Defer in case of trouble. + */ + if ((gid_res = maps_find(virtual_gid_maps, state.msg_attr.user, + DICT_FLAG_FIXED)) == 0) { + *statusp = defer_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "recipient %s: gid not found in %s", + state.msg_attr.user, virtual_gid_maps->title); + RETURN(YES); + } + if ((n = atol(gid_res)) <= 0) { + *statusp = defer_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "recipient %s: bad gid %s in %s", + state.msg_attr.user, gid_res, virtual_gid_maps->title); + RETURN(YES); + } + usr_attr.gid = (gid_t) n; + + if (msg_verbose) + msg_info("%s[%d]: set user_attr: %s, uid = %u, gid = %u", + myname, state.level, usr_attr.mailbox, + (unsigned) usr_attr.uid, (unsigned) usr_attr.gid); + + /* + * Deliver to mailbox or to external command. + */ +#define LAST_CHAR(s) (s[strlen(s) - 1]) + + if (LAST_CHAR(usr_attr.mailbox) == '/') + *statusp = deliver_maildir(state, usr_attr); + else + *statusp = deliver_mailbox_file(state, usr_attr); + + /* + * Cleanup. + */ + RETURN(YES); +} diff --git a/gnu/dist/postfix/src/virtual/maildir.c b/gnu/dist/postfix/src/virtual/maildir.c new file mode 100644 index 00000000000..2db4130020a --- /dev/null +++ b/gnu/dist/postfix/src/virtual/maildir.c @@ -0,0 +1,176 @@ +/*++ +/* NAME +/* maildir 3 +/* SUMMARY +/* delivery to maildir +/* SYNOPSIS +/* #include "virtual.h" +/* +/* int deliver_maildir(state, usr_attr) +/* LOCAL_STATE state; +/* USER_ATTR usr_attr; +/* DESCRIPTION +/* deliver_maildir() delivers a message to a qmail-style maildir. +/* +/* Arguments: +/* .IP state +/* The attributes that specify the message, recipient and more. +/* .IP usr_attr +/* Attributes describing user rights and environment information. +/* DIAGNOSTICS +/* deliver_maildir() always succeeds or it bounces the message. +/* SEE ALSO +/* bounce(3) +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include "sys_defs.h" +#include <errno.h> + +#ifndef EDQUOT +#define EDQUOT EFBIG +#endif + +/* Utility library. */ + +#include <msg.h> +#include <mymalloc.h> +#include <stringops.h> +#include <vstream.h> +#include <vstring.h> +#include <make_dirs.h> +#include <set_eugid.h> +#include <get_hostname.h> +#include <sane_fsops.h> + +/* Global library. */ + +#include <mail_copy.h> +#include <bounce.h> +#include <defer.h> +#include <sent.h> +#include <mail_params.h> + +/* Application-specific. */ + +#include "virtual.h" + +/* deliver_maildir - delivery to maildir-style mailbox */ + +int deliver_maildir(LOCAL_STATE state, USER_ATTR usr_attr) +{ + char *myname = "deliver_maildir"; + char *newdir; + char *tmpdir; + char *curdir; + char *tmpfile; + char *newfile; + VSTRING *why; + VSTRING *buf; + VSTREAM *dst; + int mail_copy_status; + int deliver_status; + int copy_flags; + static int count; + + /* + * Make verbose logging easier to understand. + */ + state.level++; + if (msg_verbose) + MSG_LOG_STATE(myname, state); + + /* + * Initialize. Assume the operation will fail. Set the delivered + * attribute to reflect the final recipient. + */ + if (vstream_fseek(state.msg_attr.fp, state.msg_attr.offset, SEEK_SET) < 0) + msg_fatal("seek message file %s: %m", VSTREAM_PATH(state.msg_attr.fp)); + state.msg_attr.delivered = state.msg_attr.recipient; + mail_copy_status = MAIL_COPY_STAT_WRITE; + buf = vstring_alloc(100); + why = vstring_alloc(100); + + copy_flags = MAIL_COPY_TOFILE | MAIL_COPY_RETURN_PATH | MAIL_COPY_DELIVERED; + + newdir = concatenate(usr_attr.mailbox, "new/", (char *) 0); + tmpdir = concatenate(usr_attr.mailbox, "tmp/", (char *) 0); + curdir = concatenate(usr_attr.mailbox, "cur/", (char *) 0); + + /* + * Create and write the file as the recipient, so that file quota work. + * Create any missing directories on the fly. The file name is chosen + * according to ftp://koobera.math.uic.edu/www/proto/maildir.html: + * + * "A unique name has three pieces, separated by dots. On the left is the + * result of time(). On the right is the result of gethostname(). In the + * middle is something that doesn't repeat within one second on a single + * host. I fork a new process for each delivery, so I just use the + * process ID. If you're delivering several messages from one process, + * use starttime.pid_count.host, where starttime is the time that your + * process started, and count is the number of messages you've + * delivered." + */ +#define STR vstring_str + + set_eugid(usr_attr.uid, usr_attr.gid); + vstring_sprintf(buf, "%ld.%d_%d.%s", (long) var_starttime, + var_pid, count++, get_hostname()); + tmpfile = concatenate(tmpdir, STR(buf), (char *) 0); + newfile = concatenate(newdir, STR(buf), (char *) 0); + if ((dst = vstream_fopen(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600)) == 0 + && (errno != ENOENT + || make_dirs(tmpdir, 0700) < 0 + || (dst = vstream_fopen(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600)) == 0)) { + vstring_sprintf(why, "create %s: %m", tmpfile); + } else { + if ((mail_copy_status = mail_copy(COPY_ATTR(state.msg_attr), + dst, copy_flags, "\n", why)) == 0) { + if (sane_link(tmpfile, newfile) < 0 + && (errno != ENOENT + || (make_dirs(curdir, 0700), make_dirs(newdir, 0700)) < 0 + || sane_link(tmpfile, newfile) < 0)) { + vstring_sprintf(why, "link to %s: %m", newfile); + mail_copy_status = MAIL_COPY_STAT_WRITE; + } + } + if (unlink(tmpfile) < 0) + msg_warn("remove %s: %m", tmpfile); + } + set_eugid(var_owner_uid, var_owner_gid); + + /* + * The maildir location is controlled by the mail administrator. If + * delivery fails, try again later. We would just bounce when the maildir + * location possibly under user control. + */ + if (mail_copy_status & MAIL_COPY_STAT_CORRUPT) { + deliver_status = DEL_STAT_DEFER; + } else if (mail_copy_status != 0) { + deliver_status = (errno == EDQUOT || errno == EFBIG ? + bounce_append : defer_append) + (BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "maildir delivery failed: %s", vstring_str(why)); + + } else { + deliver_status = sent(SENT_ATTR(state.msg_attr), "maildir"); + } + vstring_free(buf); + vstring_free(why); + myfree(newdir); + myfree(tmpdir); + myfree(curdir); + myfree(tmpfile); + myfree(newfile); + return (deliver_status); +} diff --git a/gnu/dist/postfix/src/virtual/recipient.c b/gnu/dist/postfix/src/virtual/recipient.c new file mode 100644 index 00000000000..725108f5be7 --- /dev/null +++ b/gnu/dist/postfix/src/virtual/recipient.c @@ -0,0 +1,93 @@ +/*++ +/* NAME +/* recipient 3 +/* SUMMARY +/* deliver to one local recipient +/* SYNOPSIS +/* #include "virtual.h" +/* +/* int deliver_recipient(state, usr_attr) +/* LOCAL_STATE state; +/* USER_ATTR *usr_attr; +/* DESCRIPTION +/* deliver_recipient() delivers a message to a local recipient. +/* +/* Arguments: +/* .IP state +/* The attributes that specify the message, sender, and more. +/* .IP usr_attr +/* Attributes describing user rights and mailbox location. +/* DIAGNOSTICS +/* deliver_recipient() returns non-zero when delivery should be +/* tried again. +/* SEE ALSO +/* mailbox(3) delivery to UNIX-style mailbox +/* maildir(3) delivery to qmail-style maildir +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include <sys_defs.h> + +/* Utility library. */ + +#include <msg.h> +#include <mymalloc.h> +#include <stringops.h> + +/* Global library. */ + +#include <bounce.h> + +/* Application-specific. */ + +#include "virtual.h" + +/* deliver_recipient - deliver one local recipient */ + +int deliver_recipient(LOCAL_STATE state, USER_ATTR usr_attr) +{ + char *myname = "deliver_recipient"; + int rcpt_stat; + + /* + * Make verbose logging easier to understand. + */ + state.level++; + if (msg_verbose) + MSG_LOG_STATE(myname, state); + + /* + * Set up the recipient-specific attributes. The recipient's lookup + * handle is the full address. + */ + if (state.msg_attr.delivered == 0) + state.msg_attr.delivered = state.msg_attr.recipient; + state.msg_attr.user = mystrdup(state.msg_attr.recipient); + lowercase(state.msg_attr.user); + + /* + * Deliver + */ + if (msg_verbose) + deliver_attr_dump(&state.msg_attr); + + if (deliver_mailbox(state, usr_attr, &rcpt_stat) == 0) + rcpt_stat = deliver_unknown(state); + + /* + * Cleanup. + */ + myfree(state.msg_attr.user); + + return (rcpt_stat); +} diff --git a/gnu/dist/postfix/src/virtual/unknown.c b/gnu/dist/postfix/src/virtual/unknown.c new file mode 100644 index 00000000000..8989046e0d1 --- /dev/null +++ b/gnu/dist/postfix/src/virtual/unknown.c @@ -0,0 +1,64 @@ +/*++ +/* NAME +/* unknown 3 +/* SUMMARY +/* delivery of unknown recipients +/* SYNOPSIS +/* #include "virtual.h" +/* +/* int deliver_unknown(state) +/* LOCAL_STATE state; +/* DESCRIPTION +/* deliver_unknown() delivers a message for unknown recipients. +/* .PP +/* Arguments: +/* .IP state +/* Message delivery attributes (sender, recipient etc.). +/* .IP usr_attr +/* Attributes describing user rights and mailbox location. +/* DIAGNOSTICS +/* The result status is non-zero when delivery should be tried again. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include <sys_defs.h> + +/* Utility library. */ + +#include <msg.h> + +/* Global library. */ + +#include <bounce.h> + +/* Application-specific. */ + +#include "virtual.h" + +/* deliver_unknown - delivery for unknown recipients */ + +int deliver_unknown(LOCAL_STATE state) +{ + char *myname = "deliver_unknown"; + + /* + * Make verbose logging easier to understand. + */ + state.level++; + if (msg_verbose) + MSG_LOG_STATE(myname, state); + + return (bounce_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), + "unknown user: \"%s\"", state.msg_attr.user)); + +} diff --git a/gnu/dist/postfix/src/virtual/virtual.c b/gnu/dist/postfix/src/virtual/virtual.c new file mode 100644 index 00000000000..7968dcc2856 --- /dev/null +++ b/gnu/dist/postfix/src/virtual/virtual.c @@ -0,0 +1,414 @@ +/*++ +/* NAME +/* virtual 8 +/* SUMMARY +/* Postfix virtual domain mail delivery agent +/* SYNOPSIS +/* \fBvirtual\fR [generic Postfix daemon options] +/* DESCRIPTION +/* The \fBvirtual\fR delivery agent is designed for virtual mail +/* hosting services. Originally based on the Postfix local delivery +/* agent, this agent looks up recipients with map lookups of their +/* full recipient address, instead of using hard-coded unix password +/* file lookups of the address local part only. +/* +/* This delivery agent only delivers mail. Other features such as +/* mail forwarding, out-of-office notifications, etc., must be +/* configured via virtual maps or via similar lookup mechanisms. +/* MAILBOX LOCATION +/* .ad +/* .fi +/* The mailbox location is controlled by the \fBvirtual_mailbox_base\fR +/* and \fBvirtual_mailbox_maps\fR configuration parameters (see below). +/* The \fBvirtual_mailbox_maps\fR table is indexed by the full recipient +/* address. +/* +/* The mailbox pathname is constructed as follows: +/* +/* .ti +2 +/* \fB$virtual_mailbox_base/$virtual_mailbox_maps(\fIrecipient\fB)\fR +/* +/* where \fIrecipient\fR is the full recipient address. +/* UNIX MAILBOX FORMAT +/* .ad +/* .fi +/* When the mailbox location does not end in \fB/\fR, the message +/* is delivered in UNIX mailbox format. This format stores multiple +/* messages in one textfile. +/* +/* The \fBvirtual\fR delivery agent prepends a "\fBFrom \fIsender +/* time_stamp\fR" envelope header to each message, prepends a +/* \fBDelivered-To:\fR message header with the envelope recipient +/* address, prepends a \fBReturn-Path:\fR message header with the +/* envelope sender address, prepends a \fB>\fR character to lines +/* beginning with "\fBFrom \fR", and appends an empty line. +/* +/* The mailbox is locked for exclusive access while delivery is in +/* progress. In case of problems, an attempt is made to truncate the +/* mailbox to its original length. +/* QMAIL MAILDIR FORMAT +/* .ad +/* .fi +/* When the mailbox location ends in \fB/\fR, the message is delivered +/* in qmail \fBmaildir\fR format. This format stores one message per file. +/* +/* The \fBvirtual\fR delivery agent daemon prepends a \fBDelivered-To:\fR +/* message header with the envelope recipient address and prepends a +/* \fBReturn-Path:\fR message header with the envelope sender address. +/* +/* By definition, \fBmaildir\fR format does not require file locking +/* during mail delivery or retrieval. +/* MAILBOX OWNERSHIP +/* .ad +/* .fi +/* Mailbox ownership is controlled by the \fBvirtual_uid_maps\fR +/* and \fBvirtual_gid_maps\fR lookup tables, which are indexed +/* with the full recipient address. Each table provides +/* a string with the numerical user and group ID, respectively. +/* +/* The \fBvirtual_minimum_uid\fR parameter imposes a lower bound on +/* numerical user ID values that may be specified in any +/* \fBvirtual_owner_maps\fR or \fBvirtual_uid_maps\fR. +/* SECURITY +/* .ad +/* .fi +/* The virtual delivery agent is not security sensitive, provided +/* that the lookup tables with recipient user/group ID information are +/* adequately protected. This program is not designed to run chrooted. +/* STANDARDS +/* RFC 822 (ARPA Internet Text Messages) +/* DIAGNOSTICS +/* Mail bounces when the recipient has no mailbox or when the +/* recipient is over disk quota. In all other cases, mail for +/* an existing recipient is deferred and a warning is logged. +/* +/* Problems and transactions are logged to \fBsyslogd\fR(8). +/* Corrupted message files are marked so that the queue +/* manager can move them to the \fBcorrupt\fR queue afterwards. +/* +/* Depending on the setting of the \fBnotify_classes\fR parameter, +/* the postmaster is notified of bounces and of other trouble. +/* BUGS +/* This delivery agent silently ignores address extensions. +/* +/* Postfix should have lookup tables that can return multiple result +/* attributes. In order to avoid the inconvenience of maintaining +/* three tables, use an LDAP or MYSQL database. +/* CONFIGURATION PARAMETERS +/* .ad +/* .fi +/* The following \fBmain.cf\fR parameters are especially relevant to +/* this program. See the Postfix \fBmain.cf\fR file for syntax details +/* and for default values. Use the \fBpostfix reload\fR command after +/* a configuration change. +/* .SH Mailbox delivery +/* .ad +/* .fi +/* .IP \fBvirtual_mailbox_base\fR +/* Specifies a path that is prepended to all mailbox or maildir paths. +/* This is a safety measure to ensure that an out of control map in +/* \fBvirtual_mailbox_maps\fR doesn't litter the filesystem with mailboxes. +/* While it could be set to "/", this setting isn't recommended. +/* .IP "\fBvirtual_mailbox_maps\fR (regexp maps disallowed)" +/* Recipients are looked up in these maps to determine the path to +/* their mailbox or maildir. If the returned path ends in a slash +/* ("/"), maildir-style delivery is carried out, otherwise the +/* path is assumed to specify a UNIX-style mailbox file. +/* +/* Note that \fBvirtual_mailbox_base\fR is unconditionally prepended +/* to this path. +/* .IP \fBvirtual_minimum_uid\fR +/* Specifies a minimum uid that will be accepted as a return from +/* a \fBvirtual_owner_maps\fR or \fBvirtual_uid_maps\fR lookup. +/* Returned values less than this will be rejected, and the message +/* will be deferred. +/* .IP "\fBvirtual_uid_maps\fR (regexp maps disallowed)" +/* Recipients are looked up in these maps to determine the user ID to be +/* used when writing to the target mailbox. +/* .IP "\fBvirtual_gid_maps\fR (regexp maps disallowed)" +/* Recipients are looked up in these maps to determine the group ID to be +/* used when writing to the target mailbox. +/* .SH "Locking controls" +/* .ad +/* .fi +/* .IP \fBvirtual_mailbox_lock\fR +/* How to lock UNIX-style mailboxes: one or more of \fBflock\fR, +/* \fBfcntl\fR or \fBdotlock\fR. The \fBdotlock\fR method requires +/* that the recipient UID or GID has write access to the parent +/* directory of the mailbox file. +/* +/* This setting is ignored with \fBmaildir\fR style delivery, +/* because such deliveries are safe without explicit locks. +/* +/* Use the command \fBpostconf -l\fR to find out what locking methods +/* are available on your system. +/* .IP \fBdeliver_lock_attempts\fR +/* Limit the number of attempts to acquire an exclusive lock +/* on a UNIX-style mailbox file. +/* .IP \fBdeliver_lock_delay\fR +/* Time (default: seconds) between successive attempts to acquire +/* an exclusive lock on a UNIX-style mailbox file. The actual delay +/* is slightly randomized. +/* .IP \fBstale_lock_time\fR +/* Limit the time after which a stale lockfile is removed (applicable +/* to UNIX-style mailboxes only). +/* .SH "Resource controls" +/* .ad +/* .fi +/* .IP \fBvirtual_destination_concurrency_limit\fR +/* Limit the number of parallel deliveries to the same domain +/* via the \fBvirtual\fR delivery agent. +/* The default limit is taken from the +/* \fBdefault_destination_concurrency_limit\fR parameter. +/* The limit is enforced by the Postfix queue manager. +/* .IP \fBvirtual_destination_recipient_limit\fR +/* Limit the number of recipients per message delivery +/* via the \fBvirtual\fR delivery agent. +/* The default limit is taken from the +/* \fBdefault_destination_recipient_limit\fR parameter. +/* The limit is enforced by the Postfix queue manager. +/* .IP \fBvirtual_mailbox_limit\fR +/* The maximal size in bytes of a mailbox or maildir file. +/* Set to zero to disable the limit. +/* HISTORY +/* .ad +/* .fi +/* This agent was originally based on the Postfix local delivery +/* agent. Modifications mainly consisted of removing code that either +/* was not applicable or that was not safe in this context: aliases, +/* ~user/.forward files, delivery to "|command" or to /file/name. +/* +/* The \fBDelivered-To:\fR header appears in the \fBqmail\fR system +/* by Daniel Bernstein. +/* +/* The \fBmaildir\fR structure appears in the \fBqmail\fR system +/* by Daniel Bernstein. +/* SEE ALSO +/* bounce(8) non-delivery status reports +/* syslogd(8) system logging +/* qmgr(8) queue manager +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/* +/* Andrew McNamara +/* andrewm@connect.com.au +/* connect.com.au Pty. Ltd. +/* Level 3, 213 Miller St +/* North Sydney 2060, NSW, Australia +/*--*/ + +/* System library. */ + +#include <sys_defs.h> +#include <stdlib.h> + +/* Utility library. */ + +#include <msg.h> +#include <vstring.h> +#include <vstream.h> +#include <iostuff.h> +#include <set_eugid.h> +#include <dict.h> + +/* Global library. */ + +#include <mail_queue.h> +#include <recipient_list.h> +#include <deliver_request.h> +#include <deliver_completed.h> +#include <mail_params.h> +#include <mail_conf.h> +#include <mail_params.h> + +/* Single server skeleton. */ + +#include <mail_server.h> + +/* Application-specific. */ + +#include "virtual.h" + + /* + * Tunable parameters. + */ +char *var_virt_mailbox_maps; +char *var_virt_uid_maps; +char *var_virt_gid_maps; +int var_virt_minimum_uid; +char *var_virt_mailbox_base; +char *var_virt_mailbox_lock; +int var_virt_mailbox_limit; + + /* + * Mappings. + */ +MAPS *virtual_mailbox_maps; +MAPS *virtual_uid_maps; +MAPS *virtual_gid_maps; + + /* + * Bit masks. + */ +int virtual_mbox_lock_mask; + +/* local_deliver - deliver message with extreme prejudice */ + +static int local_deliver(DELIVER_REQUEST *rqst, char *service) +{ + char *myname = "local_deliver"; + RECIPIENT *rcpt_end = rqst->rcpt_list.info + rqst->rcpt_list.len; + RECIPIENT *rcpt; + int rcpt_stat; + int msg_stat; + LOCAL_STATE state; + USER_ATTR usr_attr; + + if (msg_verbose) + msg_info("local_deliver: %s from %s", rqst->queue_id, rqst->sender); + + /* + * Initialize the delivery attributes that are not recipient specific. + */ + state.level = 0; + deliver_attr_init(&state.msg_attr); + state.msg_attr.queue_name = rqst->queue_name; + state.msg_attr.queue_id = rqst->queue_id; + state.msg_attr.fp = rqst->fp; + state.msg_attr.offset = rqst->data_offset; + state.msg_attr.sender = rqst->sender; + state.msg_attr.relay = service; + state.msg_attr.arrival_time = rqst->arrival_time; + RESET_USER_ATTR(usr_attr, state.level); + state.request = rqst; + + /* + * Iterate over each recipient named in the delivery request. When the + * mail delivery status for a given recipient is definite (i.e. bounced + * or delivered), update the message queue file and cross off the + * recipient. Update the per-message delivery status. + */ + for (msg_stat = 0, rcpt = rqst->rcpt_list.info; rcpt < rcpt_end; rcpt++) { + state.msg_attr.recipient = rcpt->address; + rcpt_stat = deliver_recipient(state, usr_attr); + if (rcpt_stat == 0) + deliver_completed(state.msg_attr.fp, rcpt->offset); + msg_stat |= rcpt_stat; + } + + return (msg_stat); +} + +/* local_service - perform service for client */ + +static void local_service(VSTREAM *stream, char *service, char **argv) +{ + DELIVER_REQUEST *request; + int status; + + /* + * Sanity check. This service takes no command-line arguments. + */ + if (argv[0]) + msg_fatal("unexpected command-line argument: %s", argv[0]); + + /* + * This routine runs whenever a client connects to the UNIX-domain socket + * that is dedicated to local mail delivery service. What we see below is + * a little protocol to (1) tell the client that we are ready, (2) read a + * delivery request from the client, and (3) report the completion status + * of that request. + */ + if ((request = deliver_request_read(stream)) != 0) { + status = local_deliver(request, service); + deliver_request_done(stream, request, status); + } +} + +/* pre_accept - see if tables have changed */ + +static void pre_accept(char *unused_name, char **unused_argv) +{ + if (dict_changed()) { + msg_info("table has changed -- exiting"); + exit(0); + } +} + +/* post_init - post-jail initialization */ + +static void post_init(char *unused_name, char **unused_argv) +{ + + /* + * Drop privileges most of the time. + */ + set_eugid(var_owner_uid, var_owner_gid); + + virtual_mailbox_maps = + maps_create(VAR_VIRT_MAILBOX_MAPS, var_virt_mailbox_maps, + DICT_FLAG_LOCK); + + virtual_uid_maps = + maps_create(VAR_VIRT_UID_MAPS, var_virt_uid_maps, DICT_FLAG_LOCK); + + virtual_gid_maps = + maps_create(VAR_VIRT_GID_MAPS, var_virt_gid_maps, DICT_FLAG_LOCK); + + virtual_mbox_lock_mask = mbox_lock_mask(var_virt_mailbox_lock); +} + +/* pre_init - pre-jail initialization */ + +static void pre_init(char *unused_name, char **unused_argv) +{ + + /* + * Reset the file size limit from the message size limit to the mailbox + * size limit. + * + * We can't have mailbox size limit smaller than the message size limit, + * because that prohibits the delivery agent from updating the queue + * file. + */ + if (var_virt_mailbox_limit) { + if (var_virt_mailbox_limit < var_message_limit) + msg_fatal("main.cf configuration error: %s is smaller than %s", + VAR_VIRT_MAILBOX_LIMIT, VAR_MESSAGE_LIMIT); + set_file_limit(var_virt_mailbox_limit); + } +} + +/* main - pass control to the single-threaded skeleton */ + +int main(int argc, char **argv) +{ + static CONFIG_INT_TABLE int_table[] = { + VAR_VIRT_MINUID, DEF_VIRT_MINUID, &var_virt_minimum_uid, 1, 0, + VAR_VIRT_MAILBOX_LIMIT, DEF_VIRT_MAILBOX_LIMIT, &var_virt_mailbox_limit, 0, 0, + 0, + }; + static CONFIG_STR_TABLE str_table[] = { + VAR_VIRT_MAILBOX_MAPS, DEF_VIRT_MAILBOX_MAPS, &var_virt_mailbox_maps, 0, 0, + VAR_VIRT_UID_MAPS, DEF_VIRT_UID_MAPS, &var_virt_uid_maps, 0, 0, + VAR_VIRT_GID_MAPS, DEF_VIRT_GID_MAPS, &var_virt_gid_maps, 0, 0, + VAR_VIRT_MAILBOX_BASE, DEF_VIRT_MAILBOX_BASE, &var_virt_mailbox_base, 0, 0, + VAR_VIRT_MAILBOX_LOCK, DEF_VIRT_MAILBOX_LOCK, &var_virt_mailbox_lock, 1, 0, + 0, + }; + + single_server_main(argc, argv, local_service, + MAIL_SERVER_INT_TABLE, int_table, + MAIL_SERVER_STR_TABLE, str_table, + MAIL_SERVER_PRE_INIT, pre_init, + MAIL_SERVER_POST_INIT, post_init, + MAIL_SERVER_PRE_ACCEPT, pre_accept, + 0); +} diff --git a/gnu/dist/postfix/src/virtual/virtual.h b/gnu/dist/postfix/src/virtual/virtual.h new file mode 100644 index 00000000000..1443bc8d04f --- /dev/null +++ b/gnu/dist/postfix/src/virtual/virtual.h @@ -0,0 +1,134 @@ +/*++ +/* NAME +/* virtual 3h +/* SUMMARY +/* virtual mail delivery +/* SYNOPSIS +/* #include "virtual.h" +/* DESCRIPTION +/* .nf + + /* + * System library. + */ +#include <unistd.h> + + /* + * Utility library. + */ +#include <vstream.h> +#include <vstring.h> + + /* + * Global library. + */ +#include <deliver_request.h> +#include <maps.h> +#include <mbox_conf.h> + + /* + * Mappings. + */ +extern MAPS *virtual_mailbox_maps; +extern MAPS *virtual_uid_maps; +extern MAPS *virtual_gid_maps; + + /* + * User attributes: these control the privileges for delivery to external + * commands, external files, or mailboxes, and the initial environment of + * external commands. + */ +typedef struct USER_ATTR { + uid_t uid; /* file/command access */ + gid_t gid; /* file/command access */ + char *mailbox; /* mailbox file or directory */ +} USER_ATTR; + + /* + * Critical macros. Not for obscurity, but to ensure consistency. + */ +#define RESET_USER_ATTR(usr_attr, level) { \ + usr_attr.uid = 0; usr_attr.gid = 0; usr_attr.mailbox = 0; \ + if (msg_verbose) \ + msg_info("%s[%d]: reset user_attr", myname, level); \ + } + + /* + * The delivery attributes are inherited from files, from aliases, and from + * whatnot. Some of the information is changed on the fly. DELIVER_ATTR + * structres are therefore passed by value, so there is no need to undo + * changes. + */ +typedef struct DELIVER_ATTR { + int level; /* recursion level */ + VSTREAM *fp; /* open queue file */ + char *queue_name; /* mail queue id */ + char *queue_id; /* mail queue id */ + long offset; /* data offset */ + char *sender; /* taken from envelope */ + char *recipient; /* taken from resolver */ + char *user; /* recipient lookup handle */ + char *delivered; /* for loop detection */ + char *relay; /* relay host */ + long arrival_time; /* arrival time */ +} DELIVER_ATTR; + +extern void deliver_attr_init(DELIVER_ATTR *); +extern void deliver_attr_dump(DELIVER_ATTR *); + +#define FEATURE_NODELIVERED (1<<0) /* no delivered-to */ + + /* + * Rather than schlepping around dozens of arguments, here is one that has + * all. Well, almost. The user attributes are just a bit too sensitive, so + * they are passed around separately. + */ +typedef struct LOCAL_STATE { + int level; /* nesting level, for logging */ + DELIVER_ATTR msg_attr; /* message attributes */ + DELIVER_REQUEST *request; /* as from queue manager */ +} LOCAL_STATE; + + /* + * Bundle up some often-user attributes. + */ +#define BOUNCE_ATTR(attr) attr.queue_id, attr.recipient, attr.relay, \ + attr.arrival_time +#define SENT_ATTR(attr) attr.queue_id, attr.recipient, attr.relay, \ + attr.arrival_time +#define COPY_ATTR(attr) attr.sender, attr.delivered, attr.fp + +#define MSG_LOG_STATE(m, p) \ + msg_info("%s[%d]: recip %s deliver %s", m, \ + p.level, \ + p.msg_attr.recipient ? p.msg_attr.recipient : "", \ + p.msg_attr.delivered ? p.msg_attr.delivered : "") + + /* + * "inner" nodes of the delivery graph. + */ +extern int deliver_recipient(LOCAL_STATE, USER_ATTR); + + /* + * "leaf" nodes of the delivery graph. + */ +extern int deliver_mailbox(LOCAL_STATE, USER_ATTR, int *); +extern int deliver_file(LOCAL_STATE, USER_ATTR, char *); +extern int deliver_maildir(LOCAL_STATE, USER_ATTR); +extern int deliver_unknown(LOCAL_STATE); + + /* + * Mailbox lock protocol. + */ +extern int virtual_mbox_lock_mask; + +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ |
