7 /* virtual mail delivery
9 /* #include "virtual.h"
27 #include <deliver_request.h>
29 #include <mbox_conf.h>
36 extern MAPS
*virtual_mailbox_maps
;
37 extern MAPS
*virtual_uid_maps
;
38 extern MAPS
*virtual_gid_maps
;
41 * User attributes: these control the privileges for delivery to external
42 * commands, external files, or mailboxes, and the initial environment of
45 typedef struct USER_ATTR
{
46 uid_t uid
; /* file/command access */
47 gid_t gid
; /* file/command access */
48 char *mailbox
; /* mailbox file or directory */
52 * Critical macros. Not for obscurity, but to ensure consistency.
54 #define RESET_USER_ATTR(usr_attr, level) { \
55 usr_attr.uid = 0; usr_attr.gid = 0; usr_attr.mailbox = 0; \
57 msg_info("%s[%d]: reset user_attr", myname, level); \
61 * The delivery attributes are inherited from files, from aliases, and from
62 * whatnot. Some of the information is changed on the fly. DELIVER_ATTR
63 * structures are therefore passed by value, so there is no need to undo
66 typedef struct DELIVER_ATTR
{
67 int level
; /* recursion level */
68 VSTREAM
*fp
; /* open queue file */
69 char *queue_name
; /* mail queue id */
70 char *queue_id
; /* mail queue id */
71 long offset
; /* data offset */
72 const char *sender
; /* taken from envelope */
73 char *dsn_envid
; /* DSN envelope ID */
74 int dsn_ret
; /* DSN headers/full */
75 RECIPIENT rcpt
; /* from delivery request */
76 char *user
; /* recipient lookup handle */
77 const char *delivered
; /* for loop detection */
78 char *relay
; /* relay host */
79 MSG_STATS msg_stats
; /* time profile */
80 DSN_BUF
*why
; /* delivery status */
83 extern void deliver_attr_init(DELIVER_ATTR
*);
84 extern void deliver_attr_dump(DELIVER_ATTR
*);
85 extern void deliver_attr_free(DELIVER_ATTR
*);
87 #define FEATURE_NODELIVERED (1<<0) /* no delivered-to */
90 * Rather than schlepping around dozens of arguments, here is one that has
91 * all. Well, almost. The user attributes are just a bit too sensitive, so
92 * they are passed around separately.
94 typedef struct LOCAL_STATE
{
95 int level
; /* nesting level, for logging */
96 DELIVER_ATTR msg_attr
; /* message/recipient attributes */
97 DELIVER_REQUEST
*request
; /* as from queue manager */
101 * Bundle up some often-user attributes.
103 #define BOUNCE_FLAGS(request) DEL_REQ_TRACE_FLAGS((request)->flags)
105 #define BOUNCE_ATTR(attr) \
106 attr.queue_id, &attr.msg_stats, &attr.rcpt, attr.relay, \
107 DSN_FROM_DSN_BUF(attr.why)
108 #define SENT_ATTR(attr) \
109 attr.queue_id, &attr.msg_stats, &attr.rcpt, attr.relay, \
110 DSN_FROM_DSN_BUF(attr.why)
111 #define COPY_ATTR(attr) \
112 attr.sender, attr.rcpt.orig_addr, attr.delivered, attr.fp
114 #define MSG_LOG_STATE(m, p) \
115 msg_info("%s[%d]: recip %s deliver %s", m, \
117 p.msg_attr.rcpt.address ? p.msg_attr.rcpt.address : "", \
118 p.msg_attr.delivered ? p.msg_attr.delivered : "")
121 * "inner" nodes of the delivery graph.
123 extern int deliver_recipient(LOCAL_STATE
, USER_ATTR
);
126 * "leaf" nodes of the delivery graph.
128 extern int deliver_mailbox(LOCAL_STATE
, USER_ATTR
, int *);
129 extern int deliver_file(LOCAL_STATE
, USER_ATTR
, char *);
130 extern int deliver_maildir(LOCAL_STATE
, USER_ATTR
);
131 extern int deliver_unknown(LOCAL_STATE
);
134 * Mailbox lock protocol.
136 extern int virtual_mbox_lock_mask
;
139 * Silly little macros.
141 #define STR(s) vstring_str(s)
146 /* The Secure Mailer license must be distributed with this software.
149 /* IBM T.J. Watson Research
151 /* Yorktown Heights, NY 10598, USA