]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-3.8-20230331-nonprod 20230331-nonprod
authorWietse Venema <wietse@porcupine.org>
Fri, 31 Mar 2023 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <ietf-dane@dukhovni.org>
Sat, 20 Jan 2024 20:32:06 +0000 (15:32 -0500)
70 files changed:
postfix/HISTORY
postfix/html/mailq.1.html
postfix/html/newaliases.1.html
postfix/html/postfix.1.html
postfix/html/postmulti.1.html
postfix/html/postsuper.1.html
postfix/html/proxymap.8.html
postfix/html/sendmail.1.html
postfix/makedefs
postfix/man/man1/postfix.1
postfix/man/man1/postmulti.1
postfix/man/man1/postsuper.1
postfix/man/man1/sendmail.1
postfix/man/man8/proxymap.8
postfix/proto/stop.double-history
postfix/proto/stop.spell-cc
postfix/src/cleanup/cleanup_init.c
postfix/src/global/attr_override.c
postfix/src/global/attr_override.h
postfix/src/global/config_known_tcp_ports.c
postfix/src/global/dict_ldap.c
postfix/src/global/dict_mysql.c
postfix/src/global/dict_pgsql.c
postfix/src/global/dynamicmaps.c
postfix/src/global/header_opts.c
postfix/src/global/login_sender_match.c
postfix/src/global/mail_conf.c
postfix/src/global/mail_parm_split.c
postfix/src/global/mail_queue.c
postfix/src/global/maillog_client.c
postfix/src/global/map_search.c
postfix/src/global/map_search.ref
postfix/src/global/maps.c
postfix/src/global/own_inet_addr.c
postfix/src/global/server_acl.c
postfix/src/local/dotforward.c
postfix/src/master/master_ent.c
postfix/src/milter/milter.c
postfix/src/milter/milter8.c
postfix/src/oqmgr/qmgr_message.c
postfix/src/postfix/postfix.c
postfix/src/postmulti/postmulti.c
postfix/src/postscreen/postscreen_dnsbl.c
postfix/src/postsuper/postsuper.c
postfix/src/proxymap/proxymap.c
postfix/src/qmgr/qmgr_message.c
postfix/src/sendmail/sendmail.c
postfix/src/smtp/smtp_connect.c
postfix/src/smtp/smtp_tls_policy.c
postfix/src/smtpd/smtpd_check.c
postfix/src/tls/tls_certkey.c
postfix/src/tls/tls_dane.c
postfix/src/tls/tls_dh.c
postfix/src/tls/tls_misc.c
postfix/src/util/argv.h
postfix/src/util/argv_split.c
postfix/src/util/argv_splitq.c
postfix/src/util/dict_file.c
postfix/src/util/dict_inline.c
postfix/src/util/dict_pipe.c
postfix/src/util/dict_random.c
postfix/src/util/dict_stream.c
postfix/src/util/dict_union.c
postfix/src/util/match_list.c
postfix/src/util/mystrtok.c
postfix/src/util/mystrtok.ref
postfix/src/util/name_mask.c
postfix/src/util/spawn_command.c
postfix/src/util/stringops.h
postfix/src/util/vstream_popen.c

index 43198443ab9f10f7cf86d1e9f502d592c5763492..b5d97117265d8c29d89d5745cc2b2b0984cc9b4a 100644 (file)
@@ -26995,3 +26995,30 @@ Apologies for any names omitted.
        form "name = value" instead of the expected "name=value".
        Found during code maintenance. Also refined an "empty name"
        check. Files: clean_env.c, split_nameval.c.
+
+       Safety: Postfix programs log a warning when a configuration
+       parameter specifies a list that contains a #comment. Examples
+       of such parameters are smtpd_*_restrictions, check_ccert_access,
+       and restriction_classes. This affects about 70 call sites
+       where a list is parsed. Files: proto/stop.spell-cc,
+       src/cleanup/cleanup_init.c, src/global/dict_ldap.c,
+       src/global/dict_mysql.c, src/global/dict_pgsql.c,
+       src/global/dynamicmaps.c, src/global/header_opts.c,
+       src/global/login_sender_match.c, src/global/mail_conf.c,
+       src/global/maillog_client.c, src/global/mail_parm_split.c,
+       src/global/mail_queue.c, src/global/maps.c,
+       src/global/map_search.c, src/global/own_inet_addr.c,
+       src/global/server_acl.c, src/local/dotforward.c,
+       src/master/master_ent.c, src/milter/milter8.c, src/milter/milter.c,
+       src/oqmgr/qmgr_message.c, src/postfix/postfix.c,
+       src/postmulti/postmulti.c, src/postscreen/postscreen_dnsbl.c,
+       src/postsuper/postsuper.c, src/proxymap/proxymap.c,
+       src/qmgr/qmgr_message.c, src/sendmail/sendmail.c,
+       src/smtpd/smtpd_check.c, src/smtp/smtp_connect.c,
+       src/smtp/smtp_tls_policy.c, src/tls/tls_certkey.c,
+       src/tls/tls_dane.c, src/util/argv.h, src/util/argv_split.c,
+       src/util/argv_splitq.c, src/util/dict_file.c,
+       src/util/dict_inline.c, src/util/dict_pipe.c,
+       src/util/dict_random.c, src/util/dict_stream.c,
+       src/util/dict_union.c, src/util/match_list.c, src/util/mystrtok.c,
+       src/util/name_mask.c, src/util/stringops.h.
index bebc17b3f8a4b6bb52a9c873516f24067696eaac..e81149a07124c59018e24ccf3026c8e222e9d94a 100644 (file)
@@ -455,9 +455,11 @@ SENDMAIL(1)                                                        SENDMAIL(1)
               The location of the Postfix top-level queue directory.
 
        <b><a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> (empty)</b>
-              Don't rewrite message headers from remote clients  at  all  when
-              this  parameter is empty; otherwise, rewrite message headers and
-              append the specified domain name to incomplete addresses.
+              Rewrite or add message headers in mail from  remote  clients  if
+              the  <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a>  parameter value is non-empty,
+              updating incomplete addresses with the domain specified  in  the
+              <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> parameter, and adding missing head-
+              ers.
 
        <b><a href="postconf.5.html#syslog_facility">syslog_facility</a> (mail)</b>
               The syslog facility of Postfix logging.
@@ -519,5 +521,7 @@ SENDMAIL(1)                                                        SENDMAIL(1)
        111 8th Avenue
        New York, NY 10011, USA
 
+       Wietse Venema
+
                                                                    SENDMAIL(1)
 </pre> </body> </html>
index bebc17b3f8a4b6bb52a9c873516f24067696eaac..e81149a07124c59018e24ccf3026c8e222e9d94a 100644 (file)
@@ -455,9 +455,11 @@ SENDMAIL(1)                                                        SENDMAIL(1)
               The location of the Postfix top-level queue directory.
 
        <b><a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> (empty)</b>
-              Don't rewrite message headers from remote clients  at  all  when
-              this  parameter is empty; otherwise, rewrite message headers and
-              append the specified domain name to incomplete addresses.
+              Rewrite or add message headers in mail from  remote  clients  if
+              the  <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a>  parameter value is non-empty,
+              updating incomplete addresses with the domain specified  in  the
+              <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> parameter, and adding missing head-
+              ers.
 
        <b><a href="postconf.5.html#syslog_facility">syslog_facility</a> (mail)</b>
               The syslog facility of Postfix logging.
@@ -519,5 +521,7 @@ SENDMAIL(1)                                                        SENDMAIL(1)
        111 8th Avenue
        New York, NY 10011, USA
 
+       Wietse Venema
+
                                                                    SENDMAIL(1)
 </pre> </body> </html>
index 4654071fa8b487654bec2366ad7d5abaea07eadf..fa3752d871442adee9943b24db7c45f82a17d3b3 100644 (file)
@@ -451,5 +451,7 @@ POSTFIX(1)                                                          POSTFIX(1)
        The Linux PLD project
        Dean Strik, Eindhoven University, The Netherlands
 
+       Wietse Venema
+
                                                                     POSTFIX(1)
 </pre> </body> </html>
index 8ef57cf4add1070eba7deabe1a671b26a6592237..d77a51bbfa43099b83d72e3e00dd501081862e2f 100644 (file)
@@ -406,5 +406,7 @@ POSTMULTI(1)                                                      POSTMULTI(1)
        111 8th Avenue
        New York, NY 10011, USA
 
+       Wietse Venema
+
                                                                   POSTMULTI(1)
 </pre> </body> </html>
index 30a524a4d540cf859682e4790e6ed40cd80b92a0..458e66a4f0865f303206c5b906a0063abe8f7f91 100644 (file)
@@ -275,7 +275,7 @@ POSTSUPER(1)                                                      POSTSUPER(1)
               subdirectory levels.
 
        <b><a href="postconf.5.html#import_environment">import_environment</a> (see 'postconf -d' output)</b>
-              The  list  of  environment  parameters that a privileged Postfix
+              The  list  of  environment  variables  that a privileged Postfix
               process will  import  from  a  non-Postfix  parent  process,  or
               name=value environment overrides.
 
@@ -314,5 +314,7 @@ POSTSUPER(1)                                                      POSTSUPER(1)
        111 8th Avenue
        New York, NY 10011, USA
 
+       Wietse Venema
+
                                                                   POSTSUPER(1)
 </pre> </body> </html>
index 7c98c47d62e425d643a5fb66ef951dad544cdf54..c4b12e11fa18b4faa79fb94296cbb4b4d80e4deb 100644 (file)
@@ -219,5 +219,7 @@ PROXYMAP(8)                                                        PROXYMAP(8)
        111 8th Avenue
        New York, NY 10011, USA
 
+       Wietse Venema
+
                                                                    PROXYMAP(8)
 </pre> </body> </html>
index bebc17b3f8a4b6bb52a9c873516f24067696eaac..e81149a07124c59018e24ccf3026c8e222e9d94a 100644 (file)
@@ -455,9 +455,11 @@ SENDMAIL(1)                                                        SENDMAIL(1)
               The location of the Postfix top-level queue directory.
 
        <b><a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> (empty)</b>
-              Don't rewrite message headers from remote clients  at  all  when
-              this  parameter is empty; otherwise, rewrite message headers and
-              append the specified domain name to incomplete addresses.
+              Rewrite or add message headers in mail from  remote  clients  if
+              the  <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a>  parameter value is non-empty,
+              updating incomplete addresses with the domain specified  in  the
+              <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> parameter, and adding missing head-
+              ers.
 
        <b><a href="postconf.5.html#syslog_facility">syslog_facility</a> (mail)</b>
               The syslog facility of Postfix logging.
@@ -519,5 +521,7 @@ SENDMAIL(1)                                                        SENDMAIL(1)
        111 8th Avenue
        New York, NY 10011, USA
 
+       Wietse Venema
+
                                                                    SENDMAIL(1)
 </pre> </body> </html>
index c8cc13d8ac5f6f80de69a70cda6b8a6cdb8cb775..48c92423c7a349525fa8e64d7ec3ad14dec49ab7 100644 (file)
@@ -969,7 +969,7 @@ CCARGS="$CCARGS -DSNAPSHOT"
 
 # Non-production: needs thorough testing, or major changes are still
 # needed before the code stabilizes.
-#CCARGS="$CCARGS -DNONPROD"
+CCARGS="$CCARGS -DNONPROD"
 
 # Workaround: prepend Postfix include files before other include files.
 CCARGS="-I. -I../../include $CCARGS"
index c3ad0d8e911a04decea123b0ecc264d09ea6c3a1..318d5b6eb1de39c611521ae9e6a76bb3c8fe2fc3 100644 (file)
@@ -432,3 +432,5 @@ Mark Huizer, Eindhoven University, The Netherlands
 Jun\-ichiro 'itojun' Hagino, KAME project, Japan
 The Linux PLD project
 Dean Strik, Eindhoven University, The Netherlands
+
+Wietse Venema
index 6db035ea196793fe1da5888dee41cc96ab988f81..3f3343742fac08f74c98828f80567446060db37b 100644 (file)
@@ -432,3 +432,5 @@ Wietse Venema
 Google, Inc.
 111 8th Avenue
 New York, NY 10011, USA
+
+Wietse Venema
index 885330f1dc4f51316c0e47acc3fe1eb846e7b793..5342fdb5b87ac9047f5a743f651329f7b3a56f90 100644 (file)
@@ -46,7 +46,7 @@ from standard input. For example, to delete all mail
 with exactly one recipient \fBuser@example.com\fR:
 .sp
 .nf
-postqueue \-j | jq -r '
+postqueue \-j | jq \-r '
     # See JSON OBJECT FORMAT section in the postqueue(1) manpage
     select(.recipients[0].address == "user@example.com")
     | select(.recipients[1].address == null)
@@ -54,7 +54,7 @@ postqueue \-j | jq -r '
  ' | postsuper \-d \-
 .fi
 .sp
-(note the "jq -r" option), or the historical form:
+(note the "jq \-r" option), or the historical form:
 .sp
 .nf
 mailq | tail \-n +2 | grep \-v '^ *(' | awk  'BEGIN { RS = "" }
@@ -302,7 +302,7 @@ the hash_queue_names parameter.
 The names of queue directories that are split across multiple
 subdirectory levels.
 .IP "\fBimport_environment (see 'postconf -d' output)\fR"
-The list of environment parameters that a privileged Postfix
+The list of environment variables that a privileged Postfix
 process will import from a non\-Postfix parent process, or name=value
 environment overrides.
 .IP "\fBqueue_directory (see 'postconf -d' output)\fR"
@@ -341,3 +341,5 @@ Wietse Venema
 Google, Inc.
 111 8th Avenue
 New York, NY 10011, USA
+
+Wietse Venema
index 22affe63752119cb96d79a66ef1c7a5d340a7596..547024f4118b18f1af17ef70ccdad810c8298e10 100644 (file)
@@ -440,9 +440,10 @@ daemon processes.
 .IP "\fBqueue_directory (see 'postconf -d' output)\fR"
 The location of the Postfix top\-level queue directory.
 .IP "\fBremote_header_rewrite_domain (empty)\fR"
-Don't rewrite message headers from remote clients at all when
-this parameter is empty; otherwise, rewrite message headers and
-append the specified domain name to incomplete addresses.
+Rewrite or add message headers in mail from remote clients if
+the remote_header_rewrite_domain parameter value is non\-empty,
+updating incomplete addresses with the domain specified in the
+remote_header_rewrite_domain parameter, and adding missing headers.
 .IP "\fBsyslog_facility (mail)\fR"
 The syslog facility of Postfix logging.
 .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
@@ -510,3 +511,5 @@ Wietse Venema
 Google, Inc.
 111 8th Avenue
 New York, NY 10011, USA
+
+Wietse Venema
index e734a2bcad1c04c4ee289f2953ab809b4aa18711..1edc50989f4c78bc04296da6eee5878f1897a536 100644 (file)
@@ -241,3 +241,5 @@ Wietse Venema
 Google, Inc.
 111 8th Avenue
 New York, NY 10011, USA
+
+Wietse Venema
index 602285f0ee3230f8561030671665f8b91418a470..9d24dfe8f617a4bc6cdfb85ec3b7aa8379729339 100644 (file)
@@ -38,3 +38,9 @@ proto  proto SASL_README html proto SQLITE_README html
  util net_mask_top hc smtpd smtpd c smtpd smtpd_peer c 
  util inet_prefix_top hc smtpd smtpd c smtpd smtpd_peer c 
  File smtp smtp h 
+ src master master_ent c src milter milter8 c src milter milter c 
+ src oqmgr qmgr_message c src postfix postfix c 
+ src postmulti postmulti c src postscreen postscreen_dnsbl c 
+ src postsuper postsuper c src proxymap proxymap c 
+ src postsuper postsuper c src proxymap proxymap c 
+ src qmgr qmgr_message c src sendmail sendmail c 
index c642c7a32e0cacb2f2d14d55b22a61bd92bc0310..3da66902586915dda2cc10fe71c18f20b4ffc765 100644 (file)
@@ -1800,3 +1800,4 @@ Stringify
 bitcount
 bytecount
 ipproto
+cw
index 8c43a021205f09bc8b37713a70daaa1376fefe59..f3b2f79d4e3a3458ca129e27e03746d26921352c 100644 (file)
@@ -77,6 +77,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -381,7 +383,8 @@ void    cleanup_pre_jail(char *unused_name, char **unused_argv)
            name_mask(VAR_CANON_CLASSES, rcpt_canon_class_table,
                      var_rcpt_canon_classes);
     if (*var_masq_domains)
-       cleanup_masq_domains = argv_split(var_masq_domains, CHARS_COMMA_SP);
+       cleanup_masq_domains =
+           argv_split_cw(var_masq_domains, CHARS_COMMA_SP, VAR_MASQ_DOMAINS);
     if (*var_header_checks)
        cleanup_header_checks =
            maps_create(VAR_HEADER_CHECKS, var_header_checks, DICT_FLAG_LOCK);
index bff29545476122b932363606142055b33d2f42cb..4d51e41cf97c3490b7b7a0f95ba3acf9d2791c41 100644 (file)
@@ -6,7 +6,8 @@
 /* SYNOPSIS
 /*     #include <attr_override.h>
 /*
-/*     void    attr_override(bp, delimiters, parens, ... CA_ATTR_OVER_END);
+/*     void    attr_override(blame, bp, delimiters, parens, ...,
+/*                             CA_ATTR_OVER_END)
 /*     char    *bp;
 /*     const char *delimiters;
 /*     const char *parens;
@@ -22,6 +23,8 @@
 /*     fall-back policies, etc.).
 /*
 /*     Arguments:
+/* .IP blame
+/*     Context for error messages.
 /* .IP bp
 /*     Pointer to input string. The input is modified.
 /* .IP "delimiters, parens"
@@ -63,6 +66,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -88,7 +93,7 @@
 
 /* attr_override - apply settings from list of attribute=value pairs */
 
-void    attr_override(char *cp, const char *sep, const char *parens,...)
+void    attr_override(const char *blame, char *cp, const char *sep, const char *parens,...)
 {
     static const char myname[] = "attr_override";
     va_list ap;
@@ -146,10 +151,16 @@ void    attr_override(char *cp, const char *sep, const char *parens,...)
         */
        /* { name = value } */
        if (*nameval == parens[0]
-           && (err = extpar(&nameval, parens, EXTPAR_FLAG_NONE)) != 0)
+           && (err = extpar(&nameval, parens, EXTPAR_FLAG_STRIP)) != 0)
            msg_fatal("%s in \"%s\"", err, nameval);
+       if (*nameval == '#')
+           msg_fatal("%s: #comment after other text is not allowed: \"...%s...\"",
+                     blame, nameval);
        if ((err = split_nameval(nameval, &key, &value)) != 0)
-           msg_fatal("malformed option: %s: \"...%s...\"", err, nameval);
+           msg_fatal("%s: malformed option: %s: \"...%s...\"", blame, err, nameval);
+       if (*value == '#')
+           msg_fatal("%s: #comment after other text is not allowed: \"...%s %s\"",
+                     blame, key, value);
 
        /*
         * Look up the name and apply the value.
index 9f061620b17895fdc01cc9359b0788102f42368f..1b40c0c312f454f46d98b3ff760cb4a3bdb7ae1c 100644 (file)
@@ -16,7 +16,7 @@
   */
 #include <check_arg.h>
 
-extern void attr_override(char *, const char *, const char *,...);
+extern void attr_override(const char *, char *, const char *, const char *,...);
 
 typedef struct {
     const char *name;
@@ -65,6 +65,8 @@ CHECK_CPTR_HELPER_DCL(ATTR_OVER, ATTR_OVER_INT);
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 #endif
index 563bbd356d4cdc7cccf9e5514e4a1d29c269c5fd..31f719f3164f90da00b22532ac75edc6328af468 100644 (file)
@@ -29,6 +29,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -64,7 +66,7 @@ void    config_known_tcp_ports(const char *source, const char *settings)
      * The settings is in the form of associations separated by comma. Split
      * it into separate associations.
      */
-    associations = argv_split(settings, ",");
+    associations = argv_split(settings, ",");  /* blame later */
     if (associations->argc == 0) {
        argv_free(associations);
        return;
@@ -79,7 +81,7 @@ void    config_known_tcp_ports(const char *source, const char *settings)
     for (cpp = associations->argv; *cpp != 0; cpp++) {
        char   *temp = concatenate(" ", *cpp, " ", (char *) 0);
 
-       association = argv_split_at(temp, '=');
+       association = argv_split_at(temp, '='); /* blame later */
        myfree(temp);
 
        if (association->argc == 0) {
@@ -97,6 +99,8 @@ void    config_known_tcp_ports(const char *source, const char *settings)
            bp = association->argv[association->argc - 1];
            if ((rhs = mystrtok(&bp, CHARS_SPACE)) == 0) {
                err = "missing port value after \"=\"";
+           } else if (*rhs == '#') {
+               err = "#comment after other text is not allowed";
            } else if (mystrtok(&bp, CHARS_SPACE) != 0) {
                err = "whitespace in port number";
            } else {
@@ -106,6 +110,8 @@ void    config_known_tcp_ports(const char *source, const char *settings)
                    bp = association->argv[n];
                    if ((lhs = mystrtok(&bp, CHARS_SPACE)) == 0) {
                        new_err = "missing service name before \"=\"";
+                   } else if (*lhs == '#') {
+                       err = "#comment after other text is not allowed";
                    } else if (mystrtok(&bp, CHARS_SPACE) != 0) {
                        new_err = "whitespace in service name";
                    } else {
index a4a4c26758a68d01a02b2c23238e0f5382501506..fb9845b49a36fd7705a6dc499321f63995d16294 100644 (file)
 /*     Institute of Mathematics of the Romanian Academy
 /*     P.O. BOX 1-764
 /*     RO-014700 Bucharest, ROMANIA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -1016,7 +1018,7 @@ static int attrdesc_subtype(const char *a1, const char *a2)
 
 /* url_attrs - attributes we want from LDAP URL */
 
-static char **url_attrs(DICT_LDAP *dict_ldap, LDAPURLDesc * url)
+static char **url_attrs(DICT_LDAP *dict_ldap, LDAPURLDesc *url)
 {
     static ARGV *attrs;
     char  **a1;
@@ -1689,7 +1691,7 @@ DICT   *dict_ldap_open(const char *ldapsource, int open_flags, int dict_flags)
 
     url_list = vstring_alloc(32);
     s = server_host;
-    while ((h = mystrtok(&s, CHARS_COMMA_SP)) != NULL) {
+    while ((h = mystrtok_cw(&s, CHARS_COMMA_SP, ldapsource)) != NULL) {
 #if defined(LDAP_API_FEATURE_X_OPENLDAP)
 
        /*
@@ -1813,14 +1815,16 @@ DICT   *dict_ldap_open(const char *ldapsource, int open_flags, int dict_flags)
 
     /* Order matters, first the terminal attributes: */
     attr = cfg_get_str(dict_ldap->parser, "terminal_result_attribute", "", 0, 0);
-    dict_ldap->result_attributes = argv_split(attr, CHARS_COMMA_SP);
+    dict_ldap->result_attributes = argv_split_cw(attr, CHARS_COMMA_SP,
+                                                ldapsource);
     dict_ldap->num_terminal = dict_ldap->result_attributes->argc;
     myfree(attr);
 
     /* Order matters, next the leaf-only attributes: */
     attr = cfg_get_str(dict_ldap->parser, "leaf_result_attribute", "", 0, 0);
     if (*attr)
-       argv_split_append(dict_ldap->result_attributes, attr, CHARS_COMMA_SP);
+       argv_split_append_cw(dict_ldap->result_attributes, attr,
+                            CHARS_COMMA_SP, ldapsource);
     dict_ldap->num_leaf =
        dict_ldap->result_attributes->argc - dict_ldap->num_terminal;
     myfree(attr);
@@ -1828,14 +1832,16 @@ DICT   *dict_ldap_open(const char *ldapsource, int open_flags, int dict_flags)
     /* Order matters, next the regular attributes: */
     attr = cfg_get_str(dict_ldap->parser, "result_attribute", "maildrop", 0, 0);
     if (*attr)
-       argv_split_append(dict_ldap->result_attributes, attr, CHARS_COMMA_SP);
+       argv_split_append_cw(dict_ldap->result_attributes, attr,
+                            CHARS_COMMA_SP, ldapsource);
     dict_ldap->num_attributes = dict_ldap->result_attributes->argc;
     myfree(attr);
 
     /* Order matters, finally the special attributes: */
     attr = cfg_get_str(dict_ldap->parser, "special_result_attribute", "", 0, 0);
     if (*attr)
-       argv_split_append(dict_ldap->result_attributes, attr, CHARS_COMMA_SP);
+       argv_split_append_cw(dict_ldap->result_attributes, attr,
+                            CHARS_COMMA_SP, ldapsource);
     myfree(attr);
 
     /*
index d90bc090dafea1d95391db0600c7a5a8a322eedd..e8b6bb86e96ea9b60bfa25d565acf30a4e91e3e5 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -790,7 +792,8 @@ static void mysql_parse_config(DICT_MYSQL *dict_mysql, const char *mysqlcf)
 
     hosts = cfg_get_str(p, "hosts", "", 0, 0);
 
-    dict_mysql->hosts = argv_split(hosts, CHARS_COMMA_SP);
+    dict_mysql->hosts = argv_split_cw(hosts, CHARS_COMMA_SP,
+                                     dict_mysql->dict.name);
     if (dict_mysql->hosts->argc == 0) {
        argv_add(dict_mysql->hosts, "localhost", ARGV_END);
        argv_terminate(dict_mysql->hosts);
index f44a29ad0203e497f5508580cef5b14bd34ac227..c33697d300ba3c3b1262741269a9ea5efdb48604 100644 (file)
 /*     Joshua Marcus
 /*     IC Group, Inc.
 /*     josh@icgroup.com
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -754,7 +756,8 @@ static void pgsql_parse_config(DICT_PGSQL *dict_pgsql, const char *pgsqlcf)
 
     hosts = cfg_get_str(p, "hosts", "", 0, 0);
 
-    dict_pgsql->hosts = argv_split(hosts, CHARS_COMMA_SP);
+    dict_pgsql->hosts = argv_split_cw(hosts, CHARS_COMMA_SP,
+                                     dict_pgsql->dict.name);
     if (dict_pgsql->hosts->argc == 0) {
        argv_add(dict_pgsql->hosts, "localhost", ARGV_END);
        argv_terminate(dict_pgsql->hosts);
index 0b66ab9f8d7d343d2297c4db771fd153214f06ae..14399e0e7efc04648b87bdb579ec23913e1ea0f8 100644 (file)
@@ -69,6 +69,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -251,7 +253,7 @@ static void dymap_read_conf(const char *path, const char *path_base)
                linenum++;
                if (*cp == '#' || *cp == '\0')
                    continue;
-               argv = argv_split(cp, " \t");
+               argv = argv_split_cw(cp, " \t", path);
                if (argv->argc != 3 && argv->argc != 4)
                    msg_fatal("%s, line %d: Expected \"dict-type .so-name dict"
                              "-function [mkmap-function]\"", path, linenum);
index c0c4d5ceb81027960c4ad4e91a04458202a90fb2..f0b54ac8487109b8ad15957e51a503be0ac7fd1e 100644 (file)
@@ -26,6 +26,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -135,7 +137,8 @@ static void header_drop_init(void)
      * 
      * Thus, it is unlikely that all header flags will become configurable.
      */
-    hdr_drop_list = argv_split(var_drop_hdrs, CHARS_COMMA_SP);
+    hdr_drop_list = argv_split_cw(var_drop_hdrs, CHARS_COMMA_SP,
+                                 VAR_DROP_HDRS);
     for (cpp = hdr_drop_list->argv; *cpp; cpp++) {
        lowercase(*cpp);
        if ((ht = htable_locate(header_hash, *cpp)) == 0) {
index e263762ef42f77f0b6309861583b59cd1817eba7..4fee9656b534cbee53cd4c4e524d6e8224574bb2 100644 (file)
@@ -79,6 +79,8 @@ r*    The lookup table(s) with (login name, sender patterns) entries.
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -201,7 +203,8 @@ int     login_sender_match(LOGIN_SENDER_MATCH *lsm, const char *login_name,
         */
        cp = saved_sender_patterns = mystrdup(sender_patterns);
        while (found_or_error == LSM_STAT_NOTFOUND
-              && (sender_pattern = mystrtokdq(&cp, CHARS_COMMA_SP)) != 0) {
+              && (sender_pattern = mystrtokdq_cw(&cp, CHARS_COMMA_SP,
+                                                 lsm->maps->title)) != 0) {
            /* Special pattern: @domain. */
            if (*sender_pattern == '@') {
                if ((at_sender_domain = strrchr(sender_addr, '@')) != 0
index cd79d35ddcb6ae2f9526cb0b9f9b4b47293f4633..9033c0d0036c470f557eb9ac9db021838062f1b5 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
 
 /* mail_conf_checkdir - authorize non-default directory */
 
-void mail_conf_checkdir(const char *config_dir)
+void    mail_conf_checkdir(const char *config_dir)
 {
     VSTRING *buf;
     VSTREAM *fp;
@@ -155,7 +157,8 @@ void mail_conf_checkdir(const char *config_dir)
        if (split_nameval(vstring_str(buf), &name, &value) == 0
            && (strcmp(name, VAR_CONFIG_DIRS) == 0
                || strcmp(name, VAR_MULTI_CONF_DIRS) == 0)) {
-           while (found == 0 && (cp = mystrtok(&value, CHARS_COMMA_SP)) != 0)
+           while (found == 0
+                  && (cp = mystrtok_cw(&value, CHARS_COMMA_SP, path)) != 0)
                if (strcmp(cp, config_dir) == 0)
                    found = 1;
        }
index cf721d80f8a7e03c4f0d87299f39431517a76957..ff85dce8b3ee1f1a8717a63023dbffc5636bd945 100644 (file)
@@ -41,6 +41,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -76,7 +78,7 @@ ARGV   *mail_parm_split(const char *name, const char *value)
      * error. In this case, mystrtokq() detects no error, extpar() signals
      * the error to its caller, and this function handles the error.
      */
-    while ((arg = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) {
+    while ((arg = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, name)) != 0) {
        if (*arg == CHARS_BRACE[0]
            && (err = extpar(&arg, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0) {
 #ifndef TEST
index f73d1f1e31a0cdb923d067ae58746dd4ae2fcfc0..6ea4dd46f66ba11a8af0072b10802b3e66e83ea3 100644 (file)
@@ -99,6 +99,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -171,7 +173,8 @@ const char *mail_queue_dir(VSTRING *buf, const char *queue_name,
     }
     if (hash_buf == 0) {
        hash_buf = vstring_alloc(100);
-       hash_queue_names = argv_split(var_hash_queue_names, CHARS_COMMA_SP);
+       hash_queue_names = argv_split_cw(var_hash_queue_names, CHARS_COMMA_SP,
+                                        VAR_HASH_QUEUE_NAMES);
     }
 
     /*
index 7f79a1f6de56fdc5e690f14fac0b7afa6c6adc02..d5c10c42ee00dc600b967ae0b873fe1341960d1f 100644 (file)
@@ -75,6 +75,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -209,8 +211,9 @@ void    maillog_client_init(const char *progname, int flags)
        char   *service_path;
 
        if (var_maillog_file && *var_maillog_file) {
-           ARGV   *good_prefixes = argv_split(var_maillog_file_pfxs,
-                                              CHARS_COMMA_SP);
+           ARGV   *good_prefixes = argv_split_cw(var_maillog_file_pfxs,
+                                                 CHARS_COMMA_SP,
+                                                 VAR_MAILLOG_FILE_PFXS);
            char  **cpp;
 
            for (cpp = good_prefixes->argv; /* see below */ ; cpp++) {
index b10f7d516829f802527ecf4f46ec627702d34b83..b2cfe4f10013e7d06eed85ff10bcc26fec21e397 100644 (file)
@@ -63,6 +63,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -158,8 +160,8 @@ const MAP_SEARCH *map_search_create(const char *map_spec)
        if ((heap_err = extpar(&bp, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0) {
            msg_warn("malformed map specification: '%s'", heap_err);
            MAP_SEARCH_CREATE_RETURN(0);
-       } else if ((map_type_name = mystrtokq(&bp, CHARS_COMMA_SP,
-                                             CHARS_BRACE)) == 0) {
+       } else if ((map_type_name = mystrtokq_cw(&bp, CHARS_COMMA_SP,
+                                            CHARS_BRACE, map_spec)) == 0) {
            msg_warn("empty map specification: '%s'", map_spec);
            MAP_SEARCH_CREATE_RETURN(0);
        }
@@ -181,7 +183,8 @@ const MAP_SEARCH *map_search_create(const char *map_spec)
      * with the same attribute name.
      */
     if (bp != 0) {
-       while ((attr_name_val = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) {
+       while ((attr_name_val = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE,
+                                            map_spec)) != 0) {
            if (*attr_name_val == CHARS_BRACE[0]) {
                if ((heap_err = extpar(&attr_name_val, CHARS_BRACE,
                                       EXTPAR_FLAG_STRIP)) != 0) {
@@ -208,7 +211,8 @@ const MAP_SEARCH *map_search_create(const char *map_spec)
      */
     if (attr_name != 0) {
        search_order = vstring_alloc(10);
-       while ((atom = mystrtok(&attr_value, CHARS_COMMA_SP)) != 0) {
+       while ((atom = mystrtok_cw(&attr_value, CHARS_COMMA_SP,
+                                  map_spec)) != 0) {
            if ((code = name_code(map_search_actions, NAME_CODE_FLAG_NONE,
                                  atom)) == MAP_SEARCH_CODE_UNKNOWN) {
                msg_warn("unknown search type '%s' in '%s'", atom, map_spec);
@@ -310,6 +314,9 @@ int     main(int argc, char **argv)
        {"{type:name {search_order=one, two, bad}}", 0, 0, 0},
        {"{inline:{a=b} {search_order=one, two}}", 1, "inline:{a=b}", "\01\02"},
        {"{inline:{a=b, c=d} {search_order=one, two}}", 1, "inline:{a=b, c=d}", "\01\02"},
+       {"#after text", 0, 0, 0},
+       {"{type:name, #after text}", 1, "type:name", 0},
+       {"{type:name {search_order=one, two, #after text}}", 1, "type:name", "\01\02"},
        {0},
     };
     TEST_CASE *test_case;
index a296e4e4a7f5b1fc301868e4b6a3b9d906ed46cd..12655cc69cdf0ed77b0d21df448572661330e6e7 100644 (file)
@@ -20,3 +20,10 @@ unknown: test case 10: '{type:name {search_order=one, two, bad}}'
 unknown: warning: unknown search type 'bad' in '{type:name {search_order=one, two, bad}}'
 unknown: test case 11: '{inline:{a=b} {search_order=one, two}}'
 unknown: test case 12: '{inline:{a=b, c=d} {search_order=one, two}}'
+unknown: test case 13: '#after text'
+unknown: warning: malformed map specification: '#after text'
+unknown: warning: expected maptype:mapname instead of '#after text'
+unknown: test case 14: '{type:name, #after text}'
+unknown: warning: {type:name, #after text}: #comment after other text is not allowed: #after text
+unknown: test case 15: '{type:name {search_order=one, two, #after text}}'
+unknown: warning: {type:name {search_order=one, two, #after text}}: #comment after other text is not allowed: #after text
index 790396bbabfb41c915c400adf93d7fe7f82c6ad6..7a86271ee52d25468bdf538f4feb44e1cf43a5e7 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -153,7 +155,7 @@ MAPS   *maps_create(const char *title, const char *map_names, int dict_flags)
 
 #define OPEN_FLAGS     O_RDONLY
 
-       while ((map_type_name = mystrtokq(&bufp, sep, parens)) != 0) {
+       while ((map_type_name = mystrtokq_cw(&bufp, sep, parens, title)) != 0) {
            vstring_sprintf(map_type_name_flags, "%s(%o,%s)",
                            map_type_name, OPEN_FLAGS,
                            dict_flags_str(dict_flags));
index d164a20b2035344c8c4b0423d25d34d334e58609..1b34d4de08012d76532cefd97f7a982c04f762f8 100644 (file)
@@ -42,6 +42,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -143,7 +145,7 @@ static void own_inet_addr_init(INET_ADDR_LIST *addr_list,
      */
     else {
        bufp = hosts = mystrdup(var_inet_interfaces);
-       while ((host = mystrtok(&bufp, sep)) != 0)
+       while ((host = mystrtok_cw(&bufp, sep, VAR_INET_INTERFACES)) != 0)
            if (inet_addr_host(addr_list, host) == 0)
                msg_fatal("config variable %s: host not found: %s",
                          VAR_INET_INTERFACES, host);
@@ -191,7 +193,7 @@ static void own_inet_addr_init(INET_ADDR_LIST *addr_list,
 
 /* own_inet_addr - is this my own internet address */
 
-int     own_inet_addr(struct sockaddr * addr)
+int     own_inet_addr(struct sockaddr *addr)
 {
     int     i;
 
@@ -239,7 +241,7 @@ static void proxy_inet_addr_init(INET_ADDR_LIST *addr_list)
      */
     inet_addr_list_init(addr_list);
     bufp = hosts = mystrdup(var_proxy_interfaces);
-    while ((host = mystrtok(&bufp, sep)) != 0)
+    while ((host = mystrtok_cw(&bufp, sep, VAR_PROXY_INTERFACES)) != 0)
        if (inet_addr_host(addr_list, host) == 0)
            msg_fatal("config variable %s: host not found: %s",
                      VAR_PROXY_INTERFACES, host);
@@ -253,7 +255,7 @@ static void proxy_inet_addr_init(INET_ADDR_LIST *addr_list)
 
 /* proxy_inet_addr - is this my proxy internet address */
 
-int     proxy_inet_addr(struct sockaddr * addr)
+int     proxy_inet_addr(struct sockaddr *addr)
 {
     int     i;
 
index 5385a5a1f28845a75bd053c1faec3926000c8da2..21a6b752c82d1b5e1f201e65b2b8b9dd786d108b 100644 (file)
@@ -64,6 +64,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -112,7 +114,7 @@ void    server_acl_pre_jail_init(const char *mynetworks, const char *origin)
     if (warn_compat_break_mynetworks_style)
        server_acl_mynetworks_host =
            addr_match_list_init(origin, MATCH_FLAG_RETURN
-                                | match_parent_style(origin), mynetworks_host());
+                          | match_parent_style(origin), mynetworks_host());
 }
 
 /* server_acl_parse - parse access list */
@@ -132,7 +134,7 @@ SERVER_ACL *server_acl_parse(const char *extern_acl, const char *origin)
      * chroot jail, while access lists are evaluated after entering the
      * chroot jail.
      */
-    while ((acl = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) {
+    while ((acl = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, origin)) != 0) {
        if (strchr(acl, ':') != 0) {
            if (strchr(origin, ':') != 0) {
                msg_warn("table %s: lookup result \"%s\" is not allowed"
@@ -240,7 +242,7 @@ int     server_acl_eval(const char *client_addr, SERVER_ACL * intern_acl,
 #include <vstring_vstream.h>
 #include <name_code.h>
 #include <split_at.h>
-    
+
 char   *var_server_acl = "";
 
 #define UPDATE_VAR(s,v) do { if (*(s)) myfree(s); (s) = mystrdup(v); } while (0)
index 3ce2cfca90565c5422d76af8601151de1860c980..226843c24dab1d19d69ea64a110189728cf71c9b 100644 (file)
@@ -43,6 +43,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -194,7 +196,7 @@ int     deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
     next = saved_forward_path;
     lookup_status = -1;
 
-    while ((lhs = mystrtok(&next, CHARS_COMMA_SP)) != 0) {
+    while ((lhs = mystrtok_cw(&next, CHARS_COMMA_SP, VAR_FORWARD_PATH)) != 0) {
        expand_status = local_expand(path, lhs, &state, &usr_attr,
                                     var_fwd_exp_filter);
        if ((expand_status & (MAC_PARSE_ERROR | MAC_PARSE_UNDEF)) == 0) {
index 5edc30872234a98111cc4d6be8f93e72de5be340..86a9ebcad0973cc725964bf8a4b45deaea2e1444 100644 (file)
@@ -62,6 +62,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System libraries. */
@@ -213,7 +215,7 @@ static char *get_str_ent(char **bufp, char *name, char *def_val)
 {
     char   *value;
 
-    if ((value = mystrtok(bufp, master_blanks)) == 0)
+    if ((value = mystrtok_cw(bufp, master_blanks, master_conf_context())) == 0)
        fatal_with_context("missing \"%s\" field", name);
     if (strcmp(value, "-") == 0) {
        if (def_val == 0)
@@ -576,6 +578,11 @@ MASTER_SERV *get_master_ent()
        argv_add(serv->args, "-s",
            vstring_str(vstring_sprintf(junk, "%d", serv->listen_fd_count)),
                 (char *) 0);
+
+    /*
+     * The remaining arguments may have application-specific syntax. Do not
+     * complain about words that start with a '#'.
+     */
     while ((cp = mystrtokq(&bufp, master_blanks, CHARS_BRACE)) != 0) {
        if (*cp == CHARS_BRACE[0]
            && (err = extpar(&cp, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0)
index dfd5e1c48d1027be6faae87a877b141b61101e0a..ec9dcb794899e6984c0048b010355a10590224ac 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -280,7 +282,8 @@ HTABLE *milter_macro_defaults_create(const char *macro_defaults)
     VSTRING *canon_buf = 0;
     char   *nameval;
 
-    while ((nameval = mystrtokq(&cp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) {
+    while ((nameval = mystrtokq_cw(&cp, CHARS_COMMA_SP, CHARS_BRACE,
+                                  VAR_MILT_MACRO_DEFLTS)) != 0) {
        const char *err;
        char   *name;
        char   *value;
@@ -335,7 +338,8 @@ static ARGV *milter_macro_lookup(MILTERS *milters, const char *macro_names)
     const char *name;
     const char *cname;
 
-    while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
+    /* XXX Which parameter to blame? */
+    while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, "milter_macros")) != 0) {
        if (msg_verbose)
            msg_info("%s: \"%s\"", myname, name);
        if (*name != '{')                       /* } */
@@ -684,10 +688,13 @@ MILTERS *milter_new(const char *names,
        char   *op;
        char   *err;
 
+       /* XXX Which parameter to blame? */
+       char   *blame = "milters";
+
        /*
         * Instantiate Milters, allowing for per-Milter overrides.
         */
-       while ((name = mystrtokq(&cp, sep, parens)) != 0) {
+       while ((name = mystrtokq_cw(&cp, sep, parens, blame)) != 0) {
            my_conn_timeout = conn_timeout;
            my_cmd_timeout = cmd_timeout;
            my_msg_timeout = msg_timeout;
@@ -697,9 +704,9 @@ MILTERS *milter_new(const char *names,
                op = name;
                if ((err = extpar(&op, parens, EXTPAR_FLAG_NONE)) != 0)
                    msg_fatal("milter service syntax error: %s", err);
-               if ((name = mystrtok(&op, sep)) == 0)
+               if ((name = mystrtok_cw(&op, sep, blame)) == 0)
                    msg_fatal("empty milter definition: \"%s\"", names);
-               attr_override(op, sep, parens,
+               attr_override(blame, op, sep, parens,
                              CA_ATTR_OVER_STR_TABLE(str_table),
                              CA_ATTR_OVER_TIME_TABLE(time_table),
                              CA_ATTR_OVER_END);
index 6c9a1eec46f18951c0d9b1868577ee01bea75bc0..953f44459f469193a13fba0764888bef296a5a93 100644 (file)
@@ -56,6 +56,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -1157,7 +1159,7 @@ static const char *milter8_event(MILTER8 *milter, int event,
            if (edit_resp == 0)
                edit_resp = parent->repl_body(parent->chg_context,
                                              MILTER_BODY_END,
-                                             /* unused*/ 0,
+                                             /* unused */ 0,
                                              (VSTRING *) 0);
            body_edit_lockout = 1;
            vstring_free(body_line_buf);
@@ -1553,7 +1555,7 @@ static const char *milter8_event(MILTER8 *milter, int event,
                        body_line_buf = vstring_alloc(var_line_limit);
                        edit_resp = parent->repl_body(parent->chg_context,
                                                      MILTER_BODY_START,
-                                                     /* unused */ 0,
+                                                      /* unused */ 0,
                                                      (VSTRING *) 0);
                    }
                    /* Extract lines from the on-the-wire CRLF format. */
@@ -1671,7 +1673,7 @@ static void milter8_connect(MILTER8 *milter)
      * don't want to take the risk that a future version will be more picky.
      */
     cp = saved_version = mystrdup(milter->protocol);
-    while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
+    while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, VAR_MILT_PROTOCOL)) != 0) {
        int     mask;
        int     vers;
 
index b885264a20d049c125b3700ea663868ac104b44f..277417f5ef7d5b46cfb50549d48d98bf11cef5e6 100644 (file)
@@ -94,6 +94,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -1148,7 +1150,9 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
         */
        if (*var_defer_xports && (message->qflags & QMGR_FLUSH_DFXP) == 0) {
            if (defer_xport_argv == 0)
-               defer_xport_argv = argv_split(var_defer_xports, CHARS_COMMA_SP);
+               defer_xport_argv = argv_split_cw(var_defer_xports,
+                                                CHARS_COMMA_SP,
+                                                VAR_DEFER_XPORTS);
            for (cpp = defer_xport_argv->argv; *cpp; cpp++)
                if (strcmp(*cpp, STR(reply.transport)) == 0)
                    break;
index c7f8b40addab29099ed410be53164dff8f633376..2ab1b95502adb7adf893ab60cb2c25b02da19806 100644 (file)
@@ -37,7 +37,7 @@
 /*     when running as PID 1.
 /*     This command requires that multi-instance support is
 /*     disabled (i.e. the multi_instance_directories parameter
-/*     value must be empty). 
+/*     value must be empty).
 /*
 /*     When running Postfix inside a container, see MAILLOG_README
 /*     for logging to stdout. Postfix logs to syslog by default,
 /*     Jun-ichiro 'itojun' Hagino, KAME project, Japan
 /*     The Linux PLD project
 /*     Dean Strik, Eindhoven University, The Netherlands
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -634,7 +636,8 @@ int     main(int argc, char **argv)
      * Run the management script.
      */
     if (force_single_instance
-       || argv_split(var_multi_conf_dirs, CHARS_COMMA_SP)->argc == 0) {
+       || argv_split_cw(var_multi_conf_dirs, CHARS_COMMA_SP,
+                        VAR_MULTI_CONF_DIRS)->argc == 0) {
        script = concatenate(var_daemon_dir, "/postfix-script", (char *) 0);
        if (optind < 1)
            msg_panic("bad optind value");
index 5adcd272cacf43ecda41bc3becf20b23ed381912..e5bbe8e7a942f680b6e16365a5227e2e2cd149d4 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -872,7 +874,8 @@ static void load_all_instances(void)
      * only comma characters. Count the actual number of elements, before we
      * decide that the list is empty.
      */
-    secondary_names = argv_split(var_multi_conf_dirs, CHARS_COMMA_SP);
+    secondary_names = argv_split_cw(var_multi_conf_dirs, CHARS_COMMA_SP,
+                                   VAR_MULTI_CONF_DIRS);
 
     /*
      * First, the primary instance.  This is synthesized out of thin air.
@@ -1471,14 +1474,15 @@ static int run_user_command(INSTANCE *ip, int iter_cmd, int iter_flags,
 
 /* word_in_list - look up command in start, stop, or control list */
 
-static int word_in_list(char *cmdlist, const char *cmd)
+static int word_in_list(char *cmdlist, const char *cmd, const char *blame)
 {
     char   *saved;
     char   *cp;
     char   *elem;
 
     cp = saved = mystrdup(cmdlist);
-    while ((elem = mystrtok(&cp, CHARS_COMMA_SP)) != 0 && strcmp(elem, cmd) != 0)
+    while ((elem = mystrtok_cw(&cp, CHARS_COMMA_SP, blame)) != 0
+          && strcmp(elem, cmd) != 0)
         /* void */ ;
     myfree(saved);
     return (elem != 0);
@@ -1497,11 +1501,13 @@ static int iterate_postfix_command(int iter_cmd, int argc, char **argv,
     /*
      * Override the iterator controls.
      */
-    if (word_in_list(var_multi_start_cmds, argv[0])) {
+    if (word_in_list(var_multi_start_cmds, argv[0], VAR_MULTI_START_CMDS)) {
        iter_flags = ITER_FLAG_CHECK_DISABLED;
-    } else if (word_in_list(var_multi_stop_cmds, argv[0])) {
+    } else if (word_in_list(var_multi_stop_cmds, argv[0],
+                           VAR_MULTI_STOP_CMDS)) {
        iter_flags = ITER_FLAG_SKIP_DISABLED | ITER_FLAG_REVERSE;
-    } else if (word_in_list(var_multi_cntrl_cmds, argv[0])) {
+    } else if (word_in_list(var_multi_cntrl_cmds, argv[0],
+                           VAR_MULTI_CNTRL_CMDS)) {
        iter_flags = ITER_FLAG_SKIP_DISABLED;
     } else {
        iter_flags = 0;
index 7d9a5e94b98beb0d0e28d42b281caf4be214cb64..9cb3f0afc77dea416f538177bfbf2f214d413253 100644 (file)
@@ -58,6 +58,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -231,7 +233,7 @@ static void psc_dnsbl_add_site(const char *site)
     int     weight;
     HTABLE_INFO *ht;
     char   *parse_err;
-    const char  *safe_dnsbl;
+    const char *safe_dnsbl;
 
     /*
      * Parse the required DNSBL domain name, the optional reply filter and
@@ -584,7 +586,8 @@ int     psc_dnsbl_request(const char *client_addr,
 void    psc_dnsbl_init(void)
 {
     const char *myname = "psc_dnsbl_init";
-    ARGV   *dnsbl_site = argv_split(var_psc_dnsbl_sites, CHARS_COMMA_SP);
+    ARGV   *dnsbl_site = argv_split_cw(var_psc_dnsbl_sites, CHARS_COMMA_SP,
+                                      VAR_PSC_DNSBL_SITES);
     char  **cpp;
 
     /*
index d3f2d5bcddd54794dc0cdc8ccaa51be87c1944fb..6884c3b4f026c9f7b56fbe6d988b02a369583e29 100644 (file)
 /*     The names of queue directories that are split across multiple
 /*     subdirectory levels.
 /* .IP "\fBimport_environment (see 'postconf -d' output)\fR"
-/*     The list of environment parameters that a privileged Postfix
+/*     The list of environment variables that a privileged Postfix
 /*     process will import from a non-Postfix parent process, or name=value
 /*     environment overrides.
 /* .IP "\fBqueue_directory (see 'postconf -d' output)\fR"
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -900,7 +902,9 @@ static int fix_queue_id(const char *actual_path, const char *actual_queue,
 
 static void super(const char **queues, int action)
 {
-    ARGV   *hash_queue_names = argv_split(var_hash_queue_names, CHARS_COMMA_SP);
+    ARGV   *hash_queue_names = argv_split_cw(var_hash_queue_names,
+                                            CHARS_COMMA_SP,
+                                            VAR_HASH_QUEUE_NAMES);
     VSTRING *actual_path = vstring_alloc(10);
     VSTRING *wanted_path = vstring_alloc(10);
     struct stat st;
index abdcf3af7a435c132711838b9c5c9b51de264ebd..63cbffa12df908fd2cb12dfe9c4b2377bb97b85b 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -685,13 +687,13 @@ DICT   *dict_proxy_open(const char *map, int open_flags, int dict_flags)
 
 /* authorize_proxied_maps - recursively authorize maps */
 
-static void authorize_proxied_maps(char *bp)
+static void authorize_proxied_maps(char *bp, const char *blame)
 {
     const char *sep = CHARS_COMMA_SP;
     const char *parens = CHARS_BRACE;
     char   *type_name;
 
-    while ((type_name = mystrtokq(&bp, sep, parens)) != 0) {
+    while ((type_name = mystrtokq_cw(&bp, sep, parens, blame)) != 0) {
        char   *nested_info;
 
        /* Maybe { maptype:mapname attr=value... } */
@@ -706,7 +708,7 @@ static void authorize_proxied_maps(char *bp)
                continue;
            }
            /* Don't try to second-guess the semantics of { }. */
-           if ((type_name = mystrtokq(&type_name, sep, parens)) == 0)
+           if ((type_name = mystrtokq_cw(&type_name, sep, parens, blame)) == 0)
                continue;
        }
        /* Recurse into nested map (pipemap, unionmap). */
@@ -722,7 +724,7 @@ static void authorize_proxied_maps(char *bp)
                myfree(err);
                continue;
            }
-           authorize_proxied_maps(nested_info);
+           authorize_proxied_maps(nested_info, blame);
            continue;
        }
        if (strncmp(type_name, PROXY_COLON, PROXY_COLON_LEN))
@@ -770,7 +772,8 @@ static void post_jail_init(char *service_name, char **unused_argv)
     saved_filter = mystrdup(proxy_writer ? var_proxy_write_maps :
                            var_proxy_read_maps);
     proxy_auth_maps = htable_create(13);
-    authorize_proxied_maps(saved_filter);
+    authorize_proxied_maps(saved_filter, proxy_writer ? VAR_PROXY_WRITE_MAPS :
+                          VAR_PROXY_READ_MAPS);
     myfree(saved_filter);
 
     /*
index 79143f3d3edbea5dfb813c6aa728a0ee198c33a4..623133dbc10ed3e22cb3ec206edf7eb453f9e564 100644 (file)
 /*     Patrik Rak
 /*     Modra 6
 /*     155 00, Prague, Czech Republic
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -1207,7 +1209,9 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
         */
        if (*var_defer_xports && (message->qflags & QMGR_FLUSH_DFXP) == 0) {
            if (defer_xport_argv == 0)
-               defer_xport_argv = argv_split(var_defer_xports, CHARS_COMMA_SP);
+               defer_xport_argv = argv_split_cw(var_defer_xports,
+                                                CHARS_COMMA_SP,
+                                                VAR_DEFER_XPORTS);
            for (cpp = defer_xport_argv->argv; *cpp; cpp++)
                if (strcmp(*cpp, STR(reply.transport)) == 0)
                    break;
index 27b3543457dd09e6e45aa7e40018425a4ef445de..fe402d523b67fd0399a06d0c93ce01121142dbce 100644 (file)
 /* .IP "\fBqueue_directory (see 'postconf -d' output)\fR"
 /*     The location of the Postfix top-level queue directory.
 /* .IP "\fBremote_header_rewrite_domain (empty)\fR"
-/*     Don't rewrite message headers from remote clients at all when
-/*     this parameter is empty; otherwise, rewrite message headers and
-/*     append the specified domain name to incomplete addresses.
+/*     Rewrite or add message headers in mail from remote clients if
+/*     the remote_header_rewrite_domain parameter value is non-empty,
+/*     updating incomplete addresses with the domain specified in the
+/*     remote_header_rewrite_domain parameter, and adding missing headers.
 /* .IP "\fBsyslog_facility (mail)\fR"
 /*     The syslog facility of Postfix logging.
 /* .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -1482,7 +1485,8 @@ int     main(int argc, char **argv)
        if (alias_map_from_args != 0)
            argv_add(ext_argv, alias_map_from_args, (char *) 0);
        else
-           argv_split_append(ext_argv, var_alias_db_map, CHARS_COMMA_SP);
+           argv_split_append_cw(ext_argv, var_alias_db_map, CHARS_COMMA_SP,
+                                VAR_ALIAS_DB_MAP);
        argv_terminate(ext_argv);
        mail_run_replace(var_command_dir, ext_argv->argv);
        /* NOTREACHED */
index 68faca18ef821ab73c6434d2c2039f64ab0e7e62..8d2076ffbef18cd778c08735dbc10bdf480ab5d0 100644 (file)
@@ -56,6 +56,8 @@
 /*     Connection caching in cooperation with:
 /*     Victor Duchovni
 /*     Morgan Stanley
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -832,7 +834,8 @@ static void smtp_connect_inet(SMTP_STATE *state, const char *nexthop,
     if (sites->argc == 0)
        msg_panic("null destination: \"%s\"", nexthop);
     non_fallback_sites = sites->argc;
-    argv_split_append(sites, var_fallback_relay, CHARS_COMMA_SP);
+    argv_split_append_cw(sites, var_fallback_relay, CHARS_COMMA_SP,
+                        VAR_SMTP_FALLBACK);
 
     /*
      * Don't give up after a hard host lookup error until we have tried the
index 92a231df5fba83bf1be899b4ef484b33f025bb8a..8db39cc36f604bbad316f484a0e0fde5bfbf0262 100644 (file)
@@ -80,6 +80,8 @@
 /*     New York, NY 10011, USA
 /*
 /*     Viktor Dukhovni
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -250,7 +252,7 @@ static void tls_policy_lookup_one(SMTP_TLS_POLICY *tls, int *site_level,
     }
     saved_policy = policy = mystrdup(lookup);
 
-    if ((tok = mystrtok(&policy, CHARS_COMMA_SP)) == 0) {
+    if ((tok = mystrtok_cw(&policy, CHARS_COMMA_SP, tls_policy->title)) == 0) {
        msg_warn("%s: invalid empty policy", WHERE);
        INVALID_RETURN(tls->why, site_level);
     }
@@ -265,7 +267,7 @@ static void tls_policy_lookup_one(SMTP_TLS_POLICY *tls, int *site_level,
      * Warn about ignored attributes when TLS is disabled.
      */
     if (*site_level < TLS_LEV_MAY) {
-       while ((tok = mystrtok(&policy, CHARS_COMMA_SP)) != 0)
+       while ((tok = mystrtok_cw(&policy, CHARS_COMMA_SP, tls_policy->title)) != 0)
            msg_warn("%s: ignoring attribute \"%s\" with TLS disabled",
                     WHERE, tok);
        FREE_RETURN;
@@ -275,7 +277,7 @@ static void tls_policy_lookup_one(SMTP_TLS_POLICY *tls, int *site_level,
      * Errors in attributes may have security consequences, don't ignore
      * errors that can degrade security.
      */
-    while ((tok = mystrtok(&policy, CHARS_COMMA_SP)) != 0) {
+    while ((tok = mystrtok_cw(&policy, CHARS_COMMA_SP, tls_policy->title)) != 0) {
        if ((err = split_nameval(tok, &name, &val)) != 0) {
            msg_warn("%s: malformed attribute/value pair \"%s\": %s",
                     WHERE, tok, err);
@@ -425,7 +427,7 @@ static void tls_policy_lookup(SMTP_TLS_POLICY *tls, int *site_level,
 
 /* load_tas - load one or more ta files */
 
-static int load_tas(TLS_DANE *dane, const char *files)
+static int load_tas(TLS_DANE *dane, const char *files, const char *blame)
 {
     int     ret = 0;
     char   *save = mystrdup(files);
@@ -433,7 +435,7 @@ static int load_tas(TLS_DANE *dane, const char *files)
     char   *file;
 
     do {
-       if ((file = mystrtok(&buf, CHARS_COMMA_SP)) != 0)
+       if ((file = mystrtok_cw(&buf, CHARS_COMMA_SP, blame)) != 0)
            ret = tls_dane_load_trustfile(dane, file);
     } while (file && ret);
 
@@ -633,14 +635,16 @@ static void *policy_create(const char *unused_key, void *context)
     case TLS_LEV_SECURE:
        if (tls->matchargv == 0)
            tls->matchargv =
-               argv_split(tls->level == TLS_LEV_VERIFY ?
-                          var_smtp_tls_vfy_cmatch : var_smtp_tls_sec_cmatch,
-                          CHARS_COMMA_SP ":");
+               argv_split_cw(tls->level == TLS_LEV_VERIFY ?
+                         var_smtp_tls_vfy_cmatch : var_smtp_tls_sec_cmatch,
+                         CHARS_COMMA_SP ":", tls->level == TLS_LEV_VERIFY ?
+                       VAR_SMTP_TLS_VFY_CMATCH : VAR_SMTP_TLS_SEC_CMATCH);
        if (*var_smtp_tls_tafile) {
            if (tls->dane == 0)
                tls->dane = tls_dane_alloc();
            if (tls->dane->tlsa == 0
-               && !load_tas(tls->dane, var_smtp_tls_tafile)) {
+               && !load_tas(tls->dane, var_smtp_tls_tafile,
+                            VAR_SMTP_TLS_TAFILE)) {
                MARK_INVALID(tls->why, &tls->level);
                return ((void *) tls);
            }
index b5ce4a94fc9834d86a12311e3b68b396e7fd7e8e..13e5828f4452b88104aafeeb82bb9778fa648159 100644 (file)
 /*     Allgemeine Elektrotechnik
 /*     Universitaetsplatz 3-4
 /*     D-03044 Cottbus, Germany
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -549,7 +551,7 @@ static const NAME_CODE search_actions[] = {
 
 /* policy_client_register - register policy service endpoint */
 
-static void policy_client_register(const char *name)
+static void policy_client_register(const char *name, const char *pname)
 {
     static const char myname[] = "policy_client_register";
     SMTPD_POLICY_CLNT *policy_client;
@@ -590,9 +592,9 @@ static void policy_client_register(const char *name)
            cp = saved_name = mystrdup(name);
            if ((err = extpar(&cp, parens, EXTPAR_FLAG_NONE)) != 0)
                msg_fatal("policy service syntax error: %s", cp);
-           if ((policy_name = mystrtok(&cp, sep)) == 0)
+           if ((policy_name = mystrtok_cw(&cp, sep, pname)) == 0)
                msg_fatal("empty policy service: \"%s\"", name);
-           attr_override(cp, sep, parens,
+           attr_override(pname, cp, sep, parens,
                          CA_ATTR_OVER_TIME_TABLE(time_table),
                          CA_ATTR_OVER_INT_TABLE(int_table),
                          CA_ATTR_OVER_STR_TABLE(str_table),
@@ -651,7 +653,7 @@ static void command_map_register(const char *name)
 
 /* smtpd_check_parse - pre-parse restrictions */
 
-static ARGV *smtpd_check_parse(int flags, const char *checks)
+static ARGV *smtpd_check_parse(int flags, const char *pname, const char *checks)
 {
     char   *saved_checks = mystrdup(checks);
     ARGV   *argv = argv_alloc(1);
@@ -669,11 +671,12 @@ static ARGV *smtpd_check_parse(int flags, const char *checks)
 #define SMTPD_CHECK_PARSE_MAPS         (1<<1)
 #define SMTPD_CHECK_PARSE_ALL          (~0)
 
-    while ((name = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) {
+    while ((name = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE,
+                               pname)) != 0) {
        argv_add(argv, name, (char *) 0);
        if ((flags & SMTPD_CHECK_PARSE_POLICY)
            && last && strcasecmp(last, CHECK_POLICY_SERVICE) == 0) {
-           policy_client_register(name);
+           policy_client_register(name, pname);
        } else if ((flags & SMTPD_CHECK_PARSE_MAPS)
                   && (*name == *CHARS_BRACE || strchr(name, ':') != 0)) {
            if ((map_search = map_search_create(name)) != 0)
@@ -881,23 +884,32 @@ void    smtpd_check_init(void)
      * before going to jail.
      */
     client_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                          VAR_CLIENT_CHECKS,
                                           var_client_checks);
     helo_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                        VAR_HELO_CHECKS,
                                         var_helo_checks);
     mail_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                        VAR_MAIL_CHECKS,
                                         var_mail_checks);
     relay_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                         VAR_RELAY_CHECKS,
                                          var_relay_checks);
     if (warn_compat_break_relay_restrictions)
        fake_relay_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                                  "fake relay restrictions",
                                                   FAKE_RELAY_CHECKS);
     rcpt_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                        VAR_RCPT_CHECKS,
                                         var_rcpt_checks);
     etrn_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                        VAR_ETRN_CHECKS,
                                         var_etrn_checks);
     data_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                        VAR_DATA_CHECKS,
                                         var_data_checks);
     eod_restrictions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                        VAR_EOD_CHECKS,
                                         var_eod_checks);
 
     /*
@@ -906,12 +918,14 @@ void    smtpd_check_init(void)
     smtpd_rest_classes = htable_create(1);
     if (*var_rest_classes) {
        cp = saved_classes = mystrdup(var_rest_classes);
-       while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
+       while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP,
+                                  VAR_REST_CLASSES)) != 0) {
            if ((value = mail_conf_lookup_eval(name)) == 0 || *value == 0)
                msg_fatal("restriction class `%s' needs a definition", name);
            /* XXX This store operation should not be case-sensitive. */
            htable_enter(smtpd_rest_classes, name,
                         (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                                   VAR_REST_CLASSES,
                                                    value));
        }
        myfree(saved_classes);
@@ -928,6 +942,7 @@ void    smtpd_check_init(void)
 #endif
     htable_enter(smtpd_rest_classes, REJECT_SENDER_LOGIN_MISMATCH,
                 (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                           REJECT_SENDER_LOGIN_MISMATCH,
                                            REJECT_AUTH_SENDER_LOGIN_MISMATCH
                                  " " REJECT_UNAUTH_SENDER_LOGIN_MISMATCH));
 
@@ -947,6 +962,7 @@ void    smtpd_check_init(void)
      * Local rewrite policy.
      */
     local_rewrite_clients = smtpd_check_parse(SMTPD_CHECK_PARSE_MAPS,
+                                             VAR_LOC_RWR_CLIENTS,
                                              var_local_rwr_clients);
 
     /*
@@ -2743,7 +2759,7 @@ static int check_table_result(SMTPD_STATE *state, const char *table,
      */
 #define ADDROF(x) ((char *) &(x))
 
-    restrictions = argv_splitq(value, CHARS_COMMA_SP, CHARS_BRACE);
+    restrictions = argv_splitq_cw(value, CHARS_COMMA_SP, CHARS_BRACE, table);
     memcpy(ADDROF(savebuf), ADDROF(smtpd_check_buf), sizeof(savebuf));
     status = setjmp(smtpd_check_buf);
     if (status != 0) {
@@ -3913,7 +3929,8 @@ static int reject_auth_sender_login_mismatch(SMTPD_STATE *state, const char *sen
        if ((owners = check_mail_addr_find(state, sender, smtpd_sender_login_maps,
                                STR(reply->recipient), (char **) 0)) != 0) {
            cp = saved_owners = mystrdup(owners);
-           while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
+           while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP,
+                                      VAR_SMTPD_SND_AUTH_MAPS)) != 0) {
                if (strcasecmp_utf8(state->sasl_username, name) == 0) {
                    found = 1;
                    break;
@@ -5920,7 +5937,7 @@ static int rest_update(char **argv)
 
 /* rest_class - (re)define a restriction class */
 
-static void rest_class(char *class)
+static void rest_class(const char *pname, char *class)
 {
     char   *cp = class;
     char   *name;
@@ -5929,13 +5946,14 @@ static void rest_class(char *class)
     if (smtpd_rest_classes == 0)
        smtpd_rest_classes = htable_create(1);
 
-    if ((name = mystrtok(&cp, CHARS_COMMA_SP)) == 0)
+    if ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, pname)) == 0)
        msg_panic("rest_class: null class name");
     if ((entry = htable_locate(smtpd_rest_classes, name)) != 0)
        argv_free((ARGV *) entry->value);
     else
        entry = htable_enter(smtpd_rest_classes, name, (void *) 0);
-    entry->value = (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, cp);
+    entry->value = (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL,
+                                             pname, cp);
 }
 
 /* resolve_clnt_init - initialize reply */
@@ -6334,7 +6352,7 @@ int     main(int argc, char **argv)
            }
 #endif
            if (strcasecmp(args->argv[0], "restriction_class") == 0) {
-               rest_class(args->argv[1]);
+               rest_class("restriction_class", args->argv[1]);
                resp = 0;
                break;
            }
index 09a35e0171d87b2868ec910638c5324d27cd85b7..772f4e7a512cc4804958979f1e44ccc32bb7d195 100644 (file)
@@ -79,6 +79,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -460,7 +462,9 @@ static int load_pem_bio(pem_load_state_t *st, int more)
 static int load_chain_files(SSL_CTX *ctx, const char *chain_files)
 {
     pem_load_state_t st;
-    ARGV   *files = argv_split(chain_files, CHARS_COMMA_SP);
+
+    /* XXX Which parameter to blame? */
+    ARGV   *files = argv_split_cw(chain_files, CHARS_COMMA_SP, "chain_files");
     char  **filep;
     int     ret = 0;
     int     more;
index a2b9b80d383de66d4077f46e5e47cd582c36d9ec..d2baf9cc87ca6bdd3f631b7deb2aae60ab2fc2de 100644 (file)
 /*     New York, NY 10011, USA
 /*
 /*     Viktor Dukhovni
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -418,7 +420,8 @@ static void dane_free(void *dane, void *unused_context)
 void    tls_dane_add_fpt_digests(TLS_DANE *dane, const char *digest,
                                         const char *delim, int smtp_mode)
 {
-    ARGV   *values = argv_split(digest, delim);
+    /* XXX Which parameter to blame? */
+    ARGV   *values = argv_split_cw(digest, delim, "fingerprint digests");
     ssize_t i;
 
     if (smtp_mode) {
@@ -850,7 +853,8 @@ void    tls_dane_digest_init(SSL_CTX *ctx, const EVP_MD *fpt_alg)
     maxtype = 2;
 
     save = cp = mystrdup(var_tls_dane_digests);
-    while ((algname = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
+    while ((algname = mystrtok_cw(&cp, CHARS_COMMA_SP,
+                                 VAR_TLS_DANE_DIGESTS)) != 0) {
        char   *algcode = split_at(algname, '=');
        int     codepoint = -1;
 
index f47b954617271c5adbcb93086e8708da4573583a..6d135f6d85ede553524e3cd482984aa606e19c16 100644 (file)
@@ -57,6 +57,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -304,11 +306,11 @@ void    tls_tmp_dh(SSL_CTX *ctx, int useauto)
 /* ------------------------------------- Common API */
 
 #define AG_STAT_OK     (0)
-#define AG_STAT_NO_GROUP (-1)  /* no usable group, may retry */
-#define AG_STAT_NO_RETRY (-2)  /* other error, don't retry */
+#define AG_STAT_NO_GROUP (-1)          /* no usable group, may retry */
+#define AG_STAT_NO_RETRY (-2)          /* other error, don't retry */
 
 static int setup_auto_groups(SSL_CTX *ctx, const char *origin,
-                               const char *eecdh,
+                                    const char *eecdh,
                                     const char *ffdhe)
 {
 #ifndef OPENSSL_NO_ECDH
@@ -335,12 +337,16 @@ static int setup_auto_groups(SSL_CTX *ctx, const char *origin,
     } while (0)
 
     groups = save = concatenate(eecdh, " ", ffdhe, NULL);
-    if ((group = mystrtok(&groups, CHARS_COMMA_SP)) == 0) {
+    /* XXX which parameter to blame? */
+    if ((group = mystrtok_cw(&groups, CHARS_COMMA_SP,
+                            "key exchange group")) == 0) {
        msg_warn("no %s key exchange group - OpenSSL requires at least one",
                 origin);
        SETUP_AG_RETURN(AG_STAT_NO_GROUP);
     }
-    for (; group != 0; group = mystrtok(&groups, CHARS_COMMA_SP)) {
+    /* XXX which parameter to blame? */
+    for (; group != 0; group = mystrtok_cw(&groups, CHARS_COMMA_SP,
+                                          "key exchange group")) {
        int     nid = EC_curve_nist2nid(group);
 
        if (nid == NID_undef)
@@ -405,7 +411,7 @@ void    tls_auto_groups(SSL_CTX *ctx, const char *eecdh, const char *ffdhe)
      * group selection is mere performance tuning and not security critical.
      * All the groups supported for negotiation should be strong enough.
      */
-    for (origin = "configured"; /* void */ ; /* void */) {
+    for (origin = "configured"; /* void */ ; /* void */ ) {
        switch (setup_auto_groups(ctx, origin, eecdh, ffdhe)) {
        case AG_STAT_OK:
            return;
index b7000cbab7ca80807c4073b04da771cf2924a844..e9a88c8664cd99cdb25b60ca04fd860244ed9b78 100644 (file)
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -611,7 +613,9 @@ int     tls_proto_mask_lims(const char *plist, int *floor, int *ceiling)
     *floor = *ceiling = 0;
 
     save = cp = mystrdup(plist);
-    while ((tok = mystrtok(&cp, CHARS_COMMA_SP ":")) != 0) {
+    /* XXX Which parameter to blame? */
+    while ((tok = mystrtok_cw(&cp, CHARS_COMMA_SP ":",
+                             "protocol exclusions")) != 0) {
        if (strncmp(tok, ">=", 2) == 0)
            code = parse_tls_version(tok + 2, floor);
        else if (strncmp(tok, "<=", 2) == 0)
@@ -833,7 +837,9 @@ const char *tls_set_ciphers(TLS_SESS_STATE *TLScontext, const char *grade,
 #define CIPHER_SEP CHARS_COMMA_SP ":"
     if (exclusions != 0) {
        cp = save = mystrdup(exclusions);
-       while ((tok = mystrtok(&cp, CIPHER_SEP)) != 0) {
+       /* XXX Which parameter to blame? */
+       while ((tok = mystrtok_cw(&cp, CIPHER_SEP,
+                                 "cipher exclusions")) != 0) {
 
            /*
             * Can't exclude ciphers that start with modifiers.
index b0098ce1303ab1f5ea0d55232c2f5bb48c6ec528..157b42b81a6750fb47b9cbf1f05c29f262221865 100644 (file)
@@ -20,7 +20,7 @@ typedef struct ARGV {
     char  **argv;                      /* string array */
 } ARGV;
 
-typedef int (*ARGV_COMPAR_FN)(const void *, const void *);
+typedef int (*ARGV_COMPAR_FN) (const void *, const void *);
 
 extern ARGV *argv_alloc(ssize_t);
 extern ARGV *argv_sort(ARGV *);                /* backwards compatibility */
@@ -36,13 +36,21 @@ extern void argv_delete(ARGV *, ssize_t, ssize_t);
 extern ARGV *argv_free(ARGV *);
 
 extern ARGV *argv_split(const char *, const char *);
+extern ARGV *argv_split_cw(const char *, const char *, const char *);
 extern ARGV *argv_split_count(const char *, const char *, ssize_t);
 extern ARGV *argv_split_append(ARGV *, const char *, const char *);
+extern ARGV *argv_split_append_cw(ARGV *, const char *, const char *, const char *);
+
+#define argv_split(cp, sp) argv_split_cw((cp), (sp), (char *) 0)
+#define argv_split_append(av, cp, sp) argv_split_append_cw((av), (cp), (sp), (char *) 0)
 
 extern ARGV *argv_splitq(const char *, const char *, const char *);
+extern ARGV *argv_splitq_cw(const char *, const char *, const char *, const char *);
 extern ARGV *argv_splitq_count(const char *, const char *, const char *, ssize_t);
 extern ARGV *argv_splitq_append(ARGV *, const char *, const char *, const char *);
 
+#define argv_splitq(cp, sp, pp) argv_splitq_cw((cp), (sp), (pp), (char *) 0)
+
 extern ARGV *argv_split_at(const char *, int);
 extern ARGV *argv_split_at_count(const char *, int, ssize_t);
 extern ARGV *argv_split_at_append(ARGV *, const char *, int);
@@ -73,6 +81,8 @@ extern ARGV *argv_split_at_append(ARGV *, const char *, int);
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 #endif
index a9f3afbdbaea8b6b99758cd00999beb18506e34e..0fd51c9b156283b1bc460ee21e39591180e74fb3 100644 (file)
 /*     const char *string;
 /*     const char *delim;
 /*
+/*     ARGV    *argv_split_cw(string, delim, blame)
+/*     const char *string;
+/*     const char *delim;
+/*     const char *blame;
+/*
 /*     ARGV    *argv_split_count(string, delim, count)
 /*     const char *string;
 /*     const char *delim;
 /*     ARGV    *argv;
 /*     const char *string;
 /*     const char *delim;
+/*
+/*     ARGV    *argv_split_append_cw(argv, string, delim, blame)
+/*     ARGV    *argv;
+/*     const char *string;
+/*     const char *delim;
+/*     const char *blame;
 /* DESCRIPTION
 /*     argv_split() breaks up \fIstring\fR into tokens according
 /*     to the delimiters specified in \fIdelim\fR. The result is
 /*     a null-terminated string array.
 /*
+/*     argv_split_cw() is like argv_split(), but stops splitting
+/*     input and logs a warning when it encounters text that looks
+/*     like a trailing comment. The \fBblame\fR argument specifies
+/*     context that is used in warning messages. Specify a null
+/*     pointer to disable the trailing comment check.
+/*
 /*     argv_split_count() is like argv_split() but stops splitting
 /*     input after at most \fIcount\fR -1 times and leaves the
 /*     remainder, if any, in the last array element. It is an error
 /*     to specify a count < 1.
-/* 
+/*
 /*     argv_split_append() performs the same operation as argv_split(),
 /*     but appends the result to an existing string array.
+/*
+/*     argv_split_append_cw() is like argv_split_append(), but
+/*     stops splitting input and logs a warning when it encounters
+/*     text that looks like a trailing comment. The \fBblame\fR
+/*     argument specifies context that is used in warning messages.
+/*     Specify a null pointer to disable the trailing comment
+/*     check.
 /* SEE ALSO
 /*     mystrtok(), safe string splitter.
 /* DIAGNOSTICS
@@ -44,6 +68,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System libraries. */
 #include "argv.h"
 #include "msg.h"
 
-/* argv_split - split string into token array */
+/* argv_split - ABI compatibility wrapper */
+
+#undef argv_split
 
 ARGV   *argv_split(const char *string, const char *delim)
+{
+    return (argv_split_cw(string, delim, (char *) 0));
+}
+
+/* argv_split_cw - split string into token array and complain about comment */
+
+ARGV   *argv_split_cw(const char *string, const char *delim, const char *blame)
 {
     ARGV   *argvp = argv_alloc(1);
     char   *saved_string = mystrdup(string);
     char   *bp = saved_string;
     char   *arg;
 
-    while ((arg = mystrtok(&bp, delim)) != 0)
+    while ((arg = mystrtok_cw(&bp, delim, blame)) != 0)
        argv_add(argvp, arg, (char *) 0);
     argv_terminate(argvp);
     myfree(saved_string);
@@ -96,15 +131,25 @@ ARGV   *argv_split_count(const char *string, const char *delim, ssize_t count)
     return (argvp);
 }
 
-/* argv_split_append - split string into token array, append to array */
+/* argv_split_append - ABI compatibility wrapper */
+
+#undef argv_split_append
 
 ARGV   *argv_split_append(ARGV *argvp, const char *string, const char *delim)
+{
+    return (argv_split_append_cw(argvp, string, delim, (char *) 0));
+}
+
+/* argv_split_append_cw - split string into token array, append to array */
+
+ARGV   *argv_split_append_cw(ARGV *argvp, const char *string, const char *delim,
+                                    const char *blame)
 {
     char   *saved_string = mystrdup(string);
     char   *bp = saved_string;
     char   *arg;
 
-    while ((arg = mystrtok(&bp, delim)) != 0)
+    while ((arg = mystrtok_cw(&bp, delim, blame)) != 0)
        argv_add(argvp, arg, (char *) 0);
     argv_terminate(argvp);
     myfree(saved_string);
index 3900ee117a8c84b03f33f1015b4a992925f1ac1e..39b04033a5f046f9df0a20a85b5c93a6bcaa8127 100644 (file)
 /*     const char *delim;
 /*     const char *parens;
 /*
+/*     ARGV    *argv_splitq_cw(string, delim, parens, blame)
+/*     const char *string;
+/*     const char *delim;
+/*     const char *parens;
+/*     const char *blame;
+/*
 /*     ARGV    *argv_splitq_count(string, delim, parens, count)
 /*     const char *string;
 /*     const char *delim;
 /*     splitting text between matching parentheses. The result is
 /*     a null-terminated string array.
 /*
+/*     argv_splitq_cw() is like argv_splitq() but stops splitting
+/*     input and logs a warning when it encounters text that looks
+/*     like a trailing comment. The \fBblame\fR argument specifies
+/*     context that is used in warning messages. Specify a null
+/*     pointer to disable the trailing comment check.
+/*
 /*     argv_splitq_count() is like argv_splitq() but stops splitting
 /*     input after at most \fIcount\fR -1 times and leaves the
 /*     remainder, if any, in the last array element. It is an error
@@ -48,6 +60,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System libraries. */
 #include "argv.h"
 #include "msg.h"
 
-/* argv_splitq - split string into token array */
+/* argv_splitq - ABI compatibility wrapper */
+
+#undef argv_splitq
 
 ARGV   *argv_splitq(const char *string, const char *delim, const char *parens)
+{
+    return (argv_splitq_cw(string, delim, parens, (char *) 0));
+}
+
+/* argv_splitq_cw - split string into token array */
+
+ARGV   *argv_splitq_cw(const char *string, const char *delim,
+                              const char *parens, const char *blame)
 {
     ARGV   *argvp = argv_alloc(1);
     char   *saved_string = mystrdup(string);
     char   *bp = saved_string;
     char   *arg;
 
-    while ((arg = mystrtokq(&bp, delim, parens)) != 0)
+    while ((arg = mystrtokq_cw(&bp, delim, parens, blame)) != 0)
        argv_add(argvp, arg, (char *) 0);
     argv_terminate(argvp);
     myfree(saved_string);
index c6ea74c9af12c1e2aa51c81ad488b84681a02ad3..054e4b37a185dbbb22248ef3bd14dac278b59eb6 100644 (file)
@@ -70,6 +70,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -114,7 +116,7 @@ VSTRING *dict_file_to_buf(DICT *dict, const char *pathnames)
        return (retval); \
     } while (0);
 
-    argv = argv_split(pathnames, CHARS_COMMA_SP);
+    argv = argv_split_cw(pathnames, CHARS_COMMA_SP, dict->name);
     if (argv->argc == 0) {
        vstring_sprintf(dict->file_buf, "empty pathname list: >>%s<<'",
                        pathnames);
index 72339b2b2fbb681f2b49a26ec78c6a331f977e5c..2b5ccf9c2612f6ef93f323d3a14b71998710fcb2 100644 (file)
@@ -31,6 +31,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -112,7 +114,8 @@ DICT   *dict_inline_open(const char *name, int open_flags, int dict_flags)
      */
     dict = dict_open3(DICT_TYPE_HT, name, open_flags, dict_flags);
     dict_type_override(dict, DICT_TYPE_INLINE);
-    while ((nameval = mystrtokq(&cp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) {
+    while ((nameval = mystrtokq_cw(&cp, CHARS_COMMA_SP, CHARS_BRACE,
+                                  name)) != 0) {
        if (nameval[0] == CHARS_BRACE[0])
            err = free_me = extpar(&nameval, CHARS_BRACE, EXTPAR_FLAG_STRIP);
        if (err != 0 || (err = split_qnameval(nameval, &vname, &value)) != 0)
index 8ce0faad728d5f973fc2718bbe2917b6670997a5..7c4cec6663511e88968405f907a5cf4730b7f7db 100644 (file)
@@ -37,6 +37,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -141,8 +143,8 @@ DICT   *dict_pipe_open(const char *name, int open_flags, int dict_flags)
      */
     if ((len = balpar(name, CHARS_BRACE)) == 0 || name[len] != 0
        || *(saved_name = mystrndup(name + 1, len - 2)) == 0
-       || ((argv = argv_splitq(saved_name, CHARS_COMMA_SP, CHARS_BRACE)),
-           (argv->argc == 0)))
+       || ((argv = argv_splitq_cw(saved_name, CHARS_COMMA_SP, CHARS_BRACE,
+                                  name)), (argv->argc == 0)))
        DICT_PIPE_RETURN(dict_surrogate(DICT_TYPE_PIPE, name,
                                        open_flags, dict_flags,
                                        "bad syntax: \"%s:%s\"; "
index 36f79b355c39b9e48ac92f3fadee54f32a1f69a4..95b724422609e3e2aebc56a4f3476ed4e8f0bfa1 100644 (file)
@@ -36,6 +36,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -93,7 +95,7 @@ static char *dict_random_parse_name(DICT *dict, ARGV **argv,
     VSTRING *b64 = 0;
     char   *err = 0;
 
-    while ((arg = mystrtokq(&bp, delim, parens)) != 0) {
+    while ((arg = mystrtokq_cw(&bp, delim, parens, string)) != 0) {
        if (dict->flags & DICT_FLAG_SRC_RHS_IS_FILE) {
            if ((b64 = dict_file_to_b64(dict, arg)) != 0) {
                argv_add(argvp, vstring_str(b64), (char *) 0);
index e28ad71fd4a08827d524be7ced18d6da69a788a3..a2f09f89fdd03f7a9ccd6ef11b4125ac9db82ecd 100644 (file)
@@ -51,7 +51,7 @@
 /*     content as specified above.
 /* .IP st
 /*     File metadata with the file owner, or fake metadata with the
-/*     real UID and GID of the dict_stream_open() caller. This is 
+/*     real UID and GID of the dict_stream_open() caller. This is
 /*     used for "taint" tracking (zero=trusted, non-zero=untrusted).
 /* IP why
 /*     Pointer to pointer to error message storage. dict_stream_open()
@@ -66,6 +66,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
  /*
@@ -98,7 +100,8 @@ static char *dict_inline_to_multiline(VSTRING *vp, const char *mapname)
     /* Strip the {} from the map "name". */
     err = extpar(&bp, CHARS_BRACE, EXTPAR_FLAG_NONE);
     /* Extract zero or more rules inside {}. */
-    while (err == 0 && (cp = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0)
+    while (err == 0
+     && (cp = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, mapname)) != 0)
        if ((err = extpar(&cp, CHARS_BRACE, EXTPAR_FLAG_STRIP)) == 0)
            /* Write rule to in-memory file. */
            vstring_sprintf_append(vp, "%s\n", cp);
index 80df03b61717d7ea943ef5768de361789d63e7c7..989950c7805ae5e9e5b0d929dae2d63d813ece5c 100644 (file)
@@ -41,6 +41,8 @@
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -154,8 +156,8 @@ DICT   *dict_union_open(const char *name, int open_flags, int dict_flags)
      */
     if ((len = balpar(name, CHARS_BRACE)) == 0 || name[len] != 0
        || *(saved_name = mystrndup(name + 1, len - 2)) == 0
-       || ((argv = argv_splitq(saved_name, CHARS_COMMA_SP, CHARS_BRACE)),
-           (argv->argc == 0)))
+       || ((argv = argv_splitq_cw(saved_name, CHARS_COMMA_SP, CHARS_BRACE,
+                                  name)), (argv->argc == 0)))
        DICT_UNION_RETURN(dict_surrogate(DICT_TYPE_UNION, name,
                                         open_flags, dict_flags,
                                         "bad syntax: \"%s:%s\"; "
index 520485dd0ca6146d5b8ee3163fa23004733436ca..d8f22f0970c6062fbaa83b82b7274d6448e2e42b 100644 (file)
@@ -84,6 +84,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -145,12 +147,8 @@ static ARGV *match_list_parse(MATCH_LIST *match_list, ARGV *pat_list,
      * If there is an error, implement graceful degradation by inserting a
      * pseudo table whose lookups fail with a warning message.
      */
-    while ((start = mystrtokq(&bp, delim, CHARS_BRACE)) != 0) {
-       if (*start == '#') {
-           msg_warn("%s: comment at end of line is not supported: %s %s",
-                    match_list->pname, start, bp);
-           break;
-       }
+    while ((start = mystrtokq_cw(&bp, delim, CHARS_BRACE,
+                                match_list->pname)) != 0) {
        for (match = init_match, item = start; *item == '!'; item++)
            match = !match;
        if (*item == 0)
index 85b15f3b3f1f433ad5b4a5cdfe1e2a1aef1da05d..a1c743cee54066303eed6a347c2cfdca0ba52a3e 100644 (file)
 /*     char    *mystrtokdq(bufp, delimiters)
 /*     char    **bufp;
 /*     const char *delimiters;
+/*
+/*     char    *mystrtok_cw(bufp, delimiters, blame)
+/*     char    **bufp;
+/*     const char *delimiters;
+/*     const char *blame;
+/*
+/*     char    *mystrtokq_cw(bufp, delimiters, parens, blame)
+/*     char    **bufp;
+/*     const char *delimiters;
+/*     const char *parens;
+/*     const char *blame;
+/*
+/*     char    *mystrtokdq_cw(bufp, delimiters, blame)
+/*     char    **bufp;
+/*     const char *delimiters;
+/*     const char *blame;
 /* DESCRIPTION
 /*     mystrtok() splits a buffer on the specified \fIdelimiters\fR.
 /*     Tokens are delimited by runs of delimiters, so this routine
 /*
 /*     The result value is the next token, or a null pointer when the
 /*     end of the buffer was reached.
+/*
+/*     mystrtok_cw(), mystrtokq_cw(), and mystrtokdq_cw, log a
+/*     warning and return null when the result would look like
+/*     comment. The \fBblame\fR argument provides context for
+/*     warning messages. Specify a null pointer to disable the
+/*     comment check.
 /* LICENSE
 /* .ad
 /* .fi
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
 
-#include "sys_defs.h"
+#include <sys_defs.h>
 #include <string.h>
 
 /* Utility library. */
 
-#include "stringops.h"
+#include <msg.h>
+#include <stringops.h>
 
-/* mystrtok - safe tokenizer */
+/* mystrtok_warn - warn for #comment after other text */
+
+static void mystrtok_warn(const char *start, const char *bufp, const char *blame)
+{
+    msg_warn("%s: #comment after other text is not allowed: %s %s",
+            blame, start, bufp);
+}
+
+/* mystrtok - ABI compatibility wrapper */
+
+#undef mystrtok
 
 char   *mystrtok(char **src, const char *sep)
+{
+    return (mystrtok_cw(src, sep, (char *) 0));
+}
+
+/* mystrtok - safe tokenizer */
+
+char   *mystrtok_cw(char **src, const char *sep, const char *blame)
 {
     char   *start = *src;
     char   *end;
@@ -86,12 +128,28 @@ char   *mystrtok(char **src, const char *sep)
     if (*end != 0)
        *end++ = 0;
     *src = end;
-    return (start);
+
+    if (blame && *start == '#') {
+       mystrtok_warn(start, *src, blame);
+       return (0);
+    } else {
+       return (start);
+    }
 }
 
-/* mystrtokq - safe tokenizer with quoting support */
+/* mystrtokq - ABI compatibility wrapper */
+
+#undef mystrtokq
 
 char   *mystrtokq(char **src, const char *sep, const char *parens)
+{
+    return (mystrtokq_cw(src, sep, parens, (char *) 0));
+}
+
+/* mystrtokq_cw - safe tokenizer with quoting support */
+
+char   *mystrtokq_cw(char **src, const char *sep, const char *parens,
+                            const char *blame)
 {
     char   *start = *src;
     static char *cp;
@@ -121,12 +179,30 @@ char   *mystrtokq(char **src, const char *sep, const char *parens)
        }
     }
     *src = cp;
-    return (start);
+
+    /*
+     * Optional detect a comment.
+     */
+    if (blame && *start == '#') {
+       mystrtok_warn(start, *src, blame);
+       return (0);
+    } else {
+       return (start);
+    }
 }
 
-/* mystrtokdq - safe tokenizer, double quote and backslash support */
+/* mystrtokdq - ABI compatibility wrapper */
+
+#undef mystrtokdq
 
 char   *mystrtokdq(char **src, const char *sep)
+{
+    return (mystrtokdq_cw(src, sep, (char *) 0));
+}
+
+/* mystrtokdq_cw - safe tokenizer, double quote and backslash support */
+
+char   *mystrtokdq_cw(char **src, const char *sep, const char *blame)
 {
     char   *cp = *src;
     char   *start;
@@ -157,7 +233,12 @@ char   *mystrtokdq(char **src, const char *sep)
        }
     }
     *src = cp;
-    return (start);
+    if (blame && start && *start == '#') {
+       mystrtok_warn(start, *src, blame);
+       return (0);
+    } else {
+       return (start);
+    }
 }
 
 #ifdef TEST
@@ -195,6 +276,12 @@ static const struct testcase testcases[] = {
     {"mystrtokdq", "  foo\\ bar  ", {"foo\\ bar"}},
     {"mystrtokdq", "  foo \\\" bar", {"foo", "\\\"", "bar"}},
     {"mystrtokdq", "  foo \" bar baz\"  ", {"foo", "\" bar baz\""}},
+    {"mystrtok_cw", "#after text"},
+    {"mystrtok_cw", "before-text #after text", {"before-text"}},
+    {"mystrtokq_cw", "#after text"},
+    {"mystrtokq_cw", "{ before text } #after text", "{ before text }"},
+    {"mystrtokdq_cw", "#after text"},
+    {"mystrtokdq_cw", "\"before text\" #after text", {"\"before text\""}},
 };
 
 int     main(void)
@@ -229,6 +316,12 @@ int     main(void)
                actual = mystrtokq(&cp, CHARS_SPACE, CHARS_BRACE);
            } else if (strcmp(tp->action, "mystrtokdq") == 0) {
                actual = mystrtokdq(&cp, CHARS_SPACE);
+           } else if (strcmp(tp->action, "mystrtok_cw") == 0) {
+               actual = mystrtok_cw(&cp, CHARS_SPACE, "test");
+           } else if (strcmp(tp->action, "mystrtokq_cw") == 0) {
+               actual = mystrtokq_cw(&cp, CHARS_SPACE, CHARS_BRACE, "test");
+           } else if (strcmp(tp->action, "mystrtokdq_cw") == 0) {
+               actual = mystrtokdq_cw(&cp, CHARS_SPACE, "test");
            } else {
                msg_panic("invalid command: %s", tp->action);
            }
index 4f920f994d6964bd1693187e0b8657a28b02cc58..6e0eae801e229b1ea32d258a810210d1ec450b7d 100644 (file)
@@ -28,3 +28,21 @@ unknown: RUN test case 13 mystrtokdq >  foo \" bar<
 unknown: PASS test 13
 unknown: RUN test case 14 mystrtokdq >  foo " bar baz"  <
 unknown: PASS test 14
+unknown: RUN test case 15 mystrtok_cw >#after text<
+unknown: warning: test: #comment after other text is not allowed: #after text
+unknown: PASS test 15
+unknown: RUN test case 16 mystrtok_cw >before-text #after text<
+unknown: warning: test: #comment after other text is not allowed: #after text
+unknown: PASS test 16
+unknown: RUN test case 17 mystrtokq_cw >#after text<
+unknown: warning: test: #comment after other text is not allowed: #after text
+unknown: PASS test 17
+unknown: RUN test case 18 mystrtokq_cw >{ before text } #after text<
+unknown: warning: test: #comment after other text is not allowed: #after text
+unknown: PASS test 18
+unknown: RUN test case 19 mystrtokdq_cw >#after text<
+unknown: warning: test: #comment after other text is not allowed: #after text
+unknown: PASS test 19
+unknown: RUN test case 20 mystrtokdq_cw >"before text" #after text<
+unknown: warning: test: #comment after other text is not allowed: #after text
+unknown: PASS test 20
index 284d4fa9d308c166f08e47e69d820fd16473affb..90404de98c016517d901e1d9ecb4cfce6ee3a814 100644 (file)
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -228,7 +230,7 @@ int     name_mask_delim_opt(const char *context, const NAME_MASK *table,
      * Break up the names string, and look up each component in the table. If
      * the name is found, merge its mask with the result.
      */
-    while ((name = mystrtok(&bp, delim)) != 0) {
+    while ((name = mystrtok_cw(&bp, delim, context)) != 0) {
        for (np = table; /* void */ ; np++) {
            if (np->name == 0) {
                if ((flags & NAME_MASK_NUMBER)
@@ -316,7 +318,7 @@ const char *str_name_mask_opt(VSTRING *buf, const char *context,
 /* long_name_mask_delim_opt - compute mask corresponding to list of names */
 
 long    long_name_mask_delim_opt(const char *context,
-                                        const LONG_NAME_MASK * table,
+                                        const LONG_NAME_MASK *table,
                                       const char *names, const char *delim,
                                         int flags)
 {
@@ -342,7 +344,7 @@ long    long_name_mask_delim_opt(const char *context,
      * Break up the names string, and look up each component in the table. If
      * the name is found, merge its mask with the result.
      */
-    while ((name = mystrtok(&bp, delim)) != 0) {
+    while ((name = mystrtok_cw(&bp, delim, context)) != 0) {
        for (np = table; /* void */ ; np++) {
            if (np->name == 0) {
                if ((flags & NAME_MASK_NUMBER)
@@ -378,7 +380,7 @@ long    long_name_mask_delim_opt(const char *context,
 /* str_long_name_mask_opt - mask to string */
 
 const char *str_long_name_mask_opt(VSTRING *buf, const char *context,
-                                          const LONG_NAME_MASK * table,
+                                          const LONG_NAME_MASK *table,
                                           long mask, int flags)
 {
     const char *myname = "name_mask";
index 739e0125bc5184531f31302bbf55f26e5a2525b1..8a396a593e2eeb94a0b758e673a9fc1e1dd4b74e 100644 (file)
@@ -73,6 +73,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -276,7 +278,8 @@ WAIT_STATUS_T spawn_command(int key,...)
            execvp(args.argv[0], args.argv);
            msg_fatal("%s: execvp %s: %m", myname, args.argv[0]);
        } else if (args.shell && *args.shell) {
-           argv = argv_split(args.shell, CHARS_SPACE);
+           /* XXX Which parameter to blame? */
+           argv = argv_split_cw(args.shell, CHARS_SPACE, "command_shell");
            argv_add(argv, args.command, (char *) 0);
            argv_terminate(argv);
            execvp(argv->argv[0], argv->argv);
index 8ac177b9258c9a51eee7420dcafa225b6caf52d8..cd9b5753b7ddc348f27a60455865cec5552e7d76 100644 (file)
@@ -31,8 +31,15 @@ extern char *concatenate(const char *,...);
 extern char *mystrtok(char **, const char *);
 extern char *mystrtokq(char **, const char *, const char *);
 extern char *mystrtokdq(char **, const char *);
+extern char *mystrtok_cw(char **, const char *, const char *);
+extern char *mystrtokq_cw(char **, const char *, const char *, const char *);
+extern char *mystrtokdq_cw(char **, const char *, const char *);
 extern char *translit(char *, const char *, const char *);
 
+#define mystrtok(cp, sp) mystrtok_cw((cp), (sp), (char *) 0)
+#define mystrtokq(cp, sp, pp) mystrtokq_cw((cp), (sp), (pp), (char *) 0)
+#define mystrtokdq(cp, sp) mystrtokdq_cw((cp), (sp), (char *) 0)
+
 #define printable(string, replacement) \
        printable_except((string), (replacement), (char *) 0)
 
@@ -102,6 +109,8 @@ extern int strncasecmp_utf8x(int, const char *, const char *, ssize_t);
 /*     Google, Inc.
 /*     111 8th Avenue
 /*     New York, NY 10011, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 #endif
index d00d49e66bf4709eeb498b7488e072c058e5d82c..9e246ae5d611bcdc7e8fce72234131fb1c445959 100644 (file)
@@ -82,6 +82,8 @@
 /*     IBM T.J. Watson Research
 /*     P.O. Box 704
 /*     Yorktown Heights, NY 10598, USA
+/*
+/*     Wietse Venema
 /*--*/
 
 /* System library. */
@@ -255,7 +257,8 @@ VSTREAM *vstream_popen(int flags,...)
            execvp(args.argv[0], args.argv);
            msg_fatal("%s: execvp %s: %m", myname, args.argv[0]);
        } else if (args.shell && *args.shell) {
-           argv = argv_split(args.shell, CHARS_SPACE);
+           /* XXX Which parameter to blame? */
+           argv = argv_split_cw(args.shell, CHARS_SPACE, "command_shell");
            argv_add(argv, args.command, (char *) 0);
            argv_terminate(argv);
            execvp(argv->argv[0], argv->argv);