/*++ /* NAME /* deliver_request 3 /* SUMMARY /* mail delivery request protocol, server side /* SYNOPSIS /* #include <deliver_request.h> /* /* typedef struct DELIVER_REQUEST { /* .in +5 /* VSTREAM *fp; /* int flags; /* char *queue_name; /* char *queue_id; /* long data_offset; /* long data_size; /* char *nexthop; /* char *encoding; /* int sendopts; /* char *sender; /* MSG_STATS msg_stats; /* RECIPIENT_LIST rcpt_list; /* DSN *hop_status; /* char *client_name; /* char *client_addr; /* char *client_port; /* char *client_proto; /* char *client_helo; /* char *sasl_method; /* char *sasl_username; /* char *sasl_sender; /* char *log_ident; /* char *rewrite_context; /* char *dsn_envid; /* int dsn_ret; /* .in -5 /* } DELIVER_REQUEST; /* /* DELIVER_REQUEST *deliver_request_read(stream) /* VSTREAM *stream; /* /* void deliver_request_done(stream, request, status) /* VSTREAM *stream; /* DELIVER_REQUEST *request; /* int status; /* DESCRIPTION /* This module implements the delivery agent side of the `queue manager /* to delivery agent' protocol. In this game, the queue manager is /* the client, while the delivery agent is the server. /* /* deliver_request_read() reads a client message delivery request, /* opens the queue file, and acquires a shared lock. /* A null result means that the client sent bad information or that /* it went away unexpectedly. /* /* The \fBflags\fR structure member is the bit-wise OR of zero or more /* of the following: /* .IP \fBDEL_REQ_FLAG_SUCCESS\fR /* Delete successful recipients from the queue file. /* /* Note: currently, this also controls whether bounced recipients /* are deleted. /* /* Note: the deliver_completed() function ignores this request /* when the recipient queue file offset is -1. /* .IP \fBDEL_REQ_FLAG_BOUNCE\fR /* Delete bounced recipients from the queue file. Currently, /* this flag is non-functional. /* .PP /* The \fBDEL_REQ_FLAG_DEFLT\fR constant provides a convenient shorthand /* for the most common case: delete successful and bounced recipients. /* /* The \fIhop_status\fR member must be updated by the caller /* when all delivery to the destination in \fInexthop\fR should /* be deferred. This member is passed to dsn_free(). /* /* deliver_request_done() reports the delivery status back to the /* client, including the optional \fIhop_status\fR etc. information, /* closes the queue file, /* and destroys the DELIVER_REQUEST structure. The result is /* non-zero when the status could not be reported to the client. /* DIAGNOSTICS /* Warnings: bad data sent by the client. Fatal errors: out of /* memory, queue file open errors. /* SEE ALSO /* attr_scan(3) low-level intra-mail input routines /* 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 /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA /* /* Wietse Venema /* porcupine.org
/*--*/
/* *Extractthequeuefilename,dataoffset,andsenderaddress.Abort *theconversationwhentheysendbadinformation.
*/ if (attr_scan(stream, ATTR_FLAG_STRICT,
RECV_ATTR_INT(MAIL_ATTR_FLAGS, &request->flags),
RECV_ATTR_STR(MAIL_ATTR_QUEUE, queue_name),
RECV_ATTR_STR(MAIL_ATTR_QUEUEID, queue_id),
RECV_ATTR_LONG(MAIL_ATTR_OFFSET, &request->data_offset),
RECV_ATTR_LONG(MAIL_ATTR_SIZE, &request->data_size),
RECV_ATTR_STR(MAIL_ATTR_NEXTHOP, nexthop),
RECV_ATTR_STR(MAIL_ATTR_ENCODING, encoding),
RECV_ATTR_INT(MAIL_ATTR_SENDOPTS, &sendopts),
RECV_ATTR_STR(MAIL_ATTR_SENDER, address),
RECV_ATTR_STR(MAIL_ATTR_DSN_ENVID, dsn_envid),
RECV_ATTR_INT(MAIL_ATTR_DSN_RET, &dsn_ret),
RECV_ATTR_FUNC(msg_stats_scan, (void *) &request->msg_stats), /* XXX Should be encapsulated with ATTR_TYPE_FUNC. */
RECV_ATTR_STR(MAIL_ATTR_LOG_CLIENT_NAME, client_name),
RECV_ATTR_STR(MAIL_ATTR_LOG_CLIENT_ADDR, client_addr),
RECV_ATTR_STR(MAIL_ATTR_LOG_CLIENT_PORT, client_port),
RECV_ATTR_STR(MAIL_ATTR_LOG_PROTO_NAME, client_proto),
RECV_ATTR_STR(MAIL_ATTR_LOG_HELO_NAME, client_helo), /* XXX Should be encapsulated with ATTR_TYPE_FUNC. */
RECV_ATTR_STR(MAIL_ATTR_SASL_METHOD, sasl_method),
RECV_ATTR_STR(MAIL_ATTR_SASL_USERNAME, sasl_username),
RECV_ATTR_STR(MAIL_ATTR_SASL_SENDER, sasl_sender), /* XXX Ditto if we want to pass TLS certificate info. */
RECV_ATTR_STR(MAIL_ATTR_LOG_IDENT, log_ident),
RECV_ATTR_STR(MAIL_ATTR_RWR_CONTEXT, rewrite_context),
RECV_ATTR_INT(MAIL_ATTR_RCPT_COUNT, &rcpt_count),
ATTR_TYPE_END) != 23) {
msg_warn("%s: error receiving common attributes", myname); return (-1);
} if (mail_open_ok(vstring_str(queue_name),
vstring_str(queue_id), &st, &path) == 0) return (-1);
/* Don't override hand-off time after deliver_pass() delegation. */ if (request->msg_stats.agent_handoff.tv_sec == 0)
GETTIMEOFDAY(&request->msg_stats.agent_handoff);
/* deliver_request_free - clean up delivery request structure */
staticvoid deliver_request_free(DELIVER_REQUEST *request)
{ if (request->fp)
vstream_fclose(request->fp); if (request->queue_name)
myfree(request->queue_name); if (request->queue_id)
myfree(request->queue_id); if (request->nexthop)
myfree(request->nexthop); if (request->encoding)
myfree(request->encoding); if (request->sender)
myfree(request->sender);
recipient_list_free(&request->rcpt_list); if (request->hop_status)
dsn_free(request->hop_status); if (request->client_name)
myfree(request->client_name); if (request->client_addr)
myfree(request->client_addr); if (request->client_port)
myfree(request->client_port); if (request->client_proto)
myfree(request->client_proto); if (request->client_helo)
myfree(request->client_helo); if (request->sasl_method)
myfree(request->sasl_method); if (request->sasl_username)
myfree(request->sasl_username); if (request->sasl_sender)
myfree(request->sasl_sender); if (request->log_ident)
myfree(request->log_ident); if (request->rewrite_context)
myfree(request->rewrite_context); if (request->dsn_envid)
myfree(request->dsn_envid);
myfree((void *) request);
}
/* deliver_request_read - create and read delivery request */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.