On Fri, Feb 14, 2014 at 09:39:00AM +0100, Sven Schwyn wrote:

> > As "root" or as "postfix"?
> 
> I can resolve the domain as both.
> 
> > Is this domain using a dedicated master.cf transport?  Is that
> > transport's smtp(8) delivery agent chrooted?
> 
> The master.cf is untouched as it comes with the Gentoo package.
> Nothing is chrooted. (It's a send-only machine and therefore incoming
> connections are blocked anyway.)
> 
> smtp      unix  -       -       n       -       -       smtp
> relay     unix  -       -       n       -       -       smtp

Compile and install Postfix from source with debug symbols enabled.
You should use your operating system's source package if available.
You can use non-default install paths.  For example:

    DEST=/var/tmp/postfix
    CCARGS='-DHAS_PCRE'
    AUXLIBS='-lpcre'
    while read -r name val
    do
            CCARGS="$CCARGS $(printf -- '-D%s=\\"%s\\"' $name $val)"
    done <<EOF
    DEF_COMMAND_DIR         $DEST/sbin
    DEF_CONFIG_DIR          $DEST/etc
    DEF_DAEMON_DIR          $DEST/libexec
    DEF_QUEUE_DIR           $DEST/spool
    DEF_DATA_DIR            $DEST/data
    DEF_MAILQ_PATH          $DEST/sbin/mailq
    DEF_HTML_DIR            $DEST/html
    DEF_MANPAGE_DIR         $DEST/man
    DEF_NEWALIAS_PATH       $DEST/sbin/newaliases
    DEF_README_DIR          $DEST/readme
    DEF_SENDMAIL_PATH       $DEST/sbin/sendmail
    EOF
    make -f Makefile.init "CCARGS=$CCARGS" "AUXLIBS=$AUXLIBS" "OPT=-g" makefiles
    make

Then as root:

    # make upgrade
    # PATH=/var/tmp/postfix/sbin:$PATH
    # postconf -e "master_service_disable = inet"

Enable smtp(8) transport debugging:

    /var/tmp/postfix/etc/master.cf:
        smtp     unix  -       -       n       -       -       smtp -D

Set gdb to run inside gnu screen(1) and set smtp as the content
filter before discarding all mail.

    /var/tmp/postfix/etc/main.cf:
        default_transport = discard:silently
        content_filter = smtp
        syslog_name = postfix-debug
        debugger_command =
            PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; HOME=/root;
            export HOME; screen -e^tt -dmS $process_name gdb
            $daemon_directory/$process_name $process_id & sleep 2

(the escape character is "Ctrl-t" so as not to conflict with gdb's readline
"Ctrl-a", use whatever you prefer).

Find the value of "RES_DEBUG" in the relevant include file on your
system.  On many systems the following will work:

    $ printf "#include <resolv.h>\nRES_DEBUG\n" | cpp | tail -1
    0x00000002

As root, (with /var/tmp/postfix/sbin still first in your PATH)
start the custom-built postfix and send a probe message to bluewin.ch:

        # postfix start
        # sendmail -f sv...@delirium.ch -bv postmas...@bluewin.ch

Attach to smtp(8) running under the debugger and set a break-point in 
the smtp_domain_addr function

        # cd /tmp; screen -DR
        ... type "Ctrl-tH" to create screen log file
        (gdb) break smtp_domain_addr
        (gdb) continue
        ... stops in smtp_domain_addr ...
        (gdb) break dns_query
        (gdb) continue
        ... stops in dns_query, use RES_DEBUG value from above ...
        (gdb) next
        (gdb) set flags = flags | 0x00000002
        (gdb) finish
        (gdb) next
        (gdb) print status
        (gdb) print reply.rcode
        (gdb) continue
        ... type "Ctrl-tH" to close/save screen log file
        ... type "Ctrl-td" to detach the screen
        # postfix stop

Post the screen transcript file here (edit it to remove terminal
control sequences and other noise), along with logging from
"postfix-debug" from your mail log file.

-- 
        Viktor.

Reply via email to