Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 71815 - qmail-smtpd won't start unless TCPSERVER_PORT is defined in /var/qmail/control/conf-smtpd
Summary: qmail-smtpd won't start unless TCPSERVER_PORT is defined in /var/qmail/contro...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High minor (vote)
Assignee: AMD64 Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-20 00:37 UTC by Michele Beltrame
Modified: 2005-02-14 04:27 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michele Beltrame 2004-11-20 00:37:19 UTC
This problem regard QMAIL 1.03-r15, the latest stable available. On my AMD64 system, if I do not specify TCPSERVER_PORT=25 in /var/qmail/control/conf-smtpd , qmail-smtpd won't start and would quickly fill my log with messages like this:

@400000004191d3d32324e12c tcpserver: fatal: unable to figure out port number for smtp

Since this seems to happen to some people, shouldn't TCPSERVER_PORT=25 better be added to the configuration file by default?


Reproducible: Always
Steps to Reproduce:
1. emerge qmail
2. ln -s /var/qmail/supervise/qmail-smtpd/ /service/

Actual Results:  
qmail-smtpd won't start and the log file /var/log/qmail/qmail-smtpd/current
quickly began filling with:

@400000004191d3d32324e12c tcpserver: fatal: unable to figure out port number for
smtp

Expected Results:  
qmail-smtpd should have started with no problem

Portage 2.0.51-r3 (default-linux/amd64/2004.3, gcc-3.4.3,
glibc-2.3.4.20041102-r0, 2.6.9-nitro2 x86_64)
=================================================================
System uname: 2.6.9-nitro2 x86_64 AMD Athlon(tm) 64 Processor 3000+
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r5
Automake: sys-devel/automake-1.8.5-r1
Binutils: sys-devel/binutils-2.15.90.0.1.1-r3
Headers:  sys-kernel/linux26-headers-2.6.8.1-r1
Libtools: sys-devel/libtool-1.5.2-r5
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CFLAGS="-march=athlon64 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown
/usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config
/var/bind /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon64 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig ccache distlocks sandbox"
GENTOO_MIRRORS="ftp://gentoo.netnitco.net/pub/mirrors/gentoo/source/
http://gentoo.math.bme.hu http://gentoo.tiscali.nl/gentoo/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="amd64 X acpi alsa apache2 arts berkdb bitmap-fonts cdr crypt cups esd f77
fam foomaticdb fortran gdbm gif gnome gpm gstreamer gtk imagemagick imlib ipv6
java jp2 jpeg libwww lzw lzw-tiff maildir mikmod motif mozilla multilib mysql
ncurses nls oggvorbis opengl oss pam pdflib perl png python readline samba slang
ssl tcpd tiff truetype usb userlocales xml2 xmms xpm xrandr xv zlib"
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-20 14:57:16 UTC
why doesn't your /etc/services contain the smtp line?
a lot of other stuff needs it beyond qmail.
Comment 2 Michele Beltrame 2004-11-21 04:13:55 UTC
> why doesn't your /etc/services contain the smtp line?

Why do you say this? My /etc/services (which is the one provided by Gentoo) *contains* the smtp line:

smtp            25/tcp          mail
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-21 04:50:05 UTC
The error 'tcpserver: fatal: unable to figure out port number for smtp'
means that tcpserver cannot resolve what port number the name 'smtp' is associated with. 

Two possible reasons for this:
1. /etc/services doesn't have it
2. nsswitch/nscd broke lookups

#2 is far more serious than #1.

You can check for either of these conditions via running:
"getent services smtp"
which should print something like:
"smtp 25/tcp mail"
Comment 4 Michele Beltrame 2004-11-21 08:52:09 UTC
> You can check for either of these conditions via running:
> "getent services smtp"
> which should print something like:
> "smtp 25/tcp mail"

Actually, it does "getent services smtp" works just fine and prints:

smtp                  25/tcp mail

So, it seems my system gets the port number fine, but qmail-qsmtpd is the only one who doesn't (other MTAs work just fine).

Michele.
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-21 12:26:09 UTC
it's not qmail-smtpd (I'm assuming you just typoed it in your last comment) that resolves the port number, it's tcpserver.

Could you possibly debug thru tcpserver and find why it isn't resolving the port name?

For a minimal tcpserver setup for testing, stop your mail system, and run:
tcpserver 0.0.0.0 smtp /usr/bin/printenv

if that works on it's own, combine it with the various tcpserver parameters that you use for qmail-smtpd.
Comment 6 Michele Beltrame 2004-11-22 00:02:06 UTC
Hi tried the command you sent me and it works, and it also works up to the following (status: 0/40), which is the command line I find in "ps ax" regarding tcpserver for qmail-smtpd:

/usr/bin/tcpserver -p -v -R -x /etc/tcprules.d/tcp.qmail-smtp.cdb -c 40 -u 201 -g 200 0.0.0.0 25 /var/qmail/bin/qmail-smtpd

And it works also if I do:

/usr/bin/tcpserver -p -v -R -x /etc/tcprules.d/tcp.qmail-smtp.cdb -c 40 -u 201 -g 200 0.0.0.0 smtp /var/qmail/bin/qmail-smtpd

(with "smtp" in place of "25" as port number). I think that supervise launches tcpserver as follows, and this causes the error:

/usr/bin/tcpserver -p -v -R -x /etc/tcprules.d/tcp.qmail-smtp.cdb -c 40 -u 201 -g 200 0.0.0.0 /var/qmail/bin/qmail-smtpd

(no port/service is specified after the IP address).

I took a look at /var/qmail/supervise/qmail-smtpd/run and it's got the following:

SERVICE=smtp
source /var/qmail/bin/qmail-config-system && \
exec /usr/bin/softlimit ${SOFTLIMIT_OPTS} \
    ${QMAIL_TCPSERVER_PRE} \
    /usr/bin/tcpserver ${TCPSERVER_OPTS} -x ${TCPSERVER_RULESCDB} \
    -c ${MAXCONN} -u ${QMAILDUID} -g ${NOFILESGID} \
    ${TCPSERVER_HOST} ${TCPSERVER_PORT} \
    ${QMAIL_SMTP_PRE} /var/qmail/bin/qmail-${SERVICE}d ${QMAIL_SMTP_POST} \
    2>&1

which, frankly, I think matches with this error: ${TCPSERVER_PORT} is passed on the command line, and if it's undefined nothing is passed. Shouldn't ${SERVICE} be used instead/also? This is just my 2 cents, it's the first time I explore these files. ;)

Thanks, Michele.

Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-22 00:20:22 UTC
the qmail-smtpd startup script (as you posted)
sets SERVICE=smtp
and sources qmail-config-system

qmail-config-system sources conf-common and then sources conf-smtpd.

conf-common does:
TCPSERVER_PORT="${SERVICE}"
amongst other things.

when control gets back to the smtpd run script, all of the variables are suitably set.

you're the first to find any problem with this.

On a hunch, did you have an old version of qmail previously, and miss etc-update on some files perhaps?

Versions should be as follows:
"grep Header /var/qmail/control/conf*"
conf-common:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/conf-common,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
conf-pop3d:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/conf-pop3d,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
conf-qmqpd:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/conf-qmqpd,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
conf-qmtpd:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/conf-qmtpd,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
conf-send:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/conf-send,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
conf-smtpd:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/conf-smtpd,v 1.2 2004/07/18 03:29:51 dragonheart Exp $

for another test,
get your system back to the point where it gives you the same error as before, and modify the smtpd run file as such:
1. replace 'exec' with 'echo'
2. new line on the end 'sleep 600'

now start up svscan again to run the script, and look at the log file for the output of the echo statement, and report that back here.
Comment 8 Michele Beltrame 2004-11-22 00:38:34 UTC
I took further investigation, after you latest comment, into /var/qmail/supervise/qmail-smtpd/run and I found out that the command line it launches is:

/usr/bin/softlimit -m 8000000 /usr/bin/tcpserver -p -v -R -x /etc/tcprules.d/tcp.qmail-smtp.cdb -c 40 -u 201 -g 200 0.0.0.0 smtp /var/qmail/bin/qmail-smtpd

which doesn't work unless I substitute "smtp" with "25" *OR* do:

/usr/bin/softlimit /usr/bin/tcpserver -p -v -R -x /etc/tcprules.d/tcp.qmail-smtp.cdb -c 40 -u 201 -g 200 0.0.0.0 smtp /var/qmail/bin/qmail-smtpd

That is to say that it's the "-m 8000000" parameter which breaks the interpreation of the "smtp" word. It seems quite strange but that's what happens!

Michele.

Comment 9 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-22 01:11:33 UTC
are you certain your config files are the most recent versions as I listed?
if you are sure, we need to pursue a different route, so please do:
"tar cvfz /tmp/broken-qmail.tgz /var/qmail"
and attach that file here for me to examine.
Comment 10 Michele Beltrame 2004-11-22 01:16:56 UTC
I think the versions are the latest (1.2 2004/07/18 03:29:51):

/var/qmail/control/conf-common:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/c onf-common,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
/var/qmail/control/conf-pop3d:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/co nf-pop3d,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
/var/qmail/control/conf-qmqpd:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/co nf-qmqpd,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
/var/qmail/control/conf-qmtpd:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/co nf-qmtpd,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
/var/qmail/control/conf-send:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/con f-send,v 1.2 2004/07/18 03:29:51 dragonheart Exp $
/var/qmail/control/conf-smtpd:# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail/files/co nf-smtpd,v 1.2 2004/07/18 03:29:51 dragonheart Exp $

I'm attaching you the tarball via email.

Michele.
Comment 11 Fernando Hallberg 2005-01-11 05:27:18 UTC
Hi,

I have the same problem with qmail and i skirted this adding the line

TCPSERVER_PORT=`cat /etc/services | tr -s '\t' ' ' | grep "^${SERVICE} " | grep tcp | cut -d ' ' -f 2 | cut -d '/' -f 1`

to /service/qmail-*/run

Att
Fernando Hallberg
Comment 12 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-01-11 10:29:33 UTC
Please use the latest ucspi-tcp (r9), it is fixed there. If it isn't, please reassign this bug to amd64.
Comment 13 Michele Beltrame 2005-01-12 03:45:43 UTC
Still doesn't work on AMD64, with the latest ucspi-tcp tools installed.
Comment 14 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-01-12 03:52:22 UTC
I'm going to test this on amd64.
Comment 15 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-01-15 06:32:58 UTC
I am really, really sorry. I was thinking about another error that happened with tcpserver, as described in bug 18892. I manually patched and compiled ucspi-tcp on AMD64 and it worked there. Giving over to AMD64 as this might be a problem with your libs or something.
Comment 16 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-15 13:42:37 UTC
amd64: see comment #8 about the "-m 8000000" parameter breaking softlimit.
Comment 17 David Varela 2005-01-29 13:43:06 UTC
I have a similar problem with my athlon64 (not sure if it's the same).

If I add TCPSERVER_PORT=25 and TCPSERVER_HOST=0.0.0.0 to conf-common I get:

tcpserver: fatal: temporarily unable to figure out IP address for 0.0.0.0: file does not exist

And if I running: # tcpserver localhost 25 /usr/bin/printenv

tcpserver: fatal: temporarily unable to figure out IP address for localhost: file does not exist
Comment 18 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-01-29 15:59:40 UTC
varelagarrido: Please see that the results of 'getent hosts localhost' are sane.
Comment 19 Chris Kloosterman 2005-02-01 00:53:10 UTC
I think the problem here is that whatever tcpserver is trying to use to translate smtp into 25 is taking up too much memory.  The softlimit command will just kill the process if it takes up too much memory (will kill the getent program, or whatever is doing the lookup).

I had the same problem as above, and fixed it the same way as above, but still had problems (qmail-smtpd disconnecting as soon as I telnetted to port 25).  Bumping up the memory limit to 16MB solved all of the problems.

I think that the memory consumption under amd64 is higher, and the 8MB limit is being hit too frequently.  Perhaps bumping the softlimit to 16MB for amd64 systems is appropriate?
Comment 20 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-02-14 04:27:10 UTC
Ok, I bumped the default memory limit to 16MB for softlimit now.