openldap-2.4.39-ntlm-1.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. Submitted By: Armin K. <krejzi at email dot com>
  2. Date: 2012-04-06
  3. Initial Package Version: 2.4.30
  4. Upstream Status: Unknown
  5. Origin: Debian
  6. Description: Patch from evolution-exchange (2.10.3). The ldap_ntlm_bind function is
  7. actually called by evolution-data-server, checked at version 1.12.2.
  8. Without this patch, the Exchange addressbook integration uses simple binds
  9. with cleartext passwords.
  10. --- openldap.orig/include/ldap.h 2012-02-29 18:37:09.000000000 +0100
  11. +++ openldap/include/ldap.h 2012-04-01 00:20:00.059827789 +0200
  12. @@ -2517,5 +2517,25 @@
  13. LDAPControl **ctrls,
  14. LDAPDerefRes **drp ));
  15. +/*
  16. + * hacks for NTLM
  17. + */
  18. +#define LDAP_AUTH_NTLM_REQUEST ((ber_tag_t) 0x8aU)
  19. +#define LDAP_AUTH_NTLM_RESPONSE ((ber_tag_t) 0x8bU)
  20. +LDAP_F( int )
  21. +ldap_ntlm_bind LDAP_P((
  22. + LDAP *ld,
  23. + LDAP_CONST char *dn,
  24. + ber_tag_t tag,
  25. + struct berval *cred,
  26. + LDAPControl **sctrls,
  27. + LDAPControl **cctrls,
  28. + int *msgidp ));
  29. +LDAP_F( int )
  30. +ldap_parse_ntlm_bind_result LDAP_P((
  31. + LDAP *ld,
  32. + LDAPMessage *res,
  33. + struct berval *challenge));
  34. +
  35. LDAP_END_DECL
  36. #endif /* _LDAP_H */
  37. --- openldap.orig/libraries/libldap/Makefile.in 2012-04-01 00:18:54.233419658 +0200
  38. +++ openldap/libraries/libldap/Makefile.in 2012-04-01 00:20:00.060827810 +0200
  39. @@ -27,7 +27,7 @@
  40. init.c options.c print.c string.c util-int.c schema.c \
  41. charray.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
  42. tls2.c tls_o.c tls_g.c tls_m.c \
  43. - turn.c ppolicy.c dds.c txn.c ldap_sync.c stctrl.c \
  44. + turn.c ppolicy.c dds.c txn.c ldap_sync.c stctrl.c ntlm.c \
  45. assertion.c deref.c ldif.c fetch.c
  46. OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
  47. @@ -40,7 +40,7 @@
  48. init.lo options.lo print.lo string.lo util-int.lo schema.lo \
  49. charray.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
  50. tls2.lo tls_o.lo tls_g.lo tls_m.lo \
  51. - turn.lo ppolicy.lo dds.lo txn.lo ldap_sync.lo stctrl.lo \
  52. + turn.lo ppolicy.lo dds.lo txn.lo ldap_sync.lo stctrl.lo ntlm.lo \
  53. assertion.lo deref.lo ldif.lo fetch.lo
  54. LDAP_INCDIR= ../../include
  55. --- openldap.orig/libraries/libldap/ntlm.c 1970-01-01 01:00:00.000000000 +0100
  56. +++ openldap/libraries/libldap/ntlm.c 2012-04-01 00:20:00.059827789 +0200
  57. @@ -0,0 +1,138 @@
  58. +/* $OpenLDAP: pkg/ldap/libraries/libldap/ntlm.c,v 1.1.4.10 2002/01/04 20:38:21 kurt Exp $ */
  59. +/*
  60. + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  61. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  62. + */
  63. +
  64. +/* Mostly copied from sasl.c */
  65. +
  66. +#include "portable.h"
  67. +
  68. +#include <stdlib.h>
  69. +#include <stdio.h>
  70. +
  71. +#include <ac/socket.h>
  72. +#include <ac/string.h>
  73. +#include <ac/time.h>
  74. +#include <ac/errno.h>
  75. +
  76. +#include "ldap-int.h"
  77. +
  78. +int
  79. +ldap_ntlm_bind(
  80. + LDAP *ld,
  81. + LDAP_CONST char *dn,
  82. + ber_tag_t tag,
  83. + struct berval *cred,
  84. + LDAPControl **sctrls,
  85. + LDAPControl **cctrls,
  86. + int *msgidp )
  87. +{
  88. + BerElement *ber;
  89. + int rc;
  90. + ber_int_t id;
  91. +
  92. + Debug( LDAP_DEBUG_TRACE, "ldap_ntlm_bind\n", 0, 0, 0 );
  93. +
  94. + assert( ld != NULL );
  95. + assert( LDAP_VALID( ld ) );
  96. + assert( msgidp != NULL );
  97. +
  98. + if( msgidp == NULL ) {
  99. + ld->ld_errno = LDAP_PARAM_ERROR;
  100. + return ld->ld_errno;
  101. + }
  102. +
  103. + /* create a message to send */
  104. + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
  105. + ld->ld_errno = LDAP_NO_MEMORY;
  106. + return ld->ld_errno;
  107. + }
  108. +
  109. + assert( LBER_VALID( ber ) );
  110. +
  111. + LDAP_NEXT_MSGID( ld, id );
  112. + rc = ber_printf( ber, "{it{istON}" /*}*/,
  113. + id, LDAP_REQ_BIND,
  114. + ld->ld_version, dn, tag,
  115. + cred );
  116. +
  117. + /* Put Server Controls */
  118. + if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
  119. + ber_free( ber, 1 );
  120. + return ld->ld_errno;
  121. + }
  122. +
  123. + if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) {
  124. + ld->ld_errno = LDAP_ENCODING_ERROR;
  125. + ber_free( ber, 1 );
  126. + return ld->ld_errno;
  127. + }
  128. +
  129. + /* send the message */
  130. + *msgidp = ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber, id );
  131. +
  132. + if(*msgidp < 0)
  133. + return ld->ld_errno;
  134. +
  135. + return LDAP_SUCCESS;
  136. +}
  137. +
  138. +int
  139. +ldap_parse_ntlm_bind_result(
  140. + LDAP *ld,
  141. + LDAPMessage *res,
  142. + struct berval *challenge)
  143. +{
  144. + ber_int_t errcode;
  145. + ber_tag_t tag;
  146. + BerElement *ber;
  147. + ber_len_t len;
  148. +
  149. + Debug( LDAP_DEBUG_TRACE, "ldap_parse_ntlm_bind_result\n", 0, 0, 0 );
  150. +
  151. + assert( ld != NULL );
  152. + assert( LDAP_VALID( ld ) );
  153. + assert( res != NULL );
  154. +
  155. + if ( ld == NULL || res == NULL ) {
  156. + return LDAP_PARAM_ERROR;
  157. + }
  158. +
  159. + if( res->lm_msgtype != LDAP_RES_BIND ) {
  160. + ld->ld_errno = LDAP_PARAM_ERROR;
  161. + return ld->ld_errno;
  162. + }
  163. +
  164. + if ( ld->ld_error ) {
  165. + LDAP_FREE( ld->ld_error );
  166. + ld->ld_error = NULL;
  167. + }
  168. + if ( ld->ld_matched ) {
  169. + LDAP_FREE( ld->ld_matched );
  170. + ld->ld_matched = NULL;
  171. + }
  172. +
  173. + /* parse results */
  174. +
  175. + ber = ber_dup( res->lm_ber );
  176. +
  177. + if( ber == NULL ) {
  178. + ld->ld_errno = LDAP_NO_MEMORY;
  179. + return ld->ld_errno;
  180. + }
  181. +
  182. + tag = ber_scanf( ber, "{ioa" /*}*/,
  183. + &errcode, challenge, &ld->ld_error );
  184. + ber_free( ber, 0 );
  185. +
  186. + if( tag == LBER_ERROR ) {
  187. + ld->ld_errno = LDAP_DECODING_ERROR;
  188. + return ld->ld_errno;
  189. + }
  190. +
  191. + ld->ld_errno = errcode;
  192. +
  193. + return( ld->ld_errno );
  194. +}
  195. +
  196. --- openldap.orig/libraries/libldap_r/Makefile.in 2012-04-01 00:18:54.234419703 +0200
  197. +++ openldap/libraries/libldap_r/Makefile.in 2012-04-01 00:20:00.060827810 +0200
  198. @@ -29,7 +29,7 @@
  199. init.c options.c print.c string.c util-int.c schema.c \
  200. charray.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
  201. tls2.c tls_o.c tls_g.c tls_m.c \
  202. - turn.c ppolicy.c dds.c txn.c ldap_sync.c stctrl.c \
  203. + turn.c ppolicy.c dds.c txn.c ldap_sync.c stctrl.c ntlm.c \
  204. assertion.c deref.c ldif.c fetch.c
  205. SRCS = threads.c rdwr.c rmutex.c tpool.c rq.c \
  206. thr_posix.c thr_cthreads.c thr_thr.c thr_nt.c \
  207. @@ -47,7 +47,7 @@
  208. init.lo options.lo print.lo string.lo util-int.lo schema.lo \
  209. charray.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
  210. tls2.lo tls_o.lo tls_g.lo tls_m.lo \
  211. - turn.lo ppolicy.lo dds.lo txn.lo ldap_sync.lo stctrl.lo \
  212. + turn.lo ppolicy.lo dds.lo txn.lo ldap_sync.lo stctrl.lo ntlm.lo \
  213. assertion.lo deref.lo ldif.lo fetch.lo
  214. LDAP_INCDIR= ../../include