Postfix3.3.1
postconf.c
[詳解]
1 /*++
2 /* NAME
3 /* postconf 1
4 /* SUMMARY
5 /* Postfix configuration utility
6 /* SYNOPSIS
7 /* .fi
8 /* .ti -4
9 /* \fBManaging main.cf:\fR
10 /*
11 /* \fBpostconf\fR [\fB-dfhHnopvx\fR] [\fB-c \fIconfig_dir\fR]
12 /* [\fB-C \fIclass,...\fR] [\fIparameter ...\fR]
13 /*
14 /* \fBpostconf\fR [\fB-epv\fR] [\fB-c \fIconfig_dir\fR]
15 /* \fIparameter\fB=\fIvalue ...\fR
16 /*
17 /* \fBpostconf\fR \fB-#\fR [\fB-pv\fR] [\fB-c \fIconfig_dir\fR]
18 /* \fIparameter ...\fR
19 /*
20 /* \fBpostconf\fR \fB-X\fR [\fB-pv\fR] [\fB-c \fIconfig_dir\fR]
21 /* \fIparameter ...\fR
22 /*
23 /* .ti -4
24 /* \fBManaging master.cf service entries:\fR
25 /*
26 /* \fBpostconf\fR \fB-M\fR [\fB-fovx\fR] [\fB-c \fIconfig_dir\fR]
27 /* [\fIservice\fR[\fB/\fItype\fR]\fI ...\fR]
28 /*
29 /* \fBpostconf\fR \fB-M\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
30 /* \fIservice\fB/\fItype\fB=\fIvalue ...\fR
31 /*
32 /* \fBpostconf\fR \fB-M#\fR [\fB-v\fR] [\fB-c \fIconfig_dir\fR]
33 /* \fIservice\fB/\fItype ...\fR
34 /*
35 /* \fBpostconf\fR \fB-MX\fR [\fB-v\fR] [\fB-c \fIconfig_dir\fR]
36 /* \fIservice\fB/\fItype ...\fR
37 /*
38 /* .ti -4
39 /* \fBManaging master.cf service fields:\fR
40 /*
41 /* \fBpostconf\fR \fB-F\fR [\fB-fhHovx\fR] [\fB-c \fIconfig_dir\fR]
42 /* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIfield\fR]]\fI ...\fR]
43 /*
44 /* \fBpostconf\fR \fB-F\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
45 /* \fIservice\fB/\fItype\fB/\fIfield\fB=\fIvalue ...\fR
46 /*
47 /* .ti -4
48 /* \fBManaging master.cf service parameters:\fR
49 /*
50 /* \fBpostconf\fR \fB-P\fR [\fB-fhHovx\fR] [\fB-c \fIconfig_dir\fR]
51 /* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIparameter\fR]]\fI ...\fR]
52 /*
53 /* \fBpostconf\fR \fB-P\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
54 /* \fIservice\fB/\fItype\fB/\fIparameter\fB=\fIvalue ...\fR
55 /*
56 /* \fBpostconf\fR \fB-PX\fR [\fB-v\fR] [\fB-c \fIconfig_dir\fR]
57 /* \fIservice\fB/\fItype\fB/\fIparameter ...\fR
58 /*
59 /* .ti -4
60 /* \fBManaging bounce message templates:\fR
61 /*
62 /* \fBpostconf\fR \fB-b\fR [\fB-v\fR] [\fB-c \fIconfig_dir\fR]
63 /* [\fItemplate_file\fR]
64 /*
65 /* \fBpostconf\fR \fB-t\fR [\fB-v\fR] [\fB-c \fIconfig_dir\fR]
66 /* [\fItemplate_file\fR]
67 /*
68 /* .ti -4
69 /* \fBManaging TLS features:\fR
70 /*
71 /* \fBpostconf\fR \fB-T \fImode\fR [\fB-v\fR] [\fB-c \fIconfig_dir\fR]
72 /*
73 /* .ti -4
74 /* \fBManaging other configuration:\fR
75 /*
76 /* \fBpostconf\fR \fB-a\fR|\fB-A\fR|\fB-l\fR|\fB-m\fR [\fB-v\fR]
77 /* [\fB-c \fIconfig_dir\fR]
78 /* DESCRIPTION
79 /* By default, the \fBpostconf\fR(1) command displays the
80 /* values of \fBmain.cf\fR configuration parameters, and warns
81 /* about possible mis-typed parameter names (Postfix 2.9 and later).
82 /* The command can also change \fBmain.cf\fR configuration
83 /* parameter values, or display other configuration information
84 /* about the Postfix mail system.
85 /*
86 /* Options:
87 /* .IP \fB-a\fR
88 /* List the available SASL plug-in types for the Postfix SMTP
89 /* server. The plug-in type is selected with the \fBsmtpd_sasl_type\fR
90 /* configuration parameter by specifying one of the names
91 /* listed below.
92 /* .RS
93 /* .IP \fBcyrus\fR
94 /* This server plug-in is available when Postfix is built with
95 /* Cyrus SASL support.
96 /* .IP \fBdovecot\fR
97 /* This server plug-in uses the Dovecot authentication server,
98 /* and is available when Postfix is built with any form of SASL
99 /* support.
100 /* .RE
101 /* .IP
102 /* This feature is available with Postfix 2.3 and later.
103 /* .IP \fB-A\fR
104 /* List the available SASL plug-in types for the Postfix SMTP
105 /* client. The plug-in type is selected with the \fBsmtp_sasl_type\fR
106 /* or \fBlmtp_sasl_type\fR configuration parameters by specifying
107 /* one of the names listed below.
108 /* .RS
109 /* .IP \fBcyrus\fR
110 /* This client plug-in is available when Postfix is built with
111 /* Cyrus SASL support.
112 /* .RE
113 /* .IP
114 /* This feature is available with Postfix 2.3 and later.
115 /* .IP "\fB-b\fR [\fItemplate_file\fR]"
116 /* Display the message text that appears at the beginning of
117 /* delivery status notification (DSN) messages, expanding
118 /* $\fBname\fR expressions with actual values as described in
119 /* \fBbounce\fR(5).
120 /*
121 /* To override the \fBbounce_template_file\fR parameter setting,
122 /* specify a template file name at the end of the "\fBpostconf
123 /* -b\fR" command line. Specify an empty file name to display
124 /* built-in templates (in shell language: "").
125 /*
126 /* This feature is available with Postfix 2.3 and later.
127 /* .IP "\fB-c \fIconfig_dir\fR"
128 /* The \fBmain.cf\fR configuration file is in the named directory
129 /* instead of the default configuration directory.
130 /* .IP "\fB-C \fIclass,...\fR"
131 /* When displaying \fBmain.cf\fR parameters, select only
132 /* parameters from the specified class(es):
133 /* .RS
134 /* .IP \fBbuiltin\fR
135 /* Parameters with built-in names.
136 /* .IP \fBservice\fR
137 /* Parameters with service-defined names (the first field of
138 /* a \fBmaster.cf\fR entry plus a Postfix-defined suffix).
139 /* .IP \fBuser\fR
140 /* Parameters with user-defined names.
141 /* .IP \fBall\fR
142 /* All the above classes.
143 /* .RE
144 /* .IP
145 /* The default is as if "\fB-C all\fR" is
146 /* specified.
147 /*
148 /* This feature is available with Postfix 2.9 and later.
149 /* .IP \fB-d\fR
150 /* Print \fBmain.cf\fR default parameter settings instead of
151 /* actual settings.
152 /* Specify \fB-df\fR to fold long lines for human readability
153 /* (Postfix 2.9 and later).
154 /* .IP \fB-e\fR
155 /* Edit the \fBmain.cf\fR configuration file, and update
156 /* parameter settings with the "\fIname=value\fR" pairs on the
157 /* \fBpostconf\fR(1) command line.
158 /*
159 /* With \fB-M\fR, edit the \fBmaster.cf\fR configuration file,
160 /* and replace one or more service entries with new values as
161 /* specified with "\fIservice/type=value\fR" on the \fBpostconf\fR(1)
162 /* command line.
163 /*
164 /* With \fB-F\fR, edit the \fBmaster.cf\fR configuration file,
165 /* and replace one or more service fields with new values as
166 /* specified with "\fIservice/type/field=value\fR" on the
167 /* \fBpostconf\fR(1) command line. Currently, the "command"
168 /* field contains the command name and command arguments. this
169 /* may change in the near future, so that the "command" field
170 /* contains only the command name, and a new "arguments"
171 /* pseudofield contains the command arguments.
172 /*
173 /* With \fB-P\fR, edit the \fBmaster.cf\fR configuration file,
174 /* and add or update one or more service parameter settings
175 /* (-o parameter=value settings) with new values as specified
176 /* with "\fIservice/type/parameter=value\fR" on the \fBpostconf\fR(1)
177 /* command line.
178 /*
179 /* In all cases the file is copied to a temporary file then
180 /* renamed into place. Specify quotes to protect special
181 /* characters and whitespace on the \fBpostconf\fR(1) command
182 /* line.
183 /*
184 /* The \fB-e\fR option is no longer needed with Postfix version
185 /* 2.8 and later.
186 /* .IP \fB-f\fR
187 /* Fold long lines when printing \fBmain.cf\fR or \fBmaster.cf\fR
188 /* configuration file entries, for human readability.
189 /*
190 /* This feature is available with Postfix 2.9 and later.
191 /* .IP \fB-F\fR
192 /* Show \fBmaster.cf\fR per-entry field settings (by default
193 /* all services and all fields), formatted as
194 /* "\fIservice/type/field=value\fR", one per line. Specify
195 /* \fB-Ff\fR to fold long lines.
196 /*
197 /* Specify one or more "\fIservice/type/field\fR" instances
198 /* on the \fBpostconf\fR(1) command line to limit the output
199 /* to fields of interest. Trailing parameter name or service
200 /* type fields that are omitted will be handled as "*" wildcard
201 /* fields.
202 /*
203 /* This feature is available with Postfix 2.11 and later.
204 /* .IP \fB-h\fR
205 /* Show parameter or attribute values without the "\fIname\fR
206 /* = " label that normally precedes the value.
207 /* .IP \fB-H\fR
208 /* Show parameter or attribute names without the " = \fIvalue\fR"
209 /* that normally follows the name.
210 /*
211 /* This feature is available with Postfix 3.1 and later.
212 /* .IP \fB-l\fR
213 /* List the names of all supported mailbox locking methods.
214 /* Postfix supports the following methods:
215 /* .RS
216 /* .IP \fBflock\fR
217 /* A kernel-based advisory locking method for local files only.
218 /* This locking method is available on systems with a BSD
219 /* compatible library.
220 /* .IP \fBfcntl\fR
221 /* A kernel-based advisory locking method for local and remote
222 /* files.
223 /* .IP \fBdotlock\fR
224 /* An application-level locking method. An application locks
225 /* a file named \fIfilename\fR by creating a file named
226 /* \fIfilename\fB.lock\fR. The application is expected to
227 /* remove its own lock file, as well as stale lock files that
228 /* were left behind after abnormal program termination.
229 /* .RE
230 /* .IP \fB-m\fR
231 /* List the names of all supported lookup table types. In
232 /* Postfix configuration files, lookup tables are specified
233 /* as \fItype\fB:\fIname\fR, where \fItype\fR is one of the
234 /* types listed below. The table \fIname\fR syntax depends on
235 /* the lookup table type as described in the DATABASE_README
236 /* document.
237 /* .RS
238 /* .IP \fBbtree\fR
239 /* A sorted, balanced tree structure. Available on systems
240 /* with support for Berkeley DB databases.
241 /* .IP \fBcdb\fR
242 /* A read-optimized structure with no support for incremental
243 /* updates. Available on systems with support for CDB databases.
244 /*
245 /* This feature is available with Postfix 2.2 and later.
246 /* .IP \fBcidr\fR
247 /* A table that associates values with Classless Inter-Domain
248 /* Routing (CIDR) patterns. This is described in \fBcidr_table\fR(5).
249 /*
250 /* This feature is available with Postfix 2.2 and later.
251 /* .IP \fBdbm\fR
252 /* An indexed file type based on hashing. Available on systems
253 /* with support for DBM databases.
254 /* .IP \fBenviron\fR
255 /* The UNIX process environment array. The lookup key is the
256 /* environment variable name; the table name is ignored. Originally
257 /* implemented for testing, someone may find this useful someday.
258 /* .IP \fBfail\fR
259 /* A table that reliably fails all requests. The lookup table
260 /* name is used for logging. This table exists to simplify
261 /* Postfix error tests.
262 /*
263 /* This feature is available with Postfix 2.9 and later.
264 /* .IP \fBhash\fR
265 /* An indexed file type based on hashing. Available on systems
266 /* with support for Berkeley DB databases.
267 /* .IP "\fBinline\fR (read-only)"
268 /* A non-shared, in-memory lookup table. Example: "\fBinline:{
269 /* \fIkey\fB=\fIvalue\fB, { \fIkey\fB = \fItext with whitespace
270 /* or comma\fB }}\fR". Key-value pairs are separated by
271 /* whitespace or comma; whitespace after "\fB{\fR" and before "\fB}\fR"
272 /* is ignored. Inline tables eliminate the need to create a
273 /* database file for just a few fixed elements. See also the
274 /* \fIstatic:\fR map type.
275 /*
276 /* This feature is available with Postfix 3.0 and later.
277 /* .IP \fBinternal\fR
278 /* A non-shared, in-memory hash table. Its content are lost
279 /* when a process terminates.
280 /* .IP "\fBlmdb\fR"
281 /* OpenLDAP LMDB database (a memory-mapped, persistent file).
282 /* Available on systems with support for LMDB databases. This
283 /* is described in \fBlmdb_table\fR(5).
284 /*
285 /* This feature is available with Postfix 2.11 and later.
286 /* .IP "\fBldap\fR (read-only)"
287 /* LDAP database client. This is described in \fBldap_table\fR(5).
288 /* .IP "\fBmemcache\fR"
289 /* Memcache database client. This is described in
290 /* \fBmemcache_table\fR(5).
291 /*
292 /* This feature is available with Postfix 2.9 and later.
293 /* .IP "\fBmysql\fR (read-only)"
294 /* MySQL database client. Available on systems with support
295 /* for MySQL databases. This is described in \fBmysql_table\fR(5).
296 /* .IP "\fBpcre\fR (read-only)"
297 /* A lookup table based on Perl Compatible Regular Expressions.
298 /* The file format is described in \fBpcre_table\fR(5).
299 /* .IP "\fBpgsql\fR (read-only)"
300 /* PostgreSQL database client. This is described in
301 /* \fBpgsql_table\fR(5).
302 /*
303 /* This feature is available with Postfix 2.1 and later.
304 /* .IP "\fBpipemap\fR (read-only)"
305 /* A lookup table that constructs a pipeline of tables. Example:
306 /* "\fBpipemap:{\fItype_1:name_1, ..., type_n:name_n\fB}\fR".
307 /* Each "pipemap:" query is given to the first table. Each
308 /* lookup result becomes the query for the next table in the
309 /* pipeline, and the last table produces the final result.
310 /* When any table lookup produces no result, the pipeline
311 /* produces no result. The first and last characters of the
312 /* "pipemap:" table name must be "\fB{\fR" and "\fB}\fR".
313 /* Within these, individual maps are separated with comma or
314 /* whitespace.
315 /*
316 /* This feature is available with Postfix 3.0 and later.
317 /* .IP "\fBproxy\fR"
318 /* Postfix \fBproxymap\fR(8) client for shared access to Postfix
319 /* databases. The table name syntax is \fItype\fB:\fIname\fR.
320 /*
321 /* This feature is available with Postfix 2.0 and later.
322 /* .IP "\fBrandmap\fR (read-only)"
323 /* An in-memory table that performs random selection. Example:
324 /* "\fBrandmap:{\fIresult_1, ..., result_n\fB}\fR". Each table query
325 /* returns a random choice from the specified results. The first
326 /* and last characters of the "randmap:" table name must be
327 /* "\fB{\fR" and "\fB}\fR". Within these, individual results
328 /* are separated with comma or whitespace. To give a specific
329 /* result more weight, specify it multiple times.
330 /*
331 /* This feature is available with Postfix 3.0 and later.
332 /* .IP "\fBregexp\fR (read-only)"
333 /* A lookup table based on regular expressions. The file format
334 /* is described in \fBregexp_table\fR(5).
335 /* .IP \fBsdbm\fR
336 /* An indexed file type based on hashing. Available on systems
337 /* with support for SDBM databases.
338 /*
339 /* This feature is available with Postfix 2.2 and later.
340 /* .IP "\fBsocketmap\fR (read-only)"
341 /* Sendmail-style socketmap client. The table name is
342 /* \fBinet\fR:\fIhost\fR:\fIport\fR:\fIname\fR for a TCP/IP
343 /* server, or \fBunix\fR:\fIpathname\fR:\fIname\fR for a
344 /* UNIX-domain server. This is described in \fBsocketmap_table\fR(5).
345 /*
346 /* This feature is available with Postfix 2.10 and later.
347 /* .IP "\fBsqlite\fR (read-only)"
348 /* SQLite database. This is described in \fBsqlite_table\fR(5).
349 /*
350 /* This feature is available with Postfix 2.8 and later.
351 /* .IP "\fBstatic\fR (read-only)"
352 /* A table that always returns its name as lookup result. For
353 /* example, \fBstatic:foobar\fR always returns the string
354 /* \fBfoobar\fR as lookup result. Specify "\fBstatic:{ \fItext
355 /* with whitespace\fB }\fR" when the result contains whitespace;
356 /* this form ignores whitespace after "\fB{\fR" and before
357 /* "\fB}\fR". See also the \fIinline:\fR map.
358 /*
359 /* The form "\fBstatic:{\fItext\fB}\fR is available with Postfix
360 /* 3.0 and later.
361 /* .IP "\fBtcp\fR (read-only)"
362 /* TCP/IP client. The protocol is described in \fBtcp_table\fR(5).
363 /* .IP "\fBtexthash\fR (read-only)"
364 /* Produces similar results as hash: files, except that you
365 /* don't need to run the \fBpostmap\fR(1) command before you
366 /* can use the file, and that it does not detect changes after
367 /* the file is read.
368 /*
369 /* This feature is available with Postfix 2.8 and later.
370 /* .IP "\fBunionmap\fR (read-only)"
371 /* A table that sends each query to multiple lookup tables and
372 /* that concatenates all found results, separated by comma.
373 /* The table name syntax is the same as for \fBpipemap\fR.
374 /*
375 /* This feature is available with Postfix 3.0 and later.
376 /* .IP "\fBunix\fR (read-only)"
377 /* A limited view of the UNIX authentication database. The
378 /* following tables are implemented:
379 /* .RS
380 /*. IP \fBunix:passwd.byname\fR
381 /* The table is the UNIX password database. The key is a login
382 /* name. The result is a password file entry in \fBpasswd\fR(5)
383 /* format.
384 /* .IP \fBunix:group.byname\fR
385 /* The table is the UNIX group database. The key is a group
386 /* name. The result is a group file entry in \fBgroup\fR(5)
387 /* format.
388 /* .RE
389 /* .RE
390 /* .IP
391 /* Other table types may exist depending on how Postfix was
392 /* built.
393 /* .IP \fB-M\fR
394 /* Show \fBmaster.cf\fR file contents instead of \fBmain.cf\fR
395 /* file contents. Specify \fB-Mf\fR to fold long lines for
396 /* human readability.
397 /*
398 /* Specify zero or more arguments, each with a \fIservice-name\fR
399 /* or \fIservice-name/service-type\fR pair, where \fIservice-name\fR
400 /* is the first field of a master.cf entry and \fIservice-type\fR
401 /* is one of (\fBinet\fR, \fBunix\fR, \fBfifo\fR, or \fBpass\fR).
402 /*
403 /* If \fIservice-name\fR or \fIservice-name/service-type\fR
404 /* is specified, only the matching master.cf entries will be
405 /* output. For example, "\fBpostconf -Mf smtp\fR" will output
406 /* all services named "smtp", and "\fBpostconf -Mf smtp/inet\fR"
407 /* will output only the smtp service that listens on the
408 /* network. Trailing service type fields that are omitted
409 /* will be handled as "*" wildcard fields.
410 /*
411 /* This feature is available with Postfix 2.9 and later. The
412 /* syntax was changed from "\fIname.type\fR" to "\fIname/type\fR",
413 /* and "*" wildcard support was added with Postfix 2.11.
414 /* .IP \fB-n\fR
415 /* Show only configuration parameters that have explicit
416 /* \fIname=value\fR settings in \fBmain.cf\fR. Specify \fB-nf\fR
417 /* to fold long lines for human readability (Postfix 2.9 and
418 /* later).
419 /* .IP "\fB-o \fIname=value\fR"
420 /* Override \fBmain.cf\fR parameter settings.
421 /*
422 /* This feature is available with Postfix 2.10 and later.
423 /* .IP \fB-p\fR
424 /* Show \fBmain.cf\fR parameter settings. This is the default.
425 /*
426 /* This feature is available with Postfix 2.11 and later.
427 /* .IP \fB-P\fR
428 /* Show \fBmaster.cf\fR service parameter settings (by default
429 /* all services and all parameters), formatted as
430 /* "\fIservice/type/parameter=value\fR", one per line. Specify
431 /* \fB-Pf\fR to fold long lines.
432 /*
433 /* Specify one or more "\fIservice/type/parameter\fR" instances
434 /* on the \fBpostconf\fR(1) command line to limit the output
435 /* to parameters of interest. Trailing parameter name or
436 /* service type fields that are omitted will be handled as "*"
437 /* wildcard fields.
438 /*
439 /* This feature is available with Postfix 2.11 and later.
440 /* .IP "\fB-t\fR [\fItemplate_file\fR]"
441 /* Display the templates for text that appears at the beginning
442 /* of delivery status notification (DSN) messages, without
443 /* expanding $\fBname\fR expressions.
444 /*
445 /* To override the \fBbounce_template_file\fR parameter setting,
446 /* specify a template file name at the end of the "\fBpostconf
447 /* -t\fR" command line. Specify an empty file name to display
448 /* built-in templates (in shell language: "").
449 /*
450 /* This feature is available with Postfix 2.3 and later.
451 /* .IP "\fB-T \fImode\fR"
452 /* If Postfix is compiled without TLS support, the \fB-T\fR option
453 /* produces no output. Otherwise, if an invalid \fImode\fR is specified,
454 /* the \fB-T\fR option reports an error and exits with a non-zero status
455 /* code. The valid modes are:
456 /* .RS
457 /* .IP \fBcompile-version\fR
458 /* Output the OpenSSL version that Postfix was compiled with
459 /* (i.e. the OpenSSL version in a header file). The output
460 /* format is the same as with the command "\fBopenssl version\fR".
461 /* .IP \fBrun-version\fR
462 /* Output the OpenSSL version that Postfix is linked with at
463 /* runtime (i.e. the OpenSSL version in a shared library).
464 /* .IP \fBpublic-key-algorithms\fR
465 /* Output the lower-case names of the supported public-key
466 /* algorithms, one per-line.
467 /* .RE
468 /* .IP
469 /* This feature is available with Postfix 3.1 and later.
470 /* .IP \fB-v\fR
471 /* Enable verbose logging for debugging purposes. Multiple
472 /* \fB-v\fR options make the software increasingly verbose.
473 /* .IP \fB-x\fR
474 /* Expand \fI$name\fR in \fBmain.cf\fR or \fBmaster.cf\fR
475 /* parameter values. The expansion is recursive.
476 /*
477 /* This feature is available with Postfix 2.10 and later.
478 /* .IP \fB-X\fR
479 /* Edit the \fBmain.cf\fR configuration file, and remove the
480 /* parameters named on the \fBpostconf\fR(1) command line.
481 /* Specify a list of parameter names, not "\fIname=value\fR"
482 /* pairs.
483 /*
484 /* With \fB-M\fR, edit the \fBmaster.cf\fR configuration file,
485 /* and remove one or more service entries as specified with
486 /* "\fIservice/type\fR" on the \fBpostconf\fR(1) command line.
487 /*
488 /* With \fB-P\fR, edit the \fBmaster.cf\fR configuration file,
489 /* and remove one or more service parameter settings (-o
490 /* parameter=value settings) as specified with
491 /* "\fIservice/type/parameter\fR" on the \fBpostconf\fR(1)
492 /* command line.
493 /*
494 /* In all cases the file is copied to a temporary file then
495 /* renamed into place. Specify quotes to protect special
496 /* characters on the \fBpostconf\fR(1) command line.
497 /*
498 /* There is no \fBpostconf\fR(1) command to perform the reverse
499 /* operation.
500 /*
501 /* This feature is available with Postfix 2.10 and later.
502 /* Support for -M and -P was added with Postfix 2.11.
503 /* .IP \fB-#\fR
504 /* Edit the \fBmain.cf\fR configuration file, and comment out
505 /* the parameters named on the \fBpostconf\fR(1) command line,
506 /* so that those parameters revert to their default values.
507 /* Specify a list of parameter names, not "\fIname=value\fR"
508 /* pairs.
509 /*
510 /* With \fB-M\fR, edit the \fBmaster.cf\fR configuration file,
511 /* and comment out one or more service entries as specified
512 /* with "\fIservice/type\fR" on the \fBpostconf\fR(1) command
513 /* line.
514 /*
515 /* In all cases the file is copied to a temporary file then
516 /* renamed into place. Specify quotes to protect special
517 /* characters on the \fBpostconf\fR(1) command line.
518 /*
519 /* There is no \fBpostconf\fR(1) command to perform the reverse
520 /* operation.
521 /*
522 /* This feature is available with Postfix 2.6 and later. Support
523 /* for -M was added with Postfix 2.11.
524 /* DIAGNOSTICS
525 /* Problems are reported to the standard error stream.
526 /* ENVIRONMENT
527 /* .ad
528 /* .fi
529 /* .IP \fBMAIL_CONFIG\fR
530 /* Directory with Postfix configuration files.
531 /* CONFIGURATION PARAMETERS
532 /* .ad
533 /* .fi
534 /* The following \fBmain.cf\fR parameters are especially
535 /* relevant to this program.
536 /*
537 /* The text below provides only a parameter summary. See
538 /* \fBpostconf\fR(5) for more details including examples.
539 /* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
540 /* The default location of the Postfix main.cf and master.cf
541 /* configuration files.
542 /* .IP "\fBbounce_template_file (empty)\fR"
543 /* Pathname of a configuration file with bounce message templates.
544 /* FILES
545 /* /etc/postfix/main.cf, Postfix configuration parameters
546 /* /etc/postfix/master.cf, Postfix master daemon configuration
547 /* SEE ALSO
548 /* bounce(5), bounce template file format
549 /* master(5), master.cf configuration file syntax
550 /* postconf(5), main.cf configuration file syntax
551 /* README FILES
552 /* .ad
553 /* .fi
554 /* Use "\fBpostconf readme_directory\fR" or "\fBpostconf
555 /* html_directory\fR" to locate this information.
556 /* .na
557 /* .nf
558 /* DATABASE_README, Postfix lookup table overview
559 /* LICENSE
560 /* .ad
561 /* .fi
562 /* The Secure Mailer license must be distributed with this
563 /* software.
564 /* AUTHOR(S)
565 /* Wietse Venema
566 /* IBM T.J. Watson Research
567 /* P.O. Box 704
568 /* Yorktown Heights, NY 10598, USA
569 /*
570 /* Wietse Venema
571 /* Google, Inc.
572 /* 111 8th Avenue
573 /* New York, NY 10011, USA
574 /*--*/
575 
576 /* System library. */
577 
578 #include <sys_defs.h>
579 #include <sys/stat.h>
580 #include <stdlib.h>
581 
582 /* Utility library. */
583 
584 #include <msg.h>
585 #include <msg_vstream.h>
586 #include <dict.h>
587 #include <htable.h>
588 #include <vstring.h>
589 #include <vstream.h>
590 #include <stringops.h>
591 #include <name_mask.h>
592 #include <warn_stat.h>
593 #include <mymalloc.h>
594 
595 /* Global library. */
596 
597 #include <mail_params.h>
598 #include <mail_conf.h>
599 #include <mail_version.h>
600 #include <mail_run.h>
601 #include <mail_dict.h>
602 
603 /* Application-specific. */
604 
605 #include <postconf.h>
606 
607  /*
608  * Global storage. See postconf.h for description.
609  */
613 
614  /*
615  * Application fingerprinting.
616  */
618 
619  /*
620  * This program has so many command-line options that we have to implement a
621  * compatibility matrix to weed out the conflicting option combinations, and
622  * to alert the user about option combinations that have no effect.
623  */
624 
625  /*
626  * Options that are mutually-exclusive. First entry must specify the major
627  * modes. Other entries specify conflicts between option modifiers.
628  */
629 static const int pcf_incompat_options[] = {
630  /* Major modes. */
634  /* Modifiers. */
636  |PCF_EDIT_EXCL,
640  |PCF_EDIT_EXCL,
643  0,
644 };
645 
646  /*
647  * Options, and the only options that they are compatible with. There must
648  * be one entry for each major mode. Other entries specify compatibility
649  * between option modifiers.
650  */
651 static const int pcf_compat_options[][2] = {
652  /* Major modes. */
653  {PCF_SHOW_SASL_SERV, 0},
654  {PCF_SHOW_SASL_CLNT, 0},
655  {PCF_EXP_DSN_TEMPL, 0},
656  {PCF_SHOW_LOCKS, 0},
657  {PCF_SHOW_MAPS, 0,},
658  {PCF_SHOW_TLS, 0,},
659  {PCF_DUMP_DSN_TEMPL, 0},
670  |PCF_HIDE_VALUE)},
671  /* Modifiers. */
673  0,
674 };
675 
676  /*
677  * Compatibility to string conversion support.
678  */
679 static const NAME_MASK pcf_compat_names[] = {
680  "-a", PCF_SHOW_SASL_SERV,
681  "-A", PCF_SHOW_SASL_CLNT,
682  "-b", PCF_EXP_DSN_TEMPL,
683  "-C", PCF_PARAM_CLASS,
684  "-d", PCF_SHOW_DEFS,
685  "-e", PCF_EDIT_CONF,
686  "-f", PCF_FOLD_LINE,
687  "-F", PCF_MASTER_FLD,
688  "-h", PCF_HIDE_NAME,
689  "-H", PCF_HIDE_VALUE,
690  "-l", PCF_SHOW_LOCKS,
691  "-m", PCF_SHOW_MAPS,
692  "-M", PCF_MASTER_ENTRY,
693  "-n", PCF_SHOW_NONDEF,
694  "-o", PCF_MAIN_OVER,
695  "-p", PCF_MAIN_PARAM,
696  "-P", PCF_MASTER_PARAM,
697  "-t", PCF_DUMP_DSN_TEMPL,
698  "-T", PCF_SHOW_TLS,
699  "-x", PCF_SHOW_EVAL,
700  "-X", PCF_EDIT_EXCL,
701  "-#", PCF_COMMENT_OUT,
702  0,
703 };
704 
705 /* usage - enumerate parameters without compatibility info */
706 
707 static void usage(const char *progname)
708 {
709  msg_fatal("usage: %s"
710  " [-a (server SASL types)]"
711  " [-A (client SASL types)]"
712  " [-b (bounce templates)]"
713  " [-c config_dir]"
714  " [-c param_class]"
715  " [-d (parameter defaults)]"
716  " [-e (edit configuration)]"
717  " [-f (fold lines)]"
718  " [-F (master.cf fields)]"
719  " [-h (no names)]"
720  " [-H (no values)]"
721  " [-l (lock types)]"
722  " [-m (map types)]"
723  " [-M (master.cf)]"
724  " [-n (non-default parameters)]"
725  " [-o name=value (override parameter value)]"
726  " [-p (main.cf, default)]"
727  " [-P (master.cf parameters)]"
728  " [-t (bounce templates)]"
729  " [-T compile-version|run-version|public-key-algorithms]"
730  " [-v (verbose)]"
731  " [-x (expand parameter values)]"
732  " [-X (exclude)]"
733  " [-# (comment-out)]"
734  " [name...]", progname);
735 }
736 
737 /* pcf_check_exclusive_options - complain about mutually-exclusive options */
738 
739 static void pcf_check_exclusive_options(int optval)
740 {
741  const char *myname = "pcf_check_exclusive_options";
742  const int *op;
743  int oval;
744  unsigned mask;
745 
746  for (op = pcf_incompat_options; (oval = *op) != 0; op++) {
747  oval &= optval;
748  for (mask = ~0U; (mask & oval) != 0; mask >>= 1) {
749  if ((mask & oval) != oval)
750  msg_fatal("specify one of %s",
751  str_name_mask(myname, pcf_compat_names, oval));
752  }
753  }
754 }
755 
756 /* pcf_check_compat_options - complain about incompatible options */
757 
758 static void pcf_check_compat_options(int optval)
759 {
760  const char *myname = "pcf_check_compat_options";
761  VSTRING *buf1 = vstring_alloc(10);
762  VSTRING *buf2 = vstring_alloc(10);
763  const int (*op)[2];
764  int excess;
765 
766  for (op = pcf_compat_options; op[0][0] != 0; op++) {
767  if ((optval & *op[0]) != 0
768  && (excess = (optval & ~((*op)[0] | (*op)[1]))) != 0)
769  msg_fatal("with option %s, do not specify %s",
770  str_name_mask_opt(buf1, myname, pcf_compat_names,
771  (*op)[0], NAME_MASK_NUMBER),
772  str_name_mask_opt(buf2, myname, pcf_compat_names,
773  excess, NAME_MASK_NUMBER));
774  }
775  vstring_free(buf1);
776  vstring_free(buf2);
777 }
778 
779 /* main */
780 
781 int main(int argc, char **argv)
782 {
783  int ch;
784  int fd;
785  struct stat st;
786  ARGV *ext_argv = 0;
787  int param_class = PCF_PARAM_MASK_CLASS;
788  static const NAME_MASK param_class_table[] = {
789  "builtin", PCF_PARAM_FLAG_BUILTIN,
790  "service", PCF_PARAM_FLAG_SERVICE,
791  "user", PCF_PARAM_FLAG_USER,
792  "all", PCF_PARAM_MASK_CLASS,
793  0,
794  };
795  ARGV *override_params = 0;
796  const char *pcf_tls_arg = 0;
797 
798  /*
799  * Fingerprint executables and core dumps.
800  */
802 
803  /*
804  * Be consistent with file permissions.
805  */
806  umask(022);
807 
808  /*
809  * To minimize confusion, make sure that the standard file descriptors
810  * are open before opening anything else. XXX Work around for 44BSD where
811  * fstat can return EBADF on an open file descriptor.
812  */
813  for (fd = 0; fd < 3; fd++)
814  if (fstat(fd, &st) == -1
815  && (close(fd), open("/dev/null", O_RDWR, 0)) != fd)
816  msg_fatal("open /dev/null: %m");
817 
818  /*
819  * Set up logging.
820  */
821  msg_vstream_init(argv[0], VSTREAM_ERR);
822 
823  /*
824  * Parse JCL.
825  */
826  while ((ch = GETOPT(argc, argv, "aAbc:C:deEfFhHlmMno:pPtT:vxX#")) > 0) {
827  switch (ch) {
828  case 'a':
830  break;
831  case 'A':
833  break;
834  case 'b':
836  if (ext_argv)
837  msg_fatal("specify one of -b and -t");
838  ext_argv = argv_alloc(2);
839  argv_add(ext_argv, "bounce", "-SVnexpand_templates", (char *) 0);
840  break;
841  case 'c':
842  if (setenv(CONF_ENV_PATH, optarg, 1) < 0)
843  msg_fatal("out of memory");
844  break;
845  case 'C':
846  param_class = name_mask_opt("-C option", param_class_table,
848  break;
849  case 'd':
851  break;
852  case 'e':
854  break;
855  case 'f':
857  break;
858  case 'F':
860  break;
861  case '#':
863  break;
864  case 'h':
866  break;
867  case 'H':
869  break;
870  case 'l':
872  break;
873  case 'm':
875  break;
876  case 'M':
878  break;
879  case 'n':
881  break;
882  case 'o':
884  if (override_params == 0)
885  override_params = argv_alloc(2);
886  argv_add(override_params, optarg, (char *) 0);
887  break;
888  case 'p':
890  break;
891  case 'P':
893  break;
894  case 't':
896  if (ext_argv)
897  msg_fatal("specify one of -b and -t");
898  ext_argv = argv_alloc(2);
899  argv_add(ext_argv, "bounce", "-SVndump_templates", (char *) 0);
900  break;
901  case 'T':
903  msg_fatal("At most one -T <mode> option may be specified");
905  pcf_tls_arg = optarg;
906  break;
907  case 'x':
909  break;
910  case 'X':
911  /* This is irreversible, therefore require two-finger action. */
913  break;
914  case 'v':
915  msg_verbose++;
916  break;
917  default:
918  usage(argv[0]);
919  }
920  }
921 
922  /*
923  * We don't enforce import_environment consistency in this program.
924  *
925  * We don't extract import_environment from main.cf, because the postconf
926  * command must be able to extract parameter settings from main.cf before
927  * all installation parameters such as mail_owner or setgid_group have a
928  * legitimate value.
929  *
930  * We would need the functionality of mail_params_init() including all the
931  * side effects of populating the CONFIG_DICT with default values so that
932  * $name expansion works correctly, but excluding all the parameter value
933  * sanity checks so that it would not abort at installation time.
934  */
935 
936  /*
937  * Make all options explicit, before checking their compatibility.
938  */
939 #define PCF_MAIN_OR_MASTER \
940  (PCF_MAIN_PARAM | PCF_MASTER_ENTRY | PCF_MASTER_FLD | PCF_MASTER_PARAM)
941 
942  if ((pcf_cmd_mode & pcf_incompat_options[0]) == 0)
945  && argv[optind] && strchr(argv[optind], '='))
947 
948  /*
949  * Sanity check.
950  */
951  pcf_check_exclusive_options(pcf_cmd_mode);
952  pcf_check_compat_options(pcf_cmd_mode);
953 
954  if ((pcf_cmd_mode & PCF_EDIT_CONF) && argc == optind)
955  msg_fatal("-e requires name=value argument");
956 
957  /*
958  * Display bounce template information and exit.
959  */
960  if (ext_argv) {
961  if (argv[optind]) {
962  if (argv[optind + 1])
963  msg_fatal("options -b and -t require at most one template file");
964  argv_add(ext_argv, "-o",
966  argv[optind], (char *) 0),
967  (char *) 0);
968  }
969  /* Grr... */
970  argv_add(ext_argv, "-o",
971  concatenate(VAR_QUEUE_DIR, "=", ".", (char *) 0),
972  (char *) 0);
973  mail_conf_read();
974  mail_run_replace(var_daemon_dir, ext_argv->argv);
975  /* NOTREACHED */
976  }
977 
978  /*
979  * If showing map types, show them and exit
980  */
981  if (pcf_cmd_mode & PCF_SHOW_MAPS) {
982  mail_conf_read();
983  mail_dict_init();
984  pcf_show_maps();
985  }
986 
987  /*
988  * If showing locking methods, show them and exit
989  */
990  else if (pcf_cmd_mode & PCF_SHOW_LOCKS) {
991  pcf_show_locks();
992  }
993 
994  /*
995  * If showing master.cf entries, show them and exit
996  */
998  && !(pcf_cmd_mode & (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_COMMENT_OUT))) {
1001  if (override_params)
1002  pcf_set_parameters(override_params->argv);
1003  pcf_register_builtin_parameters(basename(argv[0]), getpid());
1008  argv + optind);
1009  else if (pcf_cmd_mode & PCF_MASTER_PARAM)
1011  argv + optind);
1012  else
1014  argv + optind);
1016  }
1017 
1018  /*
1019  * If showing SASL plug-in types, show them and exit
1020  */
1021  else if (pcf_cmd_mode & PCF_SHOW_SASL_SERV) {
1022  pcf_show_sasl(PCF_SHOW_SASL_SERV);
1023  } else if (pcf_cmd_mode & PCF_SHOW_SASL_CLNT) {
1024  pcf_show_sasl(PCF_SHOW_SASL_CLNT);
1025  }
1026 
1027  /*
1028  * Show TLS info and exit.
1029  */
1030  else if (pcf_cmd_mode & PCF_SHOW_TLS) {
1031  pcf_show_tls(pcf_tls_arg);
1032  }
1033 
1034  /*
1035  * Edit main.cf or master.cf.
1036  */
1037  else if (pcf_cmd_mode & (PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL)) {
1038  if (optind == argc)
1039  msg_fatal("missing service argument");
1041  pcf_edit_master(pcf_cmd_mode, argc - optind, argv + optind);
1042  } else {
1043  pcf_edit_main(pcf_cmd_mode, argc - optind, argv + optind);
1044  }
1045  }
1046 
1047  /*
1048  * If showing non-default values, read main.cf.
1049  */
1050  else {
1051  if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0) {
1053  if (override_params)
1054  pcf_set_parameters(override_params->argv);
1055  }
1056  pcf_register_builtin_parameters(basename(argv[0]), getpid());
1057 
1058  /*
1059  * Add service-dependent parameters (service names from master.cf)
1060  * and user-defined parameters ($name macros in parameter values in
1061  * main.cf and master.cf, but only if those names have a name=value
1062  * in main.cf or master.cf).
1063  */
1066  if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0)
1068 
1069  /*
1070  * Show the requested values.
1071  */
1073  argv + optind);
1074 
1075  /*
1076  * Flag unused parameters. This makes no sense with "postconf -d",
1077  * because that ignores all the user-specified parameters and
1078  * user-specified macro expansions in main.cf.
1079  */
1080  if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0) {
1083  }
1084  }
1086  exit(0);
1087 }
int msg_verbose
Definition: msg.c:177
void pcf_register_builtin_parameters(const char *, pid_t)
MAIL_VERSION_STAMP_DECLARE
Definition: postconf.c:617
#define str_name_mask(tag, table, mask)
Definition: name_mask.h:51
PCF_MASTER_ENT * pcf_master_table
Definition: postconf.c:611
Definition: argv.h:17
#define PCF_SHOW_SASL_SERV
Definition: postconf.h:34
#define VSTREAM_OUT
Definition: vstream.h:67
void pcf_set_parameters(char **)
#define stat(p, s)
Definition: warn_stat.h:18
NORETURN mail_run_replace(const char *dir, char **argv)
Definition: mail_run.c:143
#define PCF_MASTER_FLD
Definition: postconf.h:40
#define PCF_FAIL_ON_OPEN_ERROR
Definition: postconf.h:203
void const char void pcf_flag_unused_main_parameters(void)
void pcf_show_master_params(VSTREAM *, int, int, char **)
char ** argv
Definition: argv.h:20
#define PCF_SHOW_MAPS
Definition: postconf.h:30
void argv_add(ARGV *argvp,...)
Definition: argv.c:197
#define PCF_FOLD_LINE
Definition: postconf.h:38
void pcf_edit_master(int, int, char **)
int pcf_cmd_mode
Definition: postconf.c:612
ARGV * argv_alloc(ssize_t len)
Definition: argv.c:149
#define PCF_EXP_DSN_TEMPL
Definition: postconf.h:42
void pcf_show_master_fields(VSTREAM *, int, int, char **)
#define PCF_SHOW_NONDEF
Definition: postconf.h:27
#define VAR_QUEUE_DIR
Definition: mail_params.h:277
void mail_conf_read(void)
Definition: mail_conf.c:178
void pcf_show_sasl(int)
#define PCF_HIDE_VALUE
Definition: postconf.h:47
int main(int argc, char **argv)
Definition: postconf.c:781
#define PCF_COMMENT_OUT
Definition: postconf.h:36
void pcf_read_master(int)
#define CONF_ENV_PATH
Definition: mail_conf.h:22
const char * str_name_mask_opt(VSTRING *buf, const char *context, const NAME_MASK *table, int mask, int flags)
Definition: name_mask.c:265
#define PCF_PARAM_FLAG_SERVICE
Definition: postconf.h:66
#define PCF_SHOW_EVAL
Definition: postconf.h:33
#define PCF_SHOW_SASL_CLNT
Definition: postconf.h:35
void pcf_show_locks(void)
#define VAR_BOUNCE_TMPL
Definition: mail_params.h:3180
VSTRING * vstring_alloc(ssize_t len)
Definition: vstring.c:353
void mail_dict_init(void)
Definition: mail_dict.c:81
#define PCF_PARAM_TABLE
Definition: postconf.h:91
#define MAIL_VERSION_STAMP_ALLOCATE
Definition: mail_version.h:67
void pcf_read_parameters(void)
#define PCF_SHOW_TLS
Definition: postconf.h:48
#define PCF_WARN_ON_OPEN_ERROR
Definition: postconf.h:202
void pcf_edit_main(int, int, char **)
NORETURN msg_fatal(const char *fmt,...)
Definition: msg.c:249
#define PCF_MAIN_OVER
Definition: postconf.h:44
int vstream_fflush(VSTREAM *stream)
Definition: vstream.c:1257
char * concatenate(const char *arg0,...)
Definition: concatenate.c:42
#define PCF_SHOW_LOCKS
Definition: postconf.h:32
#define GETOPT(argc, argv, str)
Definition: sys_defs.h:1313
#define PCF_MAIN_PARAM
Definition: postconf.h:41
#define PCF_DEF_MODE
Definition: postconf.h:50
#define PCF_PARAM_FLAG_BUILTIN
Definition: postconf.h:65
#define PCF_PARAM_MASK_CLASS
Definition: postconf.h:72
int int
Definition: smtpd_proxy.h:21
#define PCF_SHOW_DEFS
Definition: postconf.h:28
void pcf_show_maps(void)
#define PCF_PARAM_FLAG_USER
Definition: postconf.h:67
#define PCF_MASTER_PARAM
Definition: postconf.h:46
void pcf_flag_unused_master_parameters(void)
void pcf_show_parameters(VSTREAM *, int, int, char **)
VSTRING * vstring_free(VSTRING *vp)
Definition: vstring.c:380
char * var_daemon_dir
Definition: mail_params.c:242
#define NAME_MASK_NUMBER
Definition: name_mask.h:32
#define PCF_DUMP_DSN_TEMPL
Definition: postconf.h:45
PCF_PARAM_TABLE * pcf_param_table
Definition: postconf.c:610
void msg_vstream_init(const char *name, VSTREAM *vp)
Definition: msg_vstream.c:77
#define NAME_MASK_FATAL
Definition: name_mask.h:27
#define NAME_MASK_ANY_CASE
Definition: name_mask.h:28
#define PCF_HIDE_NAME
Definition: postconf.h:29
void pcf_register_user_parameters(void)
#define PCF_MAIN_OR_MASTER
#define PCF_MASTER_ENTRY
Definition: postconf.h:37
#define PCF_EDIT_EXCL
Definition: postconf.h:39
#define PCF_PARAM_CLASS
Definition: postconf.h:43
#define basename
Definition: stringops.h:36
#define name_mask_opt(tag, table, str, flags)
Definition: name_mask.h:46
void pcf_show_master_entries(VSTREAM *, int, int, char **)
#define VSTREAM_ERR
Definition: vstream.h:68
#define fstat(f, s)
Definition: warn_stat.h:20
#define PCF_EDIT_CONF
Definition: postconf.h:31
void pcf_register_service_parameters(void)
void pcf_show_tls(const char *)