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