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