Hello,
this is a patch against qmail-ldap-20050401a to make auth_pop and auth_imap
work with tcpserver+ssl (patch from
http://www.nrg4u.com/qmail/ucspi-tcp-ssl-20050405.patch.gz)
It changes the function copyloop so that it uses to fds for the connection
to the {POP3|IMAP}-Client instead of one. One is used exclusively for reads
(stdin), one is used exclusively for writes (stdout). I think this is
necessary because of the way the tcpserver+ssl patch works: chained programs
get pipes instead of sockets for communication.
For me this causes the connection forwarding of auth_pop/auth_imap in
following scenario to work
User <---spop3---> cluster_member <---pop3--> mailbox_server
Previously the scenario above resulted in abortion of the connection as soon
the password was sent from the user.
best regards,
Jochen
--- qmail-1.03/auth_mod.c 2006-01-17 16:22:21.000000000 +0100
+++ qmail-1.03.orig/auth_mod.c 2005-12-27 13:22:16.000000000 +0100
@@ -219,7 +219,7 @@
#ifdef QLDAP_CLUSTER
static int allwrite(int (*)(),int, void *,int);
-static void copyloop(int, int, int, int);
+static void copyloop(int, int, int);
static char copybuf[4096];
static int
@@ -242,21 +242,21 @@
}
static void
-copyloop(int infdread, int infdwrite, int outfd, int timeout)
+copyloop(int infd, int outfd, int timeout)
{
fd_set iofds;
struct timeval tv;
int maxfd; /* Maximum numbered fd used */
int bytes, ret;
- ndelay_off(infdread); ndelay_off(infdwrite); ndelay_off(outfd);
+ ndelay_off(infd); ndelay_off(outfd);
while (1) {
/* file descriptor bits */
FD_ZERO(&iofds);
maxfd = -1;
- FD_SET(infdread, &iofds);
- if (infdread > maxfd)
- maxfd = infdread;
+ FD_SET(infd, &iofds);
+ if (infd > maxfd)
+ maxfd = infd;
FD_SET(outfd, &iofds);
if (outfd > maxfd)
maxfd = outfd;
@@ -274,8 +274,8 @@
logit(32, "copyloop: select timeout\n");
break;
}
- if (FD_ISSET(infdread, &iofds)) {
- if ((bytes = read(infdread, copybuf,
+ if (FD_ISSET(infd, &iofds)) {
+ if ((bytes = read(infd, copybuf,
sizeof(copybuf))) < 0) {
logit(1, "copyloop: read failed: %s\n",
error_str(errno));
@@ -299,15 +299,14 @@
logit(32, "copyloop: read in %i bytes read\n",
bytes);
if (bytes == 0)
break;
- if (allwrite(subwrite, infdwrite, copybuf, bytes) !=
0) {
+ if (allwrite(subwrite, infd, copybuf, bytes) != 0) {
logit(1, "copyloop: write in failed: %s\n",
error_str(errno));
break;
}
}
}
- close(infdread);
- close(infdwrite);
+ close(infd);
close(outfd);
return;
}
@@ -358,7 +357,7 @@
/* We have a connection, first send user and pass */
auth_forward(ffd, name, passwd);
- copyloop(0,1, ffd, timeout);
+ copyloop(0, ffd, timeout);
_exit(0); /* all went ok, exit normaly */
}
EOM