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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
/*++
/* NAME
/* postconf_unused 3
/* SUMMARY
/* report unused or deprecated parameters
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void pcf_flag_unused_main_parameters()
/*
/* void pcf_flag_unused_master_parameters()
/* DESCRIPTION
/* These functions must be called after all parameter information
/* is initialized: built-ins, service-defined and user-defined.
/* In other words, don't call these functions with "postconf
/* -d" which ignores user-defined main.cf settings.
/*
/* pcf_flag_unused_main_parameters() reports unused or deprecated
/* "name=value" entries in main.cf.
/*
/* pcf_flag_unused_master_parameters() reports unused or
/* deprecated "-o name=value" entries in master.cf.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* 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
/* porcupine.org
/* Amawalk, NY 10501, USA
/*--*/
/* System library. */
#include <sys_defs.h>
/* Utility library. */
#include <msg.h>
#include <dict.h>
#include <vstream.h>
/* Global library. */
#include <mail_params.h>
#include <mail_conf.h>
/* Application-specific. */
#include <postconf.h>
/*
* Deprecated parameter names and suggested alternatives. If we keep deleted
* parameter names in the table, a warning can still suggest alternatives.
* The downside of keeping deleted names in the table is that we may falsely
* warn about a user-defined parameter whose name matches that of a deleted
* parameter.
*/
typedef struct {
char *name;
char *alternative;
} PCF_DEPR_PARAM_INFO;
static const PCF_DEPR_PARAM_INFO pcf_depr_param_info[] = {
/*
* Parameters with deprecation warnings as of Postfix 3.9. The
* disable_dns_lookups parameter was documented as deprecated since
* Postfix 2.11 but nothing was logged.
*/
"disable_dns_lookups", "specify \"smtp_dns_support_level\"",
"lmtp_use_tls", "specify \"lmtp_tls_security_level\"",
"postscreen_use_tls", "specify \"postscreen_tls_security_level\"",
"smtp_use_tls", "specify \"smtp_tls_security_level\"",
"smtpd_use_tls", "specify \"smtpd_tls_security_level\"",
"tlsproxy_client_use_tls", "specify \"tlsproxy_client_security_level\"",
"tlsproxy_use_tls", "specify \"tlsproxy_tls_security_level\"",
"lmtp_enforce_tls", "lmtp_tls_security_level",
"postscreen_enforce_tls", "specify \"postscreen_tls_security_level\"",
"smtp_enforce_tls", "specify \"smtp_tls_security_level\"",
"smtpd_enforce_tls", "specify \"smtpd_tls_security_level\"",
"tlsproxy_client_enforce_tls", "specify \"tlsproxy_client_security_level\"",
"tlsproxy_enforce_tls", "specify \"tlsproxy_tls_security_level\"",
"lmtp_tls_per_site", "specify \"lmtp_tls_policy_maps\"",
"smtp_tls_per_site", "specify \"smtp_tls_policy_maps\"",
"tlsproxy_client_per_site", "specify \"tlsproxy_client_policy_maps\"",
"smtpd_tls_dh1024_param_file", "do not specify (leave at default)",
"smtpd_tls_eecdh_grade", "do not specify (leave at default)",
"deleted-test-only", "do not specify", /* For testing */
0,
};
static HTABLE *pcf_depr_param_table;
/* pcf_init_depr_params - initialize lookup table */
static void pcf_init_depr_params(void)
{
const PCF_DEPR_PARAM_INFO *dp;
pcf_depr_param_table = htable_create(30);
for (dp = pcf_depr_param_info; dp->name; dp++)
(void) htable_enter(pcf_depr_param_table, dp->name, (void *) dp);
}
/* pcf_flag_unused_parameters - warn about unused parameters */
static void pcf_flag_unused_parameters(DICT *dict, const char *conf_name,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "pcf_flag_unused_parameters";
const PCF_DEPR_PARAM_INFO *dp;
const char *param_name;
const char *param_value;
int how;
/*
* Sanity checks.
*/
if (pcf_param_table == 0)
msg_panic("%s: global parameter table is not initialized", myname);
if (dict->sequence == 0)
msg_panic("%s: parameter dictionary %s has no iterator",
myname, conf_name);
/*
* One-time initialization.
*/
if (pcf_depr_param_table == 0)
pcf_init_depr_params();
/*
* Iterate over all entries, and flag parameter names that aren't used
* anywhere, or that are deprecated. Show the warning message(s) after
* the end of the stdout output.
*/
for (how = DICT_SEQ_FUN_FIRST;
dict->sequence(dict, how, ¶m_name, ¶m_value) == 0;
how = DICT_SEQ_FUN_NEXT) {
/*
* Flag a parameter that is not used (deleted name, or incorrect
* name).
*/
if (PCF_PARAM_TABLE_LOCATE(pcf_param_table, param_name) == 0
&& (local_scope == 0
|| PCF_PARAM_TABLE_LOCATE(local_scope->valid_names, param_name) == 0)) {
vstream_fflush(VSTREAM_OUT);
if ((dp = (const PCF_DEPR_PARAM_INFO *)
htable_find(pcf_depr_param_table, param_name)) != 0) {
msg_warn("%s/%s: support for parameter %s has been removed;"
" instead, %s", var_config_dir, conf_name,
param_name, dp->alternative);
} else {
msg_warn("%s/%s: unused parameter: %s=%s",
var_config_dir, conf_name, param_name, param_value);
}
}
/*
* Flag a parameter that is used but deprecated. Note that this may
* falsely complain about a user-defined parameter whose name matches
* that of a deleted parameter.
*/
else if ((dp = (const PCF_DEPR_PARAM_INFO *)
htable_find(pcf_depr_param_table, param_name)) != 0) {
vstream_fflush(VSTREAM_OUT);
msg_warn("%s/%s: support for parameter \"%s\" will be removed;"
" instead, %s", var_config_dir, conf_name,
param_name, dp->alternative);
}
}
}
/* pcf_flag_unused_main_parameters - warn about unused parameters */
void pcf_flag_unused_main_parameters(void)
{
const char *myname = "pcf_flag_unused_main_parameters";
DICT *dict;
/*
* Iterate over all main.cf entries, and flag parameter names that aren't
* used anywhere.
*/
if ((dict = dict_handle(CONFIG_DICT)) == 0)
msg_panic("%s: parameter dictionary %s not found",
myname, CONFIG_DICT);
pcf_flag_unused_parameters(dict, MAIN_CONF_FILE, (PCF_MASTER_ENT *) 0);
}
/* pcf_flag_unused_master_parameters - warn about unused parameters */
void pcf_flag_unused_master_parameters(void)
{
const char *myname = "pcf_flag_unused_master_parameters";
PCF_MASTER_ENT *masterp;
DICT *dict;
/*
* Sanity checks.
*/
if (pcf_master_table == 0)
msg_panic("%s: master table is not initialized", myname);
/*
* Iterate over all master.cf entries, and flag parameter names that
* aren't used anywhere.
*/
for (masterp = pcf_master_table; masterp->argv != 0; masterp++)
if ((dict = masterp->all_params) != 0)
pcf_flag_unused_parameters(dict, MASTER_CONF_FILE, masterp);
}
|