1 #ifndef _MAIL_PROTO_H_INCLUDED_
2 #define _MAIL_PROTO_H_INCLUDED_
3 
4 /*++
5 /* NAME
6 /*	mail_proto 3h
7 /* SUMMARY
8 /*	mail internal and external protocol support
9 /* SYNOPSIS
10 /*	#include <mail_proto.h>
11 /* DESCRIPTION
12 /* .nf
13 
14  /*
15   * System library.
16   */
17 #include <stdarg.h>
18 #include <string.h>
19 
20  /*
21   * Utility library.
22   */
23 #include <vstream.h>
24 #include <iostuff.h>
25 #include <attr.h>
26 
27  /*
28   * External protocols.
29   */
30 #define MAIL_PROTO_SMTP		"SMTP"
31 #define MAIL_PROTO_ESMTP	"ESMTP"
32 #define MAIL_PROTO_QMQP		"QMQP"
33 
34  /*
35   * Names of services: these are the names of the UNIX-domain socket or or
36   * FIFO that a service listens on.
37   */
38 #define MAIL_SERVICE_BOUNCE	"bounce"
39 #define MAIL_SERVICE_CLEANUP	"cleanup"
40 #define MAIL_SERVICE_DEFER	"defer"
41 #define MAIL_SERVICE_FORWARD	"forward"
42 #define MAIL_SERVICE_LOCAL	"local"
43 #define MAIL_SERVICE_PICKUP	"pickup"
44 #define MAIL_SERVICE_QUEUE	"qmgr"
45 #define MAIL_SERVICE_TLSMGR	"tlsmgr"
46 #define MAIL_SERVICE_RESOLVE	"resolve"
47 #define MAIL_SERVICE_REWRITE	"rewrite"
48 #define MAIL_SERVICE_VIRTUAL	"virtual"
49 #define MAIL_SERVICE_SMTP	"smtp"
50 #define MAIL_SERVICE_SMTPD	"smtpd"
51 #define MAIL_SERVICE_SHOWQ	"showq"
52 #define MAIL_SERVICE_ERROR	"error"
53 #define MAIL_SERVICE_RETRY	"retry"
54 #define MAIL_SERVICE_FLUSH	"flush"
55 #define MAIL_SERVICE_VERIFY	"verify"
56 #define MAIL_SERVICE_TRACE	"trace"
57 #define MAIL_SERVICE_RELAY	"relay"
58 #define MAIL_SERVICE_PROXYMAP	"proxymap"
59 #define MAIL_SERVICE_PROXYWRITE	"proxywrite"
60 #define MAIL_SERVICE_SCACHE	"scache"
61 #define MAIL_SERVICE_DNSBLOG	"dnsblog"
62 #define MAIL_SERVICE_TLSPROXY	"tlsproxy"
63 #define MAIL_SERVICE_POSTLOG	"postlog"
64 
65  /*
66   * Mail source classes. Used to specify policy decisions for content
67   * inspection and SMTPUTF8 detection.
68   */
69 #define MAIL_SRC_NAME_SENDMAIL	"sendmail"	/* sendmail(1) */
70 #define MAIL_SRC_NAME_SMTPD	"smtpd"	/* smtpd(8) */
71 #define MAIL_SRC_NAME_QMQPD	"qmqpd"	/* qmqpd(8) */
72 #define MAIL_SRC_NAME_FORWARD	"forward"	/* local(8) forward/alias */
73 #define MAIL_SRC_NAME_BOUNCE	"bounce"/* bounce(8) */
74 #define MAIL_SRC_NAME_NOTIFY	"notify"/* protocol etc. errors */
75 #define MAIL_SRC_NAME_VERIFY	"verify"/* protocol etc. errors */
76 #define MAIL_SRC_NAME_ALL	"all"	/* all sources */
77 
78 #define MAIL_SRC_MASK_SENDMAIL	(1<<0)	/* sendmail(1) */
79 #define MAIL_SRC_MASK_SMTPD	(1<<1)	/* smtpd(8) */
80 #define MAIL_SRC_MASK_QMQPD	(1<<2)	/* qmqpd(8) */
81 #define MAIL_SRC_MASK_FORWARD	(1<<3)	/* local(8) forward/alias */
82 #define MAIL_SRC_MASK_BOUNCE	(1<<4)	/* bounce(8) */
83 #define MAIL_SRC_MASK_NOTIFY	(1<<5)	/* protocol etc. errors */
84 #define MAIL_SRC_MASK_VERIFY	(1<<6)	/* protocol etc. errors */
85 
86 #define MAIL_SRC_MASK_ALL \
87 	( MAIL_SRC_MASK_SENDMAIL | MAIL_SRC_MASK_SMTPD \
88 	| MAIL_SRC_MASK_QMQPD |  MAIL_SRC_MASK_FORWARD \
89 	| MAIL_SRC_MASK_BOUNCE | MAIL_SRC_MASK_NOTIFY \
90 	| MAIL_SRC_MASK_VERIFY)
91 
92  /*
93   * Well-known socket or FIFO directories. The main difference is in file
94   * access permissions.
95   */
96 #define MAIL_CLASS_PUBLIC	"public"
97 #define MAIL_CLASS_PRIVATE	"private"
98 
99  /*
100   * Generic triggers.
101   */
102 #define TRIGGER_REQ_WAKEUP	'W'	/* wakeup */
103 
104  /*
105   * Queue manager requests.
106   */
107 #define QMGR_REQ_SCAN_DEFERRED	'D'	/* scan deferred queue */
108 #define QMGR_REQ_SCAN_INCOMING	'I'	/* scan incoming queue */
109 #define QMGR_REQ_FLUSH_DEAD	'F'	/* flush dead xport/site */
110 #define QMGR_REQ_SCAN_ALL	'A'	/* ignore time stamps */
111 
112  /*
113   * Functional interface.
114   */
115 extern VSTREAM *mail_connect(const char *, const char *, int);
116 extern VSTREAM *mail_connect_wait(const char *, const char *);
117 extern int mail_command_client(const char *, const char *, const char *,...);
118 extern int mail_command_server(VSTREAM *,...);
119 extern int mail_trigger(const char *, const char *, const char *, ssize_t);
120 extern char *mail_pathname(const char *, const char *);
121 
122  /*
123   * Each Postfix internal service identifies the protocol that it intends to
124   * use. On the receiver end, this information does not contribute to the
125   * reported number of received attributes (it is a constant).
126   */
127 #define MAIL_ATTR_PROTO		"protocol"
128 
129 #define MAIL_ATTR_PROTO_ANVIL	"anvil_protocol"
130 #define MAIL_ATTR_PROTO_BOUNCE	"delivery_status_protocol"
131 #define MAIL_ATTR_PROTO_CLEANUP	"cleanup_protocol"
132 #define MAIL_ATTR_PROTO_DELIVER	"delivery_request_protocol"
133 #define MAIL_ATTR_PROTO_FLUSH	"queue_flush_protocol"
134 #define MAIL_ATTR_PROTO_POSTDROP "postdrop_protocol"
135 #define MAIL_ATTR_PROTO_PROXYMAP "proxymap_protocol"
136 #define MAIL_ATTR_PROTO_SCACHE	"connection_cache_protocol"
137 #define MAIL_ATTR_PROTO_SHOWQ	"mail_queue_list_protocol"
138 #define MAIL_ATTR_PROTO_TLSMGR	"tlsmgr_protocol"
139 #define MAIL_ATTR_PROTO_TLSPROXY "tlsproxy_protocol"
140 #define MAIL_ATTR_PROTO_TRIVIAL	"trivial_rewrite_protocol"
141 #define MAIL_ATTR_PROTO_VERIFY	"address_verification_prrotocol"
142 
143  /*
144   * Attribute names.
145   */
146 #define MAIL_ATTR_REQ		"request"
147 #define MAIL_ATTR_NREQ		"nrequest"
148 #define MAIL_ATTR_STATUS	"status"
149 
150 #define MAIL_ATTR_FLAGS		"flags"
151 #define MAIL_ATTR_QUEUE		"queue_name"
152 #define MAIL_ATTR_QUEUEID	"queue_id"
153 #define MAIL_ATTR_SENDER	"sender"
154 #define MAIL_ATTR_RCPT_COUNT	"recipient_count"
155 #define MAIL_ATTR_ORCPT		"original_recipient"
156 #define MAIL_ATTR_RECIP		"recipient"
157 #define MAIL_ATTR_WHY		"reason"
158 #define MAIL_ATTR_VERPDL	"verp_delimiters"
159 #define MAIL_ATTR_SITE		"site"
160 #define MAIL_ATTR_OFFSET	"offset"
161 #define MAIL_ATTR_SIZE		"size"
162 #define MAIL_ATTR_ERRTO		"errors-to"
163 #define MAIL_ATTR_RRCPT		"return-receipt"
164 #define MAIL_ATTR_TIME		"time"
165 #define MAIL_ATTR_LOCALTIME	"localtime"
166 #define MAIL_ATTR_CREATE_TIME	"create_time"
167 #define MAIL_ATTR_RULE		"rule"
168 #define MAIL_ATTR_ADDR		"address"
169 #define MAIL_ATTR_TRANSPORT	"transport"
170 #define MAIL_ATTR_NEXTHOP	"nexthop"
171 #define MAIL_ATTR_TRACE_FLAGS	"trace_flags"
172 #define MAIL_ATTR_ADDR_STATUS	"recipient_status"
173 #define MAIL_ATTR_ACTION	"action"
174 #define MAIL_ATTR_TABLE		"table"
175 #define MAIL_ATTR_KEY		"key"
176 #define MAIL_ATTR_VALUE		"value"
177 #define MAIL_ATTR_INSTANCE	"instance"
178 #define MAIL_ATTR_SASL_METHOD	"sasl_method"
179 #define MAIL_ATTR_SASL_USERNAME	"sasl_username"
180 #define MAIL_ATTR_SASL_SENDER	"sasl_sender"
181 #define MAIL_ATTR_ETRN_DOMAIN	"etrn_domain"
182 #define MAIL_ATTR_DUMMY		"dummy"
183 #define MAIL_ATTR_STRESS	"stress"
184 #define MAIL_ATTR_LOG_IDENT	"log_ident"
185 #define MAIL_ATTR_RWR_CONTEXT	"rewrite_context"
186 #define MAIL_ATTR_POL_CONTEXT	"policy_context"
187 #define MAIL_ATTR_FORCED_EXPIRE	"forced_expire"
188 
189 #define MAIL_ATTR_RWR_LOCAL	"local"
190 #define MAIL_ATTR_RWR_REMOTE	"remote"
191 
192 #define MAIL_ATTR_TTL		"ttl"
193 #define MAIL_ATTR_LABEL		"label"
194 #define MAIL_ATTR_PROP		"property"
195 #define MAIL_ATTR_FUNC		"function"
196 #define MAIL_ATTR_CCERT_SUBJECT	"ccert_subject"
197 #define MAIL_ATTR_CCERT_ISSUER	"ccert_issuer"
198 #define MAIL_ATTR_CCERT_CERT_FPRINT "ccert_fingerprint"
199 #define MAIL_ATTR_CCERT_PKEY_FPRINT "ccert_pubkey_fingerprint"
200 #define MAIL_ATTR_CRYPTO_PROTOCOL "encryption_protocol"
201 #define MAIL_ATTR_CRYPTO_CIPHER	"encryption_cipher"
202 #define MAIL_ATTR_CRYPTO_KEYSIZE "encryption_keysize"
203 
204  /*
205   * Suffixes for sender_name, sender_domain etc.
206   */
207 #define MAIL_ATTR_S_NAME	"_name"
208 #define MAIL_ATTR_S_DOMAIN	"_domain"
209 
210  /*
211   * Special names for RBL results.
212   */
213 #define MAIL_ATTR_RBL_WHAT	"rbl_what"
214 #define MAIL_ATTR_RBL_DOMAIN	"rbl_domain"
215 #define MAIL_ATTR_RBL_REASON	"rbl_reason"
216 #define MAIL_ATTR_RBL_TXT	"rbl_txt"	/* LaMont compatibility */
217 #define MAIL_ATTR_RBL_CLASS	"rbl_class"
218 #define MAIL_ATTR_RBL_CODE	"rbl_code"
219 #define MAIL_ATTR_RBL_ADDR	"rbl_addr"
220 
221  /*
222   * The following attribute names are stored in queue files. Changing this
223   * means lots of work to maintain backwards compatibility with queued mail.
224   */
225 #define MAIL_ATTR_ENCODING	"encoding"	/* internal encoding */
226 #define MAIL_ATTR_ENC_8BIT	"8bit"	/* 8BITMIME equivalent */
227 #define MAIL_ATTR_ENC_7BIT	"7bit"	/* 7BIT equivalent */
228 #define MAIL_ATTR_ENC_NONE	""	/* encoding unknown */
229 
230 #define MAIL_ATTR_LOG_CLIENT_NAME "log_client_name"	/* client hostname */
231 #define MAIL_ATTR_LOG_CLIENT_ADDR "log_client_address"	/* client address */
232 #define MAIL_ATTR_LOG_CLIENT_PORT "log_client_port"	/* client port */
233 #define MAIL_ATTR_LOG_HELO_NAME	"log_helo_name"	/* SMTP helo name */
234 #define MAIL_ATTR_LOG_PROTO_NAME "log_protocol_name"	/* SMTP/ESMTP/QMQP */
235 #define MAIL_ATTR_LOG_ORIGIN	"log_message_origin"	/* name[addr]:port */
236 
237 #define MAIL_ATTR_ACT_CLIENT	"client"/* client name addr */
238 #define MAIL_ATTR_ACT_CLIENT_NAME "client_name"	/* client name */
239 #define MAIL_ATTR_ACT_CLIENT_ADDR "client_address"	/* client address */
240 #define MAIL_ATTR_ACT_CLIENT_PORT "client_port"	/* client TCP port */
241 #define MAIL_ATTR_ACT_CLIENT_AF	"client_address_type"	/* AF_INET etc. */
242 #define MAIL_ATTR_ACT_HELO_NAME	"helo_name"	/* SMTP helo name */
243 #define MAIL_ATTR_ACT_PROTO_NAME "protocol_name"	/* SMTP/ESMTP/QMQP */
244 #define MAIL_ATTR_ACT_REVERSE_CLIENT_NAME "reverse_client_name"
245 #define MAIL_ATTR_ACT_FORWARD_CLIENT_NAME "forward_client_name"
246 
247 #define MAIL_ATTR_ACT_SERVER_ADDR "server_address"	/* server address */
248 #define MAIL_ATTR_ACT_SERVER_PORT "server_port"	/* server TCP port */
249 
250 #define MAIL_ATTR_PROTO_STATE	"protocol_state"	/* MAIL/RCPT/... */
251 #define MAIL_ATTR_ORG_NONE	"unknown"	/* origin unknown */
252 #define MAIL_ATTR_ORG_LOCAL	"local"	/* local submission */
253 
254  /*
255   * XCLIENT/XFORWARD in SMTP.
256   */
257 #define XCLIENT_CMD		"XCLIENT"	/* XCLIENT command */
258 #define XCLIENT_NAME		"NAME"	/* client name */
259 #define XCLIENT_REVERSE_NAME	"REVERSE_NAME"	/* reverse client name */
260 #ifdef FORWARD_CLIENT_NAME
261 #define XCLIENT_FORWARD_NAME	"FORWARD_NAME"	/* forward client name */
262 #endif
263 #define XCLIENT_ADDR		"ADDR"	/* client address */
264 #define XCLIENT_PORT		"PORT"	/* client port */
265 #define XCLIENT_PROTO		"PROTO"	/* client protocol */
266 #define XCLIENT_HELO		"HELO"	/* client helo */
267 #define XCLIENT_LOGIN		"LOGIN"	/* SASL login name */
268 #define XCLIENT_DESTADDR	"DESTADDR"	/* server address */
269 #define XCLIENT_DESTPORT	"DESTPORT"	/* server port */
270 
271 #define XCLIENT_UNAVAILABLE	"[UNAVAILABLE]"	/* permanently unavailable */
272 #define XCLIENT_TEMPORARY	"[TEMPUNAVAIL]"	/* temporarily unavailable */
273 
274 #define XFORWARD_CMD		"XFORWARD"	/* XFORWARD command */
275 #define XFORWARD_NAME		"NAME"	/* client name */
276 #define XFORWARD_ADDR		"ADDR"	/* client address */
277 #define XFORWARD_PORT		"PORT"	/* client port */
278 #define XFORWARD_PROTO		"PROTO"	/* client protocol */
279 #define XFORWARD_HELO		"HELO"	/* client helo */
280 #define XFORWARD_IDENT		"IDENT"	/* message identifier */
281 #define XFORWARD_DOMAIN		"SOURCE"/* origin type */
282 #define XFORWARD_DOM_LOCAL	"LOCAL"	/* local origin */
283 #define XFORWARD_DOM_REMOTE	"REMOTE"/* remote origin */
284 
285 #define XFORWARD_UNAVAILABLE	"[UNAVAILABLE]"	/* attribute unavailable */
286 
287  /*
288   * DSN support.
289   */
290 #define MAIL_ATTR_DSN_STATUS	"status"/* XXX Postfix <2.3 compat */
291 #define MAIL_ATTR_DSN_DTYPE	"diag_type"	/* dsn diagnostic code */
292 #define MAIL_ATTR_DSN_DTEXT	"diag_text"	/* dsn diagnostic code */
293 #define MAIL_ATTR_DSN_MTYPE	"mta_type"	/* dsn remote MTA */
294 #define MAIL_ATTR_DSN_MNAME	"mta_mname"	/* dsn remote MTA */
295 #define MAIL_ATTR_DSN_ACTION	"action"/* XXX Postfix <2.3 compat */
296 #define MAIL_ATTR_DSN_ENVID	"envelope_id"	/* dsn envelope id */
297 #define MAIL_ATTR_DSN_RET	"ret_flags"	/* dsn full/headers */
298 #define MAIL_ATTR_DSN_NOTIFY	"notify_flags"	/* dsn notify flags */
299 #define MAIL_ATTR_DSN_ORCPT	"dsn_orig_rcpt"	/* dsn original recipient */
300 #define MAIL_ATTR_SMTPUTF8	"smtputf8"	/* RFC6531 support */
301 
302  /*
303   * SMTP reply footer support.
304   */
305 #define MAIL_ATTR_SERVER_NAME	"server_name"
306 
307 /* LICENSE
308 /* .ad
309 /* .fi
310 /*	The Secure Mailer license must be distributed with this software.
311 /* AUTHOR(S)
312 /*	Wietse Venema
313 /*	IBM T.J. Watson Research
314 /*	P.O. Box 704
315 /*	Yorktown Heights, NY 10598, USA
316 /*
317 /*	Wietse Venema
318 /*	Google, Inc.
319 /*	111 8th Avenue
320 /*	New York, NY 10011, USA
321 /*--*/
322 
323 #endif
324