1*41fbaed0Stron /*	$NetBSD: input_transp.c,v 1.1.1.1 2009/06/23 10:08:46 tron Exp $	*/
2*41fbaed0Stron 
3*41fbaed0Stron /*++
4*41fbaed0Stron /* NAME
5*41fbaed0Stron /*	input_transp 3
6*41fbaed0Stron /* SUMMARY
7*41fbaed0Stron /*	receive transparency control
8*41fbaed0Stron /* SYNOPSIS
9*41fbaed0Stron /*	#include <input_transp.h>
10*41fbaed0Stron /*
11*41fbaed0Stron /*	int	input_transp_mask(param_name, pattern)
12*41fbaed0Stron /*	const char *param_name;
13*41fbaed0Stron /*	const char *pattern;
14*41fbaed0Stron /*
15*41fbaed0Stron /*	int	input_transp_cleanup(cleanup_flags, transp_mask)
16*41fbaed0Stron /*	int	cleanup_flags;
17*41fbaed0Stron /*	int	transp_mask;
18*41fbaed0Stron /* DESCRIPTION
19*41fbaed0Stron /*	This module controls how much processing happens before mail is
20*41fbaed0Stron /*	written to the Postfix queue. Each transparency option is either
21*41fbaed0Stron /*	implemented by a client of the cleanup service, or is passed
22*41fbaed0Stron /*	along in a client request to the cleanup service. This eliminates
23*41fbaed0Stron /*	the need to configure multiple cleanup service instances.
24*41fbaed0Stron /*
25*41fbaed0Stron /*	input_transp_mask() takes a comma-separated list of names and
26*41fbaed0Stron /*	computes the corresponding mask. The following names are
27*41fbaed0Stron /*	recognized in \fBpattern\fR, with the corresponding bit mask
28*41fbaed0Stron /*	given in parentheses:
29*41fbaed0Stron /* .IP "no_unknown_recipient_checks (INPUT_TRANSP_UNKNOWN_RCPT)"
30*41fbaed0Stron /*	Do not try to reject unknown recipients.
31*41fbaed0Stron /* .IP "no_address_mappings (INPUT_TRANSP_ADDRESS_MAPPING)"
32*41fbaed0Stron /*	Disable canonical address mapping, virtual alias map expansion,
33*41fbaed0Stron /*	address masquerading, and automatic BCC recipients.
34*41fbaed0Stron /* .IP "no_header_body_checks (INPUT_TRANSP_HEADER_BODY)"
35*41fbaed0Stron /*	Disable header/body_checks.
36*41fbaed0Stron /* .IP "no_milters (INPUT_TRANSP_MILTER)"
37*41fbaed0Stron /*	Disable Milter applications.
38*41fbaed0Stron /*
39*41fbaed0Stron /*	input_transp_cleanup() takes a bunch of cleanup processing
40*41fbaed0Stron /*	flags and updates them according to the settings in the
41*41fbaed0Stron /*	specified input transparency mask.
42*41fbaed0Stron /* DIAGNOSTICS
43*41fbaed0Stron /*	Panic: inappropriate use.
44*41fbaed0Stron /* LICENSE
45*41fbaed0Stron /* .ad
46*41fbaed0Stron /* .fi
47*41fbaed0Stron /*	The Secure Mailer license must be distributed with this software.
48*41fbaed0Stron /* AUTHOR(S)
49*41fbaed0Stron /*	Wietse Venema
50*41fbaed0Stron /*	IBM T.J. Watson Research
51*41fbaed0Stron /*	P.O. Box 704
52*41fbaed0Stron /*	Yorktown Heights, NY 10598, USA
53*41fbaed0Stron /*--*/
54*41fbaed0Stron 
55*41fbaed0Stron /* System library. */
56*41fbaed0Stron 
57*41fbaed0Stron #include <sys_defs.h>
58*41fbaed0Stron 
59*41fbaed0Stron /* Utility library. */
60*41fbaed0Stron 
61*41fbaed0Stron #include <name_mask.h>
62*41fbaed0Stron #include <msg.h>
63*41fbaed0Stron 
64*41fbaed0Stron /* Global library. */
65*41fbaed0Stron 
66*41fbaed0Stron #include <mail_params.h>
67*41fbaed0Stron #include <cleanup_user.h>
68*41fbaed0Stron #include <input_transp.h>
69*41fbaed0Stron 
70*41fbaed0Stron /* input_transp_mask - compute mail receive transparency mask */
71*41fbaed0Stron 
input_transp_mask(const char * param_name,const char * pattern)72*41fbaed0Stron int     input_transp_mask(const char *param_name, const char *pattern)
73*41fbaed0Stron {
74*41fbaed0Stron     static const NAME_MASK table[] = {
75*41fbaed0Stron 	"no_unknown_recipient_checks", INPUT_TRANSP_UNKNOWN_RCPT,
76*41fbaed0Stron 	"no_address_mappings", INPUT_TRANSP_ADDRESS_MAPPING,
77*41fbaed0Stron 	"no_header_body_checks", INPUT_TRANSP_HEADER_BODY,
78*41fbaed0Stron 	"no_milters", INPUT_TRANSP_MILTER,
79*41fbaed0Stron 	0,
80*41fbaed0Stron     };
81*41fbaed0Stron 
82*41fbaed0Stron     return (name_mask(param_name, table, pattern));
83*41fbaed0Stron }
84*41fbaed0Stron 
85*41fbaed0Stron /* input_transp_cleanup - adjust cleanup options */
86*41fbaed0Stron 
input_transp_cleanup(int cleanup_flags,int transp_mask)87*41fbaed0Stron int     input_transp_cleanup(int cleanup_flags, int transp_mask)
88*41fbaed0Stron {
89*41fbaed0Stron     const char *myname = "input_transp_cleanup";
90*41fbaed0Stron 
91*41fbaed0Stron     if (msg_verbose)
92*41fbaed0Stron 	msg_info("before %s: cleanup flags = %s",
93*41fbaed0Stron 		 myname, cleanup_strflags(cleanup_flags));
94*41fbaed0Stron     if (transp_mask & INPUT_TRANSP_ADDRESS_MAPPING)
95*41fbaed0Stron 	cleanup_flags &= ~(CLEANUP_FLAG_BCC_OK | CLEANUP_FLAG_MAP_OK);
96*41fbaed0Stron     if (transp_mask & INPUT_TRANSP_HEADER_BODY)
97*41fbaed0Stron 	cleanup_flags &= ~CLEANUP_FLAG_FILTER;
98*41fbaed0Stron     if (transp_mask & INPUT_TRANSP_MILTER)
99*41fbaed0Stron 	cleanup_flags &= ~CLEANUP_FLAG_MILTER;
100*41fbaed0Stron     if (msg_verbose)
101*41fbaed0Stron 	msg_info("after %s: cleanup flags = %s",
102*41fbaed0Stron 		 myname, cleanup_strflags(cleanup_flags));
103*41fbaed0Stron     return (cleanup_flags);
104*41fbaed0Stron }
105