5
/* virtual mail delivery
7
/* #include "virtual.h"
25
#include <deliver_request.h>
27
#include <mbox_conf.h>
32
extern MAPS *virtual_mailbox_maps;
33
extern MAPS *virtual_uid_maps;
34
extern MAPS *virtual_gid_maps;
37
* User attributes: these control the privileges for delivery to external
38
* commands, external files, or mailboxes, and the initial environment of
41
typedef struct USER_ATTR {
42
uid_t uid; /* file/command access */
43
gid_t gid; /* file/command access */
44
char *mailbox; /* mailbox file or directory */
48
* Critical macros. Not for obscurity, but to ensure consistency.
50
#define RESET_USER_ATTR(usr_attr, level) { \
51
usr_attr.uid = 0; usr_attr.gid = 0; usr_attr.mailbox = 0; \
53
msg_info("%s[%d]: reset user_attr", myname, level); \
57
* The delivery attributes are inherited from files, from aliases, and from
58
* whatnot. Some of the information is changed on the fly. DELIVER_ATTR
59
* structres are therefore passed by value, so there is no need to undo
62
typedef struct DELIVER_ATTR {
63
int level; /* recursion level */
64
VSTREAM *fp; /* open queue file */
65
char *queue_name; /* mail queue id */
66
char *queue_id; /* mail queue id */
67
long offset; /* data offset */
68
char *sender; /* taken from envelope */
69
char *orig_rcpt; /* taken from sender */
70
char *recipient; /* taken from resolver */
71
long rcpt_offset; /* taken from resolver */
72
char *user; /* recipient lookup handle */
73
char *delivered; /* for loop detection */
74
char *relay; /* relay host */
75
long arrival_time; /* arrival time */
78
extern void deliver_attr_init(DELIVER_ATTR *);
79
extern void deliver_attr_dump(DELIVER_ATTR *);
81
#define FEATURE_NODELIVERED (1<<0) /* no delivered-to */
84
* Rather than schlepping around dozens of arguments, here is one that has
85
* all. Well, almost. The user attributes are just a bit too sensitive, so
86
* they are passed around separately.
88
typedef struct LOCAL_STATE {
89
int level; /* nesting level, for logging */
90
DELIVER_ATTR msg_attr; /* message attributes */
91
DELIVER_REQUEST *request; /* as from queue manager */
95
* Bundle up some often-user attributes.
97
#define BOUNCE_FLAGS(request) DEL_REQ_TRACE_FLAGS((request)->flags)
99
#define BOUNCE_ATTR(attr) attr.queue_id, attr.orig_rcpt, attr.recipient, \
100
attr.rcpt_offset, attr.relay, \
102
#define SENT_ATTR(attr) attr.queue_id, attr.orig_rcpt, attr.recipient, \
103
attr.rcpt_offset, attr.relay, \
105
#define COPY_ATTR(attr) attr.sender, attr.orig_rcpt, attr.delivered, \
108
#define MSG_LOG_STATE(m, p) \
109
msg_info("%s[%d]: recip %s deliver %s", m, \
111
p.msg_attr.recipient ? p.msg_attr.recipient : "", \
112
p.msg_attr.delivered ? p.msg_attr.delivered : "")
115
* "inner" nodes of the delivery graph.
117
extern int deliver_recipient(LOCAL_STATE, USER_ATTR);
120
* "leaf" nodes of the delivery graph.
122
extern int deliver_mailbox(LOCAL_STATE, USER_ATTR, int *);
123
extern int deliver_file(LOCAL_STATE, USER_ATTR, char *);
124
extern int deliver_maildir(LOCAL_STATE, USER_ATTR);
125
extern int deliver_unknown(LOCAL_STATE);
128
* Mailbox lock protocol.
130
extern int virtual_mbox_lock_mask;
135
/* The Secure Mailer license must be distributed with this software.
138
/* IBM T.J. Watson Research
140
/* Yorktown Heights, NY 10598, USA