? mutt/aclocal.m4
? mutt/Makefile.in
? mutt/config.h.in
? mutt/configure
? mutt/.deps
? mutt/keymap_defs.h
? mutt/makedoc
? mutt/charmaps/Makefile.in
? mutt/charmaps/Makefile
? mutt/contrib/Makefile
? mutt/doc/manual.sgml
? mutt/doc/manual.txt
? mutt/doc/muttrc.man
? mutt/imap/Makefile.in
? mutt/imap/.deps
? mutt/m4/Makefile.in
? mutt/m4/Makefile.am
? mutt/po/de.gmo
? mutt/po/mutt.pot
? mutt/po/stamp-cat-id
? mutt/po/cat-id-tbl.c
? mutt/po/ru.gmo
? mutt/po/it.gmo
? mutt/po/es.gmo
? mutt/po/uk.gmo
? mutt/po/fr.gmo
? mutt/po/pl.gmo
? mutt/po/nl.gmo
? mutt/po/cs.gmo
? mutt/po/id.gmo
? mutt/po/sk.gmo
? mutt/po/ko.gmo
? mutt/po/el.gmo
? mutt/po/zh_TW.Big5.gmo
Index: mutt/Makefile.am
===================================================================
RCS file: /home/roessler/cvs/mutt/Makefile.am,v
retrieving revision 2.36
diff -c -r2.36 Makefile.am
*** Makefile.am	1999/09/02 11:17:34	2.36
--- Makefile.am	1999/09/09 13:52:31
***************
*** 37,43 ****
  	status.c system.c thread.c charset.c history.c lib.c \
  	muttlib.c editmsg.c
  
! mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(GSSLIBS) $(INTLLIBS) 
  mutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) $(INTLDEPS)
  
  CPP=@CPP@
--- 37,43 ----
  	status.c system.c thread.c charset.c history.c lib.c \
  	muttlib.c editmsg.c
  
! mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(GSSLIBS) $(NTLMLIB) $(INTLLIBS) 
  mutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) $(INTLDEPS)
  
  CPP=@CPP@
Index: mutt/acconfig.h
===================================================================
RCS file: /home/roessler/cvs/mutt/acconfig.h,v
retrieving revision 2.8
diff -c -r2.8 acconfig.h
*** acconfig.h	1999/08/23 14:21:33	2.8
--- acconfig.h	1999/09/09 13:52:32
***************
*** 48,53 ****
--- 48,56 ----
  /* Do you want support for the IMAP protocol? (--enable-imap) */
  #undef USE_IMAP
  
+ /* Do you want support for IMAP NTLM authentication? (--with-ntlm) */
+ #undef USE_NTLM
+ 
  /* Do you want support for IMAP GSSAPI authentication? (--with-gss) */
  #undef USE_GSS
  
Index: mutt/configure.in
===================================================================
RCS file: /home/roessler/cvs/mutt/configure.in,v
retrieving revision 2.31
diff -c -r2.31 configure.in
*** configure.in	1999/09/03 18:09:12	2.31
--- configure.in	1999/09/09 13:52:33
***************
*** 451,456 ****
--- 451,475 ----
  ])
  AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes)
  
+ AC_ARG_WITH(ntlm, [  --with-ntlm[=DIR]        Compile in NTLM authentication for IMAP],
+ 	[
+ 	if test "$with_ntlm" != "no"
+ 	then
+ 	  if test "$with_ntlm" != "yes"
+ 	  then
+ 	    CPPFLAGS="$CPPFLAGS -I$with_ntlm/include"
+ 	    LDFLAGS="$LDFLAGS -L$with_ntlm/lib"
+ 	  fi
+ 
+ 	  saved_LIBS="$LIBS"
+ 	  AC_CHECK_LIB(ntlm, buildSmbNtlmAuthResponse,,
+ 	    AC_MSG_ERROR([could not find libntlm which is needed for ntlm authentication]))
+ 	  LIBS="$saved_LIBS"
+ 	  NTLMLIB=" -lntlm"
+ 	  AC_DEFINE(USE_NTLM)
+ 	fi
+ ])
+ 
  AC_ARG_WITH(gss, [  --with-gss[=DIR]        Compile in GSSAPI authentication for IMAP],
  	[
  	if test "$with_gss" != "no"
***************
*** 527,532 ****
--- 546,552 ----
  AC_SUBST(LIBIMAP)
  AC_SUBST(LIBIMAPDEPS)
  AC_SUBST(GSSLIBS)
+ AC_SUBST(NTLMLIB)
  
  MUTT_AM_GNU_GETTEXT
  CPPFLAGS="$CPPFLAGS -I\$(srcdir)/intl"
Index: mutt/imap/auth.c
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/auth.c,v
retrieving revision 1.3
diff -c -r1.3 auth.c
*** auth.c	1999/09/02 07:41:34	1.3
--- auth.c	1999/09/09 13:52:44
***************
*** 73,79 ****
      secret_len = MD5_DIGEST_LEN;
    }
    else
!     strfcpy ((char *) secret, password, sizeof (secret));
  
    memset (ipad, 0, sizeof (ipad));
    memset (opad, 0, sizeof (opad));
--- 73,79 ----
      secret_len = MD5_DIGEST_LEN;
    }
    else
!     strfcpy ((char*)secret, password, sizeof (secret));
  
    memset (ipad, 0, sizeof (ipad));
    memset (opad, 0, sizeof (opad));
***************
*** 396,401 ****
--- 396,492 ----
    return -1;
  }
  
+ 
+ 
+ 
+ 
+ #if defined(USE_NTLM)
+ 
+ #include "ntlm.h"
+ 
+ int imap_auth_ntlm(IMAP_DATA *idata, char *user, char *pass)
+ {
+   char buf[LONG_STRING];
+   char seq[16];
+   char tmpstr[32];
+   int len;
+   tSmbNtlmAuthRequest   request;              
+   tSmbNtlmAuthChallenge challenge;
+   tSmbNtlmAuthResponse  response;
+   
+   mutt_message _("NTLM Authentication...");
+   imap_make_sequence (seq, sizeof (seq));
+   
+   snprintf (buf, sizeof (buf), "%s AUTHENTICATE NTLM\r\n", seq);
+ 
+   mutt_socket_write (idata->conn, buf);
+   
+   if (mutt_socket_read_line_d (buf, sizeof buf, idata->conn) < 0)
+     return -1;
+   
+   if (buf[0] != '+')
+     return -1;
+   
+   buildSmbNtlmAuthRequest(&request,user,NULL);
+ 
+ #ifdef DEBUG
+   if (debuglevel > 0)
+     dumpSmbNtlmAuthRequest(debugfile,&request);
+ #endif  
+   
+   memset(buf,0,sizeof buf);
+   mutt_to_base64((unsigned char*)buf, (unsigned char*)&request, SmbLength(&request));
+   strcat(buf,"\r\n");
+ 
+   mutt_socket_write (idata->conn, buf);
+   
+   if (mutt_socket_read_line_d (buf, sizeof buf, idata->conn) < 0)
+     return -1;
+   
+   if ((buf[0] != '+') || (buf[1] != ' '))
+     return -1;
+   
+   len = mutt_from_base64((char*)&challenge, buf+2);
+   
+ #ifdef DEBUG
+   if (debuglevel > 0)
+     dumpSmbNtlmAuthChallenge(debugfile,&challenge);
+ #endif
+ 
+   buildSmbNtlmAuthResponse(&challenge, &response, user, pass);
+ 
+ #ifdef DEBUG
+   if (debuglevel > 0)
+     dumpSmbNtlmAuthResponse(debugfile,&response);
+ #endif
+   
+   memset(buf,0,sizeof buf);
+   mutt_to_base64((unsigned char*)buf, (unsigned char*)&response, SmbLength(&response));
+   strcat(buf,"\r\n");
+ 
+   mutt_socket_write (idata->conn, buf);
+   
+   if (mutt_socket_read_line_d (buf, sizeof buf, idata->conn) < 0)
+     return -1;
+ 
+   snprintf (tmpstr, sizeof tmpstr, "%s OK", seq);
+   
+   if (strncmp(buf,tmpstr,strlen(tmpstr)))
+   {
+     mutt_error _("Login failed.");
+     FREE (&ImapUser);
+     FREE (&ImapPass);
+     return -2;
+   }
+ 
+   return 0;
+ }
+ #endif
+ 
+ 
+ 
+ 
+ 
  /* imap_authenticate: loop until success or user abort. At each loop, all
   *   supported authentication methods are tried, from strongest to weakest.
   *   Currently available:
***************
*** 436,442 ****
      }
      else
        strfcpy (user, ImapUser, sizeof (user));
! 
  #ifdef USE_GSS
      /* attempt GSSAPI authentication, if available */
      if (mutt_bit_isset (idata->capabilities, AGSSAPI))
--- 527,533 ----
      }
      else
        strfcpy (user, ImapUser, sizeof (user));
!     
  #ifdef USE_GSS
      /* attempt GSSAPI authentication, if available */
      if (mutt_bit_isset (idata->capabilities, AGSSAPI))
***************
*** 495,500 ****
--- 586,616 ----
      else
        strfcpy (pass, ImapPass, sizeof (pass));
  
+ #ifdef USE_NTLM
+     if (mutt_bit_isset (idata->capabilities, ANTLM))
+     {
+       if ((r = imap_auth_ntlm (idata, user, pass)))
+       {
+         mutt_error _("NTLM authentication failed.");
+         sleep (1);
+       FREE (&ImapUser);
+       FREE (&ImapPass);
+       }
+       else
+       {
+ 	/* If they have a successful login, we may as well cache the 
+ 	 * user/password. */
+ 	if (!ImapUser)
+ 	  ImapUser = safe_strdup (user);
+ 	if (!ImapPass)
+ 	  ImapPass = safe_strdup (pass);
+         return 0;
+       }
+     }
+     else
+       dprint (2, (debugfile, "NTLM authentication is not available\n"));
+ #endif    
+ 
      imap_quote_string (q_user, sizeof (q_user), user);
      imap_quote_string (q_pass, sizeof (q_pass), pass);
  
***************
*** 528,530 ****
--- 644,648 ----
    }
    return 0;
  }
+ 
+ 
Index: mutt/imap/imap.c
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/imap.c,v
retrieving revision 1.7
diff -c -r1.7 imap.c
*** imap.c	1999/09/08 06:05:54	1.7
--- imap.c	1999/09/09 13:52:55
***************
*** 39,45 ****
  #include <sys/stat.h>
  
  static char *Capabilities[] = {"IMAP4", "IMAP4rev1", "STATUS", "ACL", 
!   "NAMESPACE", "AUTH=CRAM-MD5", "AUTH=KERBEROS_V4", "AUTH=GSSAPI", 
    "AUTH=LOGIN", "AUTH-LOGIN", "AUTH=PLAIN", "AUTH=SKEY", "IDLE", 
    "LOGIN-REFERRALS", "MAILBOX-REFERRALS", "QUOTA", "SCAN", "SORT", 
    "THREAD=ORDEREDSUBJECT", "UIDPLUS", NULL};
--- 39,45 ----
  #include <sys/stat.h>
  
  static char *Capabilities[] = {"IMAP4", "IMAP4rev1", "STATUS", "ACL", 
!   "NAMESPACE", "AUTH=CRAM-MD5", "AUTH=KERBEROS_V4", "AUTH=GSSAPI", "AUTH=NTLM",
    "AUTH=LOGIN", "AUTH-LOGIN", "AUTH=PLAIN", "AUTH=SKEY", "IDLE", 
    "LOGIN-REFERRALS", "MAILBOX-REFERRALS", "QUOTA", "SCAN", "SORT", 
    "THREAD=ORDEREDSUBJECT", "UIDPLUS", NULL};
Index: mutt/imap/imap_private.h
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/imap_private.h,v
retrieving revision 1.6
diff -c -r1.6 imap_private.h
*** imap_private.h	1999/09/08 06:05:54	1.6
--- imap_private.h	1999/09/09 13:52:56
***************
*** 85,90 ****
--- 85,91 ----
    ACRAM_MD5,			/* RFC 2195: CRAM-MD5 authentication */
    AKERBEROS_V4,			/* AUTH=KERBEROS_V4 */
    AGSSAPI,			/* RFC 1731: GSSAPI authentication */
+   ANTLM,                        /* AUTH=NTLM for MS Exchange Server */
    /* From here down, we don't care */
    ALOGIN,			/* AUTH=LOGIN */
    AUTH_LOGIN,			/* AUTH-LOGIN */
