diff -ru /usr/local/src/libc-client-ssl2001.2/uw-imap-ssl-2001adebian/imap-2001a/src/c-client/mail.c imap-2001a/src/c-client/mail.c
--- /usr/local/src/libc-client-ssl2001.2/uw-imap-ssl-2001adebian/imap-2001a/src/c-client/mail.c	Tue Nov 13 21:29:07 2001
+++ imap-2001a/src/c-client/mail.c	Thu Sep 23 18:48:50 2004
@@ -509,7 +509,7 @@
   char tmp[MAILTMPLEN];
   DRIVER *factory = NIL;
 				/* validate name, find driver factory */
-  if (strlen (mailbox) < (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+50))
+  if (strlen (mailbox) < (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+NETMAXTUNNEL+50))
     for (factory = maildrivers; factory && 
 	 ((factory->flags & DR_DISABLE) ||
 	  ((factory->flags & DR_LOCAL) && (*mailbox == '{')) ||
@@ -604,6 +604,8 @@
 	}
 	if (!compare_cstring (s,"service") && (i < NETMAXSRV) && !*mb->service)
 	  strcpy (mb->service,lcase (v));
+	else if (!compare_cstring (s,"tunnel") && (i < NETMAXTUNNEL) && !*mb->tunnel)
+	  strcpy (mb->tunnel,v);
 	else if (!compare_cstring (s,"user") && (i < NETMAXUSER) && !*mb->user)
 	  strcpy (mb->user,v);
 	else if (!compare_cstring (s,"authuser") && (i < NETMAXUSER) &&
@@ -800,7 +802,7 @@
   char *s,*t,tmp[MAILTMPLEN];
   size_t i;
   DRIVER *d;
-  if (strlen (mailbox) >= (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+50)) {
+  if (strlen (mailbox) >= (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+NETMAXTUNNEL+50)) {
     sprintf (tmp,"Can't create %.80s: %s",mailbox,(*mailbox == '{') ?
 	     "invalid remote specification" : "no such mailbox");
     MM_LOG (tmp,ERROR);
@@ -2170,7 +2172,7 @@
 {
   char *s,tmp[MAILTMPLEN];
   DRIVER *d = NIL;
-  if (strlen (mailbox) >= (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+50)) {
+  if (strlen (mailbox) >= (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+NETMAXTUNNEL+50)) {
     sprintf (tmp,"Can't append %.80s: %s",mailbox,(*mailbox == '{') ?
 	     "invalid remote specification" : "no such mailbox");
     MM_LOG (tmp,ERROR);
diff -ru /usr/local/src/libc-client-ssl2001.2/uw-imap-ssl-2001adebian/imap-2001a/src/c-client/mail.h imap-2001a/src/c-client/mail.h
--- /usr/local/src/libc-client-ssl2001.2/uw-imap-ssl-2001adebian/imap-2001a/src/c-client/mail.h	Tue Nov 13 21:29:05 2001
+++ imap-2001a/src/c-client/mail.h	Thu Sep 23 18:45:38 2004
@@ -495,6 +495,7 @@
 #define NETMAXUSER 65
 #define NETMAXMBX (MAILTMPLEN/4)
 #define NETMAXSRV 21
+#define NETMAXTUNNEL 256
 typedef struct net_mailbox {
   char host[NETMAXHOST];	/* host name (may be canonicalized) */
   char orighost[NETMAXHOST];	/* host name before canonicalization */
@@ -502,6 +503,7 @@
   char authuser[NETMAXUSER];	/* authentication user name */
   char mailbox[NETMAXMBX];	/* mailbox name */
   char service[NETMAXSRV];	/* service name */
+  char tunnel[NETMAXTUNNEL];    /* ssh tunnel replacement */
   unsigned long port;		/* TCP port number */
   unsigned int anoflag : 1;	/* anonymous */
   unsigned int dbgflag : 1;	/* debug flag */
diff -ru /usr/local/src/libc-client-ssl2001.2/uw-imap-ssl-2001adebian/imap-2001a/src/osdep/unix/tcp_unix.c imap-2001a/src/osdep/unix/tcp_unix.c
--- /usr/local/src/libc-client-ssl2001.2/uw-imap-ssl-2001adebian/imap-2001a/src/osdep/unix/tcp_unix.c	Sat Oct 27 05:25:12 2001
+++ imap-2001a/src/osdep/unix/tcp_unix.c	Thu Sep 23 18:47:36 2004
@@ -366,7 +366,10 @@
     (*bn) (BLOCK_NONE,NIL);
   }
 
-  if (*service == '*')		/* build ssh command */
+  if (mb->tunnel[0])
+    sprintf (tmp,mb->tunnel,host,
+	     mb->user[0] ? mb->user : myusername (),service + 1);
+  else if (*service == '*')		/* build ssh command */
     sprintf (tmp,sshcommand,sshpath,host,
 	     mb->user[0] ? mb->user : myusername (),service + 1);
   else sprintf (tmp,rshcommand,rshpath,host,
