[EMAIL PROTECTED] wrote: > Trying to start a Perl smtp(port 25) server from inetd. > Script works OK as stand alone but fails to start from inetd.
Hopefully it has been designed to be run from inetd. > Question 1: Is there a way to log inetd? Information and errors is logged via syslogd. This usually logs to /var/log/syslog as configured by /etc/syslog.conf. > Question 2: should the server be started differently for inetd (as > compared to a standalone server) Yes, very much so. Normal daemons fork into the background and disassociate from the terminal. Normal daemons will need to open their own network ports. But daemons from inetd expect all of that to have happened already. Plus traditional inetds only open file descriptor zero for reading and writing whereas newer versions open up fd 1 and 2 as well because it is simpler for simple programs like perl scripts. There are many details here. I don't even know where to begin to describe the process. Googling for how to write a unix daemon and other things would turn up good information. > netstat shows . . . > :~> netstat -ntalc | grep ':25' > tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN > tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN > tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN > tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN > tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN That does not look normal. How can you have five of them running at once? Very odd. > tcp 0 0 127.0.0.1:33052 127.0.0.1:25 CLOSE_WAIT And yet another one bound specifically to localhost. It does not look happy to me. > -- upon attempting to telnet to port 25 . . . > :~> telnet localhost 25 > Trying ::1... > telnet: connect to address ::1: Connection refused > Trying 127.0.0.1... > Connected to localhost. > Escape character is '^]'. > Failed to start server :Address already in use > (in cleanup) Can't call method "close" on an undefined value at > /usr/lib/perl5/site_perl/5.6.1/Net/SMTP/Server.pm line 55. > Connection closed by foreign host. This really looks like inetd was listening on port 25, started up your perl script, your perl tried to open port 25 again. Of course that won't work. > -- some of different ways I have tried to start the server > my $srv = new Net::SMTP::Server( 'localhost', 25 ) > my $srv = new Net::SMTP::Server( '0.0.0.0', 25 ) > my $srv = new Net::SMTP::Server( , 25 ) > my $srv = new Net::SMTP::Server( ) > > none have behaved any differently If you are starting from inetd then don't try to open any network ports. Just read and write from stdin and stdout. (In the old inetd you would have needed to write to fd 0 as well. But for newer versions just write to stdout.) Remove all of the network operations from your perl script and try again. You should be able to test your script by talking to it interactively. Try running 'sendmail -bs' for a compison. /usr/sbin/sendmail -bs 220 discord.proulx.com ESMTP Postfix (Debian/GNU) EHLO localhost ... You are creating an SMTP replacement and so it must behave the same. If your script does not behave the same way then you need to fix it so that it does. Bob
pgpgJIin6Ijn9.pgp
Description: PGP signature