pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/44656: mail/postfix fails on NetBSD when pgsql is enabled



>Number:         44656
>Category:       pkg
>Synopsis:       mail/postfix fails on NetBSD when pgsql is enabled
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 01 11:20:00 +0000 2011
>Originator:     r.tarnell%IEEE.ORG@localhost
>Release:        NetBSD 5.1.0_PATCH
>Organization:
TCX.ORG.UK
>Environment:
System: NetBSD tamara.TCX.ORG.UK 5.1.0_PATCH NetBSD 5.1.0_PATCH (TAMARA) #2: 
Thu Feb 24 06:06:17 GMT 2011 
root%tamara.TCX.ORG.UK@localhost:/usr/src/sys/arch/amd64/compile/TAMARA amd64
Architecture: x86_64
Machine: amd64
>Description:
When postfix is built with pgsql support, libpq pulls in libpthread.  
libpthread contains a replacement version of __res_state() (aka _res) which 
aborts the program when called.  Since Postfix smtp and smtpd both use _res to 
perform DNS lookups for RBLs, any attempt to do an RBL lookup will crash 
Postfix:

Mar  1 11:00:03 tamara postfix/smtpd[23620]: connect from localhost[127.0.0.1]
Mar  1 11:00:03 tamara postfix/smtpd[23620]: 815C148212: 
client=localhost[127.0.0.1]
Mar  1 11:00:03 tamara postfix/cleanup[13517]: 815C148212: 
message-id=<20110301105559.67C537A490%turnera.esi.toolserver.org@localhost>
Mar  1 11:00:03 tamara postfix/qmgr[22476]: 815C148212: 
from=<daemon%turnera.esi.toolserver.org@localhost>, size=2266, nrcpt=1 (queue 
active)
Mar  1 11:00:03 tamara postfix/qmgr[22476]: warning: private/smtp socket: 
malformed response
Mar  1 11:00:03 tamara postfix/qmgr[22476]: warning: transport smtp failure -- 
see a previous warning/fatal/panic logfile record for the problem description
Mar  1 11:00:03 tamara postfix/master[6091]: warning: process 
/usr/pkg/libexec/postfix/smtp pid 13453 killed by signal 6
Mar  1 11:00:03 tamara postfix/master[6091]: warning: 
/usr/pkg/libexec/postfix/smtp: bad command startup -- throttling

>How-To-Repeat:
Build Postfix with pgsql support on NetBSD, configure it to use an RBL and then 
make an SMTP connection.

>Fix:
Use res_ninit instead of res_init, which works in multi-threaded programs.

However, it could easily be argued that the real bug here is in NetBSD 
libpthread.  There are plenty of examples of legitimate uses of _res in 
multi-threaded programs, and programs which are not multi-threaded but link 
against libpthread anyway (like Postfix).

--- src/dns/dns_lookup.c        2009-08-06 20:25:33.000000000 +0100
+++ src/dns/dns_lookup.c        2011-03-01 10:33:18.000000000 +0000
@@ -153,6 +153,8 @@
 
 /* Local stuff. */
 
+struct __res_state rstate;
+
  /*
   * Structure to keep track of things while decoding a name server reply.
   */
@@ -192,7 +194,7 @@
     /*
      * Initialize the name service.
      */
-    if ((_res.options & RES_INIT) == 0 && res_init() < 0) {
+    if ((rstate.options & RES_INIT) == 0 && res_ninit(&rstate) < 0) {
        if (why)
            vstring_strcpy(why, "Name service initialization failure");
        return (DNS_FAIL);
@@ -206,18 +208,18 @@
 
     if ((flags & USER_FLAGS) != flags)
        msg_panic("dns_query: bad flags: %d", flags);
-    saved_options = (_res.options & USER_FLAGS);
+    saved_options = (rstate.options & USER_FLAGS);
 
     /*
      * Perform the lookup. Claim that the information cannot be found if and
      * only if the name server told us so.
      */
     for (;;) {
-       _res.options &= ~saved_options;
-       _res.options |= flags;
-       len = res_search((char *) name, C_IN, type, reply->buf, reply->buf_len);
-       _res.options &= ~flags;
-       _res.options |= saved_options;
+       rstate.options &= ~saved_options;
+       rstate.options |= flags;
+       len = res_nsearch(&rstate, (char *) name, C_IN, type, reply->buf, 
reply->buf_len);
+       rstate.options &= ~flags;
+       rstate.options |= saved_options;
        if (len < 0) {
            if (why)
                vstring_sprintf(why, "Host or domain name not found. "



Home | Main Index | Thread Index | Old Index