This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU Mailutils".
http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad The branch, master has been updated via d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad (commit) via dc62b3998f0fe8ce0f131e269b130831093264fb (commit) from b4c787e6ea89ba0005845925cc33070a264d2a77 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d434dd4bf5d822eaaa42f1a2288ab303f77ab5ad Author: Sergey Poznyakoff <g...@gnu.org.ua> Date: Wed Nov 2 15:14:13 2016 +0200 Rename default configuration file The default configuration file name is "mailutils.conf". Legacy configuration file "mailutils.rc" is processed if necessary. * libmailutils/cli/cli.c: Rename main configuration file to mailutils.conf Remove 'rcfile' option aliases. (mu_cli_ext): Special handling for legacy configuration file. * NEWS: Update. * doc/texinfo/mailutils.texi: Update. * doc/texinfo/programs.texi: Update. commit dc62b3998f0fe8ce0f131e269b130831093264fb Author: Sergey Poznyakoff <g...@gnu.org.ua> Date: Wed Nov 2 12:06:08 2016 +0200 Improve configuration file handling. * include/mailutils/cfg.h (mu_cfg_parse_hints): Rename site_rcfile to site_file, custom_rcfile to custom_file. Remove append_tree and data fields. (MU_PARSE_CONFIG_GLOBAL,MU_CFG_PARSE_PROGRAM): Remove. (MU_PARSE_CONFIG_VERBOSE): Rename to MU_CF_VERBOSE. (MU_PARSE_CONFIG_DUMP): Rename to MU_CF_DUMP. (MU_CFG_FMT_LOCUS): Rename to MU_CF_FMT_LOCUS. (MU_CFG_FMT_VALUE_ONLY): Rename to MU_CF_FMT_VALUE_ONLY. (MU_CFG_FMT_PARAM_PATH): Rename to MU_CF_FMT_PARAM_PATH. (MU_CFG_COMPATIBILITY,MU_CFG_DEPRECATED): Remove. (mu_parse_config, mu_get_config): Remove deprecated functions. * libmailutils/cli/cli.c (mu_general_help_text): New global. (app_data): New struct. (init_options): Construct configuration option group depending on which configuration files are in use. (mu_cli_ext): Don't use per-user configuration files for servers. Pass pointer to app_data structure as po.po_data (mu_cli): Set MU_CFHINT_PER_USER_FILE flag by default. * mail/testsuite/lib/mail.exp: Rewrite invocation of the mu_init command. * include/mailutils/cli.h (mu_cli_setup) <server>: New field. * comsat/comsat.c (cli): Mark as server. (main): Bugfix: pass pointer to server to mu_cli. * imap4d/imap4d.c (cli): Mark as server. * pop3d/pop3d.c: Likewise. * comsat/tests/testsuite.at: Use the --no-site-config option. * imap4d/tests/testsuite.at: Likewise. * libmailutils/cfg/driver.c: Update. * libmailutils/cfg/format.c: Update. * libmailutils/cfg/lexer.l: Update. * libmailutils/cfg/parser.y: Update. * mu/acl.c: Update. * pop3d/testsuite/lib/pop3d.exp: Likewise. * mu/mu.c: Don't read configuration files. * mu/query.c: Fix args_doc * testsuite/lib/mailutils.exp (mu_init): Change option handling. Set --no-config option by default. ----------------------------------------------------------------------- Summary of changes: NEWS | 4 +- comsat/comsat.c | 12 +- comsat/tests/testsuite.at | 2 +- doc/texinfo/mailutils.texi | 32 ++--- doc/texinfo/programs.texi | 280 +++++++++++++++++++++++++++-------------- imap4d/imap4d.c | 11 +- imap4d/tests/testsuite.at | 1 - include/mailutils/cfg.h | 65 +++++----- include/mailutils/cli.h | 5 +- libmailutils/cfg/driver.c | 28 +---- libmailutils/cfg/format.c | 12 +- libmailutils/cfg/lexer.l | 34 +---- libmailutils/cfg/parser.y | 43 +++---- libmailutils/cli/cli.c | 274 +++++++++++++++++++++++++++++++--------- mail/testsuite/lib/mail.exp | 2 +- mu/acl.c | 4 +- mu/mu.c | 17 ++- mu/query.c | 14 +-- pop3d/pop3d.c | 7 +- pop3d/testsuite/lib/pop3d.exp | 3 +- sieve/tests/testsuite.at | 2 +- testsuite/lib/mailutils.exp | 23 +++- testsuite/testsuite.inc | 3 +- 23 files changed, 548 insertions(+), 330 deletions(-) diff --git a/NEWS b/NEWS index 4aa8610..a3190d4 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU mailutils NEWS -- history of user-visible changes. 2016-10-30 +GNU mailutils NEWS -- history of user-visible changes. 2016-11-02 Copyright (C) 2002-2016 Free Software Foundation, Inc. See the end of file for copying conditions. @@ -39,6 +39,8 @@ programmers which use or wish to use Mailutils in their projects. * Important changes +** Main configuration file renamed to mailutils.conf + ** IPv6 support. The core library as well as client and server utilities support diff --git a/comsat/comsat.c b/comsat/comsat.c index e16f91a..2a6d69f 100644 --- a/comsat/comsat.c +++ b/comsat/comsat.c @@ -194,11 +194,11 @@ struct mu_cfg_param comsat_cfg_param[] = { static char const *alt_args[] = { N_("--test MBOX-URL MSG-QID"), NULL }; static struct mu_cli_setup cli = { - options, - comsat_cfg_param, - N_("GNU comsatd -- notify users about incoming mail"), - "", - alt_args, + .optv = options, + .cfg =comsat_cfg_param, + .prog_doc = N_("GNU comsatd -- notify users about incoming mail"), + .prog_alt_args = alt_args, + .server = 1 }; static char *capa[] = { @@ -568,7 +568,7 @@ main (int argc, char **argv) save_argv = argv; - mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); + mu_cli (argc, argv, &cli, capa, server, &argc, &argv); if (test_mode) { diff --git a/comsat/tests/testsuite.at b/comsat/tests/testsuite.at index 4c04223..a37ad5b 100644 --- a/comsat/tests/testsuite.at +++ b/comsat/tests/testsuite.at @@ -22,7 +22,7 @@ m4_pushdef([BIFF_MBOX],[`pwd`/mailbox]) dnl ------------------------------------------------------------ dnl comsatcmd -m4_pushdef([comsatcmd],[comsatd --no-site --no-user --file ./biff.rc dnl +m4_pushdef([comsatcmd],[comsatd --no-site-config --file ./biff.rc dnl --set logging.syslog=no --test]) dnl ------------------------------------------------------------ diff --git a/doc/texinfo/mailutils.texi b/doc/texinfo/mailutils.texi index 671aae4..c9fac62 100644 --- a/doc/texinfo/mailutils.texi +++ b/doc/texinfo/mailutils.texi @@ -154,23 +154,23 @@ Command Line Mailutils Configuration File * conf-syntax:: Configuration File Syntax -* Include:: Include Statement -* Logging Statement:: -* Debug Statement:: -* Mailbox Statement:: -* Locking Statement:: -* Mailer Statement:: -* ACL Statement:: -* Tcp-wrappers Statement:: +* include:: Include Statement +* logging statement:: +* debug statement:: +* mailbox statement:: +* locking statement:: +* mailer statement:: +* acl statement:: +* tcp-wrappers statement:: * Server Settings:: -* Auth Statement:: -* PAM Statement:: -* Virtdomain Statement:: -* Radius Statement:: -* SQL Statement:: -* LDAP Statement:: -* TLS Statement:: -* GSASL Statement:: +* auth statement:: +* pam statement:: +* virtdomain statement:: +* radius statement:: +* sql statement:: +* ldap statement:: +* tls statement:: +* gsasl statement:: Configuration File Syntax diff --git a/doc/texinfo/programs.texi b/doc/texinfo/programs.texi index a4edcf8..c087984 100644 --- a/doc/texinfo/programs.texi +++ b/doc/texinfo/programs.texi @@ -225,6 +225,10 @@ Do not load site-wide configuration file. @item --no-user-config Do not load user configuration file. +@xopindex{no-config, introduced} +@item --no-config +Don't load site-wide and user configuration files. + @xopindex{set, introduced} @item --set=@var{path}=@var{value} Set configuration variable. @@ -233,7 +237,7 @@ Set configuration variable. @node configuration @section Mailutils Configuration File @cindex Mailutils configuration file -@cindex mailutils.rc +@cindex mailutils.conf Configuration files are the principal means of configuring any GNU Mailutils component. When started, each utility tries to load its @@ -242,9 +246,9 @@ configuration from the following locations, in that order: @enumerate 1 @item Main site-wide configuration file. -It is named @file{@var{sysconfdir}/mailutils.rc}, where @var{sysconfdir} stands -for the system configuration directory set when compiling the package. -You can obtain the value of @var{sysconfdir} by running +It is named @file{@var{sysconfdir}/mailutils.conf}, where +@var{sysconfdir} stands for the system configuration directory set +when compiling the package. You can obtain the value of @var{sysconfdir} by running @example $ mailutils info sysconfdir @@ -261,30 +265,58 @@ $ @var{prog} --show-config-options | grep SYSCONFDIR where @var{prog} stands for any GNU Mailutils utility. @xopindex{no-site-config, described} -The site-wide configuration file is not read if the @option{--no-site-config} -command line option was given. +The site-wide configuration file is not read if any of +@option{--no-site-config} or @option{--no-config} command line options +was given. + +Older versions of GNU Mailutils read configuration from file +@file{mailutils.rc}. To facilitate transition, mailutils will look +for that file as well. If both the default site-wide configuration +file and legacy configuration file are present you will get the +following warning: + +@example +legacy configuration file /etc/mailutils.rc ignored +@end example + +Otherwise, if @file{mailutils.conf} does not exist and +@file{mailutils.rc} is present, it will be used instead and the +following warning will be issued: + +@example + using legacy configuration file /etc/mailutils.rc: + please rename it to /etc/mailutils.conf +@end example @item Per-user configuration file. -A per user configuration file is located in the user home directory -and is named @samp{.@var{prog}}, where @var{prog} is the name of the -utility. For example, the per-user configuration file for -@command{sieve} utility is named @file{.sieve}. +Client utilities, such as @command{frm} or @command{sieve}, look in +the user home directory for a file named @samp{.@var{prog}}, where +@var{prog} is the name of the utility. If it is present, it will be +loaded after loading the site-wide configuration file. This file +allows users to customize such utilities. -@xopindex{no-user-config, described} -This configuration file is not read if the @option{--no-user-config} -command line option was given. +For example, the per-user configuration file for @command{sieve} +utility is named @file{.sieve}. -@xopindex{config-file, described} -@item Additional configuration file, if specified using the -@option{--config-file} command line option. +@xopindex{no-user-config, described} +Loading of per-user configuration file is disabled by +@option{--no-user-config} and @option{--no-config} options. @end enumerate -The order in which configuration files are loaded defines the -precedence of their settings. Thus, settings from additional -configuration file override those set in per-user configuration file. -The latter, in their turn, take precedence over the settings from the -site-wide configuration file. +Server programs, such as @command{imap4d} don't use per-user +configuration files. + +The @option{--no-config} option provides a shortcut for disabling +loading of the default configuration files. For servers, its effect +is the same as of @option{--no-site-config}. For client utilities, it +is equivalent to @option{--no-site-config --no-user-config} used +together. + +@xopindex{config-file, described} +The @option{--config-file} command line option instructs the program +to read configuration from the file supplied as its argument. In that +case, default configuration files are not used at all. @xopindex{config-verbose, described} Neither site-wide nor user configuration files are required to @@ -342,11 +374,16 @@ $ imap4d --config-help > imap4d.rc @noindent and to edit the @file{imap4d.rc} file with your editor of choice. +The order in which configuration files are loaded defines the +precedence of their settings. Thus, for client utilities, settings +from the per-user configuration file override those from the site-wide +configuration. + @xopindex{set, described} It is also possible to set or override arbitrary configuration variables in the command line. It can be done via the @option{--set} option. Its argument is a @dfn{pathname} of the variable to be set, -followed by an equals sign and value. For example, to define the +followed by an equals sign and a value. For example, to define the variable @samp{syslog} in section @samp{logging} to @samp{no}, do the following: @@ -356,26 +393,30 @@ $ imap4d --set .logging.syslog=no Configuration pathnames are discussed in detail in @ref{Paths}. +The @option{--set} options are processed after loading all +configuration files. + @menu * conf-syntax:: Configuration File Syntax * Variables:: Variable Expansion -* Include:: Include Statement -* Logging Statement:: -* Debug Statement:: -* Mailbox Statement:: -* Locking Statement:: -* Mailer Statement:: -* ACL Statement:: -* Tcp-wrappers Statement:: +* include:: Include Statement +* program statement:: +* logging statement:: +* debug statement:: +* mailbox statement:: +* locking statement:: +* mailer statement:: +* acl statement:: +* tcp-wrappers statement:: * Server Settings:: -* Auth Statement:: -* PAM Statement:: -* Virtdomain Statement:: -* Radius Statement:: -* SQL Statement:: -* LDAP Statement:: -* TLS Statement:: -* GSASL Statement:: +* auth statement:: +* pam statement:: +* virtdomain statement:: +* radius statement:: +* sql statement:: +* ldap statement:: +* tls statement:: +* gsasl statement:: @end menu @node conf-syntax @@ -611,8 +652,7 @@ this is not required. @command{Mailutils} configuration files have a distinct hierarchical structure. Each statement in such files can therefore be identified by its name and the names of block statements containing it. Such -names form this statement @dfn{pathname}, similar to that used, -e.g. by UNIX file system. +names form the @dfn{pathname}, similar to that used by UNIX file system. For example, consider the following file: @@ -650,9 +690,9 @@ Any other punctuation character can be used as a component separator, provided that it appears at the beginning of the pathname. In other words, only absolute pathnames allow for a change in component separators. -A block statement that has a tag is referred to by its name, followed -by an equals sign, followed by the tag value. For example, the -statement @samp{A} in the file below: +A block statement that has a tag is referred to by the statement's +name, followed by an equals sign, followed by the tag value. For +example, the statement @samp{A} in the file below: @example program x @{ @@ -722,24 +762,27 @@ substituted, otherwise the expansion of @var{word} is substituted. The subsections below define variable names that are valid for use in each configuration statement. -@node Include -@subsection Include Statement +@node include +@subsection The @code{include} Statement +@anchor{Include} @c for backward-compatibility @cindex include statement, configuration file @kwindex include The @dfn{include statement} is a special statement that causes -inclusion of a named file. It has the following syntax: +inclusion of the named file. It has the following syntax: @example include @var{file}; @end example -If @var{file} names a regular file, the contents of this file is -included in this point. Otherwise, if @var{file} names a directory, -Mailutils searches in that directory for a file whose name coincides -with the name of utility being executed, and includes this file, if it -exists. +The effect of this statement is that the contents of this @var{file} is +included in this point. -It is a common approach to end the site-wide configuration file with +In site-wide configuration file, @var{file} can be a directory name. +In this case, Mailutils will search this directory for a file with the +same name as the utility being executed. If found, this file will be +loaded. + +It is a common to end the site-wide configuration file with an include statement, e.g.: @example @@ -747,11 +790,40 @@ include /etc/mailutils.d; @end example This allows each particular utility to have its own configuration -file. Thus. @command{imap4d} will read +file. Thus, @command{imap4d} will read @file{/etc/mailutils.d/imap4d}, etc. -@node Logging Statement -@subsection Logging Statement +@node program statement +@subsection The @command{program} statement +@kwindex program +Another way to configure program-specific settings is by using the +@command{program} statement. The syntax is as follows: + +@example +program @var{progname} @{ + ... +@} +@end example + +The @command{program} statement is allowed only in the site-wide +configuration file. When encountered, its tag (@var{progname}) is +compared with the name of the program being run. If two strings are +the same, the statements between curly braces are stored in a +temporary memory, otherwise the statement is ignored. When entire +configuration file is loaded, the statements accumulated in the +temporary storage are processed. + +Notice the difference between this statement and a per-program +configuration file loaded via an @code{include} statement. No matter +where in the file the @command{program} statement is, it is always +processed after the entire configuraion file is processed. In the +contrast, the per-program configuration file loaded via @code{include} +with the directory name as its argument is processed right where it is +encountered. + +@node logging statement +@subsection The @code{logging} Statement +@anchor{Logging Statement} @kwindex logging @subheading Syntax @example @@ -822,8 +894,9 @@ programs that handle multiple user sessions simultaneously, such as @command{pop3d} and @command{imap4d}. @end deffn -@node Debug Statement -@subsection Debug Statement +@node debug statement +@subsection The @code{debug} Statement +@anchor{Debug Statement} @kwindex debug @subheading Syntax @example @@ -850,8 +923,9 @@ debugging messages to be prefixed with locations in Mailutils source files where they appear. Normally, only Mailutils developers need this option. -@node Mailbox Statement -@subsection Mailbox Statement +@node mailbox statement +@subsection The @code{mailbox} Statement +@anchor{Mailbox Statement} @kwindex mailbox @subheading Syntax @example @@ -1045,8 +1119,9 @@ The @var{dir} argument can contain mailbox type prefix, e.g The default folder name is @samp{Mail/}. @end deffn -@node Locking Statement -@subsection Locking Statement +@node locking statement +@subsection The @command{locking} Statement +@anchor{Locking Statement} @kwindex locking @subheading Syntax @example @@ -1121,8 +1196,9 @@ Set command line of an external locker program. The @samp{E} flag must be set for this to take effect. @end deffn -@node Mailer Statement -@subsection Mailer Statement +@node mailer statement +@subsection The @code{mailer} Statement +@anchor{Mailer Statement} @kwindex mailer @subheading Syntax @example @@ -1176,8 +1252,9 @@ mailer that allows to use arbitrary external programs as mailers. It is described in detain in @ref{Program Mailboxes,,prog}. @end table -@node ACL Statement -@subsection ACL Statement +@node acl statement +@subsection The @code{acl} Statement +@anchor{ACL Statement} @kwindex acl @subheading Syntax @example @@ -1321,8 +1398,9 @@ the given @var{program}. Do not wait for it to terminate, and ignore its exit code. @end deffn -@node Tcp-wrappers Statement -@subsection Tcp-wrappers Statement +@node tcp-wrappers statement +@subsection The @code{tcp-wrappers} Statement +@anchor{Tcp-wrappers Statement} @kwindex tcp-wrappers @subheading Syntax @example @@ -1501,7 +1579,7 @@ requests during @var{time} seconds, the child process terminates. @end deffn @node Server Statement -@subsubsection Server Statement +@subsubsection The @code{server} Statement @cindex server statement @kwindex server @* Syntax: @@ -1516,6 +1594,9 @@ server @var{ipaddr}[:@var{port}] @{ # @r{Set idle timeout.} timeout @var{time}; + # Size of the queue of pending connections + backlog <number: callback>; + # @r{Kind of TLS encryption to use for this server.} tls @samp{no}|@samp{ondemand}|@samp{required}|@samp{connection}; @@ -1569,6 +1650,10 @@ Set idle timeout for this server. This overrides global timeout settings (@pxref{General Server Configuration, timeout}). @end deffn +@deffn {Configuration} backlog @var{number}; +Configures the size of the queue of pending connections +@end deffn + @deffn {Configuration} tls @var{mode}; Configure the use of TLS encryption. The @var{mode} argument is one of the following: @@ -1602,9 +1687,9 @@ ACL are used, the connection is allowed only if both of them allow it, and is denied if any one of them denies it. @end deffn -@node Auth Statement -@subsection Auth Statement -@UNREVISED +@node auth statement +@subsection The @code{auth} Statement +@anchor{Auth Statement} @cindex authorization @cindex authentication @kwindex auth @@ -1680,17 +1765,17 @@ User credentials are retrieved from the system user database @item sql User credentials are retrieved from a @acronym{SQL} database. A separate configuration statement, @code{sql}, is used to configure -it (@pxref{SQL Statement}). +it (@pxref{sql statement}). @item virtdomain User credentials are retrieved from a ``virtual domain'' user database. Virtual domains are configured using @code{virtdomain} -statement (@pxref{Virtdomain Statement}). +statement (@pxref{virtdomain statement}). @item radius -User credentials are retrieved using @acronym{RADIUS}. @xref{Radius -Statement}, for a detailed description on how to configure it. +User credentials are retrieved using @acronym{RADIUS}. @xref{radius +statement}, for a detailed description on how to configure it. @item ldap User credentials are retrieved from an @acronym{LDAP} -database. @xref{LDAP Statement}, for an information on how to +database. @xref{ldap statement}, for an information on how to configure it. @end table @@ -1719,16 +1804,16 @@ The hashed value of the user password is retrieved from @item sql The hashed value of the user password is retrieved from a @acronym{SQL} database using query supplied by @code{getpass} -statement (@pxref{SQL Statement, getpass}). +statement (@pxref{sql statement, getpass}). @item pam The user is authenticated via pluggable authentication module (@acronym{PAM}). The @acronym{PAM} service name to be used is -configured in @code{pam} statement (@pxref{PAM Statement}). +configured in @code{pam} statement (@pxref{pam statement}). @item radius The user is authenticated on a remote @acronym{RADIUS} -server. @xref{Radius Statement}. +server. @xref{radius statement}. @item ldap -The user is authenticated using @acronym{LDAP}. @xref{LDAP Statement}. +The user is authenticated using @acronym{LDAP}. @xref{ldap statement}. @end table @FIXME{This list is inaccurate:} @@ -1740,8 +1825,9 @@ the list of authentication modules is: @end example @end deffn -@node PAM Statement +@node pam statement @subsection PAM Statement +@anchor{PAM Statement} @UNREVISED @kwindex pam @subheading Syntax @@ -1762,10 +1848,11 @@ default, the base name of the Mailutils binary is used. @end deffn This statement takes effect only if @samp{pam} is listed in -@code{authentication} statement (@pxref{Auth Statement}). +@code{authentication} statement (@pxref{auth statement}). -@node Virtdomain Statement -@subsection Virtdomain Statement +@node virtdomain statement +@subsection The @code{virtdomain} Statement +@anchor{Virtdomain Statement} @UNREVISED @kwindex virtdomain @subheading Syntax @@ -1821,8 +1908,9 @@ the domain name corresponding to that address is looked up in the DNS system. Finally, this domain name is used as a name of the password file. -@node Radius Statement -@subsection Radius Statement +@node radius statement +@subsection The @code{radius} Statement +@anchor{Radius Statement} @UNREVISED @kwindex radius @subheading Syntax @@ -1980,8 +2068,9 @@ The reply to @code{getpwuid} request is the same as to @code{getpwnam} request (see above). @end deffn -@node SQL Statement -@subsection SQL Statement +@node sql statement +@subsection The @code{sql} Statement +@anchor{SQL Statement} @UNREVISED @kwindex sql @subheading Syntax @@ -2066,8 +2155,9 @@ Name of the database. Password to access the database. @end deffn -@node LDAP Statement -@subsection LDAP Statement +@node ldap statement +@subsection The @code{ldap} Statement +@anchor{LDAP Statement} @WRITEME @kwindex ldap @subheading Syntax @@ -2096,8 +2186,9 @@ ldap @{ @} @end example -@node TLS Statement -@subsection TLS Statement +@node tls statement +@subsection The @code{tls} Statement +@anchor{TLS Statement} @WRITEME @kwindex tls @subheading Syntax @@ -2114,8 +2205,9 @@ tls @{ @} @end example -@node GSASL Statement -@subsection GSASL Statement +@node gsasl statement +@subsection The @code{gsasl} Statement +@anchor{GSASL Statement} @WRITEME @kwindex gsasl @subheading Syntax diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index 031c3cc..df9cc7a 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -449,9 +449,10 @@ static struct mu_cfg_param imap4d_cfg_param[] = { }; struct mu_cli_setup cli = { - options, - imap4d_cfg_param, - N_("GNU imap4d -- the IMAP4D daemon.") + .optv = options, + .cfg = imap4d_cfg_param, + .prog_doc = N_("GNU imap4d -- the IMAP4D daemon."), + .server = 1 }; int @@ -659,7 +660,7 @@ get_client_address (int fd, struct sockaddr_in *pcs) } static int -set_strerr_flt () +set_strerr_flt (void) { mu_stream_t flt, trans[2]; int rc; @@ -700,7 +701,7 @@ set_strerr_flt () } static void -clr_strerr_flt () +clr_strerr_flt (void) { mu_stream_t flt, trans[2]; int rc; diff --git a/imap4d/tests/testsuite.at b/imap4d/tests/testsuite.at index 8b98295..c6e84cb 100644 --- a/imap4d/tests/testsuite.at +++ b/imap4d/tests/testsuite.at @@ -20,7 +20,6 @@ m4_define([IMAP4D_HOMEDIR]) m4_define([IMAP4D_DEFAULT_OPTIONS],[dnl --no-site-config dnl ---no-user-config dnl --test dnl --set logging.syslog=0 dnl --set logging.severity=notice dnl diff --git a/include/mailutils/cfg.h b/include/mailutils/cfg.h index 1a69c82..9b8e951 100644 --- a/include/mailutils/cfg.h +++ b/include/mailutils/cfg.h @@ -72,17 +72,43 @@ struct mu_cfg_node mu_list_t nodes; /* a list of mu_cfg_node_t */ struct mu_cfg_node *parent; /* parent node */ }; - + struct mu_cfg_parse_hints { int flags; - char *site_rcfile; - char *custom_rcfile; + char *site_file; + char *custom_file; char *program; - struct mu_cfg_tree *append_tree; - void *data; }; +/* Bit constants for the flags field of struct mu_cfg_parse_hints */ +/* Parse site-wide configuration file hints.site_file */ +#define MU_CFHINT_SITE_FILE 0x0001 +/* Parse custom configuration file hints.custom_file */ +#define MU_CFHINT_CUSTOM_FILE 0x0002 +/* The hints.program field is set. The "program PROGNAME" section + will be processed, if PROGNAME is the same as hints.program. + If include statement is used with the directory name DIR as its + argument, the file DIR/PROGNAME will be looked up and read in, + if it exists. */ +#define MU_CFHINT_PROGRAM 0x0004 + +/* If MU_CFHINT_PROGRAM is set, look for the file ~/.PROGNAME after parsing + site-wide configuration */ +#define MU_CFHINT_PER_USER_FILE 0x0008 + +/* Verbosely log files being processed */ +#define MU_CF_VERBOSE 0x0010 +/* Dump the pare tree on stderr */ +#define MU_CF_DUMP 0x0020 + +/* Format location of the statement */ +#define MU_CF_FMT_LOCUS 0x0100 +/* Print only value */ +#define MU_CF_FMT_VALUE_ONLY 0x0200 +/* Print full parameter path */ +#define MU_CF_FMT_PARAM_PATH 0x0400 + struct mu_cfg_tree { mu_list_t nodes; /* a list of mu_cfg_node_t */ @@ -140,9 +166,6 @@ struct mu_cfg_param const char *argname; }; -#define MU_TARGET_REF(f) &f, 0 -#define MU_TARGET_OFF(s,f) NULL, mu_offsetof(s,f) - enum mu_cfg_section_stage { mu_cfg_section_start, @@ -230,29 +253,7 @@ int mu_config_register_plain_section (const char *parent_path, const char *ident, struct mu_cfg_param *params); -#define MU_PARSE_CONFIG_GLOBAL 0x001 -#define MU_PARSE_CONFIG_VERBOSE 0x002 -#define MU_PARSE_CONFIG_DUMP 0x004 -#define MU_PARSE_CONFIG_PLAIN 0x008 -#define MU_CFG_PARSE_SITE_RCFILE 0x010 -#define MU_CFG_PARSE_CUSTOM_RCFILE 0x020 -#define MU_CFG_PARSE_PROGRAM 0x040 -#define MU_CFG_FMT_LOCUS 0x080 -#define MU_CFG_FMT_VALUE_ONLY 0x100 -#define MU_CFG_FMT_PARAM_PATH 0x200 -#define MU_PARSE_CONFIG_LINT 0x400 -#define MU_CFG_APPEND_TREE 0x800 -#ifdef MU_CFG_COMPATIBILITY -# define MU_CFG_DEPRECATED -#else -# define MU_CFG_DEPRECATED MU_DEPRECATED -#endif - -int mu_parse_config (const char *file, const char *progname, - struct mu_cfg_param *progparam, int flags, - void *target_ptr) MU_CFG_DEPRECATED; - extern int mu_cfg_parser_verbose; extern size_t mu_cfg_error_count; @@ -279,10 +280,6 @@ int mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags); -int mu_get_config (const char *file, const char *progname, - struct mu_cfg_param *progparam, int flags, - void *target_ptr) MU_CFG_DEPRECATED; - int mu_cfg_tree_create (struct mu_cfg_tree **ptree); mu_cfg_node_t *mu_cfg_tree_create_node (struct mu_cfg_tree *tree, enum mu_cfg_node_type type, diff --git a/include/mailutils/cli.h b/include/mailutils/cli.h index eaf0f8d..b2ed7ce 100644 --- a/include/mailutils/cli.h +++ b/include/mailutils/cli.h @@ -50,11 +50,14 @@ struct mu_cli_setup int ex_usage; /* If not 0, exit code on usage errors */ int ex_config; /* If not 0, exit code on configuration errors */ - int inorder; + int inorder:1; /* Don't permute options and arguments */ + int server:1; /* This is a server: don't read per-user + configuration files */ void (*prog_doc_hook) (mu_stream_t); }; extern const char mu_version_copyright[]; +extern const char mu_general_help_text[]; void mu_version_hook (struct mu_parseopt *po, mu_stream_t stream); void mu_cli (int argc, char **argv, struct mu_cli_setup *setup, diff --git a/libmailutils/cfg/driver.c b/libmailutils/cfg/driver.c index f2a43a3..1b1ff05 100644 --- a/libmailutils/cfg/driver.c +++ b/libmailutils/cfg/driver.c @@ -27,7 +27,6 @@ #include <ctype.h> #include <mailutils/argcv.h> #include <mailutils/nls.h> -#define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */ #include <mailutils/cfg.h> #include <mailutils/errno.h> #include <mailutils/error.h> @@ -466,14 +465,14 @@ mu_cfg_tree_reduce (mu_cfg_tree_t *parse_tree, struct mu_cfg_cont *cont; if (!parse_tree) return 0; - if (hints && (hints->flags & MU_PARSE_CONFIG_DUMP)) + if (hints && (hints->flags & MU_CF_DUMP)) { int yes = 1; mu_stream_t stream; mu_stdio_stream_create (&stream, MU_STDERR_FD, 0); mu_stream_ioctl (stream, MU_IOCTL_FD, MU_IOCTL_FD_SET_BORROW, &yes); - mu_cfg_format_parse_tree (stream, parse_tree, MU_CFG_FMT_LOCUS); + mu_cfg_format_parse_tree (stream, parse_tree, MU_CF_FMT_LOCUS); mu_stream_destroy (&stream); } @@ -492,29 +491,6 @@ mu_format_config_tree (mu_stream_t stream, struct mu_cfg_param *progparam) mu_config_destroy_container (&cont); } -int -mu_parse_config (const char *file, const char *progname, - struct mu_cfg_param *progparam, int flags, - void *target_ptr) -{ - int rc; - char *full_name = mu_tilde_expansion (file, MU_HIERARCHY_DELIMITER, NULL); - if (full_name) - { - if (access (full_name, R_OK) == 0) - { - rc = mu_get_config (full_name, progname, progparam, flags, - target_ptr); - } - else - rc = ENOENT; - free (full_name); - } - else - rc = ENOMEM; - return rc; -} - static const char * _first_value_ptr (mu_config_value_t *val) { diff --git a/libmailutils/cfg/format.c b/libmailutils/cfg/format.c index d94c878..926c9d5 100644 --- a/libmailutils/cfg/format.c +++ b/libmailutils/cfg/format.c @@ -152,7 +152,7 @@ format_node (const mu_cfg_node_t *node, void *data) { struct tree_print *tp = data; - if ((tp->flags & MU_CFG_FMT_LOCUS) && node->locus.mu_file) + if ((tp->flags & MU_CF_FMT_LOCUS) && node->locus.mu_file) mu_stream_printf (tp->stream, "# %lu \"%s\"\n", (unsigned long) node->locus.mu_line, node->locus.mu_file); @@ -165,7 +165,7 @@ format_node (const mu_cfg_node_t *node, void *data) break; case mu_cfg_node_statement: - if (tp->flags & MU_CFG_FMT_PARAM_PATH) + if (tp->flags & MU_CF_FMT_PARAM_PATH) return MU_CFG_ITER_OK; else { @@ -181,9 +181,9 @@ format_node (const mu_cfg_node_t *node, void *data) break; case mu_cfg_node_param: - if (tp->flags & MU_CFG_FMT_VALUE_ONLY) + if (tp->flags & MU_CF_FMT_VALUE_ONLY) format_value (tp, node->label); - else if (tp->flags & MU_CFG_FMT_PARAM_PATH) + else if (tp->flags & MU_CF_FMT_PARAM_PATH) { format_path (tp, node, ':'); mu_stream_write (tp->stream, " ", 1, NULL); @@ -209,7 +209,7 @@ static int format_node_end (const mu_cfg_node_t *node, void *data) { struct tree_print *tp = data; - if (!(tp->flags & MU_CFG_FMT_PARAM_PATH)) + if (!(tp->flags & MU_CF_FMT_PARAM_PATH)) { tp->level--; format_level (tp->stream, tp->level); @@ -242,7 +242,7 @@ mu_cfg_format_node (mu_stream_t stream, const mu_cfg_node_t *node, int flags) struct tree_print t; if (node->type == mu_cfg_node_statement) - flags &= ~MU_CFG_FMT_VALUE_ONLY; + flags &= ~MU_CF_FMT_VALUE_ONLY; t.flags = flags; t.level = 0; t.stream = stream; diff --git a/libmailutils/cfg/lexer.l b/libmailutils/cfg/lexer.l index 2ecefce..5e8cbf5 100644 --- a/libmailutils/cfg/lexer.l +++ b/libmailutils/cfg/lexer.l @@ -330,14 +330,14 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags) int rc; char *full_name = mu_tilde_expansion (file, MU_HIERARCHY_DELIMITER, NULL); - if (flags & MU_PARSE_CONFIG_VERBOSE) + if (flags & MU_CF_VERBOSE) mu_diag_output (MU_DIAG_INFO, _("opening configuration file %s"), full_name); if (stat (full_name, &st)) { if (errno != ENOENT) mu_error (_("cannot stat `%s': %s"), full_name, mu_strerror (errno)); - else if (flags & MU_PARSE_CONFIG_VERBOSE) + else if (flags & MU_CF_VERBOSE) mu_diag_output (MU_DIAG_INFO, _("configuration file %s doesn't exist"), full_name); free (full_name); @@ -345,7 +345,7 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags) } else if (!S_ISREG (st.st_mode)) { - if (flags & MU_PARSE_CONFIG_VERBOSE) + if (flags & MU_CF_VERBOSE) mu_diag_output (MU_DIAG_INFO, _("%s: not a regular file"), full_name); free (full_name); return ENOENT; @@ -360,7 +360,7 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags) return errno; } - if (flags & MU_PARSE_CONFIG_VERBOSE) + if (flags & MU_CF_VERBOSE) mu_diag_output (MU_DIAG_INFO, _("parsing file `%s'"), full_name); mu_cfg_set_lex_debug (); @@ -379,37 +379,13 @@ mu_cfg_parse_file (mu_cfg_tree_t **return_tree, const char *file, int flags) yyrestart (fp); rc = mu_cfg_parse (return_tree); fclose (fp); - if (flags & MU_PARSE_CONFIG_VERBOSE) + if (flags & MU_CF_VERBOSE) mu_diag_output (MU_DIAG_INFO, _("finished parsing file `%s'"), mu_cfg_locus.mu_file); return rc == 0 ? 0 : MU_ERR_FAILURE; } -/* FIXME: Deprecated interface */ -int -mu_get_config (const char *file, const char *progname, - struct mu_cfg_param *progparam, int flags, void *target_ptr) -{ - mu_cfg_tree_t *parse_tree; - int rc = mu_cfg_parse_file (&parse_tree, file, flags); - if (rc == 0) - { - struct mu_cfg_parse_hints hints; - - hints.flags = flags | MU_CFG_PARSE_PROGRAM; - hints.program = (char*)progname; - - rc = mu_cfg_tree_postprocess (parse_tree, &hints); - if (rc == 0) - rc = mu_cfg_tree_reduce (parse_tree, &hints, progparam, target_ptr); - mu_cfg_destroy_tree (&parse_tree); - } - - return rc == 0 ? 0 : MU_ERR_FAILURE; -} - - mu_opool_t mu_cfg_lexer_pool () { diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y index 9ad8e8d..0b362a8 100644 --- a/libmailutils/cfg/parser.y +++ b/libmailutils/cfg/parser.y @@ -501,8 +501,7 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints, if (S_ISDIR (sb.st_mode)) { - if ((hints->flags & (MU_PARSE_CONFIG_GLOBAL|MU_CFG_PARSE_PROGRAM)) == - (MU_PARSE_CONFIG_GLOBAL|MU_CFG_PARSE_PROGRAM)) + if (hints->flags & MU_CFHINT_PROGRAM) { char *file = mu_make_file_name (name, hints->program); rc = mu_cfg_parse_file (&tree, file, hints->flags); @@ -515,7 +514,7 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints, if (rc == 0 && tree) { struct mu_cfg_parse_hints xhints = *hints; - xhints.flags &= ~MU_PARSE_CONFIG_GLOBAL; + xhints.flags &= ~MU_CFHINT_PROGRAM; mu_cfg_tree_postprocess (tree, &xhints); } } @@ -538,8 +537,7 @@ do_include (const char *name, struct mu_cfg_parse_hints *hints, } int -mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, - struct mu_cfg_parse_hints *hints) +mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, struct mu_cfg_parse_hints *hints) { int rc; mu_iterator_t itr; @@ -558,13 +556,12 @@ mu_cfg_tree_postprocess (mu_cfg_tree_t *tree, if (node->type == mu_cfg_node_statement) { - if ((hints->flags & MU_PARSE_CONFIG_GLOBAL) && + if ((hints->flags & MU_CFHINT_PROGRAM) && strcmp (node->tag, "program") == 0) { if (node->label->type == MU_CFG_STRING) { - if ((hints->flags & MU_CFG_PARSE_PROGRAM) - && strcmp (node->label->v.string, hints->program) == 0) + if (strcmp (node->label->v.string, hints->program) == 0) { /* Reset the parent node */ mu_list_foreach (node->nodes, _node_set_parent, @@ -1527,10 +1524,11 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints) { int rc = 0; mu_cfg_tree_t *tree = NULL, *tmp; + struct mu_cfg_parse_hints xhints; - if ((hints->flags & MU_CFG_PARSE_SITE_RCFILE) && hints->site_rcfile) + if ((hints->flags & MU_CFHINT_SITE_FILE) && hints->site_file) { - rc = mu_cfg_parse_file (&tmp, hints->site_rcfile, hints->flags); + rc = mu_cfg_parse_file (&tmp, hints->site_file, hints->flags); if (rc == ENOMEM) { @@ -1539,14 +1537,16 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints) } else if (rc == 0) { - struct mu_cfg_parse_hints xhints = *hints; - xhints.flags |= MU_PARSE_CONFIG_GLOBAL; - mu_cfg_tree_postprocess (tmp, &xhints); + mu_cfg_tree_postprocess (tmp, hints); mu_cfg_tree_union (&tree, &tmp); } } + + xhints = *hints; + xhints.flags &= ~MU_CFHINT_PROGRAM; - if ((hints->flags & MU_CFG_PARSE_PROGRAM) && hints->program) + if ((hints->flags & MU_CFHINT_PER_USER_FILE) + && (hints->flags & MU_CFHINT_PROGRAM)) { size_t size = 3 + strlen (hints->program) + 1; char *file_name = malloc (size); @@ -1555,7 +1555,7 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints) strcpy (file_name, "~/."); strcat (file_name, hints->program); - rc = mu_cfg_parse_file (&tmp, file_name, hints->flags); + rc = mu_cfg_parse_file (&tmp, file_name, xhints.flags); if (rc == ENOMEM) { mu_error ("%s", mu_strerror (rc)); @@ -1564,7 +1564,7 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints) } else if (rc == 0) { - mu_cfg_tree_postprocess (tmp, hints); + mu_cfg_tree_postprocess (tmp, &xhints); mu_cfg_tree_union (&tree, &tmp); } else if (rc == ENOENT) @@ -1573,26 +1573,23 @@ mu_cfg_parse_config (mu_cfg_tree_t **ptree, struct mu_cfg_parse_hints *hints) } } - if ((hints->flags & MU_CFG_PARSE_CUSTOM_RCFILE) && hints->custom_rcfile) + if ((hints->flags & MU_CFHINT_CUSTOM_FILE) && hints->custom_file) { - rc = mu_cfg_parse_file (&tmp, hints->custom_rcfile, hints->flags); + rc = mu_cfg_parse_file (&tmp, hints->custom_file, xhints.flags); if (rc) { - mu_error (_("errors parsing file %s: %s"), hints->custom_rcfile, + mu_error (_("errors parsing file %s: %s"), hints->custom_file, mu_strerror (rc)); mu_cfg_destroy_tree (&tree); return rc; } else { - mu_cfg_tree_postprocess (tmp, hints); + mu_cfg_tree_postprocess (tmp, &xhints); mu_cfg_tree_union (&tree, &tmp); } } - if (hints->flags & MU_CFG_APPEND_TREE) - mu_cfg_tree_union (&tree, &hints->append_tree); - *ptree = tree; return rc; } diff --git a/libmailutils/cli/cli.c b/libmailutils/cli/cli.c index 793a3e2..557a9a6 100644 --- a/libmailutils/cli/cli.c +++ b/libmailutils/cli/cli.c @@ -18,6 +18,7 @@ # include <config.h> #endif #include <stdlib.h> +#include <unistd.h> #include <sysexits.h> #include <mailutils/cfg.h> #include <mailutils/opt.h> @@ -33,8 +34,10 @@ #include <mailutils/syslog.h> #include <mailutils/mu_auth.h> +#define MU_LEGACY_CONFIG_FILE SYSCONFDIR "/mailutils.rc" + #ifndef MU_SITE_CONFIG_FILE -# define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.rc" +# define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.conf" #endif char * @@ -76,23 +79,29 @@ There is NO WARRANTY, to the extent permitted by law.\n\ ")); } -static char gnu_general_help_url[] = +const char mu_general_help_text[] = N_("General help using GNU software: <http://www.gnu.org/gethelp/>"); +struct app_data +{ + struct mu_cli_setup *setup; + struct mu_cfg_parse_hints *hints; + struct mu_cfg_tree *append_tree; + int lint; +}; + static void extra_help_hook (struct mu_parseopt *po, mu_stream_t stream) { - struct mu_cfg_parse_hints *hints = po->po_data; - struct mu_cli_setup *setup = hints->data; - mu_stream_printf (stream, "%s\n", _(setup->prog_extra_doc)); + struct app_data *dp = po->po_data; + mu_stream_printf (stream, "%s\n", gettext (dp->setup->prog_extra_doc)); } static void prog_doc_hook (struct mu_parseopt *po, mu_stream_t stream) { - struct mu_cfg_parse_hints *hints = po->po_data; - struct mu_cli_setup *setup = hints->data; - setup->prog_doc_hook (stream); + struct app_data *dp = po->po_data; + dp->setup->prog_doc_hook (stream); } static void @@ -100,106 +109,151 @@ change_progname (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { po->po_prog_name = mu_strdup (arg); + free (mu_program_name); + mu_program_name = mu_strdup (arg); } static void no_user_config (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { - struct mu_cfg_parse_hints *hints = po->po_data; - hints->flags &= ~MU_CFG_PARSE_PROGRAM; + struct app_data *dp = po->po_data; + dp->hints->flags &= ~MU_CFHINT_PER_USER_FILE; } static void no_site_config (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { - struct mu_cfg_parse_hints *hints = po->po_data; - hints->flags &= ~MU_CFG_PARSE_SITE_RCFILE; + struct app_data *dp = po->po_data; + dp->hints->flags &= ~MU_CFHINT_SITE_FILE; +} + +static void +no_config (struct mu_parseopt *po, struct mu_option *opt, char const *arg) +{ + struct app_data *dp = po->po_data; + dp->hints->flags &= ~(MU_CFHINT_SITE_FILE|MU_CFHINT_PER_USER_FILE); } static void config_file (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { - struct mu_cfg_parse_hints *hints = po->po_data; - hints->flags |= MU_CFG_PARSE_CUSTOM_RCFILE; - hints->custom_rcfile = mu_strdup (arg); + struct app_data *dp = po->po_data; + dp->hints->flags = (dp->hints->flags + & ~(MU_CFHINT_SITE_FILE|MU_CFHINT_PROGRAM)) + | MU_CFHINT_CUSTOM_FILE; + dp->hints->custom_file = mu_strdup (arg); } static void config_verbose (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { - struct mu_cfg_parse_hints *hints = po->po_data; - if (hints->flags & MU_PARSE_CONFIG_VERBOSE) - hints->flags |= MU_PARSE_CONFIG_DUMP; + struct app_data *dp = po->po_data; + if (dp->hints->flags & MU_CF_VERBOSE) + dp->hints->flags |= MU_CF_DUMP; else - hints->flags |= MU_PARSE_CONFIG_VERBOSE; + dp->hints->flags |= MU_CF_VERBOSE; } static void config_lint (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { - struct mu_cfg_parse_hints *hints = po->po_data; - hints->flags |= MU_PARSE_CONFIG_VERBOSE|MU_PARSE_CONFIG_LINT; + struct app_data *dp = po->po_data; + dp->lint = 1; + dp->hints->flags |= MU_CF_VERBOSE; } static void param_set (struct mu_parseopt *po, struct mu_option *opt, char const *arg) { - struct mu_cfg_parse_hints *hints = po->po_data; + struct app_data *dp = po->po_data; mu_cfg_node_t *node; int rc = mu_cfg_create_subtree (arg, &node); if (rc) mu_parseopt_error (po, "%s: cannot create node: %s", arg, mu_strerror (rc)); - if (!(hints->flags & MU_CFG_APPEND_TREE)) + if (!dp->append_tree) { - mu_cfg_tree_create (&hints->append_tree); - hints->flags |= MU_CFG_APPEND_TREE; + mu_cfg_tree_create (&dp->append_tree); } - mu_cfg_tree_add_node (hints->append_tree, node); + mu_cfg_tree_add_node (dp->append_tree, node); } struct mu_option mu_common_options[] = { - MU_OPTION_GROUP(N_("Common options")), + /* MU_OPTION_GROUP(N_("Common options")),*/ { "program-name", 0, N_("NAME"), MU_OPTION_IMMEDIATE|MU_OPTION_HIDDEN, N_("set program name"), mu_c_string, NULL, change_progname }, + MU_OPTION_END +}; + +/* This varibales are used to construct the set of configuration + handling options. +*/ - { "no-user-config", 0, NULL, MU_OPTION_IMMEDIATE, - N_("do not load user configuration file"), - mu_c_string, NULL, no_user_config }, - { "no-user-rcfile", 0, NULL, MU_OPTION_ALIAS }, - +/* Option group header */ +static struct mu_option mu_config_option_header = + MU_OPTION_GROUP (N_("Configuration handling")); + +/* Disables site-wide configuration file */ +static struct mu_option mu_site_config_options[] = { { "no-site-config", 0, NULL, MU_OPTION_IMMEDIATE, N_("do not load site-wide configuration file"), mu_c_string, NULL, no_site_config }, - { "no-site-rcfile", 0, NULL, MU_OPTION_ALIAS }, - + MU_OPTION_END +}; + +/* Disables per-user configuration file */ +static struct mu_option mu_user_config_options[] = { + { "no-user-config", 0, NULL, MU_OPTION_IMMEDIATE, + N_("do not load user configuration file"), + mu_c_string, NULL, no_user_config }, + MU_OPTION_END +}; + +/* 1. If both site-wide and per-user configuration files are used, + this option is equivalent to --no-site-config --no-user-config + used together. + 2. If only site-wide configuration is used, this option is an alias + to --no-site-config + 3. If only per-user configuration is used, this option is an alias + to --no-user-config + + Thus, --no-config-option always disables parsing of the default + configuration files. + */ +static struct mu_option mu_no_config_option = { + "no-config", 0, NULL, MU_OPTION_IMMEDIATE, + N_("do not load site and user configuration files"), + mu_c_string, NULL, no_config +}; + +/* These options are always available for utilities that use at least + one of default configuration files */ +static struct mu_option mu_config_options[] = { { "config-file", 0, N_("FILE"), MU_OPTION_IMMEDIATE, - N_("load this configuration file"), + N_("load this configuration file; implies --no-config"), mu_c_string, NULL, config_file }, - { "rcfile", 0, NULL, MU_OPTION_ALIAS }, { "config-verbose", 0, NULL, MU_OPTION_IMMEDIATE, N_("verbosely log parsing of the configuration files"), mu_c_string, NULL, config_verbose }, - { "rcfile-verbose", 0, NULL, MU_OPTION_ALIAS }, { "config-lint", 0, NULL, MU_OPTION_IMMEDIATE, N_("check configuration file syntax and exit"), mu_c_string, NULL, config_lint }, - { "rcfile-lint", 0, NULL, MU_OPTION_ALIAS }, { "set", 0, N_("PARAM=VALUE"), MU_OPTION_IMMEDIATE, N_("set configuration parameter"), mu_c_string, NULL, param_set }, - - MU_OPTION_END + + MU_OPTION_END }; + static void show_comp_defaults (struct mu_parseopt *po, struct mu_option *opt, @@ -213,7 +267,7 @@ static void show_config_help (struct mu_parseopt *po, struct mu_option *opt, char const *unused) { - struct mu_cfg_parse_hints *hints = po->po_data; + struct app_data *dp = po->po_data; char *comment; mu_stream_t stream; @@ -253,11 +307,10 @@ show_config_help (struct mu_parseopt *po, struct mu_option *opt, cont = mu_config_clone_root_container (); mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL, dummy_include_param, NULL); - if (hints->data) + if (dp->setup) { - struct mu_cli_setup *setup = hints->data; mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL, - setup->cfg, NULL); + dp->setup->cfg, NULL); } mu_cfg_format_container (stream, cont); @@ -267,11 +320,15 @@ show_config_help (struct mu_parseopt *po, struct mu_option *opt, exit (0); } -struct mu_option mu_extra_help_options[] = { +static struct mu_option mu_extra_help_options[] = { MU_OPTION_GROUP (N_("Informational options")), { "show-config-options", 0, NULL, MU_OPTION_IMMEDIATE, N_("show compilation options"), mu_c_string, NULL, show_comp_defaults }, + MU_OPTION_END +}; + +static struct mu_option mu_config_help_options[] = { { "config-help", 0, NULL, MU_OPTION_IMMEDIATE, N_("show configuration file summary"), mu_c_string, NULL, show_config_help }, @@ -288,9 +345,38 @@ add_opt_group (void *item, void *data) return 0; } +#define CONFIG_ENABLED \ + (MU_CFHINT_SITE_FILE | MU_CFHINT_CUSTOM_FILE | MU_CFHINT_PER_USER_FILE) + +static void +opool_add_option (mu_opool_t pool, struct mu_option *opt) +{ + mu_opool_append (pool, opt, sizeof *opt); +} + +static void +opool_add_options (mu_opool_t pool, struct mu_option *opt) +{ + while (!MU_OPTION_IS_END (opt)) + { + opool_add_option (pool, opt); + opt++; + } +} + +static struct mu_option * +opool_end_option (mu_opool_t pool) +{ + struct mu_option end = MU_OPTION_END; + opool_add_option (pool, &end); + return mu_opool_finish (pool, NULL); +} + /* Build the list of option groups and configuration sections */ static struct mu_option ** -init_options (char **capa, struct mu_cli_setup *setup, +init_options (mu_opool_t pool, + char **capa, struct mu_cli_setup *setup, + struct mu_cfg_parse_hints const *hints, mu_list_t *ret_comlist) { size_t i, s; @@ -316,8 +402,41 @@ init_options (char **capa, struct mu_cli_setup *setup, *ret_comlist = comlist; mu_list_append (oplist, mu_common_options); - mu_list_append (oplist, mu_extra_help_options); + + /* Construct configuration option section */ + if (hints->flags & CONFIG_ENABLED) + { + opool_add_option (pool, &mu_config_option_header); + opool_add_options (pool, mu_config_options); + if (hints->flags & MU_CFHINT_SITE_FILE) + { + opool_add_options (pool, mu_site_config_options); + if (hints->flags & MU_CFHINT_PER_USER_FILE) + { + opool_add_options (pool, mu_user_config_options); + opool_add_option (pool, &mu_no_config_option); + } + else + { + struct mu_option opt = mu_no_config_option; + opt.opt_flags = MU_OPTION_ALIAS; + opool_add_option (pool, &opt); + } + } + else if (hints->flags & MU_CFHINT_PER_USER_FILE) + { + struct mu_option opt = mu_no_config_option; + opool_add_options (pool, mu_user_config_options); + opt.opt_flags = MU_OPTION_ALIAS; + opool_add_option (pool, &opt); + } + mu_list_append (oplist, opool_end_option (pool)); + } + mu_list_append (oplist, mu_extra_help_options); + if (hints->flags & CONFIG_ENABLED) + mu_list_append (oplist, mu_config_help_options); + mu_list_count (oplist, &s); po.po_optv = mu_calloc (s + 1, sizeof (po.po_optv[0])); @@ -367,6 +486,8 @@ mu_cli_ext (int argc, char **argv, char const *dfl_args[DFLARGC]; char **args = NULL; size_t argcnt; + struct app_data appd; + mu_opool_t pool; /* Set up defaults */ if (setup->ex_usage == 0) @@ -375,10 +496,11 @@ mu_cli_ext (int argc, char **argv, setup->ex_config = EX_CONFIG; hints = *cfhint; - hints.data = setup; + if (setup->server) + hints.flags &= ~MU_CFHINT_PER_USER_FILE; /* Set program name */ - if (hints.flags & MU_CFG_PARSE_PROGRAM) + if (hints.flags & MU_CFHINT_PROGRAM) { if (!mu_log_tag) mu_log_tag = (char*)hints.program; @@ -389,7 +511,7 @@ mu_cli_ext (int argc, char **argv, if (!mu_log_tag) mu_log_tag = (char*)mu_program_name; hints.program = (char*) mu_program_name; - hints.flags |= MU_CFG_PARSE_PROGRAM; + hints.flags |= MU_CFHINT_PROGRAM; } /* Initialize standard streams */ @@ -478,12 +600,17 @@ mu_cli_ext (int argc, char **argv, if (flags & MU_PARSEOPT_NEGATION) po.po_negation = pohint->po_negation; - po.po_data = &hints; + appd.setup = setup; + appd.hints = &hints; + appd.append_tree = NULL; + appd.lint = 0; + po.po_data = &appd; flags |= MU_PARSEOPT_DATA; po.po_exit_error = setup->ex_usage; - optv = init_options (capa, setup, &com_list); + mu_opool_create (&pool, MU_OPOOL_ENOMEMABRT); + optv = init_options (pool, capa, setup, &hints, &com_list); if (mu_parseopt (&po, argc, argv, optv, flags)) exit (po.po_exit_error); @@ -499,9 +626,35 @@ mu_cli_ext (int argc, char **argv, else if (argc) mu_parseopt_error (&po, "%s", _("unexpected arguments")); +#if defined(MU_LEGACY_CONFIG_FILE) + if ((hints.flags & MU_CFHINT_SITE_FILE) + && strcmp (hints.site_file, MU_SITE_CONFIG_FILE) == 0) + { + if (access (MU_LEGACY_CONFIG_FILE, F_OK) == 0) + { + if (access (hints.site_file, F_OK) == 0) + { + mu_diag_output (MU_DIAG_WARNING, + _("legacy configuration file %s ignored"), + MU_LEGACY_CONFIG_FILE); + } + else + { + mu_diag_output (MU_DIAG_WARNING, + _("using legacy configuration file %s: please rename it to %s"), + MU_LEGACY_CONFIG_FILE, MU_SITE_CONFIG_FILE); + hints.site_file = MU_LEGACY_CONFIG_FILE; + } + } + } +#endif + if (mu_cfg_parse_config (&parse_tree, &hints)) exit (setup->ex_config); + if (appd.append_tree) + mu_cfg_tree_union (&parse_tree, &appd.append_tree); + if (mu_cfg_tree_reduce (parse_tree, &hints, setup->cfg, data)) exit (setup->ex_config); @@ -513,15 +666,14 @@ mu_cli_ext (int argc, char **argv, mu_list_foreach (com_list, run_commit, NULL); mu_list_destroy (&com_list); - if (hints.flags & MU_PARSE_CONFIG_LINT) - exit (0); - mu_cfg_destroy_tree (&parse_tree); free (optv); - free (args); - - mu_parseopt_free (&po); + mu_parseopt_free (&po); + mu_opool_destroy (&pool); + + if (appd.lint) + exit (0); } void @@ -543,14 +695,14 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, pohint.po_bug_address = PACKAGE_BUGREPORT; pohint.po_flags |= MU_PARSEOPT_BUG_ADDRESS; - pohint.po_extra_info = gnu_general_help_url; + pohint.po_extra_info = mu_general_help_text; pohint.po_flags |= MU_PARSEOPT_EXTRA_INFO; pohint.po_version_hook = mu_version_hook; pohint.po_flags |= MU_PARSEOPT_VERSION_HOOK; - cfhint.site_rcfile = mu_site_config_file (); - cfhint.flags = MU_CFG_PARSE_SITE_RCFILE; + cfhint.site_file = mu_site_config_file (); + cfhint.flags = MU_CFHINT_SITE_FILE | MU_CFHINT_PER_USER_FILE; mu_cli_ext (argc, argv, setup, &pohint, &cfhint, capa, data, ret_argc, ret_argv); diff --git a/mail/testsuite/lib/mail.exp b/mail/testsuite/lib/mail.exp index ddebb2b..ad8a85b 100644 --- a/mail/testsuite/lib/mail.exp +++ b/mail/testsuite/lib/mail.exp @@ -18,7 +18,7 @@ source $top_srcdir/testsuite/lib/mailutils.exp -mu_init "--nosum --norc" +mu_init --nosum --norc #FIXME: this doesn't work with remote testing set env(MAILRC) $MU_RC_DIR/mail.rc diff --git a/mu/acl.c b/mu/acl.c index e7d2de7..2a6acc4 100644 --- a/mu/acl.c +++ b/mu/acl.c @@ -58,8 +58,8 @@ mutool_acl (int argc, char **argv) } memset (&hints, 0, sizeof (hints)); - hints.flags = MU_CFG_PARSE_CUSTOM_RCFILE; - hints.custom_rcfile = input_file_name; + hints.flags = MU_CFHINT_CUSTOM_FILE; + hints.custom_file = input_file_name; mu_acl_cfg_init (); if (mu_cfg_parse_config (&tree, &hints)) diff --git a/mu/mu.c b/mu/mu.c index 0b471aa..03e1f56 100644 --- a/mu/mu.c +++ b/mu/mu.c @@ -43,7 +43,20 @@ int main (int argc, char **argv) { mutool_action_t action; - + static struct mu_parseopt pohint = { + .po_flags = MU_PARSEOPT_PACKAGE_NAME + | MU_PARSEOPT_PACKAGE_URL + | MU_PARSEOPT_BUG_ADDRESS + | MU_PARSEOPT_EXTRA_INFO + | MU_PARSEOPT_VERSION_HOOK, + .po_package_name = PACKAGE_NAME, + .po_package_url = PACKAGE_URL, + .po_bug_address = PACKAGE_BUGREPORT, + .po_extra_info = mu_general_help_text, + .po_version_hook = mu_version_hook, + }; + struct mu_cfg_parse_hints cfhint = { .flags = 0 }; + /* Native Language Support */ MU_APP_INIT_NLS (); MU_AUTH_REGISTER_ALL_MODULES (); @@ -51,7 +64,7 @@ main (int argc, char **argv) /* Register the desired mailbox formats. */ mu_register_all_mbox_formats (); - mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); + mu_cli_ext (argc, argv, &cli, &pohint, &cfhint, capa, NULL, &argc, &argv); if (argc < 1) { diff --git a/mu/query.c b/mu/query.c index d0016da..3440637 100644 --- a/mu/query.c +++ b/mu/query.c @@ -17,7 +17,7 @@ #include "mu.h" char query_docstring[] = N_("query configuration values"); -static char query_args_doc[] = N_("path [path...]"); +static char query_args_doc[] = N_("PATH [PATH...]"); static char *file_name; int value_option; @@ -59,21 +59,21 @@ mutool_query (int argc, char **argv) return 1; } - hints.flags = MU_CFG_PARSE_SITE_RCFILE | MU_PARSE_CONFIG_GLOBAL; - hints.site_rcfile = file_name ? file_name : mu_site_config_file (); + hints.flags = MU_CFHINT_SITE_FILE; + hints.site_file = file_name ? file_name : mu_site_config_file (); if (progname) { - hints.flags |= MU_CFG_PARSE_PROGRAM; + hints.flags |= MU_CFHINT_PROGRAM; hints.program = progname; } if (verbose_option) - hints.flags |= MU_CFG_FMT_LOCUS; + hints.flags |= MU_CF_FMT_LOCUS; if (value_option) - hints.flags |= MU_CFG_FMT_VALUE_ONLY; + hints.flags |= MU_CF_FMT_VALUE_ONLY; if (path_option) - hints.flags |= MU_CFG_FMT_PARAM_PATH; + hints.flags |= MU_CF_FMT_PARAM_PATH; if (mu_cfg_parse_config (&tree, &hints)) return 1; diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c index 39e47fc..de16fbd 100644 --- a/pop3d/pop3d.c +++ b/pop3d/pop3d.c @@ -317,9 +317,10 @@ static char *capa[] = { }; struct mu_cli_setup cli = { - options, - pop3d_cfg_param, - N_("GNU pop3d -- the POP3 daemon."), + .optv = options, + .cfg = pop3d_cfg_param, + .prog_doc = N_("GNU pop3d -- the POP3 daemon."), + .server = 1 }; int diff --git a/pop3d/testsuite/lib/pop3d.exp b/pop3d/testsuite/lib/pop3d.exp index fa5fc8a..fd7f389 100644 --- a/pop3d/testsuite/lib/pop3d.exp +++ b/pop3d/testsuite/lib/pop3d.exp @@ -17,9 +17,8 @@ # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. source $top_srcdir/testsuite/lib/mailutils.exp - -mu_init "--rcfile=$objdir/pop3d.rc" +mu_init "--config-file=$objdir/pop3d.rc" mu_version if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] { clone_output "WARNING: Support for virtual domains not compiled in" diff --git a/sieve/tests/testsuite.at b/sieve/tests/testsuite.at index 68cb747..189bab8 100644 --- a/sieve/tests/testsuite.at +++ b/sieve/tests/testsuite.at @@ -21,7 +21,7 @@ dnl testcompile(SCRIPT) -- test compilation of the Sieve SCRIPT dnl m4_define([testcompile],[ AT_SETUP([compile $1]) -AT_CHECK([sieve -c $abs_top_srcdir/sieve/examples/$1], +AT_CHECK([sieve MUT_SIEVE_DEFAULT_OPTIONS -c $abs_top_srcdir/sieve/examples/$1], [0]) AT_CLEANUP ]) diff --git a/testsuite/lib/mailutils.exp b/testsuite/lib/mailutils.exp index e47e426..2520f08 100644 --- a/testsuite/lib/mailutils.exp +++ b/testsuite/lib/mailutils.exp @@ -148,14 +148,25 @@ proc mu_init {args} { set MU_SPOOL_DIR "$MU_DATA_DIR/spool" set MU_FOLDER_DIR "$MU_DATA_DIR/folder" - if {[llength $args] == 1 && [lindex $args 0] == "-noflags"} { - set MU_TOOL_FLAGS "--no-site-rcfile --no-user-rcfile" - } else { - set MU_TOOL_FLAGS "--set mailbox.mail-spool=\"'$MU_SPOOL_DIR'\" --no-site-rcfile --no-user-rcfile" - for {set i 0} {$i < [llength $args]} {incr i} { - append MU_TOOL_FLAGS " [lindex $args $i]" + lappend flags "--no-config" "--set mailbox.mail-spool=\"'$MU_SPOOL_DIR'\"" + set i 0 + for {} {$i < [llength $args]} {incr i} { + switch -- [lindex $args $i] { + -noflags { + unset flags + } + -- { + incr i + break + } + default { + + break + } } } + lappend flags {*}[lrange $args $i end] + set MU_TOOL_FLAGS [join $flags { }] } } diff --git a/testsuite/testsuite.inc b/testsuite/testsuite.inc index 09cb1c3..aa3cf18 100644 --- a/testsuite/testsuite.inc +++ b/testsuite/testsuite.inc @@ -24,8 +24,7 @@ dnl ------------------------------------------------------------ dnl MUT_DEFAULT_OPTIONS -- produce default command line options dnl ------------------------------------------------------------ m4_define([MUT_DEFAULT_OPTIONS],[dnl - --no-site-config dnl - --no-user-config dnl + --no-config dnl --set '.mailbox.mailbox-type=mbox' dnl ]) hooks/post-receive -- GNU Mailutils _______________________________________________ Commit-mailutils mailing list Commit-mailutils@gnu.org https://lists.gnu.org/mailman/listinfo/commit-mailutils