Here are the patches for the "writing to disconnected sockets" and "not running disconnect hooks" bugs I mentioned a few weeks ago.
I have also attached the setuid/address patch again, just in case it
has been forgotten about.
Let me know when these are committed so that I can forget about them.
Thanks,
Anthony
--
Au
PGP Key ID: 0x385B44CB
Fingerprint: 9E9E B116 DB2C D734 C090 E72F 43A0 95C4 385B 44CB
"Maximus vero fugiens a quodam Urso, milite Romano, interemptus est"
- Getica 235
--- /tmp/SelectServer.pm 2004-02-23 08:33:48.000000000 -0800
+++ lib/Qpsmtpd/SelectServer.pm 2004-03-08 21:53:16.000000000 -0800
@@ -131,6 +153,9 @@
next unless $outbuffer{$client};
#print "Writing to $client\n";
+ $client->connected or
+ freeclient($client), next;
+
my $rv = $client->send($outbuffer{$client}, 0);
unless (defined($rv)) {
warn("I was told to write, but I can't: $!\n");
--- /tmp/SelectServer.pm 2004-02-23 08:33:48.000000000 -0800
+++ lib/Qpsmtpd/SelectServer.pm 2004-03-08 21:53:16.000000000 -0800
@@ -164,6 +189,7 @@
delete $inbuffer{$client};
delete $outbuffer{$client};
delete $ready{$client};
+ $qp{$client}->disconnect();
delete $qp{$client};
$select->remove($client);
close($client);
--- /tmp/SelectServer.pm 2004-02-23 08:33:48.000000000 -0800
+++ lib/Qpsmtpd/SelectServer.pm 2004-03-08 21:53:16.000000000 -0800
@@ -35,9 +35,31 @@
sub main {
my $class = shift;
- my %opts = (LocalPort => 25, Reuse => 1, Listen => SOMAXCONN, @_);
+
+ my $temp = new Qpsmtpd::SMTP;
+
+ # gotta untaint this config stuff...
+ ($temp->config("IP") or "") =~ /([\d.]+)/ and
+ my $addr = $1;
+ ($temp->config("user") or "") =~ /(\w+)/ and
+ my $user = $1;
+
+ undef $temp;
+
+ $addr =~ /\:\d+$/ or
+ $addr .= ":25";
+
+ my %opts = (LocalAddr => $addr, Reuse => 1, Listen => SOMAXCONN, @_);
$server = IO::Socket::INET->new(%opts) or die "Server: $@";
- print "Listening on $opts{LocalPort}\n";
+ print "Listening on $opts{LocalAddr}\n";
+
+ my (undef, undef, $quid, $qgid) = getpwnam $user or
+ die "unable to determine uid/gid for $user\n";
+ $) = "";
+ POSIX::setgid($qgid) or
+ die "unable to change gid: $!\n";
+ POSIX::setuid($quid) or
+ die "unable to change uid: $!\n";
nonblock($server);
pgp00000.pgp
Description: PGP signature
