#ifdef TEST
/*
---- postfix-2.9.0/src/util/Makefile.in.orig 2012-02-04 19:16:54.187276228 +0100
-+++ postfix-2.9.0/src/util/Makefile.in 2012-02-04 19:30:39.503837753 +0100
+--- postfix-2.9.0/src/global/mail_dict.c.orig 2012-02-04 19:16:53.000000000 +0100
++++ postfix-2.9.0/src/global/mail_dict.c 2012-02-04 19:33:20.047179113 +0100
+@@ -47,18 +47,6 @@
+
+ static const DICT_OPEN_INFO dict_open_info[] = {
+ DICT_TYPE_PROXY, dict_proxy_open,
+-#ifdef HAS_LDAP
+- DICT_TYPE_LDAP, dict_ldap_open,
+-#endif
+-#ifdef HAS_MYSQL
+- DICT_TYPE_MYSQL, dict_mysql_open,
+-#endif
+-#ifdef HAS_PGSQL
+- DICT_TYPE_PGSQL, dict_pgsql_open,
+-#endif
+-#ifdef HAS_SQLITE
+- DICT_TYPE_SQLITE, dict_sqlite_open,
+-#endif
+ DICT_TYPE_MEMCACHE, dict_memcache_open,
+ 0,
+ };
+--- postfix-2.10.0/src/util/Makefile.in.orig 2013-03-12 18:35:34.678563247 +0100
++++ postfix-2.10.0/src/util/Makefile.in 2013-03-12 18:37:04.201043205 +0100
@@ -30,7 +30,7 @@
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 sane_basename.c format_tv.c allspace.c \
- allascii.c load_file.c killme_after.c vstream_tweak.c \
+ allascii.c load_file.c killme_after.c vstream_tweak.c load_lib.c \
- unix_pass_listen.c unix_pass_trigger.c edit_file.c inet_windowsize.c \
+ pass_trigger.c edit_file.c inet_windowsize.c \
unix_pass_fd_fix.c dict_cache.c valid_utf_8.c dict_thash.c \
- ip_match.c nbbio.c stream_pass_connect.c base32_code.c dict_test.c \
-@@ -41,7 +41,7 @@
+ ip_match.c nbbio.c base32_code.c dict_test.c \
+@@ -42,7 +42,7 @@
chroot_uid.o cidr_match.o clean_env.o close_on_exec.o concatenate.o \
ctable.o dict.o dict_alloc.o dict_cdb.o dict_cidr.o dict_db.o \
dict_dbm.o dict_debug.o dict_env.o dict_ht.o dict_ni.o dict_nis.o \
dict_static.o dict_tcp.o dict_unix.o dir_forest.o doze.o dummy_read.o \
dummy_write.o duplex_pipe.o environ.o events.o exec_command.o \
fifo_listen.o fifo_trigger.o file_limit.o find_inet.o fsspace.o \
-@@ -66,7 +66,7 @@
+@@ -67,7 +67,7 @@
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 sane_basename.o format_tv.o allspace.o \
- allascii.o load_file.o killme_after.o vstream_tweak.o \
+ allascii.o load_file.o killme_after.o vstream_tweak.o load_lib.o \
- unix_pass_listen.o unix_pass_trigger.o edit_file.o inet_windowsize.o \
+ pass_trigger.o edit_file.o inet_windowsize.o \
unix_pass_fd_fix.o dict_cache.o valid_utf_8.o dict_thash.o \
- ip_match.o nbbio.o stream_pass_connect.o base32_code.o dict_test.o \
-@@ -89,7 +89,7 @@
+ ip_match.o nbbio.o base32_code.o dict_test.o \
+@@ -91,7 +91,7 @@
sigdelay.h sock_addr.h spawn_command.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 format_tv.h load_file.h killme_after.h \
+ vstring_vstream.h watchdog.h format_tv.h load_file.h killme_after.h load_lib.h \
edit_file.h dict_cache.h dict_thash.h ip_match.h nbbio.h base32_code.h \
- dict_fail.h warn_stat.h
+ dict_fail.h warn_stat.h dict_sockmap.h line_number.h
TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \
-@@ -98,6 +98,7 @@
+@@ -100,6 +100,7 @@
CFLAGS = $(DEBUG) $(OPT) $(DEFS)
FILES = Makefile $(SRCS) $(HDRS)
INCL =
LIB = libutil.a
TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \
-@@ -113,8 +114,9 @@
+@@ -116,8 +117,9 @@
LIB_DIR = ../../lib
INC_DIR = ../../include
all: $(LIB)
-@@ -125,15 +127,19 @@
+@@ -128,15 +130,19 @@
test: $(TESTPROG)
-for i in $(HDRS); \
do \
cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
-@@ -155,7 +161,8 @@
+@@ -158,7 +164,8 @@
lint $(DEFS) $(SRCS) $(LINTFIX)
clean:
rm -rf printfck
tidy: clean
---- postfix-2.9.0/src/global/mail_dict.c.orig 2012-02-04 19:16:53.000000000 +0100
-+++ postfix-2.9.0/src/global/mail_dict.c 2012-02-04 19:33:20.047179113 +0100
-@@ -47,18 +47,6 @@
-
- static const DICT_OPEN_INFO dict_open_info[] = {
- DICT_TYPE_PROXY, dict_proxy_open,
--#ifdef HAS_LDAP
-- DICT_TYPE_LDAP, dict_ldap_open,
--#endif
--#ifdef HAS_MYSQL
-- DICT_TYPE_MYSQL, dict_mysql_open,
--#endif
--#ifdef HAS_PGSQL
-- DICT_TYPE_PGSQL, dict_pgsql_open,
--#endif
--#ifdef HAS_SQLITE
-- DICT_TYPE_SQLITE, dict_sqlite_open,
--#endif
- DICT_TYPE_MEMCACHE, dict_memcache_open,
- 0,
- };
#define SMTPD_PEER_CODE_OK 2
#define SMTPD_PEER_CODE_TEMP 4
#define SMTPD_PEER_CODE_PERM 5
---- postfix-2.8.3/src/smtpd/Makefile.in~ 2011-05-17 14:28:28.406666872 +0200
-+++ postfix-2.8.3/src/smtpd/Makefile.in 2011-05-17 14:31:06.946666872 +0200
-@@ -2,11 +2,11 @@
- SRCS = smtpd.c smtpd_token.c smtpd_check.c smtpd_chat.c smtpd_state.c \
- smtpd_peer.c smtpd_sasl_proto.c smtpd_sasl_glue.c smtpd_proxy.c \
- smtpd_xforward.c smtpd_dsn_fix.c smtpd_milter.c smtpd_resolve.c \
-- smtpd_expand.c
-+ smtpd_expand.c smtpd_ident.c
- OBJS = smtpd.o smtpd_token.o smtpd_check.o smtpd_chat.o smtpd_state.o \
- smtpd_peer.o smtpd_sasl_proto.o smtpd_sasl_glue.o smtpd_proxy.o \
- smtpd_xforward.o smtpd_dsn_fix.o smtpd_milter.o smtpd_resolve.o \
-- smtpd_expand.o
-+ smtpd_expand.o smtpd_ident.o
- HDRS = smtpd_token.h smtpd_check.h smtpd_chat.h smtpd_sasl_proto.h \
- smtpd_sasl_glue.h smtpd_proxy.h smtpd_dsn_fix.h smtpd_milter.h \
- smtpd_resolve.h smtpd_expand.h
--- postfix-2.9.0/src/smtpd/smtpd.c.orig 2012-02-04 19:34:17.737149536 +0100
+++ postfix-2.9.0/src/smtpd/smtpd.c 2012-02-04 19:36:43.414073592 +0100
@@ -1208,6 +1208,7 @@
VAR_UNV_FROM_WHY, DEF_UNV_FROM_WHY, &var_unv_from_why, 0, 0,
VAR_UNV_RCPT_WHY, DEF_UNV_RCPT_WHY, &var_unv_rcpt_why, 0, 0,
VAR_REJECT_TMPF_ACT, DEF_REJECT_TMPF_ACT, &var_reject_tmpf_act, 1, 0,
---- postfix-2.9.0/src/smtpd/smtpd_peer.c.orig 2012-02-04 19:34:17.294233547 +0100
-+++ postfix-2.9.0/src/smtpd/smtpd_peer.c 2012-02-04 19:40:48.203777370 +0100
-@@ -98,6 +98,7 @@
+--- postfix-2.10.0/src/smtpd/Makefile.in.orig 2013-03-12 18:39:01.000000000 +0100
++++ postfix-2.10.0/src/smtpd/Makefile.in 2013-03-12 18:44:40.190592153 +0100
+@@ -2,11 +2,11 @@
+ SRCS = smtpd.c smtpd_token.c smtpd_check.c smtpd_chat.c smtpd_state.c \
+ smtpd_peer.c smtpd_sasl_proto.c smtpd_sasl_glue.c smtpd_proxy.c \
+ smtpd_xforward.c smtpd_dsn_fix.c smtpd_milter.c smtpd_resolve.c \
+- smtpd_expand.c smtpd_haproxy.c
++ smtpd_expand.c smtpd_haproxy.c smtpd_ident.c
+ OBJS = smtpd.o smtpd_token.o smtpd_check.o smtpd_chat.o smtpd_state.o \
+ smtpd_peer.o smtpd_sasl_proto.o smtpd_sasl_glue.o smtpd_proxy.o \
+ smtpd_xforward.o smtpd_dsn_fix.o smtpd_milter.o smtpd_resolve.o \
+- smtpd_expand.o smtpd_haproxy.o
++ smtpd_expand.o smtpd_haproxy.o smtpd_ident.o
+ HDRS = smtpd_token.h smtpd_check.h smtpd_chat.h smtpd_sasl_proto.h \
+ smtpd_sasl_glue.h smtpd_proxy.h smtpd_dsn_fix.h smtpd_milter.h \
+ smtpd_resolve.h smtpd_expand.h
+--- postfix-2.10.0/src/smtpd/smtpd_peer.c.orig 2013-03-12 19:14:53.347495658 +0100
++++ postfix-2.10.0/src/smtpd/smtpd_peer.c 2013-03-12 22:24:19.932605940 +0100
+@@ -103,6 +103,7 @@
#include <sys_defs.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h> /* strerror() */
-@@ -117,6 +118,7 @@
+@@ -123,6 +124,7 @@
/* Global library. */
#include <mail_proto.h>
#include <valid_mailhost_addr.h>
#include <mail_params.h>
-@@ -125,6 +127,8 @@
-
+@@ -133,6 +135,7 @@
#include "smtpd.h"
+ static INET_PROTO_INFO *proto_info;
+extern NAMADR_LIST *smtpd_ident_lookup;
-+
- /* smtpd_peer_init - initialize peer information */
- void smtpd_peer_init(SMTPD_STATE *state)
-@@ -132,6 +136,9 @@
- const char *myname = "smtpd_peer_init";
- SOCKADDR_SIZE sa_length;
- struct sockaddr *sa;
+ /*
+ * XXX If we make local endpoint (getsockname) information available to
+@@ -295,6 +293,8 @@
+ static void smtpd_peer_sockaddr_to_hostname(SMTPD_STATE *state)
+ {
+ struct sockaddr *sa = (struct sockaddr *) & (state->sockaddr);
+ struct sockaddr_in serv_sin;
+ char *ident_user = NULL;
-+ SOCKADDR_SIZE sa_len;
- INET_PROTO_INFO *proto_info = inet_proto_info();
-
- sa = (struct sockaddr *) & (state->sockaddr);
-@@ -171,6 +178,7 @@
- state->addr_family = AF_UNSPEC;
- state->name_status = SMTPD_PEER_CODE_PERM;
- state->reverse_name_status = SMTPD_PEER_CODE_PERM;
-+ state->ident_user = mystrdup("NO-USER");
- state->port = mystrdup(CLIENT_PORT_UNKNOWN);
- }
-
-@@ -342,6 +350,7 @@
- if (aierr) {
- msg_warn("hostname %s does not resolve to address %s: %s",
- state->name, state->addr, MAI_STRERROR(aierr));
-+ state->ident_user = mystrdup("NO-USER");
- REJECT_PEER_NAME(state, (TEMP_AI_ERROR(aierr) ?
+ SOCKADDR_SIZE sa_length = state->sockaddr_len;
+ MAI_HOSTNAME_STR client_name;
+ int aierr;
+@@ -345,6 +350,7 @@
+ if (aierr) {
+ msg_warn("hostname %s does not resolve to address %s: %s",
+ state->name, state->addr, MAI_STRERROR(aierr));
++ state->ident_user = mystrdup("NO-USER");
+ REJECT_PEER_NAME(state, (TEMP_AI_ERROR(aierr) ?
SMTPD_PEER_CODE_TEMP : SMTPD_PEER_CODE_FORGED));
- } else {
-@@ -363,6 +372,20 @@
- freeaddrinfo(res0);
- }
+ } else {
+@@ -366,6 +372,19 @@
+ freeaddrinfo(res0);
}
-+
-+ if (namadr_list_match(smtpd_ident_lookup, state->name, state->addr)) {
-+ /* If getsockname fails, just forget it */
-+ sa_len = sizeof(serv_sin);
-+ if (getsockname(vstream_fileno(state->client), (struct sockaddr *)&serv_sin, &sa_len) >= 0) {
-+ ident_user = smtpd_ident((struct sockaddr_in *)sa, &serv_sin);
-+ if (ident_user == NULL)
-+ state->ident_user = mystrdup("NO-USER");
-+ else
-+ state->ident_user = ident_user;
-+ } else
-+ msg_warn("getsockname failed while doing ident lookup: %s", strerror(errno));
-+ } else
-+ state->ident_user = mystrdup("NO-USER");
}
++ if (namadr_list_match(smtpd_ident_lookup, state->name, state->addr)) {
++ /* If getsockname fails, just forget it */
++ sa_length = sizeof(serv_sin);
++ if (getsockname(vstream_fileno(state->client), (struct sockaddr *)&serv_sin, &sa_length) >= 0) {
++ ident_user = smtpd_ident((struct sockaddr_in *)sa, &serv_sin);
++ if (ident_user == NULL)
++ state->ident_user = mystrdup("NO-USER");
++ else
++ state->ident_user = ident_user;
++ } else
++ msg_warn("getsockname failed while doing ident lookup: %s", strerror(errno));
++ } else
++ state->ident_user = mystrdup("NO-USER");
+ }
- /*
-@@ -383,6 +406,7 @@
- state->name_status = SMTPD_PEER_CODE_OK;
- state->reverse_name_status = SMTPD_PEER_CODE_OK;
- state->port = mystrdup("0"); /* XXX bogus. */
-+ state->ident_user = mystrdup("NO-USER");
- }
+ /* smtpd_peer_hostaddr_to_sockaddr - convert numeric string to binary */
+@@ -412,6 +431,7 @@
+ state->name_status = SMTPD_PEER_CODE_OK;
+ state->reverse_name_status = SMTPD_PEER_CODE_OK;
+ state->port = mystrdup("0"); /* XXX bogus. */
++ state->ident_user = mystrdup("NO-USER");
+ }
- /*
-@@ -401,5 +425,6 @@
- myfree(state->addr);
- myfree(state->namaddr);
- myfree(state->rfc_addr);
-+ myfree(state->ident_user);
- myfree(state->port);
+ /* smtpd_peer_no_client - peer went away, or peer info unavailable */
+@@ -426,6 +446,7 @@
+ state->addr_family = AF_UNSPEC;
+ state->name_status = SMTPD_PEER_CODE_PERM;
+ state->reverse_name_status = SMTPD_PEER_CODE_PERM;
++ state->ident_user = mystrdup("NO-USER");
+ state->port = mystrdup(CLIENT_PORT_UNKNOWN);
+ }
+
+@@ -533,6 +554,7 @@
+ }
}
+
++
+ /* smtpd_peer_init - initialize peer information */
+
+ void smtpd_peer_init(SMTPD_STATE *state)
+@@ -604,6 +626,8 @@
+ myfree(state->namaddr);
+ if (state->rfc_addr)
+ myfree(state->rfc_addr);
++ if (state->ident_user)
++ myfree(state->ident_user);
+ if (state->port)
+ myfree(state->port);
+ if (state->dest_addr)