2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-08-31 06:05:37 +00:00

postfix-2.11-20131220

This commit is contained in:
Wietse Venema
2013-12-20 00:00:00 -05:00
committed by Viktor Dukhovni
parent 606fe29d27
commit 6d24e9ec74
31 changed files with 1418 additions and 1291 deletions

22
postfix/.indent.pro vendored
View File

@@ -206,17 +206,17 @@
-TNAME_MASK
-TNBBIO
-TOPTIONS
-TPC_DBMS_INFO
-TPC_EVAL_CTX
-TPC_MASTER_EDIT_REQ
-TPC_MASTER_ENT
-TPC_MASTER_FIELD_REQ
-TPC_PARAM_CTX
-TPC_PARAM_NODE
-TPC_PARAM_TABLE
-TPC_SERVICE_DEF
-TPC_SERVICE_PATTERN
-TPC_STRING_NV
-TPCF_DBMS_INFO
-TPCF_EVAL_CTX
-TPCF_MASTER_EDIT_REQ
-TPCF_MASTER_ENT
-TPCF_MASTER_FLD_REQ
-TPCF_PARAM_CTX
-TPCF_PARAM_NODE
-TPCF_PARAM_TABLE
-TPCF_SERVICE_DEF
-TPCF_SERVICE_PATTERN
-TPCF_STRING_NV
-TPEER_NAME
-TPGSQL_NAME
-TPICKUP_INFO

View File

@@ -19401,6 +19401,25 @@ Apologies for any names omitted.
20131218
Documentation: new document FORWARD_SECRECY_README that
describes how Postfix implements forward secrecy since
Postfix 2.2, and how that support has evolved. Viktor
Dukhovni. File: proto/FORWARD_SECRECY_README.html.
describes how different versions of Postfix >= 2.2 implement
"perfect" forward secrecy. Viktor Dukhovni. File:
proto/FORWARD_SECRECY_README.html, proto/Makefile.in,
conf/postfix-files, html/index.html.
20131219
Cleanup: renamed postconf(1) internal identifiers according
to a consistent scheme, to avoid name future name conflicts
as Postfix evolves. This is a no-feature change. Files:
postconf/*.[hc], postconf/extract.awk.
Documentation: linearized the order of exposition in
FORWARD_SECRECY_README. File: proto/FORWARD_SECRECY_README.html.
20131220
Bugfix: DANE support: segfault. Viktor Dukhovni. File:
tls/tls_dane.c.
Documentation: typo in SASL_README. Patrick Ben Koetter.
File: proto/SASL_README.html.

View File

@@ -49,13 +49,13 @@ FFoorrwwaarrdd SSeeccrreeccyy iinn TTLLSS
Early implementations of the SSL protocol do not provide forward secrecy (some
provide it only with artificially-weakened "export" cipher suites, but we will
ignore those cases here). The client sends a random "pre-master secret" to the
server encrypted with the server's RSA public key. The server decrypts this
with its private key, and uses it together with other data exchanged in the
clear to generate the session key. An attacker with access to the server's
private key can perform the same computation at any later time. The TLS library
in Windows XP and Windows Server 2003 only supported cipher suites of this
type, and Exchange 2003 servers largely do not support forward secrecy.
ignore those here). The client sends a random "pre-master secret" to the server
encrypted with the server's RSA public key. The server decrypts this with its
private key, and uses it together with other data exchanged in the clear to
generate the session key. An attacker with access to the server's private key
can perform the same computation at any later time. The TLS library in Windows
XP and Windows Server 2003 only supported cipher suites of this type, and
Exchange 2003 servers largely do not support forward secrecy.
Later revisions to the TLS protocol introduced forward-secrecy cipher suites in
which the client and server implement a key exchange protocol based on
@@ -91,49 +91,54 @@ each server is free to select its own suitably-strong prime and generator.
FFoorrwwaarrdd SSeeccrreeccyy iinn tthhee PPoossttffiixx SSMMTTPP SSeerrvveerr
First the good news: The Postfix SMTP server supports forward secrecy in its
default configuration. If the SMTP client also supports and prefers TLS cipher
suites with forward secrecy, then the traffic between the server and client
will resist decryption even if the server's long-term authentication keys are
later compromised. When the SMTP client is Postfix, it prefers forward secrecy
cipher suites by default.
The Postfix >= 2.2 SMTP server supports forward secrecy in its default
configuration. If the remote SMTP client prefers cipher suites with forward
secrecy, then the traffic between the server and client will resist decryption
even if the server's long-term authentication keys are later compromised.
Postfix >= 2.8 when compiled with OpenSSL >= 1.0.0 supports EECDH key exchange
by default (via the most widely supported NIST P-256 curve). So when the SMTP
client also supports EECDH and implements the P-256 curve, forward secrecy just
works.
Some remote SMTP clients may support forward secrecy, but prefer cipher suites
without forward secrecy. In that case, Postfix >= 2.8 could be configured to
ignore the client's preference with the main.cf setting "tls_preempt_cipherlist
= yes". However, this will likely cause interoperability issues with older
Exchange servers and is not recommended for now.
For Postfix 2.6 and 2.7, in which EECDH was supported, but disabled by default,
one can safely enable EECDH by setting the main.cf parameter
smtpd_tls_eecdh_grade to "strong".
EEDDHH SSeerrvveerr ssuuppppoorrtt
For Postfix 2.2-2.5, or for interoperability with clients that do not support
EECDH, you need the older prime-field EDH, and here OpenSSL wants the server to
provide two explicitly selected (prime, generator) combinations. One for the
now long obsolete "export" cipher suites, and another for non-export cipher
suites. Postfix has two such default combinations compiled in, but also
supports explicitly configured overrides.
Postfix >= 2.2 support 1024-bit-prime EDH out of the box, with no additional
configuration, but you may want to override the default prime to be 2048 bits
long, and you may want to regenerate your primes periodically. See the quick-
start section for details.
The export EDH parameters are used only with the obsolete "export" ciphers. To
use a non-default prime, generate a 512-bit DH parameter file and set
smtpd_tls_dh512_param_file to the filename.
With prime-field EDH, OpenSSL wants the server to provide two explicitly-
selected (prime, generator) combinations. One for the now long-obsolete
"export" cipher suites, and another for non-export cipher suites. Postfix has
two such default combinations compiled in, but also supports explicitly-
configured overrides.
The non-export EDH parameters are used for all other EDH cipher suites. To use
a non-default prime, generate a 1024-bit or 2048-bit DH parameter file and set
smtpd_tls_dh1024_param_file to the filename. Despite the name this is simply
the non-export parameter file and the prime need not actually be 1024 bits
long.
* The "export" EDH parameters are used only with the obsolete "export"
ciphers. To use a non-default prime, generate a 512-bit DH parameter file
and set smtpd_tls_dh512_param_file to the filename (see the quick-start
section for details).
It turns out that (inadvisably patched in some Debian releases) Exim SMTP
clients enforce a minimum of 2048 bits for the non-export prime. See the quick-
start section for the recommended configuration to work around this issue.
* The non-export EDH parameters are used for all other EDH cipher suites. To
use a non-default prime, generate a 1024-bit or 2048-bit DH parameter file
and set smtpd_tls_dh1024_param_file to the filename. Despite the name this
is simply the non-export parameter file and the prime need not actually be
1024 bits long (see the quick-start section for details).
So, in summary, Postfix supports 1024-bit-prime EDH out of the box, with no
additional configuration, but you may want to override the default prime to be
2048 bits long. It also supports NIST P-256 EECDH out of the box with Postfix
2.8 or later, but this is disabled in Postfix 2.6 and 2.7 when the feature was
too new to enable by default. In retrospect it turned out to work reliably, and
is now on by default.
It turns out that (inadvisably-patched in some Debian releases) Exim SMTP
clients enforce a minimum 2048-bit length for the non-export prime. See the
quick-start section for the recommended configuration to work around this
issue.
EEEECCDDHH SSeerrvveerr ssuuppppoorrtt
Postfix >= 2.6 support NIST P-256 EECDH when built with OpenSSL >= 1.0.0. When
the remote SMTP client also supports EECDH and implements the P-256 curve,
forward secrecy just works.
Note: With Postfix 2.6 and 2.7, enable EECDH by setting the main.cf
parameter smtpd_tls_eecdh_grade to "strong".
The elliptic curve situation is evolving, with new curves being introduced to
augment or replace the NIST curves tarnished by the Snowden revelations.
@@ -159,13 +164,11 @@ main.cf.
FFoorrwwaarrdd SSeeccrreeccyy iinn tthhee PPoossttffiixx SSMMTTPP CClliieenntt
EDH and EECDH use depends on SMTP client support and preference for the
corresponding TLS cipher suites. If the client prefers ciphers without forward
secrecy, these will be used instead. Though Postfix >= 2.8 supports setting
"tls_preempt_cipherlist = yes" to select the use of the server's, rather than
the client's, most preferred cipher suite, this setting will likely cause
interoperability issues with older Exchange servers and is not recommended for
now.
The Postfix >= 2.2 SMTP client supports forward secrecy in its default
configuration. If the remote SMTP server supports cipher suites with forward
secrecy (and does not override the SMTP client cipher preference), then the
traffic between the server and client will resist decryption even if the
server's long-term authentication keys are later compromised.
The default Postfix SMTP client cipher lists are correctly ordered to prefer
EECDH and EDH cipher suites ahead of similar cipher suites that don't implement

View File

@@ -484,7 +484,7 @@ to a PostgreSQL server:
sql_user: username
sql_passwd: secret
sql_database: dbname
sql_select: SELECT password FROM users WHERE user = '%u'@'%r'
sql_select: SELECT password FROM users WHERE user = '%u@%r'
NNoottee

View File

@@ -4,9 +4,13 @@ Wish list:
Make been_here flag BH_FLAG_FOLD configurable for masochists.
Change html/Makefile to ".pl 99999" and ".ll 78".
Replace some redundant TLS_README sections with pointers to
FORWARD_SECRECY_README.
Move html/index.html source to proto/.
Preserve case in smtpd_resolve_addr() and add a structure
member for the case-folded address.

View File

@@ -81,7 +81,7 @@ key agreement method. </p>
<p> Early implementations of the SSL protocol do not provide forward
secrecy (some provide it only with artificially-weakened "export"
cipher suites, but we will ignore those cases here). The client
cipher suites, but we will ignore those here). The client
sends a random "pre-master secret" to the server encrypted with the
server's RSA public key. The server decrypts this with its private
key, and uses it together with other data exchanged in the clear
@@ -103,11 +103,14 @@ mathematical "group" and an element of that group called a "generator".
There are two flavors of "groups" that work with PFS: </p>
<ul>
<li> Prime field groups. The server needs to be configured with a
suitably large prime and a corresponding "generator".
<li> Elliptic curve groups. The server needs to be configured with
a "named curve". These offer better security at lower computational
cost than prime field groups, but are not as widely implemented.
</ul>
<p> The acronym for forward secrecy over prime fields is EDH or
@@ -131,53 +134,68 @@ free to select its own suitably-strong prime and generator. </p>
<h2><a name="server_fs">Forward Secrecy in the Postfix SMTP Server</a></h2>
<p> First the good news: The Postfix SMTP server supports forward
secrecy in its default configuration. If the SMTP client also
supports and prefers TLS cipher suites with forward secrecy, then
the traffic between the server and client will resist decryption
even if the server's long-term authentication keys are <i>later</i>
compromised. When the SMTP client is Postfix, it prefers forward
secrecy cipher suites by default. </p>
<p> The Postfix &ge; 2.2 SMTP server supports forward secrecy in
its default configuration. If the remote SMTP client prefers cipher
suites with forward secrecy, then the traffic between the server
and client will resist decryption even if the server's long-term
authentication keys are <i>later</i> compromised. </p>
<p> Postfix &ge; 2.8 when compiled with OpenSSL &ge; 1.0.0 supports
EECDH key exchange by default (via the most widely supported NIST
P-256 curve). So when the SMTP client also supports EECDH and
implements the P-256 curve, forward secrecy just works. </p>
<p> Some remote SMTP clients may support forward secrecy, but prefer
cipher suites <i>without</i> forward secrecy. In that case, Postfix
&ge; 2.8 could be configured to ignore the client's preference with
the <a href="postconf.5.html">main.cf</a> setting "<a href="postconf.5.html#tls_preempt_cipherlist">tls_preempt_cipherlist</a> = yes". However, this
will likely cause interoperability issues with older Exchange servers
and is not recommended for now. </p>
<p> For Postfix 2.6 and 2.7, in which EECDH was supported, but
disabled by default, one can safely enable EECDH by setting the
<a href="postconf.5.html">main.cf</a> parameter <a href="postconf.5.html#smtpd_tls_eecdh_grade">smtpd_tls_eecdh_grade</a> to "strong". </p>
</ul>
<p> For Postfix 2.2-2.5, or for interoperability with clients
that do not support EECDH, you need the older prime-field EDH, and
here OpenSSL wants the server to provide two explicitly selected
(prime, generator) combinations. One for the now long obsolete
"export" cipher suites, and another for non-export cipher suites.
Postfix has two such default combinations compiled in, but also
supports explicitly configured overrides. </p>
<h3> EDH Server support </h3>
<p> The export EDH parameters are used only with the obsolete
<p> Postfix &ge; 2.2 support 1024-bit-prime EDH out of the box,
with no additional configuration, but you may want to override the
default prime to be 2048 bits long, and you may want to regenerate
your primes periodically. See the <a href="#quick-start">quick-start</a>
section for details. </p>
<p> With prime-field EDH, OpenSSL wants the server to provide
two explicitly-selected (prime, generator) combinations. One for
the now long-obsolete "export" cipher suites, and another for
non-export cipher suites. Postfix has two such default combinations
compiled in, but also supports explicitly-configured overrides.
</p>
<ul>
<li> <p> The "export" EDH parameters are used only with the obsolete
"export" ciphers. To use a non-default prime, generate a 512-bit
DH parameter file and set <a href="postconf.5.html#smtpd_tls_dh512_param_file">smtpd_tls_dh512_param_file</a> to the filename. </p>
DH parameter file and set <a href="postconf.5.html#smtpd_tls_dh512_param_file">smtpd_tls_dh512_param_file</a> to the filename
(see the <a href="#quick-start">quick-start</a> section for details).
</p>
<p> The non-export EDH parameters are used for all other EDH
<li> <p> The non-export EDH parameters are used for all other EDH
cipher suites. To use a non-default prime, generate a 1024-bit or
2048-bit DH parameter file and set <a href="postconf.5.html#smtpd_tls_dh1024_param_file">smtpd_tls_dh1024_param_file</a> to
the filename. Despite the name this is simply the non-export
parameter file and the prime need not actually be 1024 bits long. </p>
parameter file and the prime need not actually be 1024 bits long
(see the <a href="#quick-start">quick-start</a> section for details).
</p>
<p> It turns out that (inadvisably patched in some Debian releases)
Exim SMTP clients enforce a minimum of 2048 bits for the non-export
</ul>
<p> It turns out that (inadvisably-patched in some Debian releases)
Exim SMTP clients enforce a minimum 2048-bit length for the non-export
prime. See the <a href="#quick-start">quick-start</a> section for
the recommended configuration to work around this issue. </p>
<p> So, in summary, Postfix supports 1024-bit-prime EDH out of the
box, with no additional configuration, but you may want to override
the default prime to be 2048 bits long. It also supports NIST P-256
EECDH out of the box with Postfix 2.8 or later, but this is disabled
in Postfix 2.6 and 2.7 when the feature was too new to enable by
default. In retrospect it turned out to work reliably, and is now
on by default. </p>
<h3> EECDH Server support </h3>
<p> Postfix &ge; 2.6 support NIST P-256 EECDH when built with OpenSSL
&ge; 1.0.0. When the remote SMTP client also supports EECDH and
implements the P-256 curve, forward secrecy just works. </p>
<blockquote> <p> Note: With Postfix 2.6 and 2.7, enable EECDH by
setting the <a href="postconf.5.html">main.cf</a> parameter <a href="postconf.5.html#smtpd_tls_eecdh_grade">smtpd_tls_eecdh_grade</a> to "strong".
</p> </blockquote>
<p> The elliptic curve situation is evolving, with new curves being
introduced to augment or replace the NIST curves tarnished by the
@@ -209,13 +227,12 @@ more curves at the desired security level without any changes to
<h2> <a name="client_fs">Forward Secrecy in the Postfix SMTP Client</a> </h2>
<p> EDH and EECDH use depends on SMTP client support and preference
for the corresponding TLS cipher suites. If the client prefers
ciphers without forward secrecy, these will be used instead. Though
Postfix &ge; 2.8 supports setting "<a href="postconf.5.html#tls_preempt_cipherlist">tls_preempt_cipherlist</a> = yes"
to select the use of the server's, rather than the client's, most
preferred cipher suite, this setting will likely cause interoperability
issues with older Exchange servers and is not recommended for now. </p>
<p> The Postfix &ge; 2.2 SMTP client supports forward secrecy in
its default configuration. If the remote SMTP server supports
cipher suites with forward secrecy (and does not override the SMTP
client cipher preference), then the traffic between the server and
client will resist decryption even if the server's long-term
authentication keys are <i>later</i> compromised. </p>
<p> The default Postfix SMTP client cipher lists are correctly ordered
to prefer EECDH and EDH cipher suites ahead of similar cipher suites

View File

@@ -790,7 +790,7 @@ and connects it to a PostgreSQL server: </p>
sql_user: username
sql_passwd: secret
sql_database: dbname
sql_select: SELECT password FROM users WHERE user = '%u'@'%r'
sql_select: SELECT password FROM users WHERE user = '%u@%r'
</pre>
</blockquote>

View File

@@ -12,46 +12,52 @@ POSTCONF(1) POSTCONF(1)
<b>SYNOPSIS</b>
<b>Managing <a href="postconf.5.html">main.cf</a>:</b>
<b>postconf</b> [<b>-dfhnovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<b>-C</b> <i>class,...</i>] [<i>param-</i>
<i>eter ...</i>]
<b>postconf</b> [<b>-dfhnopvx</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] [<b>-C</b> <i>class,...</i>] [<i>parame-</i>
<i>ter ...</i>]
<b>postconf</b> [<b>-ev</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>parameter=value ...</i>
<b>postconf</b> [<b>-epv</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>parameter</i><b>=</b><i>value ...</i>
<b>postconf</b> [<b>-#vX</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>parameter ...</i>
<b>postconf -#</b> [<b>-pv</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>parameter ...</i>
<b>postconf -X</b> [<b>-pv</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>parameter ...</i>
<b>Managing <a href="master.5.html">master.cf</a> service entries:</b>
<b>postconf</b> [<b>-fMovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>] <i>...</i>]
<b>postconf -M</b> [<b>-fovx</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>] <i>...</i>]
<b>postconf</b> [<b>-eMv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type=value ...</i>
<b>postconf -M</b> [<b>-ev</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>=</b><i>value ...</i>
<b>postconf</b> [<b>-#MvX</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type ...</i>
<b>postconf -M#</b> [<b>-v</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type ...</i>
<b>postconf -MX</b> [<b>-v</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type ...</i>
<b>Managing <a href="master.5.html">master.cf</a> service fields:</b>
<b>postconf</b> [<b>-fFovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>field</i>]]
<b>postconf -F</b> [<b>-fovx</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>field</i>]]
<i>...</i>]
<b>postconf</b> [<b>-eFv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>field=value</i>
<b>postconf -F</b> [<b>-ev</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>field</i><b>=</b><i>value</i>
<i>...</i>
<b>Managing <a href="master.5.html">master.cf</a> service parameters:</b>
<b>postconf</b> [<b>-fPovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>parame-</i>
<b>postconf -P</b> [<b>-fovx</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>parame-</i>
<i>ter</i>]] <i>...</i>]
<b>postconf</b> [<b>-ePv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>parame-</i>
<i>ter=value ...</i>
<b>postconf -P</b> [<b>-ev</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>parame-</i>
<i>ter</i><b>=</b><i>value ...</i>
<b>postconf</b> [<b>-PXv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>parameter ...</i>
<b>postconf -PX</b> [<b>-v</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>parameter ...</i>
<b>Managing bounce message templates:</b>
<b>postconf</b> [<b>-btv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>template</i><b>_</b><i>file</i>]
<b>postconf -b</b> [<b>-v</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] [<i>template</i><b>_</b><i>file</i>]
<b>postconf -t</b> [<b>-v</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>] [<i>template</i><b>_</b><i>file</i>]
<b>Managing other configuration:</b>
<b>postconf</b> [<b>-aAlmv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>]
<b>postconf -a</b>|<b>-A</b>|<b>-l</b>|<b>-m</b> [<b>-v</b>] [<b>-c</b> <i>conf</i><b>_</b><i>dir</i>]
<b>DESCRIPTION</b>
By default, the <a href="postconf.1.html"><b>postconf</b>(1)</a> command displays the values of
@@ -109,7 +115,7 @@ POSTCONF(1) POSTCONF(1)
This feature is available with Postfix 2.3 and
later.
<b>-c</b> <i>config</i><b>_</b><i>dir</i>
<b>-c</b> <i>conf</i><b>_</b><i>dir</i>
The <a href="postconf.5.html"><b>main.cf</b></a> configuration file is in the named
directory instead of the default configuration
directory.

View File

@@ -11,52 +11,63 @@ Postfix configuration utility
.fi
\fBManaging main.cf:\fR
\fBpostconf\fR [\fB-dfhnovx\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR [\fB-dfhnopvx\fR] [\fB-c \fIconf_dir\fR]
[\fB-C \fIclass,...\fR] [\fIparameter ...\fR]
\fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
\fIparameter=value ...\fR
\fBpostconf\fR [\fB-epv\fR] [\fB-c \fIconf_dir\fR]
\fIparameter\fB=\fIvalue ...\fR
\fBpostconf\fR [\fB-#vX\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-#\fR [\fB-pv\fR] [\fB-c \fIconf_dir\fR]
\fIparameter ...\fR
\fBpostconf\fR \fB-X\fR [\fB-pv\fR] [\fB-c \fIconf_dir\fR]
\fIparameter ...\fR
\fBManaging master.cf service entries:\fR
\fBpostconf\fR [\fB-fMovx\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-M\fR [\fB-fovx\fR] [\fB-c \fIconf_dir\fR]
[\fIservice\fR[\fB/\fItype\fR]\fI ...\fR]
\fBpostconf\fR [\fB-eMv\fR] [\fB-c \fIconfig_dir\fR]
\fIservice\fB/\fItype=value ...\fR
\fBpostconf\fR \fB-M\fR [\fB-ev\fR] [\fB-c \fIconf_dir\fR]
\fIservice\fB/\fItype\fB=\fIvalue ...\fR
\fBpostconf\fR [\fB-#MvX\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-M#\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
\fIservice\fB/\fItype ...\fR
\fBpostconf\fR \fB-MX\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
\fIservice\fB/\fItype ...\fR
\fBManaging master.cf service fields:\fR
\fBpostconf\fR [\fB-fFovx\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-F\fR [\fB-fovx\fR] [\fB-c \fIconf_dir\fR]
[\fIservice\fR[\fB/\fItype\fR[\fB/\fIfield\fR]]\fI ...\fR]
\fBpostconf\fR [\fB-eFv\fR] [\fB-c \fIconfig_dir\fR]
\fIservice\fB/\fItype\fB/\fIfield=value ...\fR
\fBpostconf\fR \fB-F\fR [\fB-ev\fR] [\fB-c \fIconf_dir\fR]
\fIservice\fB/\fItype\fB/\fIfield\fB=\fIvalue ...\fR
\fBManaging master.cf service parameters:\fR
\fBpostconf\fR [\fB-fPovx\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-P\fR [\fB-fovx\fR] [\fB-c \fIconf_dir\fR]
[\fIservice\fR[\fB/\fItype\fR[\fB/\fIparameter\fR]]\fI ...\fR]
\fBpostconf\fR [\fB-ePv\fR] [\fB-c \fIconfig_dir\fR]
\fIservice\fB/\fItype\fB/\fIparameter=value ...\fR
\fBpostconf\fR \fB-P\fR [\fB-ev\fR] [\fB-c \fIconf_dir\fR]
\fIservice\fB/\fItype\fB/\fIparameter\fB=\fIvalue ...\fR
\fBpostconf\fR [\fB-PXv\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-PX\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
\fIservice\fB/\fItype\fB/\fIparameter ...\fR
\fBManaging bounce message templates:\fR
\fBpostconf\fR [\fB-btv\fR] [\fB-c \fIconfig_dir\fR] [\fItemplate_file\fR]
\fBpostconf\fR \fB-b\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
[\fItemplate_file\fR]
\fBpostconf\fR \fB-t\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
[\fItemplate_file\fR]
\fBManaging other configuration:\fR
\fBpostconf\fR [\fB-aAlmv\fR] [\fB-c \fIconfig_dir\fR]
\fBpostconf\fR \fB-a\fR|\fB-A\fR|\fB-l\fR|\fB-m\fR [\fB-v\fR]
[\fB-c \fIconf_dir\fR]
.SH DESCRIPTION
.ad
.fi
@@ -112,7 +123,7 @@ empty template file name on the \fBpostconf\fR(1) command
line (in shell language: "").
This feature is available with Postfix 2.3 and later.
.IP "\fB-c \fIconfig_dir\fR"
.IP "\fB-c \fIconf_dir\fR"
The \fBmain.cf\fR configuration file is in the named directory
instead of the default configuration directory.
.IP "\fB-C \fIclass,...\fR"

View File

@@ -81,7 +81,7 @@ key agreement method. </p>
<p> Early implementations of the SSL protocol do not provide forward
secrecy (some provide it only with artificially-weakened "export"
cipher suites, but we will ignore those cases here). The client
cipher suites, but we will ignore those here). The client
sends a random "pre-master secret" to the server encrypted with the
server's RSA public key. The server decrypts this with its private
key, and uses it together with other data exchanged in the clear
@@ -103,11 +103,14 @@ mathematical "group" and an element of that group called a "generator".
There are two flavors of "groups" that work with PFS: </p>
<ul>
<li> Prime field groups. The server needs to be configured with a
suitably large prime and a corresponding "generator".
<li> Elliptic curve groups. The server needs to be configured with
a "named curve". These offer better security at lower computational
cost than prime field groups, but are not as widely implemented.
</ul>
<p> The acronym for forward secrecy over prime fields is EDH or
@@ -131,53 +134,68 @@ free to select its own suitably-strong prime and generator. </p>
<h2><a name="server_fs">Forward Secrecy in the Postfix SMTP Server</a></h2>
<p> First the good news: The Postfix SMTP server supports forward
secrecy in its default configuration. If the SMTP client also
supports and prefers TLS cipher suites with forward secrecy, then
the traffic between the server and client will resist decryption
even if the server's long-term authentication keys are <i>later</i>
compromised. When the SMTP client is Postfix, it prefers forward
secrecy cipher suites by default. </p>
<p> The Postfix &ge; 2.2 SMTP server supports forward secrecy in
its default configuration. If the remote SMTP client prefers cipher
suites with forward secrecy, then the traffic between the server
and client will resist decryption even if the server's long-term
authentication keys are <i>later</i> compromised. </p>
<p> Postfix &ge; 2.8 when compiled with OpenSSL &ge; 1.0.0 supports
EECDH key exchange by default (via the most widely supported NIST
P-256 curve). So when the SMTP client also supports EECDH and
implements the P-256 curve, forward secrecy just works. </p>
<p> Some remote SMTP clients may support forward secrecy, but prefer
cipher suites <i>without</i> forward secrecy. In that case, Postfix
&ge; 2.8 could be configured to ignore the client's preference with
the main.cf setting "tls_preempt_cipherlist = yes". However, this
will likely cause interoperability issues with older Exchange servers
and is not recommended for now. </p>
<p> For Postfix 2.6 and 2.7, in which EECDH was supported, but
disabled by default, one can safely enable EECDH by setting the
main.cf parameter smtpd_tls_eecdh_grade to "strong". </p>
</ul>
<p> For Postfix 2.2-2.5, or for interoperability with clients
that do not support EECDH, you need the older prime-field EDH, and
here OpenSSL wants the server to provide two explicitly selected
(prime, generator) combinations. One for the now long obsolete
"export" cipher suites, and another for non-export cipher suites.
Postfix has two such default combinations compiled in, but also
supports explicitly configured overrides. </p>
<h3> EDH Server support </h3>
<p> The export EDH parameters are used only with the obsolete
<p> Postfix &ge; 2.2 support 1024-bit-prime EDH out of the box,
with no additional configuration, but you may want to override the
default prime to be 2048 bits long, and you may want to regenerate
your primes periodically. See the <a href="#quick-start">quick-start</a>
section for details. </p>
<p> With prime-field EDH, OpenSSL wants the server to provide
two explicitly-selected (prime, generator) combinations. One for
the now long-obsolete "export" cipher suites, and another for
non-export cipher suites. Postfix has two such default combinations
compiled in, but also supports explicitly-configured overrides.
</p>
<ul>
<li> <p> The "export" EDH parameters are used only with the obsolete
"export" ciphers. To use a non-default prime, generate a 512-bit
DH parameter file and set smtpd_tls_dh512_param_file to the filename. </p>
DH parameter file and set smtpd_tls_dh512_param_file to the filename
(see the <a href="#quick-start">quick-start</a> section for details).
</p>
<p> The non-export EDH parameters are used for all other EDH
<li> <p> The non-export EDH parameters are used for all other EDH
cipher suites. To use a non-default prime, generate a 1024-bit or
2048-bit DH parameter file and set smtpd_tls_dh1024_param_file to
the filename. Despite the name this is simply the non-export
parameter file and the prime need not actually be 1024 bits long. </p>
parameter file and the prime need not actually be 1024 bits long
(see the <a href="#quick-start">quick-start</a> section for details).
</p>
<p> It turns out that (inadvisably patched in some Debian releases)
Exim SMTP clients enforce a minimum of 2048 bits for the non-export
</ul>
<p> It turns out that (inadvisably-patched in some Debian releases)
Exim SMTP clients enforce a minimum 2048-bit length for the non-export
prime. See the <a href="#quick-start">quick-start</a> section for
the recommended configuration to work around this issue. </p>
<p> So, in summary, Postfix supports 1024-bit-prime EDH out of the
box, with no additional configuration, but you may want to override
the default prime to be 2048 bits long. It also supports NIST P-256
EECDH out of the box with Postfix 2.8 or later, but this is disabled
in Postfix 2.6 and 2.7 when the feature was too new to enable by
default. In retrospect it turned out to work reliably, and is now
on by default. </p>
<h3> EECDH Server support </h3>
<p> Postfix &ge; 2.6 support NIST P-256 EECDH when built with OpenSSL
&ge; 1.0.0. When the remote SMTP client also supports EECDH and
implements the P-256 curve, forward secrecy just works. </p>
<blockquote> <p> Note: With Postfix 2.6 and 2.7, enable EECDH by
setting the main.cf parameter smtpd_tls_eecdh_grade to "strong".
</p> </blockquote>
<p> The elliptic curve situation is evolving, with new curves being
introduced to augment or replace the NIST curves tarnished by the
@@ -209,13 +227,12 @@ main.cf. </p>
<h2> <a name="client_fs">Forward Secrecy in the Postfix SMTP Client</a> </h2>
<p> EDH and EECDH use depends on SMTP client support and preference
for the corresponding TLS cipher suites. If the client prefers
ciphers without forward secrecy, these will be used instead. Though
Postfix &ge; 2.8 supports setting "tls_preempt_cipherlist = yes"
to select the use of the server's, rather than the client's, most
preferred cipher suite, this setting will likely cause interoperability
issues with older Exchange servers and is not recommended for now. </p>
<p> The Postfix &ge; 2.2 SMTP client supports forward secrecy in
its default configuration. If the remote SMTP server supports
cipher suites with forward secrecy (and does not override the SMTP
client cipher preference), then the traffic between the server and
client will resist decryption even if the server's long-term
authentication keys are <i>later</i> compromised. </p>
<p> The default Postfix SMTP client cipher lists are correctly ordered
to prefer EECDH and EDH cipher suites ahead of similar cipher suites

View File

@@ -790,7 +790,7 @@ and connects it to a PostgreSQL server: </p>
sql_user: username
sql_passwd: secret
sql_database: dbname
sql_select: SELECT password FROM users WHERE user = '%u'@'%r'
sql_select: SELECT password FROM users WHERE user = '%u@%r'
</pre>
</blockquote>

View File

@@ -20,7 +20,7 @@
* Patches change both the patchlevel and the release date. Snapshots have no
* patchlevel; they change the release date only.
*/
#define MAIL_RELEASE_DATE "20131218"
#define MAIL_RELEASE_DATE "20131220"
#define MAIL_VERSION_NUMBER "2.11"
#ifdef SNAPSHOT

View File

@@ -37,7 +37,7 @@
/^(static| )*(const +)?CONFIG_STR_FN_TABLE .*\{/,/\};/ {
if ($1 ~ /^VAR/) {
str_fn_vars["char *" substr($3,2,length($3)-2) ";"] = 1
$2 = "pc_" $2
$2 = "pcf_" $2
if (++stab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
str_fn_table[$0] = 1
}

View File

@@ -1,2 +1,2 @@
VAR_CONFIG_DIR, DEF_CONFIG_DIR, &var_config_dir, 1, 0,
VAR_DEBUG_COMMAND, "", &var_debug_command, 1, 0,
VAR_DEBUG_COMMAND, "", &var_debug_command, 1, 0,

View File

@@ -7,52 +7,63 @@
/* .fi
/* \fBManaging main.cf:\fR
/*
/* \fBpostconf\fR [\fB-dfhnovx\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR [\fB-dfhnopvx\fR] [\fB-c \fIconf_dir\fR]
/* [\fB-C \fIclass,...\fR] [\fIparameter ...\fR]
/*
/* \fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
/* \fIparameter=value ...\fR
/* \fBpostconf\fR [\fB-epv\fR] [\fB-c \fIconf_dir\fR]
/* \fIparameter\fB=\fIvalue ...\fR
/*
/* \fBpostconf\fR [\fB-#vX\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-#\fR [\fB-pv\fR] [\fB-c \fIconf_dir\fR]
/* \fIparameter ...\fR
/*
/* \fBpostconf\fR \fB-X\fR [\fB-pv\fR] [\fB-c \fIconf_dir\fR]
/* \fIparameter ...\fR
/*
/* \fBManaging master.cf service entries:\fR
/*
/* \fBpostconf\fR [\fB-fMovx\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-M\fR [\fB-fovx\fR] [\fB-c \fIconf_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR]\fI ...\fR]
/*
/* \fBpostconf\fR [\fB-eMv\fR] [\fB-c \fIconfig_dir\fR]
/* \fIservice\fB/\fItype=value ...\fR
/* \fBpostconf\fR \fB-M\fR [\fB-ev\fR] [\fB-c \fIconf_dir\fR]
/* \fIservice\fB/\fItype\fB=\fIvalue ...\fR
/*
/* \fBpostconf\fR [\fB-#MvX\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-M#\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
/* \fIservice\fB/\fItype ...\fR
/*
/* \fBpostconf\fR \fB-MX\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
/* \fIservice\fB/\fItype ...\fR
/*
/* \fBManaging master.cf service fields:\fR
/*
/* \fBpostconf\fR [\fB-fFovx\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-F\fR [\fB-fovx\fR] [\fB-c \fIconf_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIfield\fR]]\fI ...\fR]
/*
/* \fBpostconf\fR [\fB-eFv\fR] [\fB-c \fIconfig_dir\fR]
/* \fIservice\fB/\fItype\fB/\fIfield=value ...\fR
/* \fBpostconf\fR \fB-F\fR [\fB-ev\fR] [\fB-c \fIconf_dir\fR]
/* \fIservice\fB/\fItype\fB/\fIfield\fB=\fIvalue ...\fR
/*
/* \fBManaging master.cf service parameters:\fR
/*
/* \fBpostconf\fR [\fB-fPovx\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-P\fR [\fB-fovx\fR] [\fB-c \fIconf_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIparameter\fR]]\fI ...\fR]
/*
/* \fBpostconf\fR [\fB-ePv\fR] [\fB-c \fIconfig_dir\fR]
/* \fIservice\fB/\fItype\fB/\fIparameter=value ...\fR
/* \fBpostconf\fR \fB-P\fR [\fB-ev\fR] [\fB-c \fIconf_dir\fR]
/* \fIservice\fB/\fItype\fB/\fIparameter\fB=\fIvalue ...\fR
/*
/* \fBpostconf\fR [\fB-PXv\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-PX\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
/* \fIservice\fB/\fItype\fB/\fIparameter ...\fR
/*
/* \fBManaging bounce message templates:\fR
/*
/* \fBpostconf\fR [\fB-btv\fR] [\fB-c \fIconfig_dir\fR] [\fItemplate_file\fR]
/* \fBpostconf\fR \fB-b\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
/* [\fItemplate_file\fR]
/*
/* \fBpostconf\fR \fB-t\fR [\fB-v\fR] [\fB-c \fIconf_dir\fR]
/* [\fItemplate_file\fR]
/*
/* \fBManaging other configuration:\fR
/*
/* \fBpostconf\fR [\fB-aAlmv\fR] [\fB-c \fIconfig_dir\fR]
/* \fBpostconf\fR \fB-a\fR|\fB-A\fR|\fB-l\fR|\fB-m\fR [\fB-v\fR]
/* [\fB-c \fIconf_dir\fR]
/* DESCRIPTION
/* By default, the \fBpostconf\fR(1) command displays the
/* values of \fBmain.cf\fR configuration parameters, and warns
@@ -106,7 +117,7 @@
/* line (in shell language: "").
/*
/* This feature is available with Postfix 2.3 and later.
/* .IP "\fB-c \fIconfig_dir\fR"
/* .IP "\fB-c \fIconf_dir\fR"
/* The \fBmain.cf\fR configuration file is in the named directory
/* instead of the default configuration directory.
/* .IP "\fB-C \fIclass,...\fR"
@@ -491,9 +502,9 @@
/*
* Global storage. See postconf.h for description.
*/
PC_PARAM_TABLE *param_table;
PC_MASTER_ENT *master_table;
int cmd_mode = DEF_MODE;
PCF_PARAM_TABLE *pcf_param_table;
PCF_MASTER_ENT *pcf_master_table;
int pcf_cmd_mode = PCF_DEF_MODE;
/*
* Application fingerprinting.
@@ -510,16 +521,19 @@ MAIL_VERSION_STAMP_DECLARE;
* Options that are mutually-exclusive. First entry must specify the major
* modes. Other entries specify conflicts between option modifiers.
*/
static const int incompat_options[] = {
static const int pcf_incompat_options[] = {
/* Major modes. */
SHOW_SASL_SERV | SHOW_SASL_CLNT | EXP_DSN_TEMPL | SHOW_LOCKS | SHOW_MAPS \
|DUMP_DSN_TEMPL | MAIN_PARAM | MASTER_ENTRY | MASTER_FIELD | MASTER_PARAM,
PCF_SHOW_SASL_SERV | PCF_SHOW_SASL_CLNT | PCF_EXP_DSN_TEMPL \
|PCF_SHOW_LOCKS | PCF_SHOW_MAPS | PCF_DUMP_DSN_TEMPL | PCF_MAIN_PARAM \
|PCF_MASTER_ENTRY | PCF_MASTER_FLD | PCF_MASTER_PARAM,
/* Modifiers. */
SHOW_DEFS | EDIT_CONF | SHOW_NONDEF | COMMENT_OUT | EDIT_EXCL,
FOLD_LINE | EDIT_CONF | COMMENT_OUT | EDIT_EXCL,
SHOW_EVAL | EDIT_CONF | COMMENT_OUT | EDIT_EXCL,
MAIN_OVER | SHOW_DEFS | EDIT_CONF | COMMENT_OUT | EDIT_EXCL,
HIDE_NAME | EDIT_CONF | COMMENT_OUT | EDIT_EXCL,
PCF_SHOW_DEFS | PCF_EDIT_CONF | PCF_SHOW_NONDEF | PCF_COMMENT_OUT \
|PCF_EDIT_EXCL,
PCF_FOLD_LINE | PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL,
PCF_SHOW_EVAL | PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL,
PCF_MAIN_OVER | PCF_SHOW_DEFS | PCF_EDIT_CONF | PCF_COMMENT_OUT \
|PCF_EDIT_EXCL,
PCF_HIDE_NAME | PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL,
0,
};
@@ -528,50 +542,53 @@ static const int incompat_options[] = {
* be one entry for each major mode. Other entries specify compatibility
* between option modifiers.
*/
static const int compat_options[][2] = {
static const int pcf_compat_options[][2] = {
/* Major modes. */
{SHOW_SASL_SERV, 0},
{SHOW_SASL_CLNT, 0},
{EXP_DSN_TEMPL, 0},
{SHOW_LOCKS, 0},
{SHOW_MAPS, 0,},
{DUMP_DSN_TEMPL, 0},
{MAIN_PARAM, EDIT_CONF | EDIT_EXCL | COMMENT_OUT | FOLD_LINE | HIDE_NAME \
|PARAM_CLASS | SHOW_EVAL | SHOW_DEFS | SHOW_NONDEF | MAIN_OVER},
{MASTER_ENTRY, EDIT_CONF | EDIT_EXCL | COMMENT_OUT | FOLD_LINE | MAIN_OVER \
|SHOW_EVAL},
{MASTER_FIELD, EDIT_CONF | FOLD_LINE | HIDE_NAME | MAIN_OVER | SHOW_EVAL},
{MASTER_PARAM, EDIT_CONF | EDIT_EXCL | FOLD_LINE | HIDE_NAME | MAIN_OVER \
|SHOW_EVAL},
{PCF_SHOW_SASL_SERV, 0},
{PCF_SHOW_SASL_CLNT, 0},
{PCF_EXP_DSN_TEMPL, 0},
{PCF_SHOW_LOCKS, 0},
{PCF_SHOW_MAPS, 0,},
{PCF_DUMP_DSN_TEMPL, 0},
{PCF_MAIN_PARAM, (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_COMMENT_OUT \
|PCF_FOLD_LINE | PCF_HIDE_NAME | PCF_PARAM_CLASS \
|PCF_SHOW_EVAL | PCF_SHOW_DEFS | PCF_SHOW_NONDEF \
|PCF_MAIN_OVER)},
{PCF_MASTER_ENTRY, (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_COMMENT_OUT \
|PCF_FOLD_LINE | PCF_MAIN_OVER | PCF_SHOW_EVAL)},
{PCF_MASTER_FLD, (PCF_EDIT_CONF | PCF_FOLD_LINE | PCF_HIDE_NAME \
|PCF_MAIN_OVER | PCF_SHOW_EVAL)},
{PCF_MASTER_PARAM, (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_FOLD_LINE \
|PCF_HIDE_NAME | PCF_MAIN_OVER | PCF_SHOW_EVAL)},
/* Modifiers. */
{PARAM_CLASS, MAIN_PARAM | SHOW_DEFS | SHOW_NONDEF},
{PCF_PARAM_CLASS, (PCF_MAIN_PARAM | PCF_SHOW_DEFS | PCF_SHOW_NONDEF)},
0,
};
/*
* Compatibility to string conversion support.
*/
static const NAME_MASK compat_names[] = {
"-a", SHOW_SASL_SERV,
"-A", SHOW_SASL_CLNT,
"-b", EXP_DSN_TEMPL,
"-C", PARAM_CLASS,
"-d", SHOW_DEFS,
"-e", EDIT_CONF,
"-f", FOLD_LINE,
"-F", MASTER_FIELD,
"-h", HIDE_NAME,
"-l", SHOW_LOCKS,
"-m", SHOW_MAPS,
"-M", MASTER_ENTRY,
"-n", SHOW_NONDEF,
"-o", MAIN_OVER,
"-p", MAIN_PARAM,
"-P", MASTER_PARAM,
"-t", DUMP_DSN_TEMPL,
"-x", SHOW_EVAL,
"-X", EDIT_EXCL,
"-#", COMMENT_OUT,
static const NAME_MASK pcf_compat_names[] = {
"-a", PCF_SHOW_SASL_SERV,
"-A", PCF_SHOW_SASL_CLNT,
"-b", PCF_EXP_DSN_TEMPL,
"-C", PCF_PARAM_CLASS,
"-d", PCF_SHOW_DEFS,
"-e", PCF_EDIT_CONF,
"-f", PCF_FOLD_LINE,
"-F", PCF_MASTER_FLD,
"-h", PCF_HIDE_NAME,
"-l", PCF_SHOW_LOCKS,
"-m", PCF_SHOW_MAPS,
"-M", PCF_MASTER_ENTRY,
"-n", PCF_SHOW_NONDEF,
"-o", PCF_MAIN_OVER,
"-p", PCF_MAIN_PARAM,
"-P", PCF_MASTER_PARAM,
"-t", PCF_DUMP_DSN_TEMPL,
"-x", PCF_SHOW_EVAL,
"-X", PCF_EDIT_EXCL,
"-#", PCF_COMMENT_OUT,
0,
};
@@ -605,43 +622,43 @@ static void usage(const char *progname)
" [name...]", progname);
}
/* check_exclusive_options - complain about mutually-exclusive options */
/* pcf_check_exclusive_options - complain about mutually-exclusive options */
static void check_exclusive_options(int optval)
static void pcf_check_exclusive_options(int optval)
{
const char *myname = "check_exclusive_options";
const char *myname = "pcf_check_exclusive_options";
const int *op;
int oval;
unsigned mask;
for (op = incompat_options; (oval = *op) != 0; op++) {
for (op = pcf_incompat_options; (oval = *op) != 0; op++) {
oval &= optval;
for (mask = ~0; (mask & oval) != 0; mask >>= 1) {
if ((mask & oval) != oval)
msg_fatal("specify one of %s",
str_name_mask(myname, compat_names, oval));
str_name_mask(myname, pcf_compat_names, oval));
}
}
}
/* check_compat_options - complain about incompatible options */
/* pcf_check_compat_options - complain about incompatible options */
static void check_compat_options(int optval)
static void pcf_check_compat_options(int optval)
{
const char *myname = "check_compat_options";
const char *myname = "pcf_check_compat_options";
VSTRING *buf1 = vstring_alloc(10);
VSTRING *buf2 = vstring_alloc(10);
const int (*op)[2];
int excess;
for (op = compat_options; op[0][0] != 0; op++) {
for (op = pcf_compat_options; op[0][0] != 0; op++) {
if ((optval & *op[0]) != 0
&& (excess = (optval & ~((*op)[0] | (*op)[1]))) != 0)
msg_fatal("with option %s, do not specify %s",
str_name_mask_opt(buf1, myname, compat_names,
str_name_mask_opt(buf1, myname, pcf_compat_names,
(*op)[0], NAME_MASK_NUMBER),
str_name_mask_opt(buf2, myname, compat_names, excess,
NAME_MASK_NUMBER));
str_name_mask_opt(buf2, myname, pcf_compat_names,
excess, NAME_MASK_NUMBER));
}
vstring_free(buf1);
vstring_free(buf2);
@@ -655,12 +672,12 @@ int main(int argc, char **argv)
int fd;
struct stat st;
ARGV *ext_argv = 0;
int param_class = PC_PARAM_MASK_CLASS;
int param_class = PCF_PARAM_MASK_CLASS;
static const NAME_MASK param_class_table[] = {
"builtin", PC_PARAM_FLAG_BUILTIN,
"service", PC_PARAM_FLAG_SERVICE,
"user", PC_PARAM_FLAG_USER,
"all", PC_PARAM_MASK_CLASS,
"builtin", PCF_PARAM_FLAG_BUILTIN,
"service", PCF_PARAM_FLAG_SERVICE,
"user", PCF_PARAM_FLAG_USER,
"all", PCF_PARAM_MASK_CLASS,
0,
};
ARGV *override_params = 0;
@@ -696,13 +713,13 @@ int main(int argc, char **argv)
while ((ch = GETOPT(argc, argv, "aAbc:C:deEfFhlmMno:pPtvxX#")) > 0) {
switch (ch) {
case 'a':
cmd_mode |= SHOW_SASL_SERV;
pcf_cmd_mode |= PCF_SHOW_SASL_SERV;
break;
case 'A':
cmd_mode |= SHOW_SASL_CLNT;
pcf_cmd_mode |= PCF_SHOW_SASL_CLNT;
break;
case 'b':
cmd_mode |= EXP_DSN_TEMPL;
pcf_cmd_mode |= PCF_EXP_DSN_TEMPL;
if (ext_argv)
msg_fatal("specify one of -b and -t");
ext_argv = argv_alloc(2);
@@ -717,60 +734,60 @@ int main(int argc, char **argv)
optarg, NAME_MASK_ANY_CASE | NAME_MASK_FATAL);
break;
case 'd':
cmd_mode |= SHOW_DEFS;
pcf_cmd_mode |= PCF_SHOW_DEFS;
break;
case 'e':
cmd_mode |= EDIT_CONF;
pcf_cmd_mode |= PCF_EDIT_CONF;
break;
case 'f':
cmd_mode |= FOLD_LINE;
pcf_cmd_mode |= PCF_FOLD_LINE;
break;
case 'F':
cmd_mode |= MASTER_FIELD;
pcf_cmd_mode |= PCF_MASTER_FLD;
break;
case '#':
cmd_mode |= COMMENT_OUT;
pcf_cmd_mode |= PCF_COMMENT_OUT;
break;
case 'h':
cmd_mode |= HIDE_NAME;
pcf_cmd_mode |= PCF_HIDE_NAME;
break;
case 'l':
cmd_mode |= SHOW_LOCKS;
pcf_cmd_mode |= PCF_SHOW_LOCKS;
break;
case 'm':
cmd_mode |= SHOW_MAPS;
pcf_cmd_mode |= PCF_SHOW_MAPS;
break;
case 'M':
cmd_mode |= MASTER_ENTRY;
pcf_cmd_mode |= PCF_MASTER_ENTRY;
break;
case 'n':
cmd_mode |= SHOW_NONDEF;
pcf_cmd_mode |= PCF_SHOW_NONDEF;
break;
case 'o':
cmd_mode |= MAIN_OVER;
pcf_cmd_mode |= PCF_MAIN_OVER;
if (override_params == 0)
override_params = argv_alloc(2);
argv_add(override_params, optarg, (char *) 0);
break;
case 'p':
cmd_mode |= MAIN_PARAM;
pcf_cmd_mode |= PCF_MAIN_PARAM;
break;
case 'P':
cmd_mode |= MASTER_PARAM;
pcf_cmd_mode |= PCF_MASTER_PARAM;
break;
case 't':
cmd_mode |= DUMP_DSN_TEMPL;
pcf_cmd_mode |= PCF_DUMP_DSN_TEMPL;
if (ext_argv)
msg_fatal("specify one of -b and -t");
ext_argv = argv_alloc(2);
argv_add(ext_argv, "bounce", "-SVndump_templates", (char *) 0);
break;
case 'x':
cmd_mode |= SHOW_EVAL;
pcf_cmd_mode |= PCF_SHOW_EVAL;
break;
case 'X':
/* This is irreversible, therefore require two-finger action. */
cmd_mode |= EDIT_EXCL;
pcf_cmd_mode |= PCF_EDIT_EXCL;
break;
case 'v':
msg_verbose++;
@@ -783,19 +800,22 @@ int main(int argc, char **argv)
/*
* Make all options explicit, before checking their compatibility.
*/
if ((cmd_mode & incompat_options[0]) == 0)
cmd_mode |= MAIN_PARAM;
if ((cmd_mode & (MAIN_PARAM | MASTER_ENTRY | MASTER_FIELD | MASTER_PARAM))
#define PCF_MAIN_OR_MASTER \
(PCF_MAIN_PARAM | PCF_MASTER_ENTRY | PCF_MASTER_FLD | PCF_MASTER_PARAM)
if ((pcf_cmd_mode & pcf_incompat_options[0]) == 0)
pcf_cmd_mode |= PCF_MAIN_PARAM;
if ((pcf_cmd_mode & PCF_MAIN_OR_MASTER)
&& argv[optind] && strchr(argv[optind], '='))
cmd_mode |= EDIT_CONF;
pcf_cmd_mode |= PCF_EDIT_CONF;
/*
* Sanity check.
*/
check_exclusive_options(cmd_mode);
check_compat_options(cmd_mode);
pcf_check_exclusive_options(pcf_cmd_mode);
pcf_check_compat_options(pcf_cmd_mode);
if ((cmd_mode & EDIT_CONF) && argc == optind)
if ((pcf_cmd_mode & PCF_EDIT_CONF) && argc == optind)
msg_fatal("-e requires name=value argument");
/*
@@ -822,57 +842,60 @@ int main(int argc, char **argv)
/*
* If showing map types, show them and exit
*/
if (cmd_mode & SHOW_MAPS) {
if (pcf_cmd_mode & PCF_SHOW_MAPS) {
mail_dict_init();
show_maps();
pcf_show_maps();
}
/*
* If showing locking methods, show them and exit
*/
else if (cmd_mode & SHOW_LOCKS) {
show_locks();
else if (pcf_cmd_mode & PCF_SHOW_LOCKS) {
pcf_show_locks();
}
/*
* If showing master.cf entries, show them and exit
*/
else if ((cmd_mode & (MASTER_ENTRY | MASTER_FIELD | MASTER_PARAM))
&& !(cmd_mode & (EDIT_CONF | EDIT_EXCL | COMMENT_OUT))) {
read_master(FAIL_ON_OPEN_ERROR);
read_parameters();
else if ((pcf_cmd_mode & (PCF_MASTER_ENTRY | PCF_MASTER_FLD | PCF_MASTER_PARAM))
&& !(pcf_cmd_mode & (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_COMMENT_OUT))) {
pcf_read_master(PCF_FAIL_ON_OPEN_ERROR);
pcf_read_parameters();
if (override_params)
set_parameters(override_params->argv);
register_builtin_parameters(basename(argv[0]), getpid());
register_service_parameters();
register_user_parameters();
if (cmd_mode & MASTER_FIELD)
show_master_fields(VSTREAM_OUT, cmd_mode, argc - optind, argv + optind);
else if (cmd_mode & MASTER_PARAM)
show_master_params(VSTREAM_OUT, cmd_mode, argc - optind, argv + optind);
pcf_set_parameters(override_params->argv);
pcf_register_builtin_parameters(basename(argv[0]), getpid());
pcf_register_service_parameters();
pcf_register_user_parameters();
if (pcf_cmd_mode & PCF_MASTER_FLD)
pcf_show_master_fields(VSTREAM_OUT, pcf_cmd_mode, argc - optind,
argv + optind);
else if (pcf_cmd_mode & PCF_MASTER_PARAM)
pcf_show_master_params(VSTREAM_OUT, pcf_cmd_mode, argc - optind,
argv + optind);
else
show_master_entries(VSTREAM_OUT, cmd_mode, argc - optind, argv + optind);
pcf_show_master_entries(VSTREAM_OUT, pcf_cmd_mode, argc - optind,
argv + optind);
}
/*
* If showing SASL plug-in types, show them and exit
*/
else if (cmd_mode & SHOW_SASL_SERV) {
show_sasl(SHOW_SASL_SERV);
} else if (cmd_mode & SHOW_SASL_CLNT) {
show_sasl(SHOW_SASL_CLNT);
else if (pcf_cmd_mode & PCF_SHOW_SASL_SERV) {
pcf_show_sasl(PCF_SHOW_SASL_SERV);
} else if (pcf_cmd_mode & PCF_SHOW_SASL_CLNT) {
pcf_show_sasl(PCF_SHOW_SASL_CLNT);
}
/*
* Edit main.cf or master.cf.
*/
else if (cmd_mode & (EDIT_CONF | COMMENT_OUT | EDIT_EXCL)) {
else if (pcf_cmd_mode & (PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL)) {
if (optind == argc)
msg_fatal("missing service argument");
if (cmd_mode & (MASTER_ENTRY | MASTER_FIELD | MASTER_PARAM)) {
edit_master(cmd_mode, argc - optind, argv + optind);
if (pcf_cmd_mode & (PCF_MASTER_ENTRY | PCF_MASTER_FLD | PCF_MASTER_PARAM)) {
pcf_edit_master(pcf_cmd_mode, argc - optind, argv + optind);
} else {
edit_main(cmd_mode, argc - optind, argv + optind);
pcf_edit_main(pcf_cmd_mode, argc - optind, argv + optind);
}
}
@@ -880,12 +903,12 @@ int main(int argc, char **argv)
* If showing non-default values, read main.cf.
*/
else {
if ((cmd_mode & SHOW_DEFS) == 0) {
read_parameters();
if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0) {
pcf_read_parameters();
if (override_params)
set_parameters(override_params->argv);
pcf_set_parameters(override_params->argv);
}
register_builtin_parameters(basename(argv[0]), getpid());
pcf_register_builtin_parameters(basename(argv[0]), getpid());
/*
* Add service-dependent parameters (service names from master.cf)
@@ -893,24 +916,25 @@ int main(int argc, char **argv)
* main.cf and master.cf, but only if those names have a name=value
* in main.cf or master.cf).
*/
read_master(WARN_ON_OPEN_ERROR);
register_service_parameters();
if ((cmd_mode & SHOW_DEFS) == 0)
register_user_parameters();
pcf_read_master(PCF_WARN_ON_OPEN_ERROR);
pcf_register_service_parameters();
if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0)
pcf_register_user_parameters();
/*
* Show the requested values.
*/
show_parameters(VSTREAM_OUT, cmd_mode, param_class, argv + optind);
pcf_show_parameters(VSTREAM_OUT, pcf_cmd_mode, param_class,
argv + optind);
/*
* Flag unused parameters. This makes no sense with "postconf -d",
* because that ignores all the user-specified parameters and
* user-specified macro expansions in main.cf.
*/
if ((cmd_mode & SHOW_DEFS) == 0) {
flag_unused_main_parameters();
flag_unused_master_parameters();
if ((pcf_cmd_mode & PCF_SHOW_DEFS) == 0) {
pcf_flag_unused_main_parameters();
pcf_flag_unused_master_parameters();
}
}
vstream_fflush(VSTREAM_OUT);

View File

@@ -24,28 +24,28 @@
/*
* What we're supposed to be doing.
*/
#define SHOW_NONDEF (1<<0) /* show main.cf non-default settings */
#define SHOW_DEFS (1<<1) /* show main.cf default setting */
#define HIDE_NAME (1<<2) /* hide main.cf parameter name */
#define SHOW_MAPS (1<<3) /* show map types */
#define EDIT_CONF (1<<4) /* edit main.cf or master.cf */
#define SHOW_LOCKS (1<<5) /* show mailbox lock methods */
#define SHOW_EVAL (1<<6) /* expand main.cf right-hand sides */
#define SHOW_SASL_SERV (1<<7) /* show server auth plugin types */
#define SHOW_SASL_CLNT (1<<8) /* show client auth plugin types */
#define COMMENT_OUT (1<<9) /* #-out selected main.cf entries */
#define MASTER_ENTRY (1<<10) /* manage master.cf entries */
#define FOLD_LINE (1<<11) /* fold long *.cf entries */
#define EDIT_EXCL (1<<12) /* exclude main.cf entries */
#define MASTER_FIELD (1<<13) /* hierarchical pathname */
#define MAIN_PARAM (1<<14) /* manage main.cf entries */
#define EXP_DSN_TEMPL (1<<15) /* expand bounce templates */
#define PARAM_CLASS (1<<16) /* select parameter class */
#define MAIN_OVER (1<<17) /* override parameter values */
#define DUMP_DSN_TEMPL (1<<18) /* show bounce templates */
#define MASTER_PARAM (1<<19) /* manage master.cf -o name=value */
#define PCF_SHOW_NONDEF (1<<0) /* show main.cf non-default settings */
#define PCF_SHOW_DEFS (1<<1) /* show main.cf default setting */
#define PCF_HIDE_NAME (1<<2) /* hide main.cf parameter name */
#define PCF_SHOW_MAPS (1<<3) /* show map types */
#define PCF_EDIT_CONF (1<<4) /* edit main.cf or master.cf */
#define PCF_SHOW_LOCKS (1<<5) /* show mailbox lock methods */
#define PCF_SHOW_EVAL (1<<6) /* expand main.cf right-hand sides */
#define PCF_SHOW_SASL_SERV (1<<7) /* show server auth plugin types */
#define PCF_SHOW_SASL_CLNT (1<<8) /* show client auth plugin types */
#define PCF_COMMENT_OUT (1<<9) /* #-out selected main.cf entries */
#define PCF_MASTER_ENTRY (1<<10) /* manage master.cf entries */
#define PCF_FOLD_LINE (1<<11) /* fold long *.cf entries */
#define PCF_EDIT_EXCL (1<<12) /* exclude main.cf entries */
#define PCF_MASTER_FLD (1<<13) /* hierarchical pathname */
#define PCF_MAIN_PARAM (1<<14) /* manage main.cf entries */
#define PCF_EXP_DSN_TEMPL (1<<15) /* expand bounce templates */
#define PCF_PARAM_CLASS (1<<16) /* select parameter class */
#define PCF_MAIN_OVER (1<<17) /* override parameter values */
#define PCF_DUMP_DSN_TEMPL (1<<18) /* show bounce templates */
#define PCF_MASTER_PARAM (1<<19) /* manage master.cf -o name=value */
#define DEF_MODE 0
#define PCF_DEF_MODE 0
/*
* Structure for one "valid parameter" (built-in, service-defined or valid
@@ -56,58 +56,58 @@ typedef struct {
int flags; /* see below */
char *param_data; /* mostly, the default value */
const char *(*convert_fn) (char *); /* value to string */
} PC_PARAM_NODE;
} PCF_PARAM_NODE;
/* Values for flags. See the postconf_node module for narrative text. */
#define PC_PARAM_FLAG_RAW (1<<0) /* raw parameter value */
#define PC_PARAM_FLAG_BUILTIN (1<<1) /* built-in parameter name */
#define PC_PARAM_FLAG_SERVICE (1<<2) /* service-defined parameter name */
#define PC_PARAM_FLAG_USER (1<<3) /* user-defined parameter name */
#define PC_PARAM_FLAG_LEGACY (1<<4) /* legacy parameter name */
#define PC_PARAM_FLAG_READONLY (1<<5) /* legacy parameter name */
#define PC_PARAM_FLAG_DBMS (1<<6) /* dbms-defined parameter name */
#define PCF_PARAM_FLAG_RAW (1<<0) /* raw parameter value */
#define PCF_PARAM_FLAG_BUILTIN (1<<1) /* built-in parameter name */
#define PCF_PARAM_FLAG_SERVICE (1<<2) /* service-defined parameter name */
#define PCF_PARAM_FLAG_USER (1<<3) /* user-defined parameter name */
#define PCF_PARAM_FLAG_LEGACY (1<<4) /* legacy parameter name */
#define PCF_PARAM_FLAG_READONLY (1<<5) /* legacy parameter name */
#define PCF_PARAM_FLAG_DBMS (1<<6) /* dbms-defined parameter name */
#define PC_PARAM_MASK_CLASS \
(PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_SERVICE | PC_PARAM_FLAG_USER)
#define PC_PARAM_CLASS_OVERRIDE(node, class) \
((node)->flags = (((node)->flags & ~PC_PARAM_MASK_CLASS) | (class)))
#define PCF_PARAM_MASK_CLASS \
(PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_SERVICE | PCF_PARAM_FLAG_USER)
#define PCF_PARAM_CLASS_OVERRIDE(node, class) \
((node)->flags = (((node)->flags & ~PCF_PARAM_MASK_CLASS) | (class)))
#define PC_RAW_PARAMETER(node) ((node)->flags & PC_PARAM_FLAG_RAW)
#define PC_LEGACY_PARAMETER(node) ((node)->flags & PC_PARAM_FLAG_LEGACY)
#define PC_READONLY_PARAMETER(node) ((node)->flags & PC_PARAM_FLAG_READONLY)
#define PC_DBMS_PARAMETER(node) ((node)->flags & PC_PARAM_FLAG_DBMS)
#define PCF_RAW_PARAMETER(node) ((node)->flags & PCF_PARAM_FLAG_RAW)
#define PCF_LEGACY_PARAMETER(node) ((node)->flags & PCF_PARAM_FLAG_LEGACY)
#define PCF_READONLY_PARAMETER(node) ((node)->flags & PCF_PARAM_FLAG_READONLY)
#define PCF_DBMS_PARAMETER(node) ((node)->flags & PCF_PARAM_FLAG_DBMS)
/* Values for param_data. See postconf_node module for narrative text. */
#define PC_PARAM_NO_DATA ((char *) 0)
#define PCF_PARAM_NO_DATA ((char *) 0)
/*
* Lookup table for global "valid parameter" information.
*/
#define PC_PARAM_TABLE HTABLE
#define PC_PARAM_INFO HTABLE_INFO
#define PCF_PARAM_TABLE HTABLE
#define PCF_PARAM_INFO HTABLE_INFO
extern PC_PARAM_TABLE *param_table;
extern PCF_PARAM_TABLE *pcf_param_table;
/*
* postconf_node.c.
*/
#define PC_PARAM_TABLE_CREATE(size) htable_create(size);
#define PC_PARAM_NODE_CAST(ptr) ((PC_PARAM_NODE *) (ptr))
#define PCF_PARAM_TABLE_CREATE(size) htable_create(size);
#define PCF_PARAM_NODE_CAST(ptr) ((PCF_PARAM_NODE *) (ptr))
#define PC_PARAM_TABLE_LIST(table) htable_list(table)
#define PC_PARAM_INFO_NAME(ht) ((const char *) (ht)->key)
#define PC_PARAM_INFO_NODE(ht) PC_PARAM_NODE_CAST((ht)->value)
#define PCF_PARAM_TABLE_LIST(table) htable_list(table)
#define PCF_PARAM_INFO_NAME(ht) ((const char *) (ht)->key)
#define PCF_PARAM_INFO_NODE(ht) PCF_PARAM_NODE_CAST((ht)->value)
#define PC_PARAM_TABLE_FIND(table, name) \
PC_PARAM_NODE_CAST(htable_find((table), (name)))
#define PC_PARAM_TABLE_LOCATE(table, name) htable_locate((table), (name))
#define PC_PARAM_TABLE_ENTER(table, name, flags, data, func) \
htable_enter((table), (name), (char *) make_param_node((flags), \
#define PCF_PARAM_TABLE_FIND(table, name) \
PCF_PARAM_NODE_CAST(htable_find((table), (name)))
#define PCF_PARAM_TABLE_LOCATE(table, name) htable_locate((table), (name))
#define PCF_PARAM_TABLE_ENTER(table, name, flags, data, func) \
htable_enter((table), (name), (char *) pcf_make_param_node((flags), \
(data), (func)))
PC_PARAM_NODE *make_param_node(int, char *, const char *(*) (char *));
const char *convert_param_node(int, const char *, PC_PARAM_NODE *);
extern VSTRING *param_string_buf;
extern PCF_PARAM_NODE *pcf_make_param_node(int, char *, const char *(*) (char *));
extern const char *pcf_convert_param_node(int, const char *, PCF_PARAM_NODE *);
extern VSTRING *pcf_param_string_buf;
/*
* Structure of one master.cf entry.
@@ -117,86 +117,86 @@ typedef struct {
ARGV *argv; /* null, or master.cf fields */
DICT *all_params; /* null, or all name=value entries */
HTABLE *valid_names; /* null, or "valid" parameter names */
} PC_MASTER_ENT;
} PCF_MASTER_ENT;
#define PC_MASTER_MIN_FIELDS 8 /* mandatory field count */
#define PCF_MASTER_MIN_FIELDS 8 /* mandatory field minimum */
#define PC_MASTER_NAME_SERVICE "service"
#define PC_MASTER_NAME_TYPE "type"
#define PC_MASTER_NAME_PRIVATE "private"
#define PC_MASTER_NAME_UNPRIV "unprivileged"
#define PC_MASTER_NAME_CHROOT "chroot"
#define PC_MASTER_NAME_WAKEUP "wakeup"
#define PC_MASTER_NAME_MAXPROC "process_limit"
#define PC_MASTER_NAME_CMD "command"
#define PCF_MASTER_NAME_SERVICE "service"
#define PCF_MASTER_NAME_TYPE "type"
#define PCF_MASTER_NAME_PRIVATE "private"
#define PCF_MASTER_NAME_UNPRIV "unprivileged"
#define PCF_MASTER_NAME_CHROOT "chroot"
#define PCF_MASTER_NAME_WAKEUP "wakeup"
#define PCF_MASTER_NAME_MAXPROC "process_limit"
#define PCF_MASTER_NAME_CMD "command"
#define PC_MASTER_FIELD_SERVICE 0 /* service name */
#define PC_MASTER_FIELD_TYPE 1 /* service type */
#define PC_MASTER_FIELD_PRIVATE 2 /* private service */
#define PC_MASTER_FIELD_UNPRIV 3 /* unprivileged service */
#define PC_MASTER_FIELD_CHROOT 4 /* chrooted service */
#define PC_MASTER_FIELD_WAKEUP 5 /* wakeup timer */
#define PC_MASTER_FIELD_MAXPROC 6 /* process limit */
#define PC_MASTER_FIELD_CMD 7 /* command */
#define PCF_MASTER_FLD_SERVICE 0 /* service name */
#define PCF_MASTER_FLD_TYPE 1 /* service type */
#define PCF_MASTER_FLD_PRIVATE 2 /* private service */
#define PCF_MASTER_FLD_UNPRIV 3 /* unprivileged service */
#define PCF_MASTER_FLD_CHROOT 4 /* chrooted service */
#define PCF_MASTER_FLD_WAKEUP 5 /* wakeup timer */
#define PCF_MASTER_FLD_MAXPROC 6 /* process limit */
#define PCF_MASTER_FLD_CMD 7 /* command */
#define PC_MASTER_FIELD_WILDC -1 /* wild-card */
#define PC_MASTER_FIELD_NONE -2 /* not available
*
/* Lookup table for master.cf
* entries. The table is terminated
* with an entry that has a null argv
* member. */
PC_MASTER_ENT *master_table;
#define PCF_MASTER_FLD_WILDC -1 /* wild-card */
#define PCF_MASTER_FLD_NONE -2 /* not available */
/*
* Lookup table for master.cf entries. The table is terminated with an entry
* that has a null argv member.
*/
PCF_MASTER_ENT *pcf_master_table;
/*
* Line-wrapping support.
*/
#define LINE_LIMIT 80 /* try to fold longer lines */
#define SEPARATORS " \t\r\n"
#define INDENT_LEN 4 /* indent long text by 4 */
#define INDENT_TEXT " "
#define PCF_LINE_LIMIT 80 /* try to fold longer lines */
#define PCF_SEPARATORS " \t\r\n"
#define PCF_INDENT_LEN 4 /* indent long text by 4 */
#define PCF_INDENT_TEXT " "
/*
* XXX Global so that postconf_builtin.c call-backs can see it.
*/
extern int cmd_mode;
extern int pcf_cmd_mode;
/*
* postconf_misc.c.
*/
extern void set_config_dir(void);
extern void pcf_set_config_dir(void);
/*
* postconf_main.c
*/
extern void read_parameters(void);
extern void set_parameters(char **);
extern void show_parameters(VSTREAM *, int, int, char **);
extern void pcf_read_parameters(void);
extern void pcf_set_parameters(char **);
extern void pcf_show_parameters(VSTREAM *, int, int, char **);
/*
* postconf_edit.c
*/
extern void edit_main(int, int, char **);
extern void edit_master(int, int, char **);
extern void pcf_edit_main(int, int, char **);
extern void pcf_edit_master(int, int, char **);
/*
* postconf_master.c.
*/
extern const char daemon_options_expecting_value[];
extern void read_master(int);
extern void show_master_entries(VSTREAM *, int, int, char **);
extern const char *parse_master_entry(PC_MASTER_ENT *, const char *);
extern void print_master_entry(VSTREAM *, int, PC_MASTER_ENT *);
extern void free_master_entry(PC_MASTER_ENT *);
extern void show_master_fields(VSTREAM *, int, int, char **);
extern void edit_master_field(PC_MASTER_ENT *, int, const char *);
extern void show_master_params(VSTREAM *, int, int, char **);
extern void edit_master_param(PC_MASTER_ENT *, int, const char *, const char *);
extern const char pcf_daemon_options_expecting_value[];
extern void pcf_read_master(int);
extern void pcf_show_master_entries(VSTREAM *, int, int, char **);
extern const char *pcf_parse_master_entry(PCF_MASTER_ENT *, const char *);
extern void pcf_print_master_entry(VSTREAM *, int, PCF_MASTER_ENT *);
extern void pcf_free_master_entry(PCF_MASTER_ENT *);
extern void pcf_show_master_fields(VSTREAM *, int, int, char **);
extern void pcf_edit_master_field(PCF_MASTER_ENT *, int, const char *);
extern void pcf_show_master_params(VSTREAM *, int, int, char **);
extern void pcf_edit_master_param(PCF_MASTER_ENT *, int, const char *, const char *);
#define WARN_ON_OPEN_ERROR 0
#define FAIL_ON_OPEN_ERROR 1
#define PCF_WARN_ON_OPEN_ERROR 0
#define PCF_FAIL_ON_OPEN_ERROR 1
#define PC_MASTER_BLANKS " \t\r\n" /* XXX */
#define PCF_MASTER_BLANKS " \t\r\n" /* XXX */
/*
* Master.cf parameter namespace management. The idea is to manage master.cf
@@ -215,91 +215,93 @@ extern void edit_master_param(PC_MASTER_ENT *, int, const char *, const char *);
*
* But it is easier if we use '/' instead.
*/
#define PC_NAMESP_SEP_CH '/'
#define PC_NAMESP_SEP_STR "/"
#define PCF_NAMESP_SEP_CH '/'
#define PCF_NAMESP_SEP_STR "/"
#define PC_LEGACY_SEP_CH '.'
#define PCF_LEGACY_SEP_CH '.'
/*
* postconf_match.c.
*/
#define PC_MATCH_WILDC_STR "*"
#define PC_MATCH_ANY(p) ((p)[0] == PC_MATCH_WILDC_STR[0] && (p)[1] == 0)
#define PC_MATCH_STRING(p, s) (PC_MATCH_ANY(p) || strcmp((p), (s)) == 0)
#define PCF_MATCH_WILDC_STR "*"
#define PCF_MATCH_ANY(p) ((p)[0] == PCF_MATCH_WILDC_STR[0] && (p)[1] == 0)
#define PCF_MATCH_STRING(p, s) (PCF_MATCH_ANY(p) || strcmp((p), (s)) == 0)
extern ARGV *parse_service_pattern(const char *, int, int);
extern int parse_field_pattern(const char *);
extern ARGV *pcf_parse_service_pattern(const char *, int, int);
extern int pcf_parse_field_pattern(const char *);
#define IS_MAGIC_SERVICE_PATTERN(pat) \
(PC_MATCH_ANY((pat)->argv[0]) || PC_MATCH_ANY((pat)->argv[1]))
#define MATCH_SERVICE_PATTERN(pat, name, type) \
(PC_MATCH_STRING((pat)->argv[0], (name)) \
&& PC_MATCH_STRING((pat)->argv[1], (type)))
#define PCF_IS_MAGIC_SERVICE_PATTERN(pat) \
(PCF_MATCH_ANY((pat)->argv[0]) || PCF_MATCH_ANY((pat)->argv[1]))
#define PCF_MATCH_SERVICE_PATTERN(pat, name, type) \
(PCF_MATCH_STRING((pat)->argv[0], (name)) \
&& PCF_MATCH_STRING((pat)->argv[1], (type)))
#define is_magic_field_pattern(pat) ((pat) == PC_MASTER_FIELD_WILDC)
#define str_field_pattern(pat) ((const char *) (field_name_offset[pat].name))
#define pcf_is_magic_field_pattern(pat) ((pat) == PCF_MASTER_FLD_WILDC)
#define pcf_str_field_pattern(pat) ((const char *) (pcf_field_name_offset[pat].name))
#define IS_MAGIC_PARAM_PATTERN(pat) PC_MATCH_ANY(pat)
#define MATCH_PARAM_PATTERN(pat, name) PC_MATCH_STRING((pat), (name))
#define PCF_IS_MAGIC_PARAM_PATTERN(pat) PCF_MATCH_ANY(pat)
#define PCF_MATCH_PARAM_PATTERN(pat, name) PCF_MATCH_STRING((pat), (name))
/* The following is not part of the postconf_match API. */
extern NAME_CODE field_name_offset[];
extern NAME_CODE pcf_field_name_offset[];
/*
* postconf_builtin.c.
*/
extern void register_builtin_parameters(const char *, pid_t);
extern void pcf_register_builtin_parameters(const char *, pid_t);
/*
* postconf_service.c.
*/
extern void register_service_parameters(void);
extern void pcf_register_service_parameters(void);
/*
* Parameter context structure.
*/
typedef struct {
PC_MASTER_ENT *local_scope;
PCF_MASTER_ENT *local_scope;
int param_class;
} PC_PARAM_CTX;
} PCF_PARAM_CTX;
/*
* postconf_user.c.
*/
extern void register_user_parameters(void);
extern void pcf_register_user_parameters(void);
/*
* postconf_dbms.c
*/
extern void register_dbms_parameters(const char *,
const char *(*) (const char *, int, PC_MASTER_ENT *),
PC_MASTER_ENT *);
extern void pcf_register_dbms_parameters(const char *,
const char *(*) (const char *, int, PCF_MASTER_ENT *),
PCF_MASTER_ENT *);
/*
* postconf_lookup.c.
*/
const char *lookup_parameter_value(int, const char *, PC_MASTER_ENT *,
PC_PARAM_NODE *);
extern const char *pcf_lookup_parameter_value(int, const char *,
PCF_MASTER_ENT *,
PCF_PARAM_NODE *);
char *expand_parameter_value(VSTRING *, int, const char *, PC_MASTER_ENT *);
extern char *pcf_expand_parameter_value(VSTRING *, int, const char *,
PCF_MASTER_ENT *);
/*
* postconf_print.c.
*/
extern void print_line(VSTREAM *, int, const char *,...);
extern void pcf_print_line(VSTREAM *, int, const char *,...);
/*
* postconf_unused.c.
*/
extern void flag_unused_main_parameters(void);
extern void flag_unused_master_parameters(void);
extern void pcf_flag_unused_main_parameters(void);
extern void pcf_flag_unused_master_parameters(void);
/*
* postconf_other.c.
*/
extern void show_maps(void);
extern void show_locks(void);
extern void show_sasl(int);
extern void pcf_show_maps(void);
extern void pcf_show_locks(void);
extern void pcf_show_sasl(int);
/* LICENSE
/* .ad

View File

@@ -2,16 +2,17 @@
/* NAME
/* postconf_builtin 3
/* SUMMARY
/* built-in parameter support
/* built-in main.cf parameter support
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void register_builtin_parameters(procname, pid)
/* void pcf_register_builtin_parameters(procname, pid)
/* const char *procname;
/* pid_t pid;
/* DESCRIPTION
/* register_builtin_parameters() initializes the global parameter
/* name space and adds all built-in parameter information.
/* pcf_register_builtin_parameters() initializes the global
/* main.cf parameter name space and adds all built-in parameter
/* information.
/*
/* Arguments:
/*.IP procname
@@ -86,43 +87,43 @@
* Support for built-in parameters: lookup tables generated by scanning
* actual C source files.
*/
static const CONFIG_TIME_TABLE time_table[] = {
static const CONFIG_TIME_TABLE pcf_time_table[] = {
#include "time_table.h"
0,
};
static const CONFIG_BOOL_TABLE bool_table[] = {
static const CONFIG_BOOL_TABLE pcf_bool_table[] = {
#include "bool_table.h"
0,
};
static const CONFIG_INT_TABLE int_table[] = {
static const CONFIG_INT_TABLE pcf_int_table[] = {
#include "int_table.h"
0,
};
static const CONFIG_STR_TABLE str_table[] = {
static const CONFIG_STR_TABLE pcf_str_table[] = {
#include "str_table.h"
#include "install_table.h"
0,
};
static const CONFIG_RAW_TABLE raw_table[] = {
static const CONFIG_RAW_TABLE pcf_raw_table[] = {
#include "raw_table.h"
0,
};
static const CONFIG_NINT_TABLE nint_table[] = {
static const CONFIG_NINT_TABLE pcf_nint_table[] = {
#include "nint_table.h"
0,
};
static const CONFIG_NBOOL_TABLE nbool_table[] = {
static const CONFIG_NBOOL_TABLE pcf_nbool_table[] = {
#include "nbool_table.h"
0,
};
static const CONFIG_LONG_TABLE long_table[] = {
static const CONFIG_LONG_TABLE pcf_long_table[] = {
#include "long_table.h"
0,
};
@@ -130,7 +131,7 @@ static const CONFIG_LONG_TABLE long_table[] = {
/*
* Legacy parameters for backwards compatibility.
*/
static const CONFIG_STR_TABLE legacy_str_table[] = {
static const CONFIG_STR_TABLE pcf_legacy_str_table[] = {
{"virtual_maps", ""},
{"fallback_relay", ""},
{"authorized_verp_clients", ""},
@@ -146,13 +147,13 @@ static const CONFIG_STR_TABLE legacy_str_table[] = {
* Important: if the evaluation of a parameter default value has any side
* effects, then those side effects must happen only once.
*/
static const char *pc_check_myhostname(void);
static const char *pc_check_mydomainname(void);
static const char *pc_mynetworks(void);
static const char *pcf_check_myhostname(void);
static const char *pcf_check_mydomainname(void);
static const char *pcf_mynetworks(void);
#include "str_fn_vars.h"
static const CONFIG_STR_FN_TABLE str_fn_table[] = {
static const CONFIG_STR_FN_TABLE pcf_str_fn_table[] = {
#include "str_fn_table.h"
0,
};
@@ -165,14 +166,14 @@ static const CONFIG_STR_FN_TABLE str_fn_table[] = {
* Important: if the evaluation of a parameter default value has any side
* effects, then those side effects must happen only once.
*/
static CONFIG_STR_TABLE adhoc_procname = {VAR_PROCNAME};
static CONFIG_INT_TABLE adhoc_pid = {VAR_PID};
static CONFIG_STR_TABLE pcf_adhoc_procname = {VAR_PROCNAME};
static CONFIG_INT_TABLE pcf_adhoc_pid = {VAR_PID};
#define STR(x) vstring_str(x)
/* pc_check_myhostname - lookup hostname and validate */
/* pcf_check_myhostname - lookup hostname and validate */
static const char *pc_check_myhostname(void)
static const char *pcf_check_myhostname(void)
{
static const char *name;
const char *dot;
@@ -197,20 +198,20 @@ static const char *pc_check_myhostname(void)
return (name);
}
/* get_myhostname - look up and store my hostname */
/* pcf_get_myhostname - look up and store my hostname */
static void get_myhostname(void)
static void pcf_get_myhostname(void)
{
const char *name;
if ((name = mail_conf_lookup_eval(VAR_MYHOSTNAME)) == 0)
name = pc_check_myhostname();
name = pcf_check_myhostname();
var_myhostname = mystrdup(name);
}
/* pc_check_mydomainname - lookup domain name and validate */
/* pcf_check_mydomainname - lookup domain name and validate */
static const char *pc_check_mydomainname(void)
static const char *pcf_check_mydomainname(void)
{
static const char *domain;
char *dot;
@@ -226,15 +227,15 @@ static const char *pc_check_mydomainname(void)
* actually is a domain name ("foo.com").
*/
if (var_myhostname == 0)
get_myhostname();
pcf_get_myhostname();
if ((dot = strchr(var_myhostname, '.')) == 0 || strchr(dot + 1, '.') == 0)
return (domain = DEF_MYDOMAIN);
return (domain = mystrdup(dot + 1));
}
/* pc_mynetworks - lookup network address list */
/* pcf_mynetworks - lookup network address list */
static const char *pc_mynetworks(void)
static const char *pcf_mynetworks(void)
{
static const char *networks;
INET_PROTO_INFO *proto_info;
@@ -247,19 +248,19 @@ static const char *pc_mynetworks(void)
return (networks);
if (var_inet_interfaces == 0) {
if ((cmd_mode & SHOW_DEFS)
if ((pcf_cmd_mode & PCF_SHOW_DEFS)
|| (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0)
junk = DEF_INET_INTERFACES;
var_inet_interfaces = mystrdup(junk);
}
if (var_mynetworks_style == 0) {
if ((cmd_mode & SHOW_DEFS)
if ((pcf_cmd_mode & PCF_SHOW_DEFS)
|| (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0)
junk = DEF_MYNETWORKS_STYLE;
var_mynetworks_style = mystrdup(junk);
}
if (var_inet_protocols == 0) {
if ((cmd_mode & SHOW_DEFS)
if ((pcf_cmd_mode & PCF_SHOW_DEFS)
|| (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0)
junk = DEF_INET_PROTOCOLS;
var_inet_protocols = mystrdup(junk);
@@ -268,92 +269,92 @@ static const char *pc_mynetworks(void)
return (networks = mystrdup(mynetworks()));
}
/* convert_bool_parameter - get boolean parameter string value */
/* pcf_conv_bool_parameter - get boolean parameter string value */
static const char *convert_bool_parameter(char *ptr)
static const char *pcf_conv_bool_parameter(char *ptr)
{
CONFIG_BOOL_TABLE *cbt = (CONFIG_BOOL_TABLE *) ptr;
return (cbt->defval ? "yes" : "no");
}
/* convert_time_parameter - get relative time parameter string value */
/* pcf_conv_time_parameter - get relative time parameter string value */
static const char *convert_time_parameter(char *ptr)
static const char *pcf_conv_time_parameter(char *ptr)
{
CONFIG_TIME_TABLE *ctt = (CONFIG_TIME_TABLE *) ptr;
return (ctt->defval);
}
/* convert_int_parameter - get integer parameter string value */
/* pcf_conv_int_parameter - get integer parameter string value */
static const char *convert_int_parameter(char *ptr)
static const char *pcf_conv_int_parameter(char *ptr)
{
CONFIG_INT_TABLE *cit = (CONFIG_INT_TABLE *) ptr;
return (STR(vstring_sprintf(param_string_buf, "%d", cit->defval)));
return (STR(vstring_sprintf(pcf_param_string_buf, "%d", cit->defval)));
}
/* convert_str_parameter - get string parameter string value */
/* pcf_conv_str_parameter - get string parameter string value */
static const char *convert_str_parameter(char *ptr)
static const char *pcf_conv_str_parameter(char *ptr)
{
CONFIG_STR_TABLE *cst = (CONFIG_STR_TABLE *) ptr;
return (cst->defval);
}
/* convert_str_fn_parameter - get string-function parameter string value */
/* pcf_conv_str_fn_parameter - get string-function parameter string value */
static const char *convert_str_fn_parameter(char *ptr)
static const char *pcf_conv_str_fn_parameter(char *ptr)
{
CONFIG_STR_FN_TABLE *cft = (CONFIG_STR_FN_TABLE *) ptr;
return (cft->defval());
}
/* convert_raw_parameter - get raw string parameter string value */
/* pcf_conv_raw_parameter - get raw string parameter string value */
static const char *convert_raw_parameter(char *ptr)
static const char *pcf_conv_raw_parameter(char *ptr)
{
CONFIG_RAW_TABLE *rst = (CONFIG_RAW_TABLE *) ptr;
return (rst->defval);
}
/* convert_nint_parameter - get new integer parameter string value */
/* pcf_conv_nint_parameter - get new integer parameter string value */
static const char *convert_nint_parameter(char *ptr)
static const char *pcf_conv_nint_parameter(char *ptr)
{
CONFIG_NINT_TABLE *rst = (CONFIG_NINT_TABLE *) ptr;
return (rst->defval);
}
/* convert_nbool_parameter - get new boolean parameter string value */
/* pcf_conv_nbool_parameter - get new boolean parameter string value */
static const char *convert_nbool_parameter(char *ptr)
static const char *pcf_conv_nbool_parameter(char *ptr)
{
CONFIG_NBOOL_TABLE *bst = (CONFIG_NBOOL_TABLE *) ptr;
return (bst->defval);
}
/* convert_long_parameter - get long parameter string value */
/* pcf_conv_long_parameter - get long parameter string value */
static const char *convert_long_parameter(char *ptr)
static const char *pcf_conv_long_parameter(char *ptr)
{
CONFIG_LONG_TABLE *clt = (CONFIG_LONG_TABLE *) ptr;
return (STR(vstring_sprintf(param_string_buf, "%ld", clt->defval)));
return (STR(vstring_sprintf(pcf_param_string_buf, "%ld", clt->defval)));
}
/* register_builtin_parameters - add built-ins to the global name space */
/* pcf_register_builtin_parameters - add built-ins to the global name space */
void register_builtin_parameters(const char *procname, pid_t pid)
void pcf_register_builtin_parameters(const char *procname, pid_t pid)
{
const char *myname = "register_builtin_parameters";
const char *myname = "pcf_register_builtin_parameters";
const CONFIG_TIME_TABLE *ctt;
const CONFIG_BOOL_TABLE *cbt;
const CONFIG_INT_TABLE *cit;
@@ -367,66 +368,75 @@ void register_builtin_parameters(const char *procname, pid_t pid)
/*
* Sanity checks.
*/
if (param_table != 0)
if (pcf_param_table != 0)
msg_panic("%s: global parameter table is already initialized", myname);
/*
* Initialize the global parameter table.
*/
param_table = PC_PARAM_TABLE_CREATE(1000);
pcf_param_table = PCF_PARAM_TABLE_CREATE(1000);
/*
* Add the built-in parameters to the global name space. The class
* (built-in) is tentative; some parameters are actually service-defined,
* but they have their own default value.
*/
for (ctt = time_table; ctt->name; ctt++)
PC_PARAM_TABLE_ENTER(param_table, ctt->name, PC_PARAM_FLAG_BUILTIN,
(char *) ctt, convert_time_parameter);
for (cbt = bool_table; cbt->name; cbt++)
PC_PARAM_TABLE_ENTER(param_table, cbt->name, PC_PARAM_FLAG_BUILTIN,
(char *) cbt, convert_bool_parameter);
for (cit = int_table; cit->name; cit++)
PC_PARAM_TABLE_ENTER(param_table, cit->name, PC_PARAM_FLAG_BUILTIN,
(char *) cit, convert_int_parameter);
for (cst = str_table; cst->name; cst++)
PC_PARAM_TABLE_ENTER(param_table, cst->name, PC_PARAM_FLAG_BUILTIN,
(char *) cst, convert_str_parameter);
for (cft = str_fn_table; cft->name; cft++)
PC_PARAM_TABLE_ENTER(param_table, cft->name, PC_PARAM_FLAG_BUILTIN,
(char *) cft, convert_str_fn_parameter);
for (rst = raw_table; rst->name; rst++)
PC_PARAM_TABLE_ENTER(param_table, rst->name,
PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_RAW,
(char *) rst, convert_raw_parameter);
for (nst = nint_table; nst->name; nst++)
PC_PARAM_TABLE_ENTER(param_table, nst->name, PC_PARAM_FLAG_BUILTIN,
(char *) nst, convert_nint_parameter);
for (bst = nbool_table; bst->name; bst++)
PC_PARAM_TABLE_ENTER(param_table, bst->name, PC_PARAM_FLAG_BUILTIN,
(char *) bst, convert_nbool_parameter);
for (lst = long_table; lst->name; lst++)
PC_PARAM_TABLE_ENTER(param_table, lst->name, PC_PARAM_FLAG_BUILTIN,
(char *) lst, convert_long_parameter);
for (ctt = pcf_time_table; ctt->name; ctt++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, ctt->name,
PCF_PARAM_FLAG_BUILTIN, (char *) ctt,
pcf_conv_time_parameter);
for (cbt = pcf_bool_table; cbt->name; cbt++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, cbt->name,
PCF_PARAM_FLAG_BUILTIN, (char *) cbt,
pcf_conv_bool_parameter);
for (cit = pcf_int_table; cit->name; cit++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, cit->name,
PCF_PARAM_FLAG_BUILTIN, (char *) cit,
pcf_conv_int_parameter);
for (cst = pcf_str_table; cst->name; cst++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, cst->name,
PCF_PARAM_FLAG_BUILTIN, (char *) cst,
pcf_conv_str_parameter);
for (cft = pcf_str_fn_table; cft->name; cft++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, cft->name,
PCF_PARAM_FLAG_BUILTIN, (char *) cft,
pcf_conv_str_fn_parameter);
for (rst = pcf_raw_table; rst->name; rst++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, rst->name,
PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_RAW,
(char *) rst, pcf_conv_raw_parameter);
for (nst = pcf_nint_table; nst->name; nst++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, nst->name,
PCF_PARAM_FLAG_BUILTIN, (char *) nst,
pcf_conv_nint_parameter);
for (bst = pcf_nbool_table; bst->name; bst++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, bst->name,
PCF_PARAM_FLAG_BUILTIN, (char *) bst,
pcf_conv_nbool_parameter);
for (lst = pcf_long_table; lst->name; lst++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, lst->name,
PCF_PARAM_FLAG_BUILTIN, (char *) lst,
pcf_conv_long_parameter);
/*
* Register legacy parameters (used as a backwards-compatible migration
* aid).
*/
for (cst = legacy_str_table; cst->name; cst++)
PC_PARAM_TABLE_ENTER(param_table, cst->name, PC_PARAM_FLAG_LEGACY,
(char *) cst, convert_str_parameter);
for (cst = pcf_legacy_str_table; cst->name; cst++)
PCF_PARAM_TABLE_ENTER(pcf_param_table, cst->name,
PCF_PARAM_FLAG_LEGACY, (char *) cst,
pcf_conv_str_parameter);
/*
* Register parameters whose default value is normally initialized by
* ad-hoc code.
*/
adhoc_procname.defval = mystrdup(procname);
PC_PARAM_TABLE_ENTER(param_table, adhoc_procname.name,
PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_READONLY,
(char *) &adhoc_procname, convert_str_parameter);
adhoc_pid.defval = pid;
PC_PARAM_TABLE_ENTER(param_table, adhoc_pid.name,
PC_PARAM_FLAG_BUILTIN | PC_PARAM_FLAG_READONLY,
(char *) &adhoc_pid, convert_int_parameter);
pcf_adhoc_procname.defval = mystrdup(procname);
PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_procname.name,
PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY,
(char *) &pcf_adhoc_procname, pcf_conv_str_parameter);
pcf_adhoc_pid.defval = pid;
PCF_PARAM_TABLE_ENTER(pcf_param_table, pcf_adhoc_pid.name,
PCF_PARAM_FLAG_BUILTIN | PCF_PARAM_FLAG_READONLY,
(char *) &pcf_adhoc_pid, pcf_conv_int_parameter);
}

View File

@@ -6,11 +6,11 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void register_dbms_parameters(param_value, flag_parameter,
/* void pcf_register_dbms_parameters(param_value, flag_parameter,
/* local_scope)
/* const char *param_value;
/* const char *(flag_parameter) (const char *, int, PC_MASTER_ENT *);
/* PC_MASTER_ENT *local_scope;
/* const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *);
/* PCF_MASTER_ENT *local_scope;
/* DESCRIPTION
/* This module implements legacy support for database configuration
/* where main.cf parameter names are generated by prepending
@@ -25,7 +25,7 @@
/* names for that database type.
/* .IP flag_parameter
/* A function that takes as arguments a candidate parameter
/* name, parameter flags, and a PC_MASTER_ENT pointer. The
/* name, parameter flags, and a PCF_MASTER_ENT pointer. The
/* function will flag the parameter as "used" if it has a
/* "name=value" entry in the local or global namespace.
/* .IP local_scope
@@ -83,7 +83,7 @@
/* See ldap_table(5). */
static const char *ldap_suffixes[] = {
static const char *pcf_ldap_suffixes[] = {
"bind", "bind_dn", "bind_pw", "cache", "cache_expiry", "cache_size",
"chase_referrals", "debuglevel", "dereference", "domain",
"expansion_limit", "leaf_result_attribute", "query_filter",
@@ -95,7 +95,7 @@ static const char *ldap_suffixes[] = {
/* See mysql_table(5). */
static const char *mysql_suffixes[] = {
static const char *pcf_mysql_suffixes[] = {
"additional_conditions", "dbname", "domain", "expansion_limit",
"hosts", "password", "query", "result_format", "select_field",
"table", "user", "where_field", 0,
@@ -103,7 +103,7 @@ static const char *mysql_suffixes[] = {
/* See pgsql_table(5). */
static const char *pgsql_suffixes[] = {
static const char *pcf_pgsql_suffixes[] = {
"additional_conditions", "dbname", "domain", "expansion_limit",
"hosts", "password", "query", "result_format", "select_field",
"select_function", "table", "user", "where_field", 0,
@@ -111,7 +111,7 @@ static const char *pgsql_suffixes[] = {
/* See sqlite_table(5). */
static const char *sqlite_suffixes[] = {
static const char *pcf_sqlite_suffixes[] = {
"additional_conditions", "dbpath", "domain", "expansion_limit",
"query", "result_format", "select_field", "table", "where_field",
0,
@@ -119,7 +119,7 @@ static const char *sqlite_suffixes[] = {
/* See memcache_table(5). */
static const char *memcache_suffixes[] = {
static const char *pcf_memcache_suffixes[] = {
"backup", "data_size_limit", "domain", "flags", "key_format",
"line_size_limit", "max_try", "memcache", "retry_pause",
"timeout", "ttl", 0,
@@ -131,24 +131,24 @@ static const char *memcache_suffixes[] = {
typedef struct {
const char *db_type;
const char **db_suffixes;
} PC_DBMS_INFO;
} PCF_DBMS_INFO;
static const PC_DBMS_INFO dbms_info[] = {
DICT_TYPE_LDAP, ldap_suffixes,
DICT_TYPE_MYSQL, mysql_suffixes,
DICT_TYPE_PGSQL, pgsql_suffixes,
DICT_TYPE_SQLITE, sqlite_suffixes,
DICT_TYPE_MEMCACHE, memcache_suffixes,
static const PCF_DBMS_INFO pcf_dbms_info[] = {
DICT_TYPE_LDAP, pcf_ldap_suffixes,
DICT_TYPE_MYSQL, pcf_mysql_suffixes,
DICT_TYPE_PGSQL, pcf_pgsql_suffixes,
DICT_TYPE_SQLITE, pcf_sqlite_suffixes,
DICT_TYPE_MEMCACHE, pcf_memcache_suffixes,
0,
};
/* register_dbms_parameters - look for database_type:prefix_name */
/* pcf_register_dbms_parameters - look for database_type:prefix_name */
void register_dbms_parameters(const char *param_value,
const char *(flag_parameter) (const char *, int, PC_MASTER_ENT *),
PC_MASTER_ENT *local_scope)
void pcf_register_dbms_parameters(const char *param_value,
const char *(flag_parameter) (const char *, int, PCF_MASTER_ENT *),
PCF_MASTER_ENT *local_scope)
{
const PC_DBMS_INFO *dp;
const PCF_DBMS_INFO *dp;
char *bufp;
char *db_type;
char *prefix;
@@ -163,7 +163,8 @@ void register_dbms_parameters(const char *param_value,
*/
if (buffer == 0)
buffer = vstring_alloc(100);
bufp = expand_parameter_value(buffer, SHOW_EVAL, param_value, local_scope);
bufp = pcf_expand_parameter_value(buffer, PCF_SHOW_EVAL, param_value,
local_scope);
/*
* Naive parsing. We don't really know if the parameter specifies free
@@ -187,14 +188,14 @@ void register_dbms_parameters(const char *param_value,
* local or global namespace.
*/
if (prefix != 0 && *prefix != '/' && *prefix != '.') {
for (dp = dbms_info; dp->db_type != 0; dp++) {
for (dp = pcf_dbms_info; dp->db_type != 0; dp++) {
if (strcmp(db_type, dp->db_type) == 0) {
for (cpp = dp->db_suffixes; *cpp; cpp++) {
vstring_sprintf(candidate ? candidate :
(candidate = vstring_alloc(30)),
"%s_%s", prefix, *cpp);
flag_parameter(STR(candidate),
PC_PARAM_FLAG_DBMS | PC_PARAM_FLAG_USER,
PCF_PARAM_FLAG_DBMS | PCF_PARAM_FLAG_USER,
local_scope);
}
break;

View File

@@ -6,46 +6,45 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void edit_main(mode, argc, argv)
/* void pcf_edit_main(mode, argc, argv)
/* int mode;
/* int argc;
/* char **argv;
/*
/* void edit_master(mode, argc, argv)
/* void pcf_edit_master(mode, argc, argv)
/* int mode;
/* int argc;
/* char **argv;
/* DESCRIPTION
/* edit_main() edits the \fBmain.cf\fR configuration
/* file. It replaces or adds parameter settings given as
/* "\fIname=value\fR" pairs given on the command line, or
/* removes parameter settings given as "\fIname\fR" on the
/* command line. The file is copied to a temporary file
/* then renamed into place.
/* pcf_edit_main() edits the \fBmain.cf\fR configuration file.
/* It replaces or adds parameter settings given as "\fIname=value\fR"
/* pairs given on the command line, or removes parameter
/* settings given as "\fIname\fR" on the command line. The
/* file is copied to a temporary file then renamed into place.
/*
/* edit_master() edits the \fBmaster.cf\fR configuration file.
/* The file is copied to a temporary file then renamed into
/* place. Depending on the flags in \fBmode\fR:
/* .IP MASTER_ENTRY
/* With EDIT_CONF, edit_master() replaces or adds entire
/* master.cf entries, specified on the command line as
/* pcf_edit_master() edits the \fBmaster.cf\fR configuration
/* file. The file is copied to a temporary file then renamed
/* into place. Depending on the flags in \fBmode\fR:
/* .IP PCF_MASTER_ENTRY
/* With PCF_EDIT_CONF, pcf_edit_master() replaces or adds
/* entire master.cf entries, specified on the command line as
/* "\fIname/type = name type private unprivileged chroot wakeup
/* process_limit command...\fR".
/*
/* With EDIT_EXCL or COMMENT_OUT, edit_master() removes or
/* comments out entries specified on the command line as
/* "\fIname/type\fR.
/* .IP MASTER_FIELD
/* With EDIT_CONF, edit_master() replaces the value of specific
/* service attributes, specified on the command line as
/* "\fIname/type/attribute = value\fR".
/* .IP MASTER_PARAM
/* With EDIT_CONF, edit_master() replaces or adds the value
/* of service parameters, specified on the command line as
/* "\fIname/type/parameter = value\fR".
/* With PCF_EDIT_EXCL or PCF_COMMENT_OUT, pcf_edit_master()
/* removes or comments out entries specified on the command
/* line as "\fIname/type\fR.
/* .IP PCF_MASTER_FLD
/* With PCF_EDIT_CONF, pcf_edit_master() replaces the value
/* of specific service attributes, specified on the command
/* line as "\fIname/type/attribute = value\fR".
/* .IP PCF_MASTER_PARAM
/* With PCF_EDIT_CONF, pcf_edit_master() replaces or adds the
/* value of service parameters, specified on the command line
/* as "\fIname/type/parameter = value\fR".
/*
/* With EDIT_EXCL, edit_master() removes service parameters
/* specified on the command line as "\fIparametername\fR".
/* With PCF_EDIT_EXCL, pcf_edit_master() removes service
/* parameters specified on the command line as "\fIparametername\fR".
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* FILES
@@ -92,9 +91,9 @@
#define STR(x) vstring_str(x)
/* find_cf_info - pass-through non-content line, return content or null */
/* pcf_find_cf_info - pass-through non-content line, return content or null */
static char *find_cf_info(VSTRING *buf, VSTREAM *dst)
static char *pcf_find_cf_info(VSTRING *buf, VSTREAM *dst)
{
char *cp;
@@ -109,25 +108,25 @@ static char *find_cf_info(VSTRING *buf, VSTREAM *dst)
}
}
/* next_cf_line - return next content line, pass-through non-content */
/* pcf_next_cf_line - return next content line, pass non-content */
static char *next_cf_line(VSTRING *buf, VSTREAM *src, VSTREAM *dst, int *lineno)
static char *pcf_next_cf_line(VSTRING *buf, VSTREAM *src, VSTREAM *dst, int *lineno)
{
char *cp;
while (vstring_get(buf, src) != VSTREAM_EOF) {
if (lineno)
*lineno += 1;
if ((cp = find_cf_info(buf, dst)) != 0)
if ((cp = pcf_find_cf_info(buf, dst)) != 0)
return (cp);
}
return (0);
}
/* gobble_cf_line - accumulate multi-line content, pass-through non-content */
/* pcf_gobble_cf_line - accumulate multi-line content, pass non-content */
static void gobble_cf_line(VSTRING *full_entry_buf, VSTRING *line_buf,
VSTREAM *src, VSTREAM *dst, int *lineno)
static void pcf_gobble_cf_line(VSTRING *full_entry_buf, VSTRING *line_buf,
VSTREAM *src, VSTREAM *dst, int *lineno)
{
int ch;
@@ -139,14 +138,14 @@ static void gobble_cf_line(VSTRING *full_entry_buf, VSTRING *line_buf,
|| vstring_get(line_buf, src) == VSTREAM_EOF)
break;
lineno += 1;
if (find_cf_info(line_buf, dst))
if (pcf_find_cf_info(line_buf, dst))
vstring_strcat(full_entry_buf, STR(line_buf));
}
}
/* edit_main - edit main.cf file */
/* pcf_edit_main - edit main.cf file */
void edit_main(int mode, int argc, char **argv)
void pcf_edit_main(int mode, int argc, char **argv)
{
char *path;
EDIT_FILE *ep;
@@ -179,10 +178,10 @@ void edit_main(int mode, int argc, char **argv)
cp++;
if (*cp == '#')
msg_fatal("-e, -X, or -# accepts no comment input");
if (mode & EDIT_CONF) {
if (mode & PCF_EDIT_CONF) {
if ((err = split_nameval(cp, &pattern, &edit_value)) != 0)
msg_fatal("%s: \"%s\"", err, cp);
} else if (mode & (COMMENT_OUT | EDIT_EXCL)) {
} else if (mode & (PCF_COMMENT_OUT | PCF_EDIT_EXCL)) {
if (*cp == 0)
msg_fatal("-X or -# requires non-blank parameter names");
if (strchr(cp, '=') != 0)
@@ -191,7 +190,7 @@ void edit_main(int mode, int argc, char **argv)
trimblanks(pattern, 0);
edit_value = 0;
} else {
msg_panic("edit_main: unknown mode %d", mode);
msg_panic("pcf_edit_main: unknown mode %d", mode);
}
cvalue = (struct cvalue *) mymalloc(sizeof(*cvalue));
cvalue->value = edit_value;
@@ -203,7 +202,7 @@ void edit_main(int mode, int argc, char **argv)
* Open a temp file for the result. This uses a deterministic name so we
* don't leave behind thrash with random names.
*/
set_config_dir();
pcf_set_config_dir();
path = concatenate(var_config_dir, "/", MAIN_CONF_FILE, (char *) 0);
if ((ep = edit_file_open(path, O_CREAT | O_WRONLY, 0644)) == 0)
msg_fatal("open %s%s: %m", path, EDIT_FILE_SUFFIX);
@@ -225,12 +224,12 @@ void edit_main(int mode, int argc, char **argv)
#define STR(x) vstring_str(x)
interesting = 0;
while ((cp = next_cf_line(buf, src, dst, (int *) 0)) != 0) {
while ((cp = pcf_next_cf_line(buf, src, dst, (int *) 0)) != 0) {
/* Copy, skip or replace continued text. */
if (cp > STR(buf)) {
if (interesting == 0)
vstream_fputs(STR(buf), dst);
else if (mode & COMMENT_OUT)
else if (mode & PCF_COMMENT_OUT)
vstream_fprintf(dst, "#%s", STR(buf));
}
/* Copy or replace start of logical line. */
@@ -240,9 +239,9 @@ void edit_main(int mode, int argc, char **argv)
if ((interesting = !!cvalue) != 0) {
if (cvalue->found++ == 1)
msg_warn("%s: multiple entries for \"%s\"", path, STR(key));
if (mode & EDIT_CONF)
if (mode & PCF_EDIT_CONF)
vstream_fprintf(dst, "%s = %s\n", STR(key), cvalue->value);
else if (mode & COMMENT_OUT)
else if (mode & PCF_COMMENT_OUT)
vstream_fprintf(dst, "#%s", cp);
} else {
vstream_fputs(STR(buf), dst);
@@ -253,7 +252,7 @@ void edit_main(int mode, int argc, char **argv)
/*
* Generate new entries for parameters that were not found.
*/
if (mode & EDIT_CONF) {
if (mode & PCF_EDIT_CONF) {
for (ht_info = ht = htable_list(table); *ht; ht++) {
cvalue = (struct cvalue *) ht[0]->value;
if (cvalue->found == 0)
@@ -290,13 +289,13 @@ typedef struct {
int field_number; /* attribute field number */
const char *param_pattern; /* parameter name */
char *edit_value; /* value substring */
} PC_MASTER_EDIT_REQ;
} PCF_MASTER_EDIT_REQ;
/* edit_master - edit master.cf file */
/* pcf_edit_master - edit master.cf file */
void edit_master(int mode, int argc, char **argv)
void pcf_edit_master(int mode, int argc, char **argv)
{
const char *myname = "edit_master";
const char *myname = "pcf_edit_master";
char *path;
EDIT_FILE *ep;
VSTREAM *src;
@@ -304,14 +303,14 @@ void edit_master(int mode, int argc, char **argv)
VSTRING *line_buf = vstring_alloc(100);
VSTRING *parse_buf = vstring_alloc(100);
int lineno;
PC_MASTER_ENT *new_entry;
PCF_MASTER_ENT *new_entry;
VSTRING *full_entry_buf = vstring_alloc(100);
char *cp;
char *pattern;
int service_name_type_matched;
const char *err;
PC_MASTER_EDIT_REQ *edit_reqs;
PC_MASTER_EDIT_REQ *req;
PCF_MASTER_EDIT_REQ *edit_reqs;
PCF_MASTER_EDIT_REQ *req;
int num_reqs = argc;
const char *edit_opts = "-Me, -Fe, -Pe, -X, or -#";
char *service_name;
@@ -326,7 +325,7 @@ void edit_master(int mode, int argc, char **argv)
/*
* Preprocessing: split pattern=value, then split the pattern components.
*/
edit_reqs = (PC_MASTER_EDIT_REQ *) mymalloc(sizeof(*edit_reqs) * num_reqs);
edit_reqs = (PCF_MASTER_EDIT_REQ *) mymalloc(sizeof(*edit_reqs) * num_reqs);
for (req = edit_reqs; *argv != 0; req++, argv++) {
req->match_count = 0;
req->raw_text = *argv;
@@ -338,14 +337,14 @@ void edit_master(int mode, int argc, char **argv)
if (*cp == '#')
msg_fatal("%s accept no comment input", edit_opts);
/* Separate the pattern from the value. */
if (mode & EDIT_CONF) {
if (mode & PCF_EDIT_CONF) {
if ((err = split_nameval(cp, &pattern, &req->edit_value)) != 0)
msg_fatal("%s: \"%s\"", err, req->raw_text);
if ((mode & MASTER_PARAM)
&& req->edit_value[strcspn(req->edit_value, PC_MASTER_BLANKS)])
if ((mode & PCF_MASTER_PARAM)
&& req->edit_value[strcspn(req->edit_value, PCF_MASTER_BLANKS)])
msg_fatal("whitespace in parameter value: \"%s\"",
req->raw_text);
} else if (mode & (COMMENT_OUT | EDIT_EXCL)) {
} else if (mode & (PCF_COMMENT_OUT | PCF_EDIT_EXCL)) {
if (strchr(cp, '=') != 0)
msg_fatal("-X or -# requires names without value");
pattern = cp;
@@ -355,39 +354,39 @@ void edit_master(int mode, int argc, char **argv)
msg_panic("%s: unknown mode %d", myname, mode);
}
#define PC_MASTER_MASK (MASTER_ENTRY | MASTER_FIELD | MASTER_PARAM)
#define PCF_MASTER_MASK (PCF_MASTER_ENTRY | PCF_MASTER_FLD | PCF_MASTER_PARAM)
/*
* Split name/type or name/type/whatever pattern into components.
*/
switch (mode & PC_MASTER_MASK) {
case MASTER_ENTRY:
switch (mode & PCF_MASTER_MASK) {
case PCF_MASTER_ENTRY:
if ((req->service_pattern =
parse_service_pattern(pattern, 2, 2)) == 0)
pcf_parse_service_pattern(pattern, 2, 2)) == 0)
msg_fatal("-Me, -MX or -M# requires service_name/type");
break;
case MASTER_FIELD:
case PCF_MASTER_FLD:
if ((req->service_pattern =
parse_service_pattern(pattern, 3, 3)) == 0)
pcf_parse_service_pattern(pattern, 3, 3)) == 0)
msg_fatal("-Fe or -FX requires service_name/type/field_name");
req->field_number =
parse_field_pattern(req->service_pattern->argv[2]);
if (is_magic_field_pattern(req->field_number))
pcf_parse_field_pattern(req->service_pattern->argv[2]);
if (pcf_is_magic_field_pattern(req->field_number))
msg_fatal("-Fe does not accept wild-card field name");
if ((mode & EDIT_CONF)
&& req->field_number < PC_MASTER_FIELD_CMD
&& req->edit_value[strcspn(req->edit_value, PC_MASTER_BLANKS)])
if ((mode & PCF_EDIT_CONF)
&& req->field_number < PCF_MASTER_FLD_CMD
&& req->edit_value[strcspn(req->edit_value, PCF_MASTER_BLANKS)])
msg_fatal("-Fe does not accept whitespace in non-command field");
break;
case MASTER_PARAM:
case PCF_MASTER_PARAM:
if ((req->service_pattern =
parse_service_pattern(pattern, 3, 3)) == 0)
pcf_parse_service_pattern(pattern, 3, 3)) == 0)
msg_fatal("-Pe or -PX requires service_name/type/parameter");
req->param_pattern = req->service_pattern->argv[2];
if (IS_MAGIC_PARAM_PATTERN(req->param_pattern))
if (PCF_IS_MAGIC_PARAM_PATTERN(req->param_pattern))
msg_fatal("-Pe does not accept wild-card parameter name");
if ((mode & EDIT_CONF)
&& req->edit_value[strcspn(req->edit_value, PC_MASTER_BLANKS)])
if ((mode & PCF_EDIT_CONF)
&& req->edit_value[strcspn(req->edit_value, PCF_MASTER_BLANKS)])
msg_fatal("-Pe does not accept whitespace in parameter value");
break;
default:
@@ -399,7 +398,7 @@ void edit_master(int mode, int argc, char **argv)
* Open a temp file for the result. This uses a deterministic name so we
* don't leave behind thrash with random names.
*/
set_config_dir();
pcf_set_config_dir();
path = concatenate(var_config_dir, "/", MASTER_CONF_FILE, (char *) 0);
if ((ep = edit_file_open(path, O_CREAT | O_WRONLY, 0644)) == 0)
msg_fatal("open %s%s: %m", path, EDIT_FILE_SUFFIX);
@@ -421,7 +420,7 @@ void edit_master(int mode, int argc, char **argv)
service_name_type_matched = 0;
new_entry = 0;
lineno = 0;
while ((cp = next_cf_line(parse_buf, src, dst, &lineno)) != 0) {
while ((cp = pcf_next_cf_line(parse_buf, src, dst, &lineno)) != 0) {
vstring_strcpy(line_buf, STR(parse_buf));
/*
@@ -430,7 +429,7 @@ void edit_master(int mode, int argc, char **argv)
if (cp > STR(parse_buf)) {
if (service_name_type_matched == 0)
vstream_fputs(STR(line_buf), dst);
else if (mode & COMMENT_OUT)
else if (mode & PCF_COMMENT_OUT)
vstream_fprintf(dst, "#%s", STR(line_buf));
}
@@ -443,8 +442,8 @@ void edit_master(int mode, int argc, char **argv)
/*
* Parse out the service name and type.
*/
if ((service_name = mystrtok(&cp, PC_MASTER_BLANKS)) == 0
|| (service_type = mystrtok(&cp, PC_MASTER_BLANKS)) == 0)
if ((service_name = mystrtok(&cp, PCF_MASTER_BLANKS)) == 0
|| (service_type = mystrtok(&cp, PCF_MASTER_BLANKS)) == 0)
msg_fatal("file %s: line %d: specify service name and type "
"on the same line", path, lineno);
if (strchr(service_name, '='))
@@ -460,54 +459,56 @@ void edit_master(int mode, int argc, char **argv)
* Match each service pattern.
*/
for (req = edit_reqs; req < edit_reqs + num_reqs; req++) {
if (MATCH_SERVICE_PATTERN(req->service_pattern, service_name,
service_type)) {
if (PCF_MATCH_SERVICE_PATTERN(req->service_pattern,
service_name,
service_type)) {
service_name_type_matched = 1; /* Sticky flag */
req->match_count += 1;
/*
* Generate replacement master.cf entries.
*/
if ((mode & EDIT_CONF)
|| ((mode & MASTER_PARAM) && (mode & EDIT_EXCL))) {
switch (mode & PC_MASTER_MASK) {
if ((mode & PCF_EDIT_CONF)
|| ((mode & PCF_MASTER_PARAM) && (mode & PCF_EDIT_EXCL))) {
switch (mode & PCF_MASTER_MASK) {
/*
* Replace master.cf entry field or parameter
* value.
*/
case MASTER_FIELD:
case MASTER_PARAM:
case PCF_MASTER_FLD:
case PCF_MASTER_PARAM:
if (new_entry == 0) {
/* Gobble up any continuation lines. */
gobble_cf_line(full_entry_buf, line_buf, src,
dst, &lineno);
new_entry = (PC_MASTER_ENT *)
pcf_gobble_cf_line(full_entry_buf, line_buf,
src, dst, &lineno);
new_entry = (PCF_MASTER_ENT *)
mymalloc(sizeof(*new_entry));
if ((err = parse_master_entry(new_entry,
if ((err = pcf_parse_master_entry(new_entry,
STR(full_entry_buf))) != 0)
msg_fatal("file %s: line %d: %s",
path, lineno, err);
}
if (mode & MASTER_FIELD) {
edit_master_field(new_entry, req->field_number,
req->edit_value);
if (mode & PCF_MASTER_FLD) {
pcf_edit_master_field(new_entry,
req->field_number,
req->edit_value);
} else {
edit_master_param(new_entry, mode,
req->param_pattern,
req->edit_value);
pcf_edit_master_param(new_entry, mode,
req->param_pattern,
req->edit_value);
}
break;
/*
* Replace entire master.cf entry.
*/
case MASTER_ENTRY:
case PCF_MASTER_ENTRY:
if (new_entry != 0)
free_master_entry(new_entry);
new_entry = (PC_MASTER_ENT *)
pcf_free_master_entry(new_entry);
new_entry = (PCF_MASTER_ENT *)
mymalloc(sizeof(*new_entry));
if ((err = parse_master_entry(new_entry,
if ((err = pcf_parse_master_entry(new_entry,
req->edit_value)) != 0)
msg_fatal("%s: \"%s\"", err, req->raw_text);
break;
@@ -522,12 +523,12 @@ void edit_master(int mode, int argc, char **argv)
* Pass through or replace the current input line.
*/
if (new_entry) {
print_master_entry(dst, FOLD_LINE, new_entry);
free_master_entry(new_entry);
pcf_print_master_entry(dst, PCF_FOLD_LINE, new_entry);
pcf_free_master_entry(new_entry);
new_entry = 0;
} else if (service_name_type_matched == 0) {
vstream_fputs(STR(line_buf), dst);
} else if (mode & COMMENT_OUT) {
} else if (mode & PCF_COMMENT_OUT) {
vstream_fprintf(dst, "#%s", STR(line_buf));
}
}
@@ -540,13 +541,13 @@ void edit_master(int mode, int argc, char **argv)
*/
for (req = edit_reqs; req < edit_reqs + num_reqs; req++) {
if (req->match_count == 0) {
if ((mode & MASTER_ENTRY) && (mode & EDIT_CONF)) {
new_entry = (PC_MASTER_ENT *) mymalloc(sizeof(*new_entry));
if ((err = parse_master_entry(new_entry, req->edit_value)) != 0)
if ((mode & PCF_MASTER_ENTRY) && (mode & PCF_EDIT_CONF)) {
new_entry = (PCF_MASTER_ENT *) mymalloc(sizeof(*new_entry));
if ((err = pcf_parse_master_entry(new_entry, req->edit_value)) != 0)
msg_fatal("%s: \"%s\"", err, req->raw_text);
print_master_entry(dst, FOLD_LINE, new_entry);
free_master_entry(new_entry);
} else if ((mode & MASTER_ENTRY) == 0) {
pcf_print_master_entry(dst, PCF_FOLD_LINE, new_entry);
pcf_free_master_entry(new_entry);
} else if ((mode & PCF_MASTER_ENTRY) == 0) {
msg_warn("unmatched service_name/type: \"%s\"", req->raw_text);
}
}

View File

@@ -6,37 +6,38 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* const char *lookup_parameter_value(mode, name, local_scope, node)
/* const char *pcf_lookup_parameter_value(mode, name, local_scope, node)
/* int mode;
/* const char *name;
/* PC_MASTER_ENT *local_scope;
/* PC_PARAM_NODE *node;
/* PCF_MASTER_ENT *local_scope;
/* PCF_PARAM_NODE *node;
/*
/* char *expand_parameter_value(buf, mode, value, local_scope)
/* char *pcf_expand_parameter_value(buf, mode, value, local_scope)
/* VSTRING *buf;
/* int mode;
/* const char *value;
/* PC_MASTER_ENT *local_scope;
/* PCF_MASTER_ENT *local_scope;
/* DESCRIPTION
/* These functions perform parameter value lookups. The order
/* of decreasing precedence is:
/* .IP \(bu
/* Search name=value parameter settings in master.cf.
/* These lookups are disabled with the SHOW_DEFS flag.
/* Search name=value parameter settings in master.cf. These
/* lookups are disabled with the PCF_SHOW_DEFS flag.
/* .IP \(bu
/* Search name=value parameter settings in main.cf.
/* These lookups are disabled with the SHOW_DEFS flag.
/* Search name=value parameter settings in main.cf. These
/* lookups are disabled with the PCF_SHOW_DEFS flag.
/* .IP \(bu
/* Search built-in default parameter settings. These lookups
/* are disabled with the SHOW_NONDEF flag.
/* are disabled with the PCF_SHOW_NONDEF flag.
/* .PP
/* lookup_parameter_value() looks up the value for the named
/* parameter, and returns null if the name was not found.
/* pcf_lookup_parameter_value() looks up the value for the
/* named parameter, and returns null if the name was not found.
/*
/* expand_parameter_value() expands $name in the specified
/* parameter value. This function ignores the SHOW_NONDEF flag.
/* The result value is a pointer to storage in a user-supplied
/* buffer, or in a buffer that is overwritten with each call.
/* pcf_expand_parameter_value() expands $name in the specified
/* parameter value. This function ignores the PCF_SHOW_NONDEF
/* flag. The result value is a pointer to storage in a
/* user-supplied buffer, or in a buffer that is overwritten
/* with each call.
/*
/* Arguments:
/* .IP buf
@@ -45,9 +46,9 @@
/* Bit-wise OR of zero or one of the following (other flags
/* are ignored):
/* .RS
/* .IP SHOW_DEFS
/* .IP PCF_SHOW_DEFS
/* Search built-in default parameter settings only.
/* .IP SHOW_NONDEF
/* .IP PCF_SHOW_NONDEF
/* Search local (master.cf) and global (main.cf) name=value
/* parameter settings only.
/* .RE
@@ -98,11 +99,11 @@
#define STR(x) vstring_str(x)
/* lookup_parameter_value - look up specific parameter value */
/* pcf_lookup_parameter_value - look up specific parameter value */
const char *lookup_parameter_value(int mode, const char *name,
PC_MASTER_ENT *local_scope,
PC_PARAM_NODE *node)
const char *pcf_lookup_parameter_value(int mode, const char *name,
PCF_MASTER_ENT *local_scope,
PCF_PARAM_NODE *node)
{
const char *value = 0;
@@ -111,13 +112,13 @@ const char *lookup_parameter_value(int mode, const char *name,
* name=value entries in main.cf. Built-in defaults have the lowest
* precedence.
*/
if ((mode & SHOW_DEFS) != 0
if ((mode & PCF_SHOW_DEFS) != 0
|| ((local_scope == 0 || local_scope->all_params == 0
|| (value = dict_get(local_scope->all_params, name)) == 0)
&& (value = dict_lookup(CONFIG_DICT, name)) == 0
&& (mode & SHOW_NONDEF) == 0)) {
if (node != 0 || (node = PC_PARAM_TABLE_FIND(param_table, name)) != 0)
value = convert_param_node(SHOW_DEFS, name, node);
&& (mode & PCF_SHOW_NONDEF) == 0)) {
if (node != 0 || (node = PCF_PARAM_TABLE_FIND(pcf_param_table, name)) != 0)
value = pcf_convert_param_node(PCF_SHOW_DEFS, name, node);
}
return (value);
}
@@ -128,30 +129,30 @@ const char *lookup_parameter_value(int mode, const char *name,
*/
typedef struct {
int mode;
PC_MASTER_ENT *local_scope;
} PC_EVAL_CTX;
PCF_MASTER_ENT *local_scope;
} PCF_EVAL_CTX;
/* lookup_parameter_value_wrapper - macro parser call-back routine */
/* pcf_lookup_parameter_value_wrapper - macro parser call-back routine */
static const char *lookup_parameter_value_wrapper(const char *key,
int unused_type,
char *context)
static const char *pcf_lookup_parameter_value_wrapper(const char *key,
int unused_type,
char *context)
{
PC_EVAL_CTX *cp = (PC_EVAL_CTX *) context;
PCF_EVAL_CTX *cp = (PCF_EVAL_CTX *) context;
return (lookup_parameter_value(cp->mode, key, cp->local_scope,
(PC_PARAM_NODE *) 0));
return (pcf_lookup_parameter_value(cp->mode, key, cp->local_scope,
(PCF_PARAM_NODE *) 0));
}
/* expand_parameter_value - expand $name in parameter value */
/* pcf_expand_parameter_value - expand $name in parameter value */
char *expand_parameter_value(VSTRING *buf, int mode, const char *value,
PC_MASTER_ENT *local_scope)
char *pcf_expand_parameter_value(VSTRING *buf, int mode, const char *value,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "expand_parameter_value";
const char *myname = "pcf_expand_parameter_value";
static VSTRING *local_buf;
int status;
PC_EVAL_CTX eval_ctx;
PCF_EVAL_CTX eval_ctx;
/*
* Initialize.
@@ -173,10 +174,10 @@ char *expand_parameter_value(VSTRING *buf, int mode, const char *value,
*/
#define DONT_FILTER (char *) 0
eval_ctx.mode = (mode & ~SHOW_NONDEF);
eval_ctx.mode = (mode & ~PCF_SHOW_NONDEF);
eval_ctx.local_scope = local_scope;
status = mac_expand(buf, value, MAC_EXP_FLAG_RECURSE, DONT_FILTER,
lookup_parameter_value_wrapper, (char *) &eval_ctx);
pcf_lookup_parameter_value_wrapper, (char *) &eval_ctx);
if (status & MAC_PARSE_ERROR)
msg_fatal("macro processing error");
if (msg_verbose > 1) {

View File

@@ -6,21 +6,21 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void read_parameters()
/* void pcf_read_parameters()
/*
/* void show_parameters(fp, mode, param_class, names)
/* void pcf_show_parameters(fp, mode, param_class, names)
/* VSTREAM *fp;
/* int mode;
/* int param_class;
/* char **names;
/* DESCRIPTION
/* read_parameters() reads parameters from main.cf.
/* pcf_read_parameters() reads parameters from main.cf.
/*
/* set_parameters() takes an array of \fIname=value\fR pairs
/* and overrides settings read with read_parameters().
/* pcf_set_parameters() takes an array of \fIname=value\fR
/* pairs and overrides settings read with pcf_read_parameters().
/*
/* show_parameters() writes main.cf parameters to the specified
/* output stream.
/* pcf_show_parameters() writes main.cf parameters to the
/* specified output stream.
/*
/* Arguments:
/* .IP fp
@@ -28,25 +28,25 @@
/* .IP mode
/* Bit-wise OR of zero or more of the following:
/* .RS
/* .IP FOLD_LINE
/* .IP PCF_FOLD_LINE
/* Fold long lines.
/* .IP SHOW_DEFS
/* .IP PCF_SHOW_DEFS
/* Output default parameter values.
/* .IP SHOW_NONDEF
/* .IP PCF_SHOW_NONDEF
/* Output explicit settings only.
/* .IP SHOW_NAME
/* Output the parameter as "name = value".
/* .IP SHOW_EVAL
/* .IP PCF_HIDE_NAME
/* Output parameter values without the "name =" prefix.
/* .IP PCF_SHOW_EVAL
/* Expand $name in parameter values.
/* .RE
/* .IP param_class
/* Bit-wise OR of one or more of the following:
/* .RS
/* .IP PC_PARAM_FLAG_BUILTIN
/* .IP PCF_PARAM_FLAG_BUILTIN
/* Show built-in parameters.
/* .IP PC_PARAM_FLAG_SERVICE
/* .IP PCF_PARAM_FLAG_SERVICE
/* Show service-defined parameters.
/* .IP PC_PARAM_FLAG_USER
/* .IP PCF_PARAM_FLAG_USER
/* Show user-defined parameters.
/* .RE
/* .IP names
@@ -95,9 +95,9 @@
#define STR(x) vstring_str(x)
/* read_parameters - read parameter info from file */
/* pcf_read_parameters - read parameter info from file */
void read_parameters(void)
void pcf_read_parameters(void)
{
char *path;
@@ -105,16 +105,16 @@ void read_parameters(void)
* A direct rip-off of mail_conf_read(). XXX Avoid code duplication by
* better code decomposition.
*/
set_config_dir();
pcf_set_config_dir();
path = concatenate(var_config_dir, "/", MAIN_CONF_FILE, (char *) 0);
if (dict_load_file_xt(CONFIG_DICT, path) == 0)
msg_fatal("open %s: %m", path);
myfree(path);
}
/* set_parameters - add or override name=value pairs */
/* pcf_set_parameters - add or override name=value pairs */
void set_parameters(char **name_val_array)
void pcf_set_parameters(char **name_val_array)
{
char *name, *value, *junk;
const char *err;
@@ -129,66 +129,67 @@ void set_parameters(char **name_val_array)
}
}
/* print_parameter - show specific parameter */
/* pcf_print_parameter - show specific parameter */
static void print_parameter(VSTREAM *fp, int mode, const char *name,
PC_PARAM_NODE *node)
static void pcf_print_parameter(VSTREAM *fp, int mode, const char *name,
PCF_PARAM_NODE *node)
{
const char *value;
/*
* Use the default or actual value.
*/
value = lookup_parameter_value(mode, name, (PC_MASTER_ENT *) 0, node);
value = pcf_lookup_parameter_value(mode, name, (PCF_MASTER_ENT *) 0, node);
/*
* Optionally expand $name in the parameter value. Print the result with
* or without the name= prefix.
*/
if (value != 0) {
if ((mode & SHOW_EVAL) != 0 && PC_RAW_PARAMETER(node) == 0)
value = expand_parameter_value((VSTRING *) 0, mode, value,
(PC_MASTER_ENT *) 0);
if ((mode & HIDE_NAME) == 0) {
print_line(fp, mode, "%s = %s\n", name, value);
if ((mode & PCF_SHOW_EVAL) != 0 && PCF_RAW_PARAMETER(node) == 0)
value = pcf_expand_parameter_value((VSTRING *) 0, mode, value,
(PCF_MASTER_ENT *) 0);
if ((mode & PCF_HIDE_NAME) == 0) {
pcf_print_line(fp, mode, "%s = %s\n", name, value);
} else {
print_line(fp, mode, "%s\n", value);
pcf_print_line(fp, mode, "%s\n", value);
}
if (msg_verbose)
vstream_fflush(fp);
}
}
/* comp_names - qsort helper */
/* pcf_comp_names - qsort helper */
static int comp_names(const void *a, const void *b)
static int pcf_comp_names(const void *a, const void *b)
{
PC_PARAM_INFO **ap = (PC_PARAM_INFO **) a;
PC_PARAM_INFO **bp = (PC_PARAM_INFO **) b;
PCF_PARAM_INFO **ap = (PCF_PARAM_INFO **) a;
PCF_PARAM_INFO **bp = (PCF_PARAM_INFO **) b;
return (strcmp(PC_PARAM_INFO_NAME(ap[0]),
PC_PARAM_INFO_NAME(bp[0])));
return (strcmp(PCF_PARAM_INFO_NAME(ap[0]),
PCF_PARAM_INFO_NAME(bp[0])));
}
/* show_parameters - show parameter info */
/* pcf_show_parameters - show parameter info */
void show_parameters(VSTREAM *fp, int mode, int param_class, char **names)
void pcf_show_parameters(VSTREAM *fp, int mode, int param_class, char **names)
{
PC_PARAM_INFO **list;
PC_PARAM_INFO **ht;
PCF_PARAM_INFO **list;
PCF_PARAM_INFO **ht;
char **namep;
PC_PARAM_NODE *node;
PCF_PARAM_NODE *node;
/*
* Show all parameters.
*/
if (*names == 0) {
list = PC_PARAM_TABLE_LIST(param_table);
qsort((char *) list, param_table->used, sizeof(*list), comp_names);
list = PCF_PARAM_TABLE_LIST(pcf_param_table);
qsort((char *) list, pcf_param_table->used, sizeof(*list),
pcf_comp_names);
for (ht = list; *ht; ht++)
if (param_class & PC_PARAM_INFO_NODE(*ht)->flags)
print_parameter(fp, mode, PC_PARAM_INFO_NAME(*ht),
PC_PARAM_INFO_NODE(*ht));
if (param_class & PCF_PARAM_INFO_NODE(*ht)->flags)
pcf_print_parameter(fp, mode, PCF_PARAM_INFO_NAME(*ht),
PCF_PARAM_INFO_NODE(*ht));
myfree((char *) list);
return;
}
@@ -197,10 +198,10 @@ void show_parameters(VSTREAM *fp, int mode, int param_class, char **names)
* Show named parameters.
*/
for (namep = names; *namep; namep++) {
if ((node = PC_PARAM_TABLE_FIND(param_table, *namep)) == 0) {
if ((node = PCF_PARAM_TABLE_FIND(pcf_param_table, *namep)) == 0) {
msg_warn("%s: unknown parameter", *namep);
} else {
print_parameter(fp, mode, *namep, node);
pcf_print_parameter(fp, mode, *namep, node);
}
}
}

View File

@@ -6,80 +6,81 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* const char daemon_options_expecting_value[];
/* const char pcf_daemon_options_expecting_value[];
/*
/* void read_master(fail_on_open)
/* void pcf_read_master(fail_on_open)
/* int fail_on_open;
/*
/* void show_master_entries(fp, mode, service_filters)
/* void pcf_show_master_entries(fp, mode, service_filters)
/* VSTREAM *fp;
/* int mode;
/* char **service_filters;
/*
/* void show_master_fields(fp, mode, n_filters, field_filters)
/* void pcf_show_master_fields(fp, mode, n_filters, field_filters)
/* VSTREAM *fp;
/* int mode;
/* int n_filters;
/* char **field_filters;
/*
/* void edit_master_field(masterp, field, new_value)
/* PC_MASTER_ENT *masterp;
/* void pcf_edit_master_field(masterp, field, new_value)
/* PCF_MASTER_ENT *masterp;
/* int field;
/* const char *new_value;
/*
/* void show_master_params(fp, mode, argc, **param_filters)
/* void pcf_show_master_params(fp, mode, argc, **param_filters)
/* VSTREAM *fp;
/* int mode;
/* int argc;
/* char **param_filters;
/*
/* void edit_master_param(masterp, mode, param_name, param_value)
/* PC_MASTER_ENT *masterp;
/* void pcf_edit_master_param(masterp, mode, param_name, param_value)
/* PCF_MASTER_ENT *masterp;
/* int mode;
/* const char *param_name;
/* const char *param_value;
/* AUXILIARY FUNCTIONS
/* const char *parse_master_entry(masterp, buf)
/* PC_MASTER_ENT *masterp;
/* const char *pcf_parse_master_entry(masterp, buf)
/* PCF_MASTER_ENT *masterp;
/* const char *buf;
/*
/* void print_master_entry(fp, mode, masterp)
/* void pcf_print_master_entry(fp, mode, masterp)
/* VSTREAM *fp;
/* int mode;
/* PC_MASTER_ENT *masterp;
/* PCF_MASTER_ENT *masterp;
/*
/* void free_master_entry(masterp)
/* PC_MASTER_ENT *masterp;
/* void pcf_free_master_entry(masterp)
/* PCF_MASTER_ENT *masterp;
/* DESCRIPTION
/* read_master() reads entries from master.cf into memory.
/* pcf_read_master() reads entries from master.cf into memory.
/*
/* show_master_entries() writes the entries in the master.cf
/* pcf_show_master_entries() writes the entries in the master.cf
/* file to the specified stream.
/*
/* show_master_fields() writes name/type/field=value records to
/* the specified stream.
/*
/* edit_master_field() updates the value of a single-column
/* or multi-column attribute.
/*
/* show_master_params() writes name/type/parameter=value records
/* pcf_show_master_fields() writes name/type/field=value records
/* to the specified stream.
/*
/* edit_master_param() updates, removes or adds the named
/* pcf_edit_master_field() updates the value of a single-column
/* or multi-column attribute.
/*
/* pcf_show_master_params() writes name/type/parameter=value
/* records to the specified stream.
/*
/* pcf_edit_master_param() updates, removes or adds the named
/* parameter in a master.cf entry (the remove request ignores
/* the parameter value).
/*
/* daemon_options_expecting_value[] is an array of master.cf
/* pcf_daemon_options_expecting_value[] is an array of master.cf
/* daemon command-line options that expect an option value.
/*
/* parse_master_entry() parses a (perhaps multi-line) string
/* that contains a complete master.cf entry, and normalizes
/* daemon command-line options to simplify further handling.
/* pcf_parse_master_entry() parses a (perhaps multi-line)
/* string that contains a complete master.cf entry, and
/* normalizes daemon command-line options to simplify further
/* handling.
/*
/* print_master_entry() prints a parsed master.cf entry.
/* pcf_print_master_entry() prints a parsed master.cf entry.
/*
/* free_master_entry() returns storage to the heap that was
/* allocated by parse_master_entry().
/* pcf_free_master_entry() returns storage to the heap that
/* was allocated by pcf_parse_master_entry().
/*
/* Arguments
/* .IP fail_on_open
@@ -88,37 +89,38 @@
/* .IP fp
/* Output stream.
/* .IP mode
/* Bit-wise OR of flags. Flags other than the following are ignored.
/* Bit-wise OR of flags. Flags other than the following are
/* ignored.
/* .RS
/* .IP FOLD_LINE
/* .IP PCF_FOLD_LINE
/* Wrap long output lines.
/* .IP SHOW_EVAL
/* .IP PCF_SHOW_EVAL
/* Expand $name in parameter values.
/* .IP EDIT_EXCL
/* Request that edit_master_param() removes the parameter.
/* .IP PCF_EDIT_EXCL
/* Request that pcf_edit_master_param() removes the parameter.
/* .RE
/* .IP n_filters
/* The number of command-line filters.
/* .IP field_filters
/* A list of zero or more service field patterns (name/type/field).
/* The output is formatted as "name/type/field = value". If
/* no filters are specified, show_master_fields() outputs the
/* fields of all master.cf entries in the specified order.
/* no filters are specified, pcf_show_master_fields() outputs
/* the fields of all master.cf entries in the specified order.
/* .IP param_filters
/* A list of zero or more service parameter patterns
/* (name/type/parameter). The output is formatted as
/* "name/type/parameter = value". If no filters are specified,
/* show_master_params() outputs the parameters of all master.cf
/* entries in sorted order.
/* pcf_show_master_params() outputs the parameters of all
/* master.cf entries in sorted order.
/* .IP service_filters
/* A list of zero or more service patterns (name or name/type).
/* If no filters are specified, show_master_entries() outputs
/* all master.cf entries in the specified order.
/* If no filters are specified, pcf_show_master_entries()
/* outputs all master.cf entries in the specified order.
/* .IP field
/* Index into parsed master.cf entry.
/* .IP new_value
/* Replacement value for the specified field. It is split
/* in whitespace in case of a multi-field attribute.
/* Replacement value for the specified field. It is split in
/* whitespace in case of a multi-field attribute.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -162,7 +164,7 @@
#include <postconf.h>
const char daemon_options_expecting_value[] = "o";
const char pcf_daemon_options_expecting_value[] = "o";
/*
* Data structure to capture a command-line service field filter.
@@ -173,12 +175,12 @@ typedef struct {
ARGV *service_pattern; /* parsed service name, type, ... */
int field_pattern; /* parsed field pattern */
const char *param_pattern; /* parameter pattern */
} PC_MASTER_FIELD_REQ;
} PCF_MASTER_FLD_REQ;
/*
* Valid inputs.
*/
static const char *valid_master_types[] = {
static const char *pcf_valid_master_types[] = {
MASTER_XPORT_NAME_UNIX,
MASTER_XPORT_NAME_FIFO,
MASTER_XPORT_NAME_INET,
@@ -186,13 +188,13 @@ static const char *valid_master_types[] = {
0,
};
static const char valid_bool_types[] = "yn-";
static const char pcf_valid_bool_types[] = "yn-";
#define STR(x) vstring_str(x)
/* normalize_options - bring options into canonical form */
/* pcf_normalize_options - bring options into canonical form */
static void normalize_options(ARGV *argv)
static void pcf_normalize_options(ARGV *argv)
{
int field;
char *arg;
@@ -202,12 +204,12 @@ static void normalize_options(ARGV *argv)
/*
* Normalize options to simplify later processing.
*/
for (field = PC_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) {
for (field = PCF_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) {
arg = argv->argv[field];
if (arg[0] != '-' || strcmp(arg, "--") == 0)
break;
for (cp = arg + 1; *cp; cp++) {
if (strchr(daemon_options_expecting_value, *cp) != 0
if (strchr(pcf_daemon_options_expecting_value, *cp) != 0
&& cp > arg + 1) {
/* Split "-stuffozz" into "-stuff" and "-ozz". */
junk = concatenate("-", cp, (char *) 0);
@@ -217,7 +219,7 @@ static void normalize_options(ARGV *argv)
break;
}
}
if (strchr(daemon_options_expecting_value, arg[1]) == 0)
if (strchr(pcf_daemon_options_expecting_value, arg[1]) == 0)
/* Option requires no value. */
continue;
if (arg[2] != 0) {
@@ -232,9 +234,9 @@ static void normalize_options(ARGV *argv)
}
}
/* fix_fatal - fix multiline text before release */
/* pcf_fix_fatal - fix multiline text before release */
static NORETURN PRINTFLIKE(1, 2) fix_fatal(const char *fmt,...)
static NORETURN PRINTFLIKE(1, 2) pcf_fix_fatal(const char *fmt,...)
{
VSTRING *buf = vstring_alloc(100);
va_list ap;
@@ -250,48 +252,48 @@ static NORETURN PRINTFLIKE(1, 2) fix_fatal(const char *fmt,...)
/* NOTREACHED */
}
/* check_master_entry - sanity check master.cf entry */
/* pcf_check_master_entry - sanity check master.cf entry */
static void check_master_entry(ARGV *argv, const char *raw_text)
static void pcf_check_master_entry(ARGV *argv, const char *raw_text)
{
const char **cpp;
char *cp;
int len;
int field;
cp = argv->argv[PC_MASTER_FIELD_TYPE];
for (cpp = valid_master_types; /* see below */ ; cpp++) {
cp = argv->argv[PCF_MASTER_FLD_TYPE];
for (cpp = pcf_valid_master_types; /* see below */ ; cpp++) {
if (*cpp == 0)
fix_fatal("invalid " PC_MASTER_NAME_TYPE " field \"%s\" in \"%s\"",
cp, raw_text);
pcf_fix_fatal("invalid " PCF_MASTER_NAME_TYPE " field \"%s\" in \"%s\"",
cp, raw_text);
if (strcmp(*cpp, cp) == 0)
break;
}
for (field = PC_MASTER_FIELD_PRIVATE; field <= PC_MASTER_FIELD_CHROOT; field++) {
for (field = PCF_MASTER_FLD_PRIVATE; field <= PCF_MASTER_FLD_CHROOT; field++) {
cp = argv->argv[field];
if (cp[1] != 0 || strchr(valid_bool_types, *cp) == 0)
fix_fatal("invalid %s field \%s\" in \"%s\"",
str_field_pattern(field), cp, raw_text);
if (cp[1] != 0 || strchr(pcf_valid_bool_types, *cp) == 0)
pcf_fix_fatal("invalid %s field \%s\" in \"%s\"",
pcf_str_field_pattern(field), cp, raw_text);
}
cp = argv->argv[PC_MASTER_FIELD_WAKEUP];
cp = argv->argv[PCF_MASTER_FLD_WAKEUP];
len = strlen(cp);
if (len > 0 && cp[len - 1] == '?')
len--;
if (!(cp[0] == '-' && len == 1) && strspn(cp, "0123456789") != len)
fix_fatal("invalid " PC_MASTER_NAME_WAKEUP " field \%s\" in \"%s\"",
cp, raw_text);
pcf_fix_fatal("invalid " PCF_MASTER_NAME_WAKEUP " field \%s\" in \"%s\"",
cp, raw_text);
cp = argv->argv[PC_MASTER_FIELD_MAXPROC];
cp = argv->argv[PCF_MASTER_FLD_MAXPROC];
if (strcmp("-", cp) != 0 && cp[strspn(cp, "0123456789")] != 0)
fix_fatal("invalid " PC_MASTER_NAME_MAXPROC " field \%s\" in \"%s\"",
cp, raw_text);
pcf_fix_fatal("invalid " PCF_MASTER_NAME_MAXPROC " field \%s\" in \"%s\"",
cp, raw_text);
}
/* free_master_entry - destroy parsed entry */
/* pcf_free_master_entry - destroy parsed entry */
void free_master_entry(PC_MASTER_ENT *masterp)
void pcf_free_master_entry(PCF_MASTER_ENT *masterp)
{
/* XX Fixme: allocation/deallocation asymmetry. */
myfree(masterp->name_space);
@@ -303,9 +305,9 @@ void free_master_entry(PC_MASTER_ENT *masterp)
myfree((char *) masterp);
}
/* parse_master_entry - parse one master line */
/* pcf_parse_master_entry - parse one master line */
const char *parse_master_entry(PC_MASTER_ENT *masterp, const char *buf)
const char *pcf_parse_master_entry(PCF_MASTER_ENT *masterp, const char *buf)
{
ARGV *argv;
@@ -320,26 +322,26 @@ const char *parse_master_entry(PC_MASTER_ENT *masterp, const char *buf)
*
* XXX Do per-field sanity checks.
*/
argv = argv_split(buf, PC_MASTER_BLANKS);
if (argv->argc < PC_MASTER_MIN_FIELDS) {
argv = argv_split(buf, PCF_MASTER_BLANKS);
if (argv->argc < PCF_MASTER_MIN_FIELDS) {
argv_free(argv); /* Coverity 201311 */
return ("bad field count");
}
check_master_entry(argv, buf);
normalize_options(argv);
pcf_check_master_entry(argv, buf);
pcf_normalize_options(argv);
masterp->name_space =
concatenate(argv->argv[0], PC_NAMESP_SEP_STR, argv->argv[1], (char *) 0);
concatenate(argv->argv[0], PCF_NAMESP_SEP_STR, argv->argv[1], (char *) 0);
masterp->argv = argv;
masterp->valid_names = 0;
masterp->all_params = 0;
return (0);
}
/* read_master - read and digest the master.cf file */
/* pcf_read_master - read and digest the master.cf file */
void read_master(int fail_on_open_error)
void pcf_read_master(int fail_on_open_error)
{
const char *myname = "read_master";
const char *myname = "pcf_read_master";
char *path;
VSTRING *buf;
VSTREAM *fp;
@@ -350,20 +352,20 @@ void read_master(int fail_on_open_error)
/*
* Sanity check.
*/
if (master_table != 0)
if (pcf_master_table != 0)
msg_panic("%s: master table is already initialized", myname);
/*
* Get the location of master.cf.
*/
if (var_config_dir == 0)
set_config_dir();
pcf_set_config_dir();
path = concatenate(var_config_dir, "/", MASTER_CONF_FILE, (char *) 0);
/*
* Initialize the in-memory master table.
*/
master_table = (PC_MASTER_ENT *) mymalloc(sizeof(*master_table));
pcf_master_table = (PCF_MASTER_ENT *) mymalloc(sizeof(*pcf_master_table));
/*
* Skip blank lines and comment lines. Degrade gracefully if master.cf is
@@ -376,10 +378,10 @@ void read_master(int fail_on_open_error)
} else {
buf = vstring_alloc(100);
while (readlline(buf, fp, &line_count) != 0) {
master_table = (PC_MASTER_ENT *) myrealloc((char *) master_table,
(entry_count + 2) * sizeof(*master_table));
if ((err = parse_master_entry(master_table + entry_count,
STR(buf))) != 0)
pcf_master_table = (PCF_MASTER_ENT *) myrealloc((char *) pcf_master_table,
(entry_count + 2) * sizeof(*pcf_master_table));
if ((err = pcf_parse_master_entry(pcf_master_table + entry_count,
STR(buf))) != 0)
msg_fatal("file %s: line %d: %s", path, line_count, err);
entry_count += 1;
}
@@ -390,13 +392,13 @@ void read_master(int fail_on_open_error)
/*
* Null-terminate the master table and clean up.
*/
master_table[entry_count].argv = 0;
pcf_master_table[entry_count].argv = 0;
myfree(path);
}
/* print_master_entry - print one master line */
/* pcf_print_master_entry - print one master line */
void print_master_entry(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
void pcf_print_master_entry(VSTREAM *fp, int mode, PCF_MASTER_ENT *masterp)
{
char **argv = masterp->argv->argv;
const char *arg;
@@ -425,7 +427,7 @@ void print_master_entry(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
* Show the standard fields at their preferred column position. Use at
* least one-space column separation.
*/
for (line_len = 0, field = 0; field < PC_MASTER_MIN_FIELDS; field++) {
for (line_len = 0, field = 0; field < PCF_MASTER_MIN_FIELDS; field++) {
arg = argv[field];
if (line_len > 0) {
do {
@@ -453,28 +455,28 @@ void print_master_entry(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
if (arg[0] != '-' || strcmp(arg, "--") == 0) {
in_daemon_options = 0;
#if 0
if (mode & FOLD_LINE)
if (mode & PCF_FOLD_LINE)
/* Force line wrap. */
line_len = LINE_LIMIT;
line_len = PCF_LINE_LIMIT;
#endif
}
/*
* Special processing for options that require a value.
*/
else if (strchr(daemon_options_expecting_value, arg[1]) != 0
else if (strchr(pcf_daemon_options_expecting_value, arg[1]) != 0
&& (aval = argv[field + 1]) != 0) {
/* Force line wrap before option with value. */
line_len = LINE_LIMIT;
line_len = PCF_LINE_LIMIT;
/*
* Optionally, expand $name in parameter value.
*/
if (strcmp(arg, "-o") == 0
&& (mode & SHOW_EVAL) != 0)
aval = expand_parameter_value((VSTRING *) 0, mode,
aval, masterp);
&& (mode & PCF_SHOW_EVAL) != 0)
aval = pcf_expand_parameter_value((VSTRING *) 0, mode,
aval, masterp);
/*
* Keep option and value on the same line.
@@ -486,13 +488,13 @@ void print_master_entry(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
/*
* Insert a line break when the next item won't fit.
*/
if (line_len > INDENT_LEN) {
if ((mode & FOLD_LINE) == 0
|| line_len + 1 + arg_len < LINE_LIMIT) {
if (line_len > PCF_INDENT_LEN) {
if ((mode & PCF_FOLD_LINE) == 0
|| line_len + 1 + arg_len < PCF_LINE_LIMIT) {
ADD_SPACE;
} else {
vstream_fputs("\n" INDENT_TEXT, fp);
line_len = INDENT_LEN;
vstream_fputs("\n" PCF_INDENT_TEXT, fp);
line_len = PCF_INDENT_LEN;
}
}
ADD_TEXT(arg, strlen(arg));
@@ -502,7 +504,7 @@ void print_master_entry(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
field += 1;
/* Force line wrap after option with value. */
line_len = LINE_LIMIT;
line_len = PCF_LINE_LIMIT;
}
}
@@ -512,25 +514,25 @@ void print_master_entry(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
vstream_fflush(fp);
}
/* show_master_entries - show master.cf entries */
/* pcf_show_master_entries - show master.cf entries */
void show_master_entries(VSTREAM *fp, int mode, int argc, char **argv)
void pcf_show_master_entries(VSTREAM *fp, int mode, int argc, char **argv)
{
PC_MASTER_ENT *masterp;
PC_MASTER_FIELD_REQ *field_reqs;
PC_MASTER_FIELD_REQ *req;
PCF_MASTER_ENT *masterp;
PCF_MASTER_FLD_REQ *field_reqs;
PCF_MASTER_FLD_REQ *req;
/*
* Parse the filter expressions.
*/
if (argc > 0) {
field_reqs = (PC_MASTER_FIELD_REQ *)
field_reqs = (PCF_MASTER_FLD_REQ *)
mymalloc(sizeof(*field_reqs) * argc);
for (req = field_reqs; req < field_reqs + argc; req++) {
req->match_count = 0;
req->raw_text = *argv++;
req->service_pattern =
parse_service_pattern(req->raw_text, 1, 2);
pcf_parse_service_pattern(req->raw_text, 1, 2);
if (req->service_pattern == 0)
msg_fatal("-M option requires service_name[/type]");
}
@@ -539,18 +541,18 @@ void show_master_entries(VSTREAM *fp, int mode, int argc, char **argv)
/*
* Iterate over the master table.
*/
for (masterp = master_table; masterp->argv != 0; masterp++) {
for (masterp = pcf_master_table; masterp->argv != 0; masterp++) {
if (argc > 0) {
for (req = field_reqs; req < field_reqs + argc; req++) {
if (MATCH_SERVICE_PATTERN(req->service_pattern,
masterp->argv->argv[0],
masterp->argv->argv[1])) {
if (PCF_MATCH_SERVICE_PATTERN(req->service_pattern,
masterp->argv->argv[0],
masterp->argv->argv[1])) {
req->match_count++;
print_master_entry(fp, mode, masterp);
pcf_print_master_entry(fp, mode, masterp);
}
}
} else {
print_master_entry(fp, mode, masterp);
pcf_print_master_entry(fp, mode, masterp);
}
}
@@ -567,11 +569,11 @@ void show_master_entries(VSTREAM *fp, int mode, int argc, char **argv)
}
}
/* print_master_field - scaffolding */
/* pcf_print_master_field - scaffolding */
static void print_master_field(VSTREAM *fp, int mode,
PC_MASTER_ENT *masterp,
int field)
static void pcf_print_master_field(VSTREAM *fp, int mode,
PCF_MASTER_ENT *masterp,
int field)
{
char **argv = masterp->argv->argv;
const char *arg;
@@ -587,16 +589,16 @@ static void print_master_field(VSTREAM *fp, int mode,
#define ADD_CHAR(ch) ADD_TEXT((ch), 1)
line_len = 0;
if ((mode & HIDE_NAME) == 0) {
if ((mode & PCF_HIDE_NAME) == 0) {
ADD_TEXT(argv[0], strlen(argv[0]));
ADD_CHAR(PC_NAMESP_SEP_STR);
ADD_CHAR(PCF_NAMESP_SEP_STR);
ADD_TEXT(argv[1], strlen(argv[1]));
ADD_CHAR(PC_NAMESP_SEP_STR);
ADD_TEXT(str_field_pattern(field), strlen(str_field_pattern(field)));
ADD_CHAR(PCF_NAMESP_SEP_STR);
ADD_TEXT(pcf_str_field_pattern(field), strlen(pcf_str_field_pattern(field)));
ADD_TEXT(" = ", 3);
if (line_len + strlen(argv[field]) > LINE_LIMIT) {
vstream_fputs("\n" INDENT_TEXT, fp);
line_len = INDENT_LEN;
if (line_len + strlen(argv[field]) > PCF_LINE_LIMIT) {
vstream_fputs("\n" PCF_INDENT_TEXT, fp);
line_len = PCF_INDENT_LEN;
}
}
ADD_TEXT(argv[field], strlen(argv[field]));
@@ -606,7 +608,7 @@ static void print_master_field(VSTREAM *fp, int mode,
* we have no data-dependent preference for column positions, but we do
* have argument grouping preferences.
*/
if (field == PC_MASTER_FIELD_CMD) {
if (field == PCF_MASTER_FLD_CMD) {
in_daemon_options = 1;
for (field += 1; (arg = argv[field]) != 0; field++) {
arg_len = strlen(arg);
@@ -619,19 +621,19 @@ static void print_master_field(VSTREAM *fp, int mode,
*/
if (arg[0] != '-' || strcmp(arg, "--") == 0) {
in_daemon_options = 0;
} else if (strchr(daemon_options_expecting_value, arg[1]) != 0
} else if (strchr(pcf_daemon_options_expecting_value, arg[1]) != 0
&& (aval = argv[field + 1]) != 0) {
/* Force line break before option with value. */
line_len = LINE_LIMIT;
line_len = PCF_LINE_LIMIT;
/*
* Optionally, expand $name in parameter value.
*/
if (strcmp(arg, "-o") == 0
&& (mode & SHOW_EVAL) != 0)
aval = expand_parameter_value((VSTRING *) 0, mode,
aval, masterp);
&& (mode & PCF_SHOW_EVAL) != 0)
aval = pcf_expand_parameter_value((VSTRING *) 0, mode,
aval, masterp);
/*
* Keep option and value on the same line.
@@ -643,13 +645,13 @@ static void print_master_field(VSTREAM *fp, int mode,
/*
* Insert a line break when the next item won't fit.
*/
if (line_len > INDENT_LEN) {
if ((mode & FOLD_LINE) == 0
|| line_len + 1 + arg_len < LINE_LIMIT) {
if (line_len > PCF_INDENT_LEN) {
if ((mode & PCF_FOLD_LINE) == 0
|| line_len + 1 + arg_len < PCF_LINE_LIMIT) {
ADD_SPACE;
} else {
vstream_fputs("\n" INDENT_TEXT, fp);
line_len = INDENT_LEN;
vstream_fputs("\n" PCF_INDENT_TEXT, fp);
line_len = PCF_INDENT_LEN;
}
}
ADD_TEXT(arg, strlen(arg));
@@ -659,7 +661,7 @@ static void print_master_field(VSTREAM *fp, int mode,
field += 1;
/* Force line break after option with value. */
line_len = LINE_LIMIT;
line_len = PCF_LINE_LIMIT;
}
}
}
@@ -669,33 +671,33 @@ static void print_master_field(VSTREAM *fp, int mode,
vstream_fflush(fp);
}
/* show_master_fields - show master.cf fields */
/* pcf_show_master_fields - show master.cf fields */
void show_master_fields(VSTREAM *fp, int mode, int argc, char **argv)
void pcf_show_master_fields(VSTREAM *fp, int mode, int argc, char **argv)
{
const char *myname = "show_master_fields";
PC_MASTER_ENT *masterp;
PC_MASTER_FIELD_REQ *field_reqs;
PC_MASTER_FIELD_REQ *req;
const char *myname = "pcf_show_master_fields";
PCF_MASTER_ENT *masterp;
PCF_MASTER_FLD_REQ *field_reqs;
PCF_MASTER_FLD_REQ *req;
int field;
/*
* Parse the filter expressions.
*/
if (argc > 0) {
field_reqs = (PC_MASTER_FIELD_REQ *)
field_reqs = (PCF_MASTER_FLD_REQ *)
mymalloc(sizeof(*field_reqs) * argc);
for (req = field_reqs; req < field_reqs + argc; req++) {
req->match_count = 0;
req->raw_text = *argv++;
req->service_pattern =
parse_service_pattern(req->raw_text, 1, 3);
pcf_parse_service_pattern(req->raw_text, 1, 3);
if (req->service_pattern == 0)
msg_fatal("-F option requires service_name[/type[/field]]");
field = req->field_pattern =
parse_field_pattern(req->service_pattern->argv[2]);
if (is_magic_field_pattern(field) == 0
&& (field < 0 || field > PC_MASTER_FIELD_CMD))
pcf_parse_field_pattern(req->service_pattern->argv[2]);
if (pcf_is_magic_field_pattern(field) == 0
&& (field < 0 || field > PCF_MASTER_FLD_CMD))
msg_panic("%s: bad attribute field index: %d",
myname, field);
}
@@ -704,25 +706,25 @@ void show_master_fields(VSTREAM *fp, int mode, int argc, char **argv)
/*
* Iterate over the master table.
*/
for (masterp = master_table; masterp->argv != 0; masterp++) {
for (masterp = pcf_master_table; masterp->argv != 0; masterp++) {
if (argc > 0) {
for (req = field_reqs; req < field_reqs + argc; req++) {
if (MATCH_SERVICE_PATTERN(req->service_pattern,
masterp->argv->argv[0],
masterp->argv->argv[1])) {
if (PCF_MATCH_SERVICE_PATTERN(req->service_pattern,
masterp->argv->argv[0],
masterp->argv->argv[1])) {
req->match_count++;
field = req->field_pattern;
if (is_magic_field_pattern(field)) {
for (field = 0; field <= PC_MASTER_FIELD_CMD; field++)
print_master_field(fp, mode, masterp, field);
if (pcf_is_magic_field_pattern(field)) {
for (field = 0; field <= PCF_MASTER_FLD_CMD; field++)
pcf_print_master_field(fp, mode, masterp, field);
} else {
print_master_field(fp, mode, masterp, field);
pcf_print_master_field(fp, mode, masterp, field);
}
}
}
} else {
for (field = 0; field <= PC_MASTER_FIELD_CMD; field++)
print_master_field(fp, mode, masterp, field);
for (field = 0; field <= PCF_MASTER_FLD_CMD; field++)
pcf_print_master_field(fp, mode, masterp, field);
}
}
@@ -739,18 +741,18 @@ void show_master_fields(VSTREAM *fp, int mode, int argc, char **argv)
}
}
/* edit_master_field - replace master.cf field value. */
/* pcf_edit_master_field - replace master.cf field value. */
void edit_master_field(PC_MASTER_ENT *masterp, int field,
const char *new_value)
void pcf_edit_master_field(PCF_MASTER_ENT *masterp, int field,
const char *new_value)
{
/*
* Replace multi-column attribute.
*/
if (field == PC_MASTER_FIELD_CMD) {
argv_truncate(masterp->argv, PC_MASTER_FIELD_CMD);
argv_split_append(masterp->argv, new_value, PC_MASTER_BLANKS);
if (field == PCF_MASTER_FLD_CMD) {
argv_truncate(masterp->argv, PCF_MASTER_FLD_CMD);
argv_split_append(masterp->argv, new_value, PCF_MASTER_BLANKS);
}
/*
@@ -763,40 +765,43 @@ void edit_master_field(PC_MASTER_ENT *masterp, int field,
/*
* Do per-field sanity checks.
*/
check_master_entry(masterp->argv, new_value);
pcf_check_master_entry(masterp->argv, new_value);
}
/* print_master_param - scaffolding */
/* pcf_print_master_param - scaffolding */
static void print_master_param(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp,
const char *param_name, const char *param_value)
static void pcf_print_master_param(VSTREAM *fp, int mode,
PCF_MASTER_ENT *masterp,
const char *param_name,
const char *param_value)
{
if ((mode & SHOW_EVAL) != 0)
param_value = expand_parameter_value((VSTRING *) 0, mode,
param_value, masterp);
if ((mode & HIDE_NAME) == 0) {
print_line(fp, mode, "%s%c%s = %s\n",
masterp->name_space, PC_NAMESP_SEP_CH,
param_name, param_value);
if ((mode & PCF_SHOW_EVAL) != 0)
param_value = pcf_expand_parameter_value((VSTRING *) 0, mode,
param_value, masterp);
if ((mode & PCF_HIDE_NAME) == 0) {
pcf_print_line(fp, mode, "%s%c%s = %s\n",
masterp->name_space, PCF_NAMESP_SEP_CH,
param_name, param_value);
} else {
print_line(fp, mode, "%s\n", param_value);
pcf_print_line(fp, mode, "%s\n", param_value);
}
if (msg_verbose)
vstream_fflush(fp);
}
/* sort_argv_cb - sort argv call-back */
/* pcf_sort_argv_cb - sort argv call-back */
static int sort_argv_cb(const void *a, const void *b)
static int pcf_sort_argv_cb(const void *a, const void *b)
{
return (strcmp(*(char **) a, *(char **) b));
}
/* show_master_any_param - show any parameter in master.cf service entry */
/* pcf_show_master_any_param - show any parameter in master.cf service entry */
static void show_master_any_param(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
static void pcf_show_master_any_param(VSTREAM *fp, int mode,
PCF_MASTER_ENT *masterp)
{
const char *myname = "show_master_any_param";
const char *myname = "pcf_show_master_any_param";
ARGV *argv = argv_alloc(10);
DICT *dict = masterp->all_params;
const char *param_name;
@@ -822,11 +827,11 @@ static void show_master_any_param(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
/* Print the parameters in sorted order. */
qsort(argv->argv, param_count, sizeof(argv->argv[0]), sort_argv_cb);
qsort(argv->argv, param_count, sizeof(argv->argv[0]), pcf_sort_argv_cb);
for (cpp = argv->argv; (param_name = *cpp) != 0; cpp++) {
if ((param_value = dict_get(dict, param_name)) == 0)
msg_panic("%s: parameter name not found: %s", myname, param_name);
print_master_param(fp, mode, masterp, param_name, param_value);
pcf_print_master_param(fp, mode, masterp, param_name, param_value);
}
/*
@@ -835,13 +840,13 @@ static void show_master_any_param(VSTREAM *fp, int mode, PC_MASTER_ENT *masterp)
argv_free(argv);
}
/* show_master_params - show master.cf params */
/* pcf_show_master_params - show master.cf params */
void show_master_params(VSTREAM *fp, int mode, int argc, char **argv)
void pcf_show_master_params(VSTREAM *fp, int mode, int argc, char **argv)
{
PC_MASTER_ENT *masterp;
PC_MASTER_FIELD_REQ *field_reqs;
PC_MASTER_FIELD_REQ *req;
PCF_MASTER_ENT *masterp;
PCF_MASTER_FLD_REQ *field_reqs;
PCF_MASTER_FLD_REQ *req;
DICT *dict;
const char *param_value;
@@ -849,13 +854,13 @@ void show_master_params(VSTREAM *fp, int mode, int argc, char **argv)
* Parse the filter expressions.
*/
if (argc > 0) {
field_reqs = (PC_MASTER_FIELD_REQ *)
field_reqs = (PCF_MASTER_FLD_REQ *)
mymalloc(sizeof(*field_reqs) * argc);
for (req = field_reqs; req < field_reqs + argc; req++) {
req->match_count = 0;
req->raw_text = *argv++;
req->service_pattern =
parse_service_pattern(req->raw_text, 1, 3);
pcf_parse_service_pattern(req->raw_text, 1, 3);
if (req->service_pattern == 0)
msg_fatal("-P option requires service_name[/type[/parameter]]");
req->param_pattern = req->service_pattern->argv[2];
@@ -865,27 +870,27 @@ void show_master_params(VSTREAM *fp, int mode, int argc, char **argv)
/*
* Iterate over the master table.
*/
for (masterp = master_table; masterp->argv != 0; masterp++) {
for (masterp = pcf_master_table; masterp->argv != 0; masterp++) {
if ((dict = masterp->all_params) != 0) {
if (argc > 0) {
for (req = field_reqs; req < field_reqs + argc; req++) {
if (MATCH_SERVICE_PATTERN(req->service_pattern,
masterp->argv->argv[0],
masterp->argv->argv[1])) {
if (IS_MAGIC_PARAM_PATTERN(req->param_pattern)) {
show_master_any_param(fp, mode, masterp);
if (PCF_MATCH_SERVICE_PATTERN(req->service_pattern,
masterp->argv->argv[0],
masterp->argv->argv[1])) {
if (PCF_IS_MAGIC_PARAM_PATTERN(req->param_pattern)) {
pcf_show_master_any_param(fp, mode, masterp);
req->match_count += 1;
} else if ((param_value = dict_get(dict,
req->param_pattern)) != 0) {
print_master_param(fp, mode, masterp,
req->param_pattern,
param_value);
pcf_print_master_param(fp, mode, masterp,
req->param_pattern,
param_value);
req->match_count += 1;
}
}
}
} else {
show_master_any_param(fp, mode, masterp);
pcf_show_master_any_param(fp, mode, masterp);
}
}
}
@@ -903,13 +908,13 @@ void show_master_params(VSTREAM *fp, int mode, int argc, char **argv)
}
}
/* edit_master_param - update, add or remove -o parameter=value */
/* pcf_edit_master_param - update, add or remove -o parameter=value */
void edit_master_param(PC_MASTER_ENT *masterp, int mode,
const char *param_name,
const char *param_value)
void pcf_edit_master_param(PCF_MASTER_ENT *masterp, int mode,
const char *param_name,
const char *param_value)
{
const char *myname = "edit_master_param";
const char *myname = "pcf_edit_master_param";
ARGV *argv = masterp->argv;
const char *arg;
const char *aval;
@@ -917,7 +922,7 @@ void edit_master_param(PC_MASTER_ENT *masterp, int mode,
int name_len = strlen(param_name);
int field;
for (field = PC_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) {
for (field = PCF_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) {
arg = argv->argv[field];
/*
@@ -930,7 +935,7 @@ void edit_master_param(PC_MASTER_ENT *masterp, int mode,
/*
* Zoom in on command-line options with a value.
*/
else if (strchr(daemon_options_expecting_value, arg[1]) != 0
else if (strchr(pcf_daemon_options_expecting_value, arg[1]) != 0
&& (aval = argv->argv[field + 1]) != 0) {
/*
@@ -940,12 +945,12 @@ void edit_master_param(PC_MASTER_ENT *masterp, int mode,
if (strncmp(aval, param_name, name_len) == 0
&& aval[name_len] == '=') {
param_match = 1;
switch (mode & (EDIT_CONF | EDIT_EXCL)) {
switch (mode & (PCF_EDIT_CONF | PCF_EDIT_EXCL)) {
/*
* Update parameter=value.
*/
case EDIT_CONF:
case PCF_EDIT_CONF:
aval = concatenate(param_name, "=",
param_value, (char *) 0);
argv_replace_one(argv, field + 1, aval);
@@ -958,7 +963,7 @@ void edit_master_param(PC_MASTER_ENT *masterp, int mode,
/*
* Delete parameter=value.
*/
case EDIT_EXCL:
case PCF_EDIT_EXCL:
argv_delete(argv, field, 2);
if (masterp->all_params)
dict_del(masterp->all_params, param_name);
@@ -981,7 +986,7 @@ void edit_master_param(PC_MASTER_ENT *masterp, int mode,
/*
* Add unmatched parameter.
*/
if ((mode & EDIT_CONF) && param_match == 0) {
if ((mode & PCF_EDIT_CONF) && param_match == 0) {
/* XXX Generalize: argv_insert(argv, where, list...) */
argv_insert_one(argv, field, "-o");
aval = concatenate(param_name, "=",

View File

@@ -6,72 +6,72 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* int parse_field_pattern(field_expr)
/* int pcf_parse_field_pattern(field_expr)
/* char *field_expr;
/*
/* const char *str_field_pattern(field_pattern)
/* const char *pcf_str_field_pattern(field_pattern)
/* int field_pattern;
/*
/* int is_magic_field_pattern(field_pattern)
/* int pcf_is_magic_field_pattern(field_pattern)
/* int field_pattern;
/*
/* ARGV *parse_service_pattern(service_expr, min_expr, max_expr)
/* ARGV *pcf_parse_service_pattern(service_expr, min_expr, max_expr)
/* const char *service_expr;
/* int min_expr;
/* int max_expr;
/*
/* int IS_MAGIC_SERVICE_PATTERN(service_pattern)
/* int PCF_IS_MAGIC_SERVICE_PATTERN(service_pattern)
/* const ARGV *service_pattern;
/*
/* int MATCH_SERVICE_PATTERN(service_pattern, service_name,
/* int PCF_MATCH_SERVICE_PATTERN(service_pattern, service_name,
/* service_type)
/* const ARGV *service_pattern;
/* const char *service_name;
/* const char *service_type;
/*
/* const char *str_field_pattern(field_pattern)
/* const char *pcf_str_field_pattern(field_pattern)
/* int field_pattern;
/*
/* int IS_MAGIC_PARAM_PATTERN(param_pattern)
/* int PCF_IS_MAGIC_PARAM_PATTERN(param_pattern)
/* const char *param_pattern;
/*
/* int MATCH_PARAM_PATTERN(param_pattern, param_name)
/* int PCF_MATCH_PARAM_PATTERN(param_pattern, param_name)
/* const char *param_pattern;
/* const char *param_name;
/* DESCRIPTION
/* parse_service_pattern() takes an expression and splits it
/* up on '/' into an array of sub-expressions, This function
/* pcf_parse_service_pattern() takes an expression and splits
/* it up on '/' into an array of sub-expressions, This function
/* returns null if the input does fewer than "min" or more
/* than "max" sub-expressions.
/*
/* IS_MAGIC_SERVICE_PATTERN() returns non-zero if any of the
/* service name or service type sub-expressions contains a
/* matching operator (as opposed to string literals that only
/* match themselves). This is an unsafe macro that evaluates
/* PCF_IS_MAGIC_SERVICE_PATTERN() returns non-zero if any of
/* the service name or service type sub-expressions contains
/* a matching operator (as opposed to string literals that
/* only match themselves). This is an unsafe macro that evaluates
/* its arguments more than once.
/*
/* MATCH_SERVICE_PATTERN() matches a service name and type
/* PCF_MATCH_SERVICE_PATTERN() matches a service name and type
/* from master.cf against the parsed pattern. This is an unsafe
/* macro that evaluates its arguments more than once.
/*
/* parse_field_pattern() converts a field sub-expression, and
/* returns the conversion result.
/* pcf_parse_field_pattern() converts a field sub-expression,
/* and returns the conversion result.
/*
/* str_field_pattern() converts a result from parse_field_pattern()
/* into string form.
/* pcf_str_field_pattern() converts a result from
/* pcf_parse_field_pattern() into string form.
/*
/* is_magic_field_pattern() returns non-zero if the field
/* pcf_is_magic_field_pattern() returns non-zero if the field
/* pattern sub-expression contained a matching operator (as
/* opposed to a string literal that only matches itself).
/*
/* IS_MAGIC_PARAM_PATTERN() returns non-zero if the parameter
/* PCF_IS_MAGIC_PARAM_PATTERN() returns non-zero if the parameter
/* sub-expression contains a matching operator (as opposed to
/* a string literal that only matches itself). This is an
/* unsafe macro that evaluates its arguments more than once.
/*
/* MATCH_PARAM_PATTERN() matches a parameter name from master.cf
/* against the parsed pattern. This is an unsafe macro that
/* evaluates its arguments more than once.
/* PCF_MATCH_PARAM_PATTERN() matches a parameter name from
/* master.cf against the parsed pattern. This is an unsafe
/* macro that evaluates its arguments more than once.
/*
/* Arguments
/* .IP field_expr
@@ -122,38 +122,38 @@
#include <postconf.h>
/*
* Conversion table. Each PC_MASTER_NAME_XXX name entry must be stored at
* table offset PC_MASTER_FIELD_XXX. So don't mess it up.
* Conversion table. Each PCF_MASTER_NAME_XXX name entry must be stored at
* table offset PCF_MASTER_FLD_XXX. So don't mess it up.
*/
NAME_CODE field_name_offset[] = {
PC_MASTER_NAME_SERVICE, PC_MASTER_FIELD_SERVICE,
PC_MASTER_NAME_TYPE, PC_MASTER_FIELD_TYPE,
PC_MASTER_NAME_PRIVATE, PC_MASTER_FIELD_PRIVATE,
PC_MASTER_NAME_UNPRIV, PC_MASTER_FIELD_UNPRIV,
PC_MASTER_NAME_CHROOT, PC_MASTER_FIELD_CHROOT,
PC_MASTER_NAME_WAKEUP, PC_MASTER_FIELD_WAKEUP,
PC_MASTER_NAME_MAXPROC, PC_MASTER_FIELD_MAXPROC,
PC_MASTER_NAME_CMD, PC_MASTER_FIELD_CMD,
"*", PC_MASTER_FIELD_WILDC,
0, PC_MASTER_FIELD_NONE,
NAME_CODE pcf_field_name_offset[] = {
PCF_MASTER_NAME_SERVICE, PCF_MASTER_FLD_SERVICE,
PCF_MASTER_NAME_TYPE, PCF_MASTER_FLD_TYPE,
PCF_MASTER_NAME_PRIVATE, PCF_MASTER_FLD_PRIVATE,
PCF_MASTER_NAME_UNPRIV, PCF_MASTER_FLD_UNPRIV,
PCF_MASTER_NAME_CHROOT, PCF_MASTER_FLD_CHROOT,
PCF_MASTER_NAME_WAKEUP, PCF_MASTER_FLD_WAKEUP,
PCF_MASTER_NAME_MAXPROC, PCF_MASTER_FLD_MAXPROC,
PCF_MASTER_NAME_CMD, PCF_MASTER_FLD_CMD,
"*", PCF_MASTER_FLD_WILDC,
0, PCF_MASTER_FLD_NONE,
};
/* parse_field_pattern - parse service attribute pattern */
/* pcf_parse_field_pattern - parse service attribute pattern */
int parse_field_pattern(const char *field_name)
int pcf_parse_field_pattern(const char *field_name)
{
int field_pattern;
if ((field_pattern = name_code(field_name_offset,
if ((field_pattern = name_code(pcf_field_name_offset,
NAME_CODE_FLAG_STRICT_CASE,
field_name)) == PC_MASTER_FIELD_NONE)
field_name)) == PCF_MASTER_FLD_NONE)
msg_fatal("invalid service attribute name: \"%s\"", field_name);
return (field_pattern);
}
/* parse_service_pattern - parse service pattern */
/* pcf_parse_service_pattern - parse service pattern */
ARGV *parse_service_pattern(const char *pattern, int min_expr, int max_expr)
ARGV *pcf_parse_service_pattern(const char *pattern, int min_expr, int max_expr)
{
ARGV *argv;
char **cpp;
@@ -163,7 +163,7 @@ ARGV *parse_service_pattern(const char *pattern, int min_expr, int max_expr)
*/
if (*pattern == '/')
return (0);
argv = argv_split(pattern, PC_NAMESP_SEP_STR);
argv = argv_split(pattern, PCF_NAMESP_SEP_STR);
if (argv->argc < min_expr || argv->argc > max_expr) {
argv_free(argv);
return (0);
@@ -173,7 +173,7 @@ ARGV *parse_service_pattern(const char *pattern, int min_expr, int max_expr)
* Allow '*' only all by itself.
*/
for (cpp = argv->argv; *cpp; cpp++) {
if (!PC_MATCH_ANY(*cpp) && strchr(*cpp, PC_MATCH_WILDC_STR[0]) != 0) {
if (!PCF_MATCH_ANY(*cpp) && strchr(*cpp, PCF_MATCH_WILDC_STR[0]) != 0) {
argv_free(argv);
return (0);
}
@@ -183,6 +183,6 @@ ARGV *parse_service_pattern(const char *pattern, int min_expr, int max_expr)
* Provide defaults for missing fields.
*/
while (argv->argc < max_expr)
argv_add(argv, PC_MATCH_WILDC_STR, ARGV_END);
argv_add(argv, PCF_MATCH_WILDC_STR, ARGV_END);
return (argv);
}

View File

@@ -6,9 +6,9 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void set_config_dir()
/* void pcf_set_config_dir()
/* DESCRIPTION
/* set_config_dir() forcibly overrides the var_config_dir
/* pcf_set_config_dir() forcibly overrides the var_config_dir
/* parameter setting with the value from the environment or
/* with the default pathname, and updates the mail parameter
/* dictionary.
@@ -43,9 +43,9 @@
#include <postconf.h>
/* set_config_dir - forcibly override var_config_dir */
/* pcf_set_config_dir - forcibly override var_config_dir */
void set_config_dir(void)
void pcf_set_config_dir(void)
{
char *config_dir;

View File

@@ -6,77 +6,77 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* PC_PARAM_TABLE *PC_PARAM_TABLE_CREATE(size)
/* PCF_PARAM_TABLE *PCF_PARAM_TABLE_CREATE(size)
/* ssize_t size;
/*
/* PC_PARAM_INFO **PC_PARAM_TABLE_LIST(table)
/* PC_PARAM_TABLE *table;
/* PCF_PARAM_INFO **PCF_PARAM_TABLE_LIST(table)
/* PCF_PARAM_TABLE *table;
/*
/* const char *PC_PARAM_INFO_NAME(info)
/* PC_PARAM_INFO *info;
/* const char *PCF_PARAM_INFO_NAME(info)
/* PCF_PARAM_INFO *info;
/*
/* PC_PARAM_NODE *PC_PARAM_INFO_NODE(info)
/* PC_PARAM_INFO *info;
/* PCF_PARAM_NODE *PCF_PARAM_INFO_NODE(info)
/* PCF_PARAM_INFO *info;
/*
/* PC_PARAM_NODE *PC_PARAM_TABLE_FIND(table, name)
/* PC_PARAM_TABLE *table;
/* PCF_PARAM_NODE *PCF_PARAM_TABLE_FIND(table, name)
/* PCF_PARAM_TABLE *table;
/* const char *name;
/*
/* PC_PARAM_INFO *PC_PARAM_TABLE_LOCATE(table, name)
/* PC_PARAM_TABLE *table;
/* PCF_PARAM_INFO *PCF_PARAM_TABLE_LOCATE(table, name)
/* PCF_PARAM_TABLE *table;
/* const char *name;
/*
/* PC_PARAM_INFO *PC_PARAM_TABLE_ENTER(table, name, flags,
/* PCF_PARAM_INFO *PCF_PARAM_TABLE_ENTER(table, name, flags,
/* param_data, convert_fn)
/* PC_PARAM_TABLE *table;
/* PCF_PARAM_TABLE *table;
/* const char *name;
/* int flags;
/* char *param_data;
/* const char *(*convert_fn)(char *);
/*
/* PC_PARAM_NODE *make_param_node(flags, param_data, convert_fn)
/* PCF_PARAM_NODE *pcf_make_param_node(flags, param_data, convert_fn)
/* int flags;
/* char *param_data;
/* const char *(*convert_fn) (char *);
/*
/* const char *convert_param_node(mode, name, node)
/* const char *pcf_convert_param_node(mode, name, node)
/* int mode;
/* const char *name;
/* PC_PARAM_NODE *node;
/* PCF_PARAM_NODE *node;
/*
/* VSTRING *param_string_buf;
/* VSTRING *pcf_param_string_buf;
/*
/* PC_RAW_PARAMETER(node)
/* const PC_PARAM_NODE *node;
/* PCF_RAW_PARAMETER(node)
/* const PCF_PARAM_NODE *node;
/* DESCRIPTION
/* This module maintains data structures (PC_PARAM_NODE) with
/* This module maintains data structures (PCF_PARAM_NODE) with
/* information about known-legitimate parameters. These data
/* structures are stored in a hash table.
/*
/* The PC_PARAM_MUMBLE() macros are wrappers around the htable(3)
/* module. Their sole purpose is to encapsulate all the pointer
/* casting from and to (PC_PARAM_NODE *). Apart from that, the
/* macros have no features worth discussing.
/* The PCF_PARAM_MUMBLE() macros are wrappers around the
/* htable(3) module. Their sole purpose is to encapsulate all
/* the pointer casting from and to (PCF_PARAM_NODE *). Apart
/* from that, the macros have no features worth discussing.
/*
/* make_param_node() creates a node for the global parameter
/* pcf_make_param_node() creates a node for the global parameter
/* table. This node provides a parameter default value, and a
/* function that converts the default value to string.
/*
/* convert_param_node() produces a string representation for
/* a global parameter default value.
/* pcf_convert_param_node() produces a string representation
/* for a global parameter default value.
/*
/* PC_RAW_PARAMETER() returns non-zero if the specified parameter
/* node represents a "raw parameter". The value of such
/* parameters must not be scanned for macro names. Some "raw
/* parameter" values contain "$" without macros, such as the
/* smtpd_expansion_filter "safe character" set; and some contain
/* $name from a private name space, such as forward_path. Some
/* "raw parameter" values in postscreen(8) are safe to expand
/* by one level. Support for that may be added later.
/* PCF_RAW_PARAMETER() returns non-zero if the specified
/* parameter node represents a "raw parameter". The value of
/* such parameters must not be scanned for macro names. Some
/* "raw parameter" values contain "$" without macros, such as
/* the smtpd_expansion_filter "safe character" set; and some
/* contain $name from a private name space, such as forward_path.
/* Some "raw parameter" values in postscreen(8) are safe to
/* expand by one level. Support for that may be added later.
/*
/* param_string_buf is a buffer that is initialized on the fly
/* and that parameter-to-string conversion functions may use for
/* temporary result storage.
/* pcf_param_string_buf is a buffer that is initialized on the
/* fly and that parameter-to-string conversion functions may
/* use for temporary result storage.
/*
/* Arguments:
/* .IP size
@@ -84,24 +84,24 @@
/* .IP table
/* A hash table for storage of "valid parameter" information.
/* .IP info
/* A data structure with a name component and a PC_PARAM_NODE
/* component. Use PC_PARAM_INFO_NAME() and PC_PARAM_INFO_NODE()
/* A data structure with a name component and a PCF_PARAM_NODE
/* component. Use PCF_PARAM_INFO_NAME() and PCF_PARAM_INFO_NODE()
/* to access these components.
/* .IP name
/* The name of a "valid parameter".
/* .IP flags
/* PC_PARAM_FLAG_RAW for a "raw parameter", PC_PARAM_FLAG_NONE
/* otherwise. See the PC_RAW_PARAMETER() discussion above for
/* PCF_PARAM_FLAG_RAW for a "raw parameter", PCF_PARAM_FLAG_NONE
/* otherwise. See the PCF_RAW_PARAMETER() discussion above for
/* discussion of "raw parameter" values.
/* .IP param_data
/* Information about the parameter value. Specify PC_PARAM_NO_DATA
/* Information about the parameter value. Specify PCF_PARAM_NO_DATA
/* if this is not applicable.
/* .IP convert_fn
/* The function that will be invoked to produce a string
/* representation of the information in param_data. The function
/* receives the param_data value as argument.
/* .IP mode
/* For now, the SHOW_DEFS flag is required.
/* For now, the PCF_SHOW_DEFS flag is required.
/* .IP name
/* The name of the parameter whose value is requested. This
/* is used for diagnostics.
@@ -137,41 +137,41 @@
#include <postconf.h>
VSTRING *param_string_buf;
VSTRING *pcf_param_string_buf;
/* make_param_node - make node for global parameter table */
/* pcf_make_param_node - make node for global parameter table */
PC_PARAM_NODE *make_param_node(int flags, char *param_data,
const char *(*convert_fn) (char *))
PCF_PARAM_NODE *pcf_make_param_node(int flags, char *param_data,
const char *(*convert_fn) (char *))
{
PC_PARAM_NODE *node;
PCF_PARAM_NODE *node;
node = (PC_PARAM_NODE *) mymalloc(sizeof(*node));
node = (PCF_PARAM_NODE *) mymalloc(sizeof(*node));
node->flags = flags;
node->param_data = param_data;
node->convert_fn = convert_fn;
return (node);
}
/* convert_param_node - get default parameter value */
/* pcf_convert_param_node - get default parameter value */
const char *convert_param_node(int mode, const char *name, PC_PARAM_NODE *node)
const char *pcf_convert_param_node(int mode, const char *name, PCF_PARAM_NODE *node)
{
const char *myname = "convert_param_node";
const char *myname = "pcf_convert_param_node";
const char *value;
/*
* One-off initialization.
*/
if (param_string_buf == 0)
param_string_buf = vstring_alloc(100);
if (pcf_param_string_buf == 0)
pcf_param_string_buf = vstring_alloc(100);
/*
* Sanity check. A null value indicates that a parameter does not have
* the requested value. At this time, the only requested value can be the
* default value, and a null pointer value makes no sense here.
*/
if ((mode & SHOW_DEFS) == 0)
if ((mode & PCF_SHOW_DEFS) == 0)
msg_panic("%s: request for non-default value of parameter %s",
myname, name);
if ((value = node->convert_fn(node->param_data)) == 0)

View File

@@ -6,24 +6,25 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void show_maps()
/* void pcf_show_maps()
/*
/* void show_locks()
/* void pcf_show_locks()
/*
/* void show_sasl(mode)
/* void pcf_show_sasl(mode)
/* int mode;
/* DESCRIPTION
/* show_maps() lists the available map (lookup table) types.
/* pcf_show_maps() lists the available map (lookup table)
/* types.
/*
/* show_locks() lists the available mailbox lock types.
/* pcf_show_locks() lists the available mailbox lock types.
/*
/* show_sasl() shows the available SASL authentication
/* pcf_show_sasl() shows the available SASL authentication
/* plugin types.
/*
/* Arguments:
/* .IP mode
/* Show server information if the SHOW_SASL_SERV flag is set,
/* otherwise show client information.
/* Show server information if the PCF_SHOW_SASL_SERV flag is
/* set, otherwise show client information.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -59,9 +60,9 @@
#include <postconf.h>
/* show_maps - show available maps */
/* pcf_show_maps - show available maps */
void show_maps(void)
void pcf_show_maps(void)
{
ARGV *maps_argv;
int i;
@@ -72,9 +73,9 @@ void show_maps(void)
argv_free(maps_argv);
}
/* show_locks - show available mailbox locking methods */
/* pcf_show_locks - show available mailbox locking methods */
void show_locks(void)
void pcf_show_locks(void)
{
ARGV *locks_argv;
int i;
@@ -85,14 +86,14 @@ void show_locks(void)
argv_free(locks_argv);
}
/* show_sasl - show SASL plug-in types */
/* pcf_show_sasl - show SASL plug-in types */
void show_sasl(int what)
void pcf_show_sasl(int what)
{
ARGV *sasl_argv;
int i;
sasl_argv = (what & SHOW_SASL_SERV) ? xsasl_server_types() :
sasl_argv = (what & PCF_SHOW_SASL_SERV) ? xsasl_server_types() :
xsasl_client_types();
for (i = 0; i < sasl_argv->argc; i++)
vstream_printf("%s\n", sasl_argv->argv[i]);

View File

@@ -6,12 +6,12 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void print_line(fp, mode, const char *fmt, ...)
/* void pcf_print_line(fp, mode, const char *fmt, ...)
/* VSTREAM *fp;
/* int mode;
/* const char *fmt;
/* DESCRIPTION
/* print_line() formats text, normalized whitespace, and
/* pcf_print_line() formats text, normalized whitespace, and
/* optionally folds long lines.
/*
/* Arguments:
@@ -21,7 +21,7 @@
/* Bit-wise OR of zero or more of the following (other flags
/* are ignored):
/* .RS
/* .IP FOLD_LINE
/* .IP PCF_FOLD_LINE
/* Fold long lines.
/* .RE
/* .IP fmt
@@ -59,9 +59,9 @@
#define STR(x) vstring_str(x)
/* print_line - show line possibly folded, and with normalized whitespace */
/* pcf_print_line - show line possibly folded, and with normalized whitespace */
void print_line(VSTREAM *fp, int mode, const char *fmt,...)
void pcf_print_line(VSTREAM *fp, int mode, const char *fmt,...)
{
va_list ap;
static VSTRING *buf = 0;
@@ -93,17 +93,18 @@ void print_line(VSTREAM *fp, int mode, const char *fmt,...)
* then perhaps readlline() can be changed to canonicalize whitespace
* that follows a newline.
*/
for (start = STR(buf); *(start += strspn(start, SEPARATORS)) != 0; start = next) {
word_len = strcspn(start, SEPARATORS);
for (start = STR(buf); *(start += strspn(start, PCF_SEPARATORS)) != 0; start = next) {
word_len = strcspn(start, PCF_SEPARATORS);
if (*(next = start + word_len) != 0)
*next++ = 0;
if (word_len > 0 && line_len > 0) {
if ((mode & FOLD_LINE) == 0 || line_len + word_len < LINE_LIMIT) {
if ((mode & PCF_FOLD_LINE) == 0
|| line_len + word_len < PCF_LINE_LIMIT) {
vstream_fputs(" ", fp);
line_len += 1;
} else {
vstream_fputs("\n" INDENT_TEXT, fp);
line_len = INDENT_LEN;
vstream_fputs("\n" PCF_INDENT_TEXT, fp);
line_len = PCF_INDENT_LEN;
}
}
vstream_fputs(start, fp);

View File

@@ -2,21 +2,21 @@
/* NAME
/* postconf_service 3
/* SUMMARY
/* service-defined parameter name support
/* service-defined main.cf parameter name support
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void register_service_parameters()
/* void pcf_register_service_parameters()
/* DESCRIPTION
/* Service-defined parameter names are created by appending
/* postfix-defined suffixes to master.cf service names. All
/* service-defined parameters have default values that are
/* defined by a built-in parameter.
/*
/* register_service_parameters() adds the service-defined parameters
/* to the global name space. This function must be called after
/* the built-in parameters are added to the global name space,
/* and after the master.cf file is read.
/* pcf_register_service_parameters() adds the service-defined
/* parameters to the global name space. This function must be
/* called after the built-in parameters are added to the global
/* name space, and after the master.cf file is read.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -72,24 +72,25 @@
typedef struct {
const char *name;
const char *value;
} PC_STRING_NV;
} PCF_STRING_NV;
#define STR(x) vstring_str(x)
/* convert_service_parameter - get service parameter string value */
/* pcf_convert_service_parameter - get service parameter string value */
static const char *convert_service_parameter(char *ptr)
static const char *pcf_convert_service_parameter(char *ptr)
{
return (STR(vstring_sprintf(param_string_buf, "$%s", ptr)));
return (STR(vstring_sprintf(pcf_param_string_buf, "$%s", ptr)));
}
/* register_service_parameter - add one service parameter name and default */
/* pcf_register_service_parameter - add service parameter name and default */
static void register_service_parameter(const char *service, const char *suffix,
const char *defparam)
static void pcf_register_service_parameter(const char *service,
const char *suffix,
const char *defparam)
{
char *name = concatenate(service, suffix, (char *) 0);
PC_PARAM_NODE *node;
PCF_PARAM_NODE *node;
/*
* Skip service parameter names that have built-in definitions. This
@@ -100,21 +101,21 @@ static void register_service_parameter(const char *service, const char *suffix,
* service parameters with their own default value. We don't change the
* default but we correct the parameter class.
*/
if ((node = PC_PARAM_TABLE_FIND(param_table, name)) != 0) {
PC_PARAM_CLASS_OVERRIDE(node, PC_PARAM_FLAG_SERVICE);
if ((node = PCF_PARAM_TABLE_FIND(pcf_param_table, name)) != 0) {
PCF_PARAM_CLASS_OVERRIDE(node, PCF_PARAM_FLAG_SERVICE);
} else {
PC_PARAM_TABLE_ENTER(param_table, name, PC_PARAM_FLAG_SERVICE,
(char *) defparam, convert_service_parameter);
PCF_PARAM_TABLE_ENTER(pcf_param_table, name, PCF_PARAM_FLAG_SERVICE,
(char *) defparam, pcf_convert_service_parameter);
}
myfree(name);
}
/* register_service_parameters - add all service parameters with defaults */
/* pcf_register_service_parameters - add all service parameters with defaults */
void register_service_parameters(void)
void pcf_register_service_parameters(void)
{
const char *myname = "register_service_parameters";
static const PC_STRING_NV pipe_params[] = {
const char *myname = "pcf_register_service_parameters";
static const PCF_STRING_NV pipe_params[] = {
/* suffix, default parameter name */
_MAXTIME, VAR_COMMAND_MAXTIME,
#define service_params (pipe_params + 1)
@@ -135,16 +136,16 @@ void register_service_parameters(void)
_DEST_RATE_DELAY, VAR_DEST_RATE_DELAY,
0,
};
static const PC_STRING_NV spawn_params[] = {
static const PCF_STRING_NV spawn_params[] = {
/* suffix, default parameter name */
_MAXTIME, VAR_COMMAND_MAXTIME,
0,
};
typedef struct {
const char *progname;
const PC_STRING_NV *params;
} PC_SERVICE_DEF;
static const PC_SERVICE_DEF service_defs[] = {
const PCF_STRING_NV *params;
} PCF_SERVICE_DEF;
static const PCF_SERVICE_DEF service_defs[] = {
MAIL_PROGRAM_LOCAL, service_params,
MAIL_PROGRAM_ERROR, service_params,
MAIL_PROGRAM_VIRTUAL, service_params,
@@ -154,26 +155,26 @@ void register_service_parameters(void)
MAIL_PROGRAM_SPAWN, spawn_params,
0,
};
const PC_STRING_NV *sp;
const PCF_STRING_NV *sp;
const char *progname;
const char *service;
PC_MASTER_ENT *masterp;
PCF_MASTER_ENT *masterp;
ARGV *argv;
const PC_SERVICE_DEF *sd;
const PCF_SERVICE_DEF *sd;
/*
* Sanity checks.
*/
if (param_table == 0)
if (pcf_param_table == 0)
msg_panic("%s: global parameter table is not initialized", myname);
if (master_table == 0)
if (pcf_master_table == 0)
msg_panic("%s: master table is not initialized", myname);
/*
* Extract service names from master.cf and generate service parameter
* information.
*/
for (masterp = master_table; (argv = masterp->argv) != 0; masterp++) {
for (masterp = pcf_master_table; (argv = masterp->argv) != 0; masterp++) {
/*
* Add service parameters for message delivery transports or spawn
@@ -184,7 +185,7 @@ void register_service_parameters(void)
if (strcmp(sd->progname, progname) == 0) {
service = argv->argv[0];
for (sp = sd->params; sp->name; sp++)
register_service_parameter(service, sp->name, sp->value);
pcf_register_service_parameter(service, sp->name, sp->value);
break;
}
}

View File

@@ -6,20 +6,20 @@
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void flag_unused_main_parameters()
/* void pcf_flag_unused_main_parameters()
/*
/* void flag_unused_master_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.
/* In other words, don't call these functions with "postconf
/* -d" which ignores user-defined main.cf settings.
/*
/* flag_unused_main_parameters() reports unused "name=value"
/* pcf_flag_unused_main_parameters() reports unused "name=value"
/* entries in main.cf.
/*
/* flag_unused_master_parameters() reports unused "-o name=value"
/* entries in master.cf.
/* pcf_flag_unused_master_parameters() reports unused "-o
/* name=value" entries in master.cf.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -52,12 +52,12 @@
#include <postconf.h>
/* flag_unused_parameters - warn about unused parameters */
/* pcf_flag_unused_parameters - warn about unused parameters */
static void flag_unused_parameters(DICT *dict, const char *conf_name,
PC_MASTER_ENT *local_scope)
static void pcf_flag_unused_parameters(DICT *dict, const char *conf_name,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "flag_unused_parameters";
const char *myname = "pcf_flag_unused_parameters";
const char *param_name;
const char *param_value;
int how;
@@ -65,7 +65,7 @@ static void flag_unused_parameters(DICT *dict, const char *conf_name,
/*
* Sanity checks.
*/
if (param_table == 0)
if (pcf_param_table == 0)
msg_panic("%s: global parameter table is not initialized", myname);
/*
@@ -78,9 +78,9 @@ static void flag_unused_parameters(DICT *dict, const char *conf_name,
for (how = DICT_SEQ_FUN_FIRST;
dict->sequence(dict, how, &param_name, &param_value) == 0;
how = DICT_SEQ_FUN_NEXT) {
if (PC_PARAM_TABLE_LOCATE(param_table, param_name) == 0
if (PCF_PARAM_TABLE_LOCATE(pcf_param_table, param_name) == 0
&& (local_scope == 0
|| PC_PARAM_TABLE_LOCATE(local_scope->valid_names, param_name) == 0)) {
|| PCF_PARAM_TABLE_LOCATE(local_scope->valid_names, param_name) == 0)) {
vstream_fflush(VSTREAM_OUT);
msg_warn("%s/%s: unused parameter: %s=%s",
var_config_dir, conf_name, param_name, param_value);
@@ -88,11 +88,11 @@ static void flag_unused_parameters(DICT *dict, const char *conf_name,
}
}
/* flag_unused_main_parameters - warn about unused parameters */
/* pcf_flag_unused_main_parameters - warn about unused parameters */
void flag_unused_main_parameters(void)
void pcf_flag_unused_main_parameters(void)
{
const char *myname = "flag_unused_main_parameters";
const char *myname = "pcf_flag_unused_main_parameters";
DICT *dict;
/*
@@ -102,28 +102,28 @@ void flag_unused_main_parameters(void)
if ((dict = dict_handle(CONFIG_DICT)) == 0)
msg_panic("%s: parameter dictionary %s not found",
myname, CONFIG_DICT);
flag_unused_parameters(dict, MAIN_CONF_FILE, (PC_MASTER_ENT *) 0);
pcf_flag_unused_parameters(dict, MAIN_CONF_FILE, (PCF_MASTER_ENT *) 0);
}
/* flag_unused_master_parameters - warn about unused parameters */
/* pcf_flag_unused_master_parameters - warn about unused parameters */
void flag_unused_master_parameters(void)
void pcf_flag_unused_master_parameters(void)
{
const char *myname = "flag_unused_master_parameters";
PC_MASTER_ENT *masterp;
const char *myname = "pcf_flag_unused_master_parameters";
PCF_MASTER_ENT *masterp;
DICT *dict;
/*
* Sanity checks.
*/
if (master_table == 0)
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 = master_table; masterp->argv != 0; masterp++)
for (masterp = pcf_master_table; masterp->argv != 0; masterp++)
if ((dict = masterp->all_params) != 0)
flag_unused_parameters(dict, MASTER_CONF_FILE, masterp);
pcf_flag_unused_parameters(dict, MASTER_CONF_FILE, masterp);
}

View File

@@ -2,11 +2,11 @@
/* NAME
/* postconf_user 3
/* SUMMARY
/* support for user-defined parameter names
/* support for user-defined main.cf parameter names
/* SYNOPSIS
/* #include <postconf.h>
/*
/* void register_user_parameters()
/* void pcf_register_user_parameters()
/* DESCRIPTION
/* Postfix has multiple parameter name spaces: the global
/* main.cf parameter name space, and the local parameter name
@@ -31,10 +31,10 @@
/*
/* Other user-defined parameter names are flagged as "unused".
/*
/* register_user_parameters() scans the global and per-service
/* name spaces for user-defined parameters and flags
/* parameters as "valid" in the global name space (param_table)
/* or in the per-service name space (valid_params).
/* pcf_register_user_parameters() scans the global and per-service
/* name spaces for user-defined parameters and flags parameters
/* as "valid" in the global name space (pcf_param_table) or
/* in the per-service name space (valid_params).
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
/* LICENSE
@@ -75,7 +75,7 @@
* value. This is used when validating "-o user-defined-name=value" entries
* in master.cf.
*/
static HTABLE *rest_class_table;
static HTABLE *pcf_rest_class_table;
/*
* SLMs.
@@ -91,25 +91,25 @@ static HTABLE *rest_class_table;
/* SCAN_USER_PARAMETER_VALUE - examine macro names in parameter value */
#define SCAN_USER_PARAMETER_VALUE(value, class, scope) do { \
PC_PARAM_CTX _ctx; \
PCF_PARAM_CTX _ctx; \
_ctx.local_scope = (scope); \
_ctx.param_class = (class); \
(void) mac_expand(NO_SCAN_RESULT, (value), MAC_EXP_FLAG_SCAN, \
NO_SCAN_FILTER, flag_user_parameter_wrapper, (char *) &_ctx); \
NO_SCAN_FILTER, pcf_flag_user_parameter_wrapper, (char *) &_ctx); \
} while (0)
/* convert_user_parameter - get user-defined parameter string value */
/* pcf_convert_user_parameter - get user-defined parameter string value */
static const char *convert_user_parameter(char *unused_ptr)
static const char *pcf_convert_user_parameter(char *unused_ptr)
{
return (""); /* can't happen */
}
/* flag_user_parameter - flag user-defined name "valid" if it has name=value */
/* pcf_flag_user_parameter - flag user-defined name "valid" if it has name=value */
static const char *flag_user_parameter(const char *mac_name,
int param_class,
PC_MASTER_ENT *local_scope)
static const char *pcf_flag_user_parameter(const char *mac_name,
int param_class,
PCF_MASTER_ENT *local_scope)
{
const char *source = local_scope ? MASTER_CONF_FILE : MAIN_CONF_FILE;
int user_supplied = 0;
@@ -125,10 +125,10 @@ static const char *flag_user_parameter(const char *mac_name,
if (local_scope && dict_get(local_scope->all_params, mac_name)) {
user_supplied = 1;
/* $name in master.cf references name=value in master.cf. */
if (PC_PARAM_TABLE_LOCATE(local_scope->valid_names, mac_name) == 0) {
PC_PARAM_TABLE_ENTER(local_scope->valid_names, mac_name,
param_class, PC_PARAM_NO_DATA,
convert_user_parameter);
if (PCF_PARAM_TABLE_LOCATE(local_scope->valid_names, mac_name) == 0) {
PCF_PARAM_TABLE_ENTER(local_scope->valid_names, mac_name,
param_class, PCF_PARAM_NO_DATA,
pcf_convert_user_parameter);
if (msg_verbose)
msg_info("$%s in %s:%s validates %s=value in %s:%s",
mac_name, MASTER_CONF_FILE,
@@ -139,9 +139,9 @@ static const char *flag_user_parameter(const char *mac_name,
} else if (mail_conf_lookup(mac_name) != 0) {
user_supplied = 1;
/* $name in main/master.cf references name=value in main.cf. */
if (PC_PARAM_TABLE_LOCATE(param_table, mac_name) == 0) {
PC_PARAM_TABLE_ENTER(param_table, mac_name, param_class,
PC_PARAM_NO_DATA, convert_user_parameter);
if (PCF_PARAM_TABLE_LOCATE(pcf_param_table, mac_name) == 0) {
PCF_PARAM_TABLE_ENTER(pcf_param_table, mac_name, param_class,
PCF_PARAM_NO_DATA, pcf_convert_user_parameter);
if (msg_verbose) {
if (local_scope)
msg_info("$%s in %s:%s validates %s=value in %s",
@@ -156,15 +156,15 @@ static const char *flag_user_parameter(const char *mac_name,
}
}
if (local_scope == 0) {
for (local_scope = master_table; local_scope->argv; local_scope++) {
for (local_scope = pcf_master_table; local_scope->argv; local_scope++) {
if (local_scope->all_params != 0
&& dict_get(local_scope->all_params, mac_name) != 0) {
user_supplied = 1;
/* $name in main.cf references name=value in master.cf. */
if (PC_PARAM_TABLE_LOCATE(local_scope->valid_names, mac_name) == 0) {
PC_PARAM_TABLE_ENTER(local_scope->valid_names, mac_name,
param_class, PC_PARAM_NO_DATA,
convert_user_parameter);
if (PCF_PARAM_TABLE_LOCATE(local_scope->valid_names, mac_name) == 0) {
PCF_PARAM_TABLE_ENTER(local_scope->valid_names, mac_name,
param_class, PCF_PARAM_NO_DATA,
pcf_convert_user_parameter);
if (msg_verbose)
msg_info("$%s in %s validates %s=value in %s:%s",
mac_name, MAIN_CONF_FILE,
@@ -181,27 +181,27 @@ static const char *flag_user_parameter(const char *mac_name,
* parameters because they exist only for backwards compatibility, so we
* don't bother to figure out which parameters come without defaults.
*/
if (user_supplied == 0 && (param_class & PC_PARAM_FLAG_DBMS) == 0
&& PC_PARAM_TABLE_LOCATE(param_table, mac_name) == 0)
if (user_supplied == 0 && (param_class & PCF_PARAM_FLAG_DBMS) == 0
&& PCF_PARAM_TABLE_LOCATE(pcf_param_table, mac_name) == 0)
msg_warn("%s/%s: undefined parameter: %s",
var_config_dir, source, mac_name);
return (0);
}
/* flag_user_parameter_wrapper - mac_expand call-back helper */
/* pcf_flag_user_parameter_wrapper - mac_expand call-back helper */
static const char *flag_user_parameter_wrapper(const char *mac_name,
int unused_mode,
char *context)
static const char *pcf_flag_user_parameter_wrapper(const char *mac_name,
int unused_mode,
char *context)
{
PC_PARAM_CTX *ctx = (PC_PARAM_CTX *) context;
PCF_PARAM_CTX *ctx = (PCF_PARAM_CTX *) context;
return (flag_user_parameter(mac_name, ctx->param_class, ctx->local_scope));
return (pcf_flag_user_parameter(mac_name, ctx->param_class, ctx->local_scope));
}
/* pc_lookup_eval - generalized mail_conf_lookup_eval */
/* pcf_lookup_eval - generalized mail_conf_lookup_eval */
static const char *pc_lookup_eval(const char *dict_name, const char *name)
static const char *pcf_lookup_eval(const char *dict_name, const char *name)
{
const char *value;
@@ -212,12 +212,12 @@ static const char *pc_lookup_eval(const char *dict_name, const char *name)
return (value);
}
/* scan_user_parameter_namespace - scan parameters in name space */
/* pcf_scan_user_parameter_namespace - scan parameters in name space */
static void scan_user_parameter_namespace(const char *dict_name,
PC_MASTER_ENT *local_scope)
static void pcf_scan_user_parameter_namespace(const char *dict_name,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "scan_user_parameter_namespace";
const char *myname = "pcf_scan_user_parameter_namespace";
const char *class_list;
char *saved_class_list;
char *cp;
@@ -226,7 +226,7 @@ static void scan_user_parameter_namespace(const char *dict_name,
int how;
const char *cparam_name;
const char *cparam_value;
PC_PARAM_NODE *node;
PCF_PARAM_NODE *node;
const char *source = local_scope ? MASTER_CONF_FILE : MAIN_CONF_FILE;
/*
@@ -235,13 +235,13 @@ static void scan_user_parameter_namespace(const char *dict_name,
* space, update the global restriction class name table, so that we can
* query the global table from within a local master.cf name space.
*/
if ((class_list = pc_lookup_eval(dict_name, VAR_REST_CLASSES)) != 0) {
if ((class_list = pcf_lookup_eval(dict_name, VAR_REST_CLASSES)) != 0) {
cp = saved_class_list = mystrdup(class_list);
while ((param_name = mystrtok(&cp, ", \t\r\n")) != 0) {
if (local_scope == 0
&& htable_locate(rest_class_table, param_name) == 0)
htable_enter(rest_class_table, param_name, "");
flag_user_parameter(param_name, PC_PARAM_FLAG_USER, local_scope);
&& htable_locate(pcf_rest_class_table, param_name) == 0)
htable_enter(pcf_rest_class_table, param_name, "");
pcf_flag_user_parameter(param_name, PCF_PARAM_FLAG_USER, local_scope);
}
myfree(saved_class_list);
}
@@ -266,13 +266,13 @@ static void scan_user_parameter_namespace(const char *dict_name,
dict->sequence(dict, how, &cparam_name, &cparam_value) == 0;
how = DICT_SEQ_FUN_NEXT) {
if (local_scope != 0
&& PC_PARAM_TABLE_LOCATE(local_scope->valid_names, cparam_name) == 0
&& htable_locate(rest_class_table, cparam_name) != 0)
PC_PARAM_TABLE_ENTER(local_scope->valid_names, cparam_name,
PC_PARAM_FLAG_USER, PC_PARAM_NO_DATA,
convert_user_parameter);
if ((node = PC_PARAM_TABLE_FIND(param_table, cparam_name)) != 0) {
if (PC_READONLY_PARAMETER(node)) {
&& PCF_PARAM_TABLE_LOCATE(local_scope->valid_names, cparam_name) == 0
&& htable_locate(pcf_rest_class_table, cparam_name) != 0)
PCF_PARAM_TABLE_ENTER(local_scope->valid_names, cparam_name,
PCF_PARAM_FLAG_USER, PCF_PARAM_NO_DATA,
pcf_convert_user_parameter);
if ((node = PCF_PARAM_TABLE_FIND(pcf_param_table, cparam_name)) != 0) {
if (PCF_READONLY_PARAMETER(node)) {
msg_warn("%s/%s: read-only parameter assignment: %s=%s",
var_config_dir, source, cparam_name, cparam_value);
/* Can't use dict_del() with Postfix<2.10 htable_sequence(). */
@@ -282,55 +282,55 @@ static void scan_user_parameter_namespace(const char *dict_name,
continue;
}
/* Re-label legacy parameter as user-defined, so it's printed. */
if (PC_LEGACY_PARAMETER(node))
PC_PARAM_CLASS_OVERRIDE(node, PC_PARAM_FLAG_USER);
if (PCF_LEGACY_PARAMETER(node))
PCF_PARAM_CLASS_OVERRIDE(node, PCF_PARAM_FLAG_USER);
/* Skip "do not expand" parameters. */
if (PC_RAW_PARAMETER(node))
if (PCF_RAW_PARAMETER(node))
continue;
}
SCAN_USER_PARAMETER_VALUE(cparam_value, PC_PARAM_FLAG_USER, local_scope);
SCAN_USER_PARAMETER_VALUE(cparam_value, PCF_PARAM_FLAG_USER, local_scope);
#ifdef LEGACY_DBMS_SUPPORT
register_dbms_parameters(cparam_value, flag_user_parameter,
local_scope);
pcf_register_dbms_parameters(cparam_value, pcf_flag_user_parameter,
local_scope);
#endif
}
}
/* scan_default_parameter_values - scan parameters at implicit defaults */
/* pcf_scan_default_parameter_values - scan parameters at implicit defaults */
static void scan_default_parameter_values(HTABLE *valid_params,
const char *dict_name,
PC_MASTER_ENT *local_scope)
static void pcf_scan_default_parameter_values(HTABLE *valid_params,
const char *dict_name,
PCF_MASTER_ENT *local_scope)
{
const char *myname = "scan_default_parameter_values";
PC_PARAM_INFO **list;
PC_PARAM_INFO **ht;
const char *myname = "pcf_scan_default_parameter_values";
PCF_PARAM_INFO **list;
PCF_PARAM_INFO **ht;
const char *param_value;
list = PC_PARAM_TABLE_LIST(valid_params);
list = PCF_PARAM_TABLE_LIST(valid_params);
for (ht = list; *ht; ht++) {
/* Skip "do not expand" parameters. */
if (PC_RAW_PARAMETER(PC_PARAM_INFO_NODE(*ht)))
if (PCF_RAW_PARAMETER(PCF_PARAM_INFO_NODE(*ht)))
continue;
/* Skip parameters with a non-default value. */
if (dict_lookup(dict_name, PC_PARAM_INFO_NAME(*ht)))
if (dict_lookup(dict_name, PCF_PARAM_INFO_NAME(*ht)))
continue;
if ((param_value = convert_param_node(SHOW_DEFS, PC_PARAM_INFO_NAME(*ht),
PC_PARAM_INFO_NODE(*ht))) == 0)
if ((param_value = pcf_convert_param_node(PCF_SHOW_DEFS, PCF_PARAM_INFO_NAME(*ht),
PCF_PARAM_INFO_NODE(*ht))) == 0)
msg_panic("%s: parameter %s has no default value",
myname, PC_PARAM_INFO_NAME(*ht));
SCAN_USER_PARAMETER_VALUE(param_value, PC_PARAM_FLAG_USER, local_scope);
myname, PCF_PARAM_INFO_NAME(*ht));
SCAN_USER_PARAMETER_VALUE(param_value, PCF_PARAM_FLAG_USER, local_scope);
/* No need to scan default values for legacy DBMS configuration. */
}
myfree((char *) list);
}
/* register_user_parameters - add parameters with user-defined names */
/* pcf_register_user_parameters - add parameters with user-defined names */
void register_user_parameters(void)
void pcf_register_user_parameters(void)
{
const char *myname = "register_user_parameters";
PC_MASTER_ENT *masterp;
const char *myname = "pcf_register_user_parameters";
PCF_MASTER_ENT *masterp;
ARGV *argv;
char *arg;
char *aval;
@@ -343,27 +343,27 @@ void register_user_parameters(void)
/*
* Sanity checks.
*/
if (param_table == 0)
if (pcf_param_table == 0)
msg_panic("%s: global parameter table is not initialized", myname);
if (master_table == 0)
if (pcf_master_table == 0)
msg_panic("%s: master table is not initialized", myname);
if (rest_class_table != 0)
if (pcf_rest_class_table != 0)
msg_panic("%s: restriction class table is already initialized", myname);
/*
* Initialize the table with global restriction class names.
*/
rest_class_table = htable_create(1);
pcf_rest_class_table = htable_create(1);
/*
* Initialize the per-service parameter name spaces.
*/
for (masterp = master_table; (argv = masterp->argv) != 0; masterp++) {
for (field = PC_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) {
for (masterp = pcf_master_table; (argv = masterp->argv) != 0; masterp++) {
for (field = PCF_MASTER_MIN_FIELDS; argv->argv[field] != 0; field++) {
arg = argv->argv[field];
if (arg[0] != '-' || strcmp(arg, "--") == 0)
break;
if (strchr(daemon_options_expecting_value, arg[1]) == 0
if (strchr(pcf_daemon_options_expecting_value, arg[1]) == 0
|| (aval = argv->argv[field + 1]) == 0)
continue;
if (strcmp(arg, "-o") == 0) {
@@ -383,9 +383,9 @@ void register_user_parameters(void)
/*
* Scan the "-o parameter=value" instances in each master.cf name space.
*/
for (masterp = master_table; masterp->argv != 0; masterp++)
for (masterp = pcf_master_table; masterp->argv != 0; masterp++)
if (masterp->all_params != 0)
scan_user_parameter_namespace(masterp->name_space, masterp);
pcf_scan_user_parameter_namespace(masterp->name_space, masterp);
/*
* Scan parameter values that are left at their defaults in the global
@@ -394,10 +394,11 @@ void register_user_parameters(void)
* name=value is obsolete, but we must not warn that the parameter is
* unused.
*/
scan_default_parameter_values(param_table, CONFIG_DICT, (PC_MASTER_ENT *) 0);
pcf_scan_default_parameter_values(pcf_param_table, CONFIG_DICT,
(PCF_MASTER_ENT *) 0);
/*
* Scan the explicit name=value entries in the global name space.
*/
scan_user_parameter_namespace(CONFIG_DICT, (PC_MASTER_ENT *) 0);
pcf_scan_user_parameter_namespace(CONFIG_DICT, (PCF_MASTER_ENT *) 0);
}

View File

@@ -1447,9 +1447,10 @@ static int add_skid(X509 *cert, AUTHORITY_KEYID *akid)
int nid = NID_subject_key_identifier;
if (!akid || !akid->keyid)
return add_ext(0, cert, nid, "hash");
return (add_ext(0, cert, nid, "hash"));
else
return X509_add1_ext_i2d(cert, nid, akid, 0, X509V3_ADD_DEFAULT) > 0;
return (X509_add1_ext_i2d(cert, nid, akid->keyid, 0,
X509V3_ADD_DEFAULT) > 0);
}
/* akid_issuer_name - get akid issuer directory name */