~ubuntu-branches/ubuntu/trusty/postfix/trusty-proposed

« back to all changes in this revision

Viewing changes to src/virtual/virtual.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-02-27 09:33:07 UTC
  • Revision ID: james.westby@ubuntu.com-20050227093307-cn789t27ibnlh6tf
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*++
 
2
/* NAME
 
3
/*      virtual 3h
 
4
/* SUMMARY
 
5
/*      virtual mail delivery
 
6
/* SYNOPSIS
 
7
/*      #include "virtual.h"
 
8
/* DESCRIPTION
 
9
/* .nf
 
10
 
 
11
 /*
 
12
  * System library.
 
13
  */
 
14
#include <unistd.h>
 
15
 
 
16
 /*
 
17
  * Utility library.
 
18
  */
 
19
#include <vstream.h>
 
20
#include <vstring.h>
 
21
 
 
22
 /*
 
23
  * Global library.
 
24
  */
 
25
#include <deliver_request.h>
 
26
#include <maps.h>
 
27
#include <mbox_conf.h>
 
28
 
 
29
 /*
 
30
  * Mappings.
 
31
  */
 
32
extern MAPS *virtual_mailbox_maps;
 
33
extern MAPS *virtual_uid_maps;
 
34
extern MAPS *virtual_gid_maps;
 
35
 
 
36
 /*
 
37
  * User attributes: these control the privileges for delivery to external
 
38
  * commands, external files, or mailboxes, and the initial environment of
 
39
  * external commands.
 
40
  */
 
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 */
 
45
} USER_ATTR;
 
46
 
 
47
 /*
 
48
  * Critical macros. Not for obscurity, but to ensure consistency.
 
49
  */
 
50
#define RESET_USER_ATTR(usr_attr, level) { \
 
51
        usr_attr.uid = 0; usr_attr.gid = 0; usr_attr.mailbox = 0; \
 
52
        if (msg_verbose) \
 
53
            msg_info("%s[%d]: reset user_attr", myname, level); \
 
54
    }
 
55
 
 
56
 /*
 
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
 
60
  * changes.
 
61
  */
 
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 */
 
76
} DELIVER_ATTR;
 
77
 
 
78
extern void deliver_attr_init(DELIVER_ATTR *);
 
79
extern void deliver_attr_dump(DELIVER_ATTR *);
 
80
 
 
81
#define FEATURE_NODELIVERED     (1<<0)  /* no delivered-to */
 
82
 
 
83
 /*
 
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.
 
87
  */
 
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 */
 
92
} LOCAL_STATE;
 
93
 
 
94
 /*
 
95
  * Bundle up some often-user attributes.
 
96
  */
 
97
#define BOUNCE_FLAGS(request)   DEL_REQ_TRACE_FLAGS((request)->flags)
 
98
 
 
99
#define BOUNCE_ATTR(attr)       attr.queue_id, attr.orig_rcpt, attr.recipient, \
 
100
                                        attr.rcpt_offset, attr.relay, \
 
101
                                        attr.arrival_time
 
102
#define SENT_ATTR(attr)         attr.queue_id, attr.orig_rcpt, attr.recipient, \
 
103
                                        attr.rcpt_offset, attr.relay, \
 
104
                                        attr.arrival_time
 
105
#define COPY_ATTR(attr)         attr.sender, attr.orig_rcpt, attr.delivered, \
 
106
                                        attr.fp
 
107
 
 
108
#define MSG_LOG_STATE(m, p) \
 
109
        msg_info("%s[%d]: recip %s deliver %s", m, \
 
110
                p.level, \
 
111
                p.msg_attr.recipient ? p.msg_attr.recipient : "", \
 
112
                p.msg_attr.delivered ? p.msg_attr.delivered : "")
 
113
 
 
114
 /*
 
115
  * "inner" nodes of the delivery graph.
 
116
  */
 
117
extern int deliver_recipient(LOCAL_STATE, USER_ATTR);
 
118
 
 
119
 /*
 
120
  * "leaf" nodes of the delivery graph.
 
121
  */
 
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);
 
126
 
 
127
 /*
 
128
  * Mailbox lock protocol.
 
129
  */
 
130
extern int virtual_mbox_lock_mask;
 
131
 
 
132
/* LICENSE
 
133
/* .ad
 
134
/* .fi
 
135
/*      The Secure Mailer license must be distributed with this software.
 
136
/* AUTHOR(S)
 
137
/*      Wietse Venema
 
138
/*      IBM T.J. Watson Research
 
139
/*      P.O. Box 704
 
140
/*      Yorktown Heights, NY 10598, USA
 
141
/*--*/