1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/*++
/* NAME
/* cleanup_extracted 3
/* SUMMARY
/* process extracted segment
/* SYNOPSIS
/* #include "cleanup.h"
/*
/* void cleanup_extracted(void)
/* DESCRIPTION
/* This module processes message segments for information
/* extracted from message content. It requires that the input
/* contains no extracted information, and writes extracted
/* information records to the output.
/* 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
/*--*/
/* System library. */
#include <sys_defs.h>
/* Utility library. */
#include <msg.h>
#include <vstring.h>
#include <vstream.h>
#include <argv.h>
#include <mymalloc.h>
/* Global library. */
#include <cleanup_user.h>
#include <record.h>
#include <rec_type.h>
#include <mail_params.h>
#include <ext_prop.h>
/* Application-specific. */
#include "cleanup.h"
#define STR(x) vstring_str(x)
/* cleanup_extracted - generate segment with header-extracted information */
void cleanup_extracted(void)
{
VSTRING *clean_addr;
ARGV *rcpt;
char **cpp;
int type;
/*
* Start the extracted segment, before copying recipient records.
*/
cleanup_out_string(REC_TYPE_XTRA, "");
/*
* Do not complain in case of premature EOF - most likely the client
* aborted the operation.
*
* XXX Rely on the front-end programs to enforce record size limits.
*/
while (CLEANUP_OUT_OK()) {
if ((type = rec_get(cleanup_src, cleanup_inbuf, 0)) < 0) {
cleanup_errs |= CLEANUP_STAT_BAD;
return;
}
if (type == REC_TYPE_RRTO) {
/* XXX Use extracted information instead. */ ;
} else if (type == REC_TYPE_ERTO) {
/* XXX Use extracted information instead. */ ;
} else if (type == REC_TYPE_RCPT) {
clean_addr = vstring_alloc(100);
cleanup_rewrite_internal(clean_addr, *STR(cleanup_inbuf) ?
STR(cleanup_inbuf) : var_empty_addr);
if (cleanup_rcpt_canon_maps)
cleanup_map11_internal(clean_addr, cleanup_rcpt_canon_maps,
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
if (cleanup_comm_canon_maps)
cleanup_map11_internal(clean_addr, cleanup_comm_canon_maps,
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
cleanup_out_recipient(STR(clean_addr));
if (cleanup_recip == 0)
cleanup_recip = mystrdup(STR(clean_addr));
vstring_free(clean_addr);
} else if (type == REC_TYPE_END) {
break;
} else {
msg_warn("%s: unexpected record type %d in extracted segment",
cleanup_queue_id, type);
cleanup_errs |= CLEANUP_STAT_BAD;
if (type >= 0)
cleanup_skip();
return;
}
}
/*
* Always emit Return-Receipt-To and Errors-To records, and always emit
* them ahead of extracted recipients, so that the queue manager does not
* waste lots of time searching through large numbers of recipient
* addresses.
*/
cleanup_out_string(REC_TYPE_RRTO, cleanup_return_receipt ?
cleanup_return_receipt : "");
cleanup_out_string(REC_TYPE_ERTO, cleanup_errors_to ?
cleanup_errors_to : cleanup_sender);
/*
* Optionally account for missing recipient envelope records.
*
* Don't extract recipients when some header was too long. We have
* incomplete information.
*
* XXX Code duplication from cleanup_envelope.c. This should be in one
* place.
*/
if (cleanup_recip == 0 && (cleanup_errs & CLEANUP_STAT_HOVFL) == 0) {
rcpt = (cleanup_resent[0] ? cleanup_resent_recip : cleanup_recipients);
if (*var_always_bcc && rcpt->argv[0]) {
clean_addr = vstring_alloc(100);
cleanup_rewrite_internal(clean_addr, var_always_bcc);
if (cleanup_rcpt_canon_maps)
cleanup_map11_internal(clean_addr, cleanup_rcpt_canon_maps,
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
if (cleanup_comm_canon_maps)
cleanup_map11_internal(clean_addr, cleanup_comm_canon_maps,
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
argv_add(rcpt, STR(clean_addr), (char *) 0);
vstring_free(clean_addr);
}
argv_terminate(rcpt);
for (cpp = rcpt->argv; CLEANUP_OUT_OK() && *cpp; cpp++)
cleanup_out_recipient(*cpp);
if (rcpt->argv[0])
cleanup_recip = mystrdup(rcpt->argv[0]);
}
/*
* Terminate the extracted segment.
*/
cleanup_out_string(REC_TYPE_END, "");
}
|