Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu sync wth 20010228-pl04.
details: https://anonhg.NetBSD.org/src/rev/1746f7fda92d
branches: trunk
changeset: 513712:1746f7fda92d
user: itojun <itojun%NetBSD.org@localhost>
date: Thu Aug 09 08:10:17 2001 +0000
description:
sync wth 20010228-pl04.
diffstat:
gnu/dist/postfix/src/global/own_inet_addr.c | 8 +
gnu/dist/postfix/src/smtp/smtp_connect.c | 2 +-
gnu/dist/postfix/src/smtpd/smtpd_check.c | 275 +++++++++++++++++----------
gnu/dist/postfix/src/util/Makefile.in | 38 +++-
gnu/dist/postfix/src/util/inet_addr_list.c | 79 ++++++++
gnu/dist/postfix/src/util/inet_addr_list.h | 1 +
gnu/usr.sbin/postfix/util/Makefile | 4 +-
7 files changed, 297 insertions(+), 110 deletions(-)
diffs (truncated from 930 to 300 lines):
diff -r 787966dec0ff -r 1746f7fda92d gnu/dist/postfix/src/global/own_inet_addr.c
--- a/gnu/dist/postfix/src/global/own_inet_addr.c Thu Aug 09 08:03:34 2001 +0000
+++ b/gnu/dist/postfix/src/global/own_inet_addr.c Thu Aug 09 08:10:17 2001 +0000
@@ -111,6 +111,14 @@
VAR_INET_INTERFACES, host);
myfree(hosts);
+ /*
+ * Weed out duplicate IP addresses. Duplicates happen when the same
+ * IP address is listed under multiple hostnames. If we don't weed
+ * out duplicates, Postfix can suddenly stop working after the DNS is
+ * changed.
+ */
+ inet_addr_list_uniq(addr_list);
+
inet_addr_list_init(&local_addrs);
inet_addr_list_init(&local_masks);
if (inet_addr_local(&local_addrs, &local_masks) == 0)
diff -r 787966dec0ff -r 1746f7fda92d gnu/dist/postfix/src/smtp/smtp_connect.c
--- a/gnu/dist/postfix/src/smtp/smtp_connect.c Thu Aug 09 08:03:34 2001 +0000
+++ b/gnu/dist/postfix/src/smtp/smtp_connect.c Thu Aug 09 08:10:17 2001 +0000
@@ -534,7 +534,7 @@
char *save;
char *dest;
char *cp;
- int found_myself;
+ int found_myself = 0;
/*
* First try to deliver to the indicated destination, then try to deliver
diff -r 787966dec0ff -r 1746f7fda92d gnu/dist/postfix/src/smtpd/smtpd_check.c
--- a/gnu/dist/postfix/src/smtpd/smtpd_check.c Thu Aug 09 08:03:34 2001 +0000
+++ b/gnu/dist/postfix/src/smtpd/smtpd_check.c Thu Aug 09 08:10:17 2001 +0000
@@ -269,6 +269,7 @@
#include <mymalloc.h>
#include <dict.h>
#include <htable.h>
+#include <ctable.h>
/* DNS library. */
@@ -310,9 +311,8 @@
* Intermediate results. These are static to avoid unnecessary stress on the
* memory manager routines.
*/
-static RESOLVE_REPLY reply;
-static VSTRING *query;
static VSTRING *error_text;
+static CTABLE *smtpd_resolve_cache;
/*
* Pre-opened SMTP recipient maps so we can reject mail for unknown users.
@@ -345,7 +345,7 @@
/*
* The routine that recursively applies restrictions.
*/
-static int generic_checks(SMTPD_STATE *, ARGV *, char *, char *, char *);
+static int generic_checks(SMTPD_STATE *, ARGV *, const char *, const char *, const char *);
/*
* Reject context.
@@ -360,6 +360,49 @@
* YASLM.
*/
#define STR vstring_str
+#define CONST_STR(x) ((const char *) vstring_str(x))
+
+/* resolve_pagein - page in an address resolver result */
+
+static void *resolve_pagein(const char *addr, void *unused_context)
+{
+ static VSTRING *query;
+ RESOLVE_REPLY *reply;
+
+ /*
+ * Initialize on the fly.
+ */
+ if (query == 0)
+ query = vstring_alloc(10);
+
+ /*
+ * Initialize.
+ */
+ reply = (RESOLVE_REPLY *) mymalloc(sizeof(*reply));
+ resolve_clnt_init(reply);
+
+ /*
+ * Resolve the address.
+ */
+ canon_addr_internal(query, addr);
+ resolve_clnt_query(STR(query), reply);
+ lowercase(STR(reply->recipient));
+
+ /*
+ * Save the result.
+ */
+ return ((void *) reply);
+}
+
+/* resolve_pageout - page out an address resolver result */
+
+static void resolve_pageout(void *data, void *unused_context)
+{
+ RESOLVE_REPLY *reply = (RESOLVE_REPLY *) data;
+
+ resolve_clnt_free(reply);
+ myfree((void *) reply);
+}
/* smtpd_check_parse - pre-parse restrictions */
@@ -471,14 +514,17 @@
DICT_FLAG_LOCK);
/*
- * Reply is used as a cache for resolved addresses, and error_text is
- * used for returning error responses.
+ * error_text is used for returning error responses.
*/
- resolve_clnt_init(&reply);
- query = vstring_alloc(10);
error_text = vstring_alloc(10);
/*
+ * Initialize the resolved address cache.
+ */
+ smtpd_resolve_cache = ctable_create(100, resolve_pagein,
+ resolve_pageout, (void *) 0);
+
+ /*
* Pre-parse the restriction lists. At the same time, pre-open tables
* before going to jail.
*/
@@ -620,8 +666,10 @@
/* check_mail_addr_find - reject with temporary failure if dict lookup fails */
-static const char *check_mail_addr_find(SMTPD_STATE *state, const char *reply_name,
- MAPS *maps, const char *key, char **ext)
+static const char *check_mail_addr_find(SMTPD_STATE *state,
+ const char *reply_name,
+ MAPS *maps, const char *key,
+ char **ext)
{
const char *result;
@@ -820,8 +868,8 @@
/* reject_unknown_mailhost - fail if name has no A or MX record */
-static int reject_unknown_mailhost(SMTPD_STATE *state, char *name,
- char *reply_name, char *reply_class)
+static int reject_unknown_mailhost(SMTPD_STATE *state, const char *name,
+ const char *reply_name, const char *reply_class)
{
char *myname = "reject_unknown_mailhost";
int dns_status;
@@ -881,7 +929,8 @@
static int permit_auth_destination(SMTPD_STATE *state, char *recipient)
{
char *myname = "permit_auth_destination";
- char *domain;
+ const RESOLVE_REPLY *reply;
+ const char *domain;
if (msg_verbose)
msg_info("%s: %s", myname, recipient);
@@ -889,14 +938,13 @@
/*
* Resolve the address.
*/
- canon_addr_internal(query, recipient);
- resolve_clnt_query(STR(query), &reply);
- lowercase(STR(reply.recipient));
+ reply = (const RESOLVE_REPLY *)
+ ctable_locate(smtpd_resolve_cache, recipient);
/*
* Handle special case that is not supposed to happen.
*/
- if ((domain = strrchr(STR(reply.recipient), '@')) == 0)
+ if ((domain = strrchr(CONST_STR(reply->recipient), '@')) == 0)
return (SMTPD_CHECK_OK);
domain += 1;
@@ -912,7 +960,7 @@
/*
* Skip source-routed mail (uncertain destination).
*/
- if (var_allow_untrust_route == 0 && (reply.flags & RESOLVE_FLAG_ROUTED))
+ if (var_allow_untrust_route == 0 && (reply->flags & RESOLVE_FLAG_ROUTED))
return (SMTPD_CHECK_DUNNO);
/*
@@ -971,7 +1019,7 @@
/* has_my_addr - see if this host name lists one of my network addresses */
-static int has_my_addr(char *host)
+static int has_my_addr(const char *host)
{
#ifdef INET6
char *myname = "has_my_addr";
@@ -1059,7 +1107,8 @@
static int permit_mx_backup(SMTPD_STATE *state, const char *recipient)
{
char *myname = "permit_mx_backup";
- char *domain;
+ const RESOLVE_REPLY *reply;
+ const char *domain;
DNS_RR *mx_list;
DNS_RR *mx;
@@ -1071,15 +1120,14 @@
/*
* Resolve the address.
*/
- canon_addr_internal(query, recipient);
- resolve_clnt_query(STR(query), &reply);
- lowercase(STR(reply.recipient));
+ reply = (const RESOLVE_REPLY *)
+ ctable_locate(smtpd_resolve_cache, recipient);
/*
* If the destination is local, it is acceptable, because we are
* supposedly MX for our own address.
*/
- if ((domain = strrchr(STR(reply.recipient), '@')) == 0)
+ if ((domain = strrchr(CONST_STR(reply->recipient), '@')) == 0)
return (SMTPD_CHECK_OK);
domain += 1;
if (resolve_local(domain)
@@ -1093,7 +1141,7 @@
/*
* Skip source-routed mail (uncertain destination).
*/
- if (var_allow_untrust_route == 0 && (reply.flags & RESOLVE_FLAG_ROUTED))
+ if (var_allow_untrust_route == 0 && (reply->flags & RESOLVE_FLAG_ROUTED))
return (SMTPD_CHECK_DUNNO);
/*
@@ -1202,11 +1250,12 @@
/* reject_unknown_address - fail if address does not resolve */
-static int reject_unknown_address(SMTPD_STATE *state, char *addr,
- char *reply_name, char *reply_class)
+static int reject_unknown_address(SMTPD_STATE *state, const char *addr,
+ const char *reply_name, const char *reply_class)
{
char *myname = "reject_unknown_address";
- char *domain;
+ const RESOLVE_REPLY *reply;
+ const char *domain;
if (msg_verbose)
msg_info("%s: %s", myname, addr);
@@ -1214,14 +1263,12 @@
/*
* Resolve the address.
*/
- canon_addr_internal(query, addr);
- resolve_clnt_query(STR(query), &reply);
- lowercase(STR(reply.recipient));
+ reply = (const RESOLVE_REPLY *) ctable_locate(smtpd_resolve_cache, addr);
/*
* Skip local destinations and non-DNS forms.
*/
- if ((domain = strrchr(STR(reply.recipient), '@')) == 0)
+ if ((domain = strrchr(CONST_STR(reply->recipient), '@')) == 0)
return (SMTPD_CHECK_DUNNO);
domain += 1;
if (resolve_local(domain)
@@ -1241,10 +1288,11 @@
/* check_table_result - translate table lookup result into pass/reject */
-static int check_table_result(SMTPD_STATE *state, char *table,
+static int check_table_result(SMTPD_STATE *state, const char *table,
const char *value, const char *datum,
- char *reply_name, char *reply_class,
- char *def_acl)
+ const char *reply_name,
+ const char *reply_class,
+ const char *def_acl)
{
char *myname = "check_table_result";
int code;
@@ -1339,17 +1387,20 @@
/* check_access - table lookup without substring magic */
-static int check_access(SMTPD_STATE *state, char *table, char *name, int flags,
- char *reply_name, char *reply_class, char *def_acl)
+static int check_access(SMTPD_STATE *state, const char *table, const char *name,
+ int flags, int *found, const char *reply_name,
+ const char *reply_class, const char *def_acl)
{
char *myname = "check_access";
Home |
Main Index |
Thread Index |
Old Index