Subject: Q: reusing PREAUTH connections

From: John-Paul Robinson <[email-masked]>
Date: Mon, 07 Feb 2000 22:26:22 -0600

Hello,

We've noticed a peculiarity with the reuse of the mail stream for
PREAUTH'd connections. It appears the connections are not getting reused
for PREAUTH'd sessions.

If an IMAP connection is PREAUTH'd then the code in imap_open() can
cause the rewrite of the stream->mailbox to omit the closing "}" on the
network mailbox name. The problem seems to occur because imap_open()
assumes either LOCAL->user or usr[] will have been set by the time of
the rewrite of the mailbox name.  The reconnection is triggered because
the second mail_valid_net_parse() in mail_usable_network_stream() fails
due to the invalid stream->mailbox name set in the original imap_open(). 

To reproduce the problem, configure inetd to run imapd at some port
(8143) on localhost and start inetd as a normal user so connections are
PREAUTH'd.  Run ./imapd so it starts up PREAUTH'd. If you enter '1
select "{localhost:8143/debug}"' you will get the connection to inbox.
If you then enter '2 select "{localhost:8143/debug}inbox"' the first
connection will close and a new one will be established.

Is this the expected behavior?  Is an application using c-client
required to do some sort of initialization which prevents the missing
"user" string?  

Thanks,

John-Paul Robinson
[email-masked]
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Mon, 7 Feb 2000 21:19:48 -0800 (PST)

On Mon, 07 Feb 2000 22:26:22 -0600, John-Paul Robinson wrote:
> network mailbox name.

What is expected is that either you use ordinary TCP, and go through the IMAP
driver's authentication, or use a non-TCP mechanism akin to tcp_aopen() that
will set up the user string.

Having an ordinary TCP server return that it's preauthentication, without
benefit of either IMAP authenticator or tcp_aopen() authentication, is
completely unexpected.  Why are you doing this?

Nevertheless, I agree that the missing "}" is a bug.  The following patch will
fix it:

674c674
<       if (LOCAL->user) sprintf (tmp + strlen (tmp),"/user=\"%s\"}",
---
>       if (LOCAL->user) sprintf (tmp + strlen (tmp),"/user=\"%s\"",
686c686,687
< 	strcat (tmp,mb.mailbox);/* mailbox name */
---
> 				/* mailbox name */
> 	sprintf (tmp + strlen (tmp),"}%s",mb.mailbox);
706c707
<       strcat (tmp,"<no_mailbox>");
---
>       strcat (tmp,"}<no_mailbox>");

---

From: John-Paul Robinson <[email-masked]>
Date: Tue, 08 Feb 2000 18:52:06 -0600

We were doing this to help understand the protocol without needing
special priviledges to run a server.  I looked a little harder at the
RSH parameters and found that setting the RSHPATH to the imapd
executable will successfully invoke a local imapd process without using
inetd or rsh.  Is this a better solution?

  mail_parameters( NIL, SET_RSHPATH, "/usr/sbin/imapd" );
  mail_parameters( NIL, SET_RSHCOMMAND, "%s");
  mail_parameters( NIL, SET_RSHTIMEOUT, 30  );

Thanks for you help.

John-Paul Robinson