]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.0.16-20031204
authorWietse Venema <wietse@porcupine.org>
Thu, 4 Dec 2003 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:29:17 +0000 (06:29 +0000)
postfix/.indent.pro
postfix/HISTORY
postfix/conf/post-install
postfix/src/anvil/anvil.c
postfix/src/global/mail_version.h
postfix/src/smtpd/smtpd.c
postfix/src/smtpd/smtpd_xclient.c
postfix/src/util/Makefile.in
postfix/src/util/attr_print_plain.c
postfix/src/util/name_code.c [new file with mode: 0644]
postfix/src/util/name_code.h [new file with mode: 0644]

index 6c4de13ef8388f85936b7334651f473f186db388..2a0bd5bd347743bd6941ca4fbe52ccd6b285d466 100644 (file)
 -TMYSQL
 -TMYSQL_NAME
 -TNAMADR_LIST
+-TNAME_CODE
 -TNAME_MASK
 -TPEER_NAME
 -TPGSQL_NAME
index 4cdfb467c250682a1c1dfa4331b972d704ecec3a..483a03b8555a8329e6d7c7eff9b50b27c9a6be18 100644 (file)
@@ -8804,6 +8804,14 @@ Apologies for any names omitted.
        is accepted (and thus, before a cleanup server connection
        is available).  Files:  smtpd/{smtpd,smtpd_state,smtpd_check}.c.
 
+20031204
+
+       Bugfix: conf/post-install didn't skip non-existent obsolete
+       files.  Victor Duchovni.
+
+       Minor cleanups of the xclient error messages; xclient
+       command lookup tables. File: smtpd/smtpd.c.
+
 Open problems:
 
        High: when virtual aliasing is turned off after content
index 7f1a1f3afad2a5edb9d278c0cf4bb08b8c129718..6cb0c4ed3800c1f358004e5066ad534af540c155 100644 (file)
@@ -425,9 +425,9 @@ test -n "$create" && {
        case $flags in *r*) recursive="-R";; *) recursive=;; esac
        case $flags in *o*) obsolete_flag=1;; *) obsolete_flag=;; esac
        # Flag obsolete objects. XXX Solaris 2..9 does not have "test -e".
-       if [ -n "$obsolete_flag" -a -r $path ]
+       if [ -n "$obsolete_flag" ]
        then
-           obsolete="$obsolete $path"
+           test -r $path && obsolete="$obsolete $path"
            continue;
        fi
        # Create missing directories with proper owner/group/mode settings.
index 0502d38866a68628180f2ff66cddb6e0f9c3b22f..80cd3a0e227620f0133dfecb6c0a27459ff4b9e7 100644 (file)
@@ -289,6 +289,10 @@ static void anvil_remote_expire(int unused_event, char *context)
     htable_delete(anvil_remote_map, anvil_remote->ident,
                  (void (*) (char *)) 0);
     ANVIL_REMOTE_FREE(anvil_remote);
+
+    if (msg_verbose)
+       msg_info("%s: anvil_remote_map used=%d", 
+               myname, anvil_remote_map->used);
 }
 
 /* anvil_remote_lookup - dump address status */
@@ -491,6 +495,10 @@ static void anvil_service_done(VSTREAM *client_stream, char *unused_service,
     } else if (msg_verbose)
        msg_info("client socket not found for fd=%d",
                 vstream_fileno(client_stream));
+
+    if (msg_verbose)
+       msg_info("%s: anvil_local_map used=%d", 
+               myname, anvil_local_map->used);
 }
 
 /* anvil_service - perform service for client */
index 73de6a5f411f2ce3f171b10450bcbb90e44a3dd0..f47afcf293f560d59ef22f80e920e3aa6232b37c 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change the patchlevel and the release date. Snapshots change the
   * release date only, unless they include the same bugfix as a patch release.
   */
-#define MAIL_RELEASE_DATE      "20031203"
+#define MAIL_RELEASE_DATE      "20031204"
 
 #define VAR_MAIL_VERSION       "mail_version"
 #define DEF_MAIL_VERSION       "2.0.16-" MAIL_RELEASE_DATE
index f80e2c39b9b2c0ea7ba0124f8d64b2cf78f5eb4d..07d69080281299944d5dc3e2e0f194e13f830213 100644 (file)
 #include <watchdog.h>
 #include <iostuff.h>
 #include <split_at.h>
+#include <name_code.h>
 
 /* Global library. */
 
@@ -1758,6 +1759,18 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
     char   *arg_val;
     int     update_namaddr = 0;
     int     function;
+    int     code;
+    static NAME_CODE xclient_functions[] = {
+       XCLIENT_OVERRIDE, FUNC_OVERRIDE,
+       XCLIENT_FORWARD, FUNC_FORWARD,
+       0, -1,
+    };
+    static NAME_CODE xclient_codes[] = {
+       "OK", SMTPD_PEER_CODE_OK,
+       "PERM", SMTPD_PEER_CODE_PERM,
+       "TEMP", SMTPD_PEER_CODE_TEMP,
+       0, -1,
+    };
 
     /*
      * Sanity checks. The XCLIENT command does not override its own access
@@ -1787,18 +1800,14 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
      */
     arg_val = argv[1].strval;
     printable(arg_val, '?');
-    if (STREQ(arg_val, XCLIENT_OVERRIDE)) {
-       function = FUNC_OVERRIDE;
-    } else if (STREQ(arg_val, XCLIENT_FORWARD)) {
-       function = FUNC_FORWARD;
-       if (state->xclient.used == 0)
-           smtpd_xclient_preset(state);
-    } else {                                   /* error */
+    if ((function = name_code(xclient_functions, arg_val)) < 0) {
        state->error_mask |= MAIL_ERROR_PROTOCOL;
        smtpd_chat_reply(state, "501 Bad %s function: %s",
                         XCLIENT_CMD, arg_val);
        return (-1);
     }
+    if (function == FUNC_FORWARD && state->xclient.used == 0)
+       smtpd_xclient_preset(state);
 
     /*
      * Iterate over all NAME=VALUE attributes. An empty value means the
@@ -1844,8 +1853,8 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
            if (*raw_value && !valid_hostaddr(cooked_value, DONT_GRIPE)) {
                if (!valid_hostname(cooked_value, DONT_GRIPE)) {
                    state->error_mask |= MAIL_ERROR_PROTOCOL;
-                   smtpd_chat_reply(state, "501 Bad hostname syntax: %s",
-                                    cooked_value);
+                   smtpd_chat_reply(state, "501 Bad %s syntax: %s",
+                                    XCLIENT_NAME, raw_value);
                    return (-1);
                }
                UPD_STR_ATTR(state, function, name, cooked_value);
@@ -1864,8 +1873,8 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
            if (*raw_value) {
                if (!valid_hostaddr(cooked_value, DONT_GRIPE)) {
                    state->error_mask |= MAIL_ERROR_PROTOCOL;
-                   smtpd_chat_reply(state, "501 Bad address syntax: %s",
-                                    cooked_value);
+                   smtpd_chat_reply(state, "501 Bad %s syntax: %s",
+                                    XCLIENT_ADDR, raw_value);
                    return (-1);
                }
                UPD_STR_ATTR(state, function, addr, cooked_value);
@@ -1880,21 +1889,18 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
         * the hostname lookup status is not OK.
         */
        else if (STREQ(arg_val, XCLIENT_CODE)) {
-           if (STREQ(cooked_value, "OK")) {
-               UPD_INT_ATTR(state, function, peer_code, SMTPD_PEER_CODE_OK);
-           } else if (STREQ(cooked_value, "TEMP")) {
-               UPD_INT_ATTR(state, function, peer_code, SMTPD_PEER_CODE_TEMP);
-               UPD_STR_ATTR(state, function, name, CLIENT_NAME_UNKNOWN);
-               update_namaddr = 1;
-           } else if (STREQ(cooked_value, "PERM")) {
-               UPD_INT_ATTR(state, function, peer_code, SMTPD_PEER_CODE_PERM);
-               UPD_STR_ATTR(state, function, name, CLIENT_NAME_UNKNOWN);
-               update_namaddr = 1;
-           } else {
-               state->error_mask |= MAIL_ERROR_PROTOCOL;
-               smtpd_chat_reply(state, "501 Bad hostname status: %s",
-                                cooked_value);
-               return (-1);
+           if (*raw_value) {
+               if ((code = name_code(xclient_codes, cooked_value)) < 0) {
+                   state->error_mask |= MAIL_ERROR_PROTOCOL;
+                   smtpd_chat_reply(state, "501 Bad %s value: %s",
+                                    XCLIENT_CODE, raw_value);
+                   return (-1);
+               }
+               UPD_INT_ATTR(state, function, peer_code, code);
+               if (code != SMTPD_PEER_CODE_OK) {
+                   UPD_STR_ATTR(state, function, name, CLIENT_NAME_UNKNOWN);
+                   update_namaddr = 1;
+               }
            }
        }
 
@@ -1906,8 +1912,8 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
            if (*raw_value) {
                if (strlen(cooked_value) > VALID_HOSTNAME_LEN) {
                    state->error_mask |= MAIL_ERROR_PROTOCOL;
-                   smtpd_chat_reply(state, "501 Bad HELO syntax: %s",
-                                    cooked_value);
+                   smtpd_chat_reply(state, "501 Bad %s syntax: %s",
+                                    XCLIENT_HELO, raw_value);
                    return (-1);
                }
                neuter(cooked_value, "<>()\\\";:@", '?');
@@ -1925,8 +1931,8 @@ static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
            if (*raw_value) {
                if (*cooked_value == 0 || strlen(cooked_value) > 64) {
                    state->error_mask |= MAIL_ERROR_PROTOCOL;
-                   smtpd_chat_reply(state, "501 Bad protocol syntax: %s",
-                                    cooked_value);
+                   smtpd_chat_reply(state, "501 Bad %s syntax: %s",
+                                    XCLIENT_PROTO, raw_value);
                    return (-1);
                }
                neuter(cooked_value, "[]<>()\\\";:@", '?');
index 874b7570ed60dccd8c65a9ceae46dfb877350335..f8688111cc46c731e5c067cd10dc870d8a114bc3 100644 (file)
@@ -18,7 +18,7 @@
 /*     smtpd_xclient_preset() takes the result from smtpd_xclient_init()
 /*     and sets all fields to the same "unknown" value that regular
 /*     client attributes would have.
-*/
+/*
 /*     smtpd_xclient_reset() restores the state from smtpd_xclient_init().
 /* LICENSE
 /* .ad
index efdd532e4e0cdd3ca41b9d87ff30e70204dcf4a7..112c7d766a964954fd953ff88f5cee51a3440cc7 100644 (file)
@@ -27,7 +27,7 @@ SRCS  = alldig.c argv.c argv_split.c attr_print0.c attr_print64.c \
        username.c valid_hostname.c vbuf.c vbuf_print.c vstream.c \
        vstream_popen.c vstring.c vstring_vstream.c watchdog.c writable.c \
        write_buf.c write_wait.c auto_clnt.c attr_clnt.c attr_scan_plain.c \
-       attr_print_plain.c sane_connect.c neuter.c
+       attr_print_plain.c sane_connect.c neuter.c name_code.c
 OBJS   = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \
        attr_scan0.o attr_scan64.o base64_code.o basename.o binhash.o \
        chroot_uid.o clean_env.o close_on_exec.o concatenate.o ctable.o \
@@ -56,7 +56,7 @@ OBJS  = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \
        username.o valid_hostname.o vbuf.o vbuf_print.o vstream.o \
        vstream_popen.o vstring.o vstring_vstream.o watchdog.o writable.o \
        write_buf.o write_wait.o auto_clnt.o attr_clnt.o attr_scan_plain.o \
-       attr_print_plain.o sane_connect.o $(STRCASE) neuter.o
+       attr_print_plain.o sane_connect.o $(STRCASE) neuter.o name_code.o
 HDRS   = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \
        connect.h ctable.h dict.h dict_db.h dict_dbm.h dict_env.h \
        dict_cidr.h dict_ht.h dict_ldap.h dict_mysql.h dict_ni.h dict_nis.h \
@@ -75,7 +75,7 @@ HDRS  = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \
        split_at.h stat_as.h stringops.h sys_defs.h timed_connect.h \
        timed_wait.h trigger.h username.h valid_hostname.h vbuf.h \
        vbuf_print.h vstream.h vstring.h vstring_vstream.h watchdog.h \
-       auto_clnt.h attr_clnt.h sane_connect.h
+       auto_clnt.h attr_clnt.h sane_connect.h name_code.h
 TESTSRC        = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \
        stream_test.c dup2_pass_on_exec.c
 DEFS   = -I. -D$(SYSTYPE)
@@ -485,8 +485,6 @@ attr_print_plain.o: mymalloc.h
 attr_print_plain.o: vstream.h
 attr_print_plain.o: vbuf.h
 attr_print_plain.o: htable.h
-attr_print_plain.o: base64_code.h
-attr_print_plain.o: vstring.h
 attr_print_plain.o: attr.h
 attr_scan0.o: attr_scan0.c
 attr_scan0.o: sys_defs.h
@@ -1028,6 +1026,9 @@ mystrtok.o: sys_defs.h
 mystrtok.o: stringops.h
 mystrtok.o: vstring.h
 mystrtok.o: vbuf.h
+name_code.o: name_code.c
+name_code.o: sys_defs.h
+name_code.o: name_code.h
 name_mask.o: name_mask.c
 name_mask.o: sys_defs.h
 name_mask.o: msg.h
index 89054b248182c38f09a66bc0c1bca909937e84ea..7b898950592b68d40f715ababbbfb9caaefe93ff 100644 (file)
@@ -88,7 +88,6 @@
 #include <mymalloc.h>
 #include <vstream.h>
 #include <htable.h>
-#include <base64_code.h>
 #include <attr.h>
 
 #define STR(x) vstring_str(x)
diff --git a/postfix/src/util/name_code.c b/postfix/src/util/name_code.c
new file mode 100644 (file)
index 0000000..ece60c0
--- /dev/null
@@ -0,0 +1,82 @@
+/*++
+/* NAME
+/*     name_code 3
+/* SUMMARY
+/*     name to number table mapping
+/* SYNOPSIS
+/*     #include <name_code.h>
+/*
+/*     typedef struct {
+/* .in +4
+/*             const char *name;
+/*             int code;
+/* .in -4
+/*     } NAME_CODE;
+/*
+/*     int     name_code(table, name)
+/*     NAME_CODE *table;
+/*     const char *name;
+/*
+/*     const char *str_name_code(table, code)
+/*     NAME_CODE *table;
+/*     int     code;
+/* DESCRIPTION
+/*     This module does simple name<->number mapping. The process
+/*     is controlled by a table of (name, code) values.
+/*     The table is terminated with a null pointer and a code that
+/*     corresponds to "name not found".
+/*
+/*     name_code() looks up the code that corresponds with the name.
+/*     The lookup is case insensitive.
+/*
+/*     str_name_code() translates a number to its equivalend string.
+/* DIAGNOSTICS
+/*     When the search fails, the result is the "name not found" code
+/*     or the null pointer, respectively.
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Wietse Venema
+/*     IBM T.J. Watson Research
+/*     P.O. Box 704
+/*     Yorktown Heights, NY 10598, USA
+/*--*/
+
+/* System library. */
+
+#include <sys_defs.h>
+#include <string.h>
+
+#ifdef STRCASECMP_IN_STRINGS_H
+#include <strings.h>
+#endif
+
+/* Utility library. */
+
+#include <name_code.h>
+
+/* name_code - look up code by name */
+
+int     name_code(NAME_CODE *table, const char *name)
+{
+    NAME_CODE *np;
+
+    for (np = table; np->name; np++)
+       if (strcasecmp(name, np->name) == 0)
+           break;
+    return (np->code);
+}
+
+/* str_name_code - look up name by code */
+
+const char *str_name_code(NAME_CODE *table, int code)
+{
+    NAME_CODE *np;
+
+    for (np = table; np->name; np++)
+       if (code == np->code)
+           break;
+    return (np->name);
+}
diff --git a/postfix/src/util/name_code.h b/postfix/src/util/name_code.h
new file mode 100644 (file)
index 0000000..6722eee
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef _NAME_CODE_H_INCLUDED_
+#define _NAME_CODE_H_INCLUDED_
+
+/*++
+/* NAME
+/*     name_mask 3h
+/* SUMMARY
+/*     name to number table mapping
+/* SYNOPSIS
+/*     #include <name_code.h>
+/* DESCRIPTION
+/* .nf
+
+ /*
+  * External interface.
+  */
+typedef struct {
+    const char *name;
+    int     code;
+} NAME_CODE;
+
+extern int name_code(NAME_CODE *, const char *);
+extern const char *str_name_code(NAME_CODE *, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Wietse Venema
+/*     IBM T.J. Watson Research
+/*     P.O. Box 704
+/*     Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif