On 2006-11-05 03:53:33 -0800, Ask Bjørn Hansen wrote:
> On Nov 5, 2006, at 3:06 AM, Peter J. Holzer wrote:
> >* someone who has commit privilege to the repository indicates some
> >  interest in getting (x)inetd support working again.
> 
> I don't see any reason why it shouldn't work, so patches welcome as  
> long as they are simple.

Here it is. It's basically the same patch as for 0.28. From some old
mails I conclude that it was included in 0.29 and was lost again some
time before 0.32, but I've not actually checked the repository.

The RPM for 0.33 will in any case have xinetd support again (it's now
actually simpler than it used to be because logging plugins make an
external logging program unnecessary).

        hp

-- 
   _  | Peter J. Holzer    | Schlagfertigkeit ist das, was einem
|_|_) | Sysadmin WSR       | auf dem Nachhauseweg einfällt.
| |   | [EMAIL PROTECTED]         |    -- Lars 'Cebewee' Noschinski in dasr.
__/   | http://www.hjp.at/ |
--- lib/Qpsmtpd/TcpServer.pm.xinetd     Wed Oct  4 15:49:49 2006
+++ lib/Qpsmtpd/TcpServer.pm    Sun Nov  5 16:20:44 2006
@@ -1,6 +1,7 @@
 package Qpsmtpd::TcpServer;
 use Qpsmtpd::SMTP;
 use Qpsmtpd::Constants;
+use Socket;
 
 @ISA = qw(Qpsmtpd::SMTP);
 use strict;
@@ -12,12 +13,25 @@
 sub start_connection {
     my $self = shift;
 
-    die "Qpsmtpd::TcpServer must be started by tcpserver\n"
-      unless $ENV{TCPREMOTEIP};
+    my ($remote_host, $remote_info, $remote_ip);
 
-    my $remote_host = $ENV{TCPREMOTEHOST} || ( $ENV{TCPREMOTEIP} ? 
"[$ENV{TCPREMOTEIP}]" : "[noip!]");
-    my $remote_info = $ENV{TCPREMOTEINFO} ? "[EMAIL PROTECTED]" : $remote_host;
-    my $remote_ip   = $ENV{TCPREMOTEIP};
+    if ($ENV{TCPREMOTEIP}) {
+       # started from tcpserver (or some other superserver which
+       # exports the TCPREMOTE* variables.
+       $remote_ip   = $ENV{TCPREMOTEIP};
+       $remote_host = $ENV{TCPREMOTEHOST} || "[$remote_ip]";
+       $remote_info = $ENV{TCPREMOTEINFO} ? "[EMAIL PROTECTED]" : $remote_host;
+    } else {
+       # Started from inetd or similar. 
+       # get info on the remote host from the socket.
+       # ignore ident/tap/...
+       my $hersockaddr    = getpeername(STDIN) 
+           or die "getpeername failed: $0 must be called from tcpserver, 
(x)inetd or a similar program which passes a socket to stdin";
+       my ($port, $iaddr) = sockaddr_in($hersockaddr);
+       $remote_ip     = inet_ntoa($iaddr);
+       $remote_host    = gethostbyaddr($iaddr, AF_INET) || "[$remote_ip]";
+       $remote_info    = $remote_host;
+    }
     $self->log(LOGNOTICE, "Connection from $remote_info [$remote_ip]");
 
     # if the local dns resolver doesn't filter it out we might get

Attachment: signature.asc
Description: Digital signature

Reply via email to