merge the formfield patch from ooo-build
[ooovba.git] / neon / neon.patch
blob569ed0f0a1892d68197a23e8e8e97064d0968783
1 --- misc/neon-0.28.2/src/config.h 2009-08-30 19:00:56.000000000 +0200
2 +++ misc/build/neon-0.28.2/src/config.h 2009-08-11 09:48:54.000000000 +0200
3 @@ -1 +1,484 @@
4 -dummy
6 +/* Define to specific EGD socket path */
7 +/* #undef EGD_PATH */
9 +/* Define if EGD should be supported */
10 +/* #undef ENABLE_EGD */
12 +/* Define if GSS_C_NT_HOSTBASED_SERVICE is not defined otherwise */
13 +/* #undef GSS_C_NT_HOSTBASED_SERVICE */
15 +/* Define to 1 if you have the <arpa/inet.h> header file. */
16 +#ifdef UNX
17 +#define HAVE_ARPA_INET_H 1
18 +#endif
20 +/* Define to 1 if you have the `bind_textdomain_codeset' function. */
21 +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET 1 */
23 +/* Define to 1 if you have the declaration of `h_errno', and to 0 if you
24 + don't. */
25 +#ifdef WIN32
26 +#define HAVE_DECL_H_ERRNO 1
27 +#endif
29 +/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
30 + */
31 +#ifdef LINUX
32 +#define HAVE_DECL_STPCPY 1
33 +#endif
35 +/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
36 + don't. */
37 +#ifdef LINUX
38 +#define HAVE_DECL_STRERROR_R 1
39 +#endif
41 +/* Define to 1 if you have the <dlfcn.h> header file. */
42 +#ifdef UNX
43 +#define HAVE_DLFCN_H 1
44 +#endif
46 +/* Define to 1 if you have the <errno.h> header file. */
47 +#define HAVE_ERRNO_H 1
49 +/* Define if you have expat */
50 +/* #undef HAVE_EXPAT */
52 +/* Define to 1 if you have the `fstat64' function. */
53 +#define HAVE_FSTAT64
55 +/* Define to 1 if you have the `gai_strerror' function. */
56 +#define HAVE_GAI_STRERROR 1
58 +/* Define if GnuTLS support is enabled */
59 +/* #undef HAVE_GNUTLS */
61 +/* Define to 1 if you have the `gnutls_session_get_data2' function. */
62 +/* #undef HAVE_GNUTLS_SESSION_GET_DATA2 */
64 +/* Define if GSSAPI support is enabled */
65 +/* #undef HAVE_GSSAPI */
67 +/* Define to 1 if you have the <gssapi/gssapi_generic.h> header file. */
68 +/* #undef HAVE_GSSAPI_GSSAPI_GENERIC_H */
70 +/* Define to 1 if you have the <gssapi/gssapi.h> header file. */
71 +/* #undef HAVE_GSSAPI_GSSAPI_H */
73 +/* Define to 1 if you have the <gssapi.h> header file. */
74 +/* #undef HAVE_GSSAPI_H */
76 +/* Define to 1 if you have the `gss_init_sec_context' function. */
77 +/* #undef HAVE_GSS_INIT_SEC_CONTEXT */
79 +/* Define to 1 if you have the `hstrerror' function. */
80 +/* #undef HAVE_HSTRERROR */
82 +/* Define to 1 if you have the `inet_ntop' function. */
83 +#ifdef UNX
84 +#define HAVE_INET_NTOP 1
85 +#endif
87 +/* Define to 1 if you have the <inttypes.h> header file. */
88 +#ifdef UNX
89 +#define HAVE_INTTYPES_H 1
90 +#endif
92 +/* Define to 1 if you have the `isatty' function. */
93 +#define HAVE_ISATTY 1
95 +/* Define to 1 if you have the <libintl.h> header file. */
96 +/* #undef HAVE_LIBINTL_H */
98 +/* Define if you have libxml */
99 +#define HAVE_LIBXML 1
101 +/* Define to 1 if you have the <libxml/parser.h> header file. */
102 +#define HAVE_LIBXML_PARSER_H 1
104 +/* Define to 1 if you have the <libxml/xmlversion.h> header file. */
105 +#define HAVE_LIBXML_XMLVERSION_H 1
107 +/* Define to 1 if you have the <limits.h> header file. */
108 +#define HAVE_LIMITS_H 1
110 +/* Define to 1 if you have the <locale.h> header file. */
111 +#define HAVE_LOCALE_H 1
113 +/* Define to 1 if you have the `lseek64' function. */
114 +#define HAVE_LSEEK64 1
116 +/* Define to 1 if you have the <memory.h> header file. */
117 +#define HAVE_MEMORY_H 1
119 +/* Define to 1 if you have the <netdb.h> header file. */
120 +#ifdef UNX
121 +#define HAVE_NETDB_H 1
122 +#endif
124 +/* Define to 1 if you have the <netinet/in.h> header file. */
125 +#ifdef UNX
126 +#define HAVE_NETINET_IN_H 1
127 +#endif
129 +/* Define to 1 if you have the <netinet/tcp.h> header file. */
130 +#ifdef UNX
131 +#define HAVE_NETINET_TCP_H 1
132 +#endif
134 +/* Define if OpenSSL support is enabled */
135 +/* #undef HAVE_OPENSSL */
136 +#define HAVE_OPENSSL
137 +/* Define to 1 if you have the <openssl/opensslv.h> header file. */
138 +/* #undef HAVE_OPENSSL_OPENSSLV_H */
139 +#define HAVE_OPENSSL_OPENSSLV_H 1
140 +/* Define to 1 if you have the <openssl/ssl.h> header file. */
141 +/* #undef HAVE_OPENSSL_SSL_H */
142 +#define HAVE_OPENSSL_SSL_H 1
143 +/* Define to 1 if you have the `pipe' function. */
144 +#define HAVE_PIPE 1
146 +/* Define to 1 if you have the `poll' function. */
147 +#define HAVE_POLL 1
149 +/* Define to 1 if you have the `pthread_mutex_init' function. */
150 +/* #undef HAVE_PTHREAD_MUTEX_INIT */
152 +/* Define to 1 if you have the `pthread_mutex_lock' function. */
153 +/* #undef HAVE_PTHREAD_MUTEX_LOCK */
155 +/* Define to 1 if you have the `setlocale' function. */
156 +#define HAVE_SETLOCALE 1
158 +/* Define to 1 if you have the `setsockopt' function. */
159 +#if defined (LINUX) || defined (WIN32)
160 +#define HAVE_SETSOCKOPT 1
161 +#endif
163 +/* Define to 1 if you have the `setvbuf' function. */
164 +#define HAVE_SETVBUF 1
166 +/* Define to 1 if you have the `shutdown' function. */
167 +#ifdef LINUX
168 +#define HAVE_SHUTDOWN 1
169 +#endif
171 +/* Define to 1 if you have the `signal' function. */
172 +#define HAVE_SIGNAL 1
174 +/* Define to 1 if you have the <signal.h> header file. */
175 +#define HAVE_SIGNAL_H 1
177 +/* Define to 1 if you have the `snprintf' function. */
178 +#ifdef UNX
179 +#define HAVE_SNPRINTF 1
180 +#endif
182 +#ifdef WIN32
183 +#define snprintf _snprintf
184 +#endif
186 +/* Define to 1 if you have the <socks.h> header file. */
187 +/* #undef HAVE_SOCKS_H */
189 +/* Define to 1 if you have the <stdarg.h> header file. */
190 +#define HAVE_STDARG_H 1
192 +/* Define to 1 if you have the <stdint.h> header file. */
193 +#define HAVE_STDINT_H 1
195 +/* Define to 1 if you have the <stdlib.h> header file. */
196 +#define HAVE_STDLIB_H 1
198 +/* Define to 1 if you have the `stpcpy' function. */
199 +#ifdef LINUX
200 +#define HAVE_STPCPY 1
201 +#endif
203 +/* Define to 1 if you have the `strcasecmp' function. */
204 +#ifdef UNX
205 +#define HAVE_STRCASECMP 1
206 +#endif
208 +#ifdef WIN32
209 +#define strcasecmp strcmpi
210 +#endif
212 +/* Define to 1 if you have the `strerror_r' function. */
213 +#ifdef LINUX
214 +#define HAVE_STRERROR_R 1
215 +#endif
217 +/* Define to 1 if you have the <strings.h> header file. */
218 +#ifdef UNX
219 +#define HAVE_STRINGS_H 1
220 +#endif
222 +/* Define to 1 if you have the <string.h> header file. */
223 +#define HAVE_STRING_H 1
225 +/* Define to 1 if you have the `strtoll' function. */
226 +#define HAVE_STRTOLL 1
228 +/* Define to 1 if you have the `strtoq' function. */
229 +/* #undef HAVE_STRTOQ */
231 +/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */
232 +#ifdef LINUX
233 +#define HAVE_STRUCT_TM_TM_GMTOFF 1
234 +#endif
236 +/* Define to 1 if `__tm_gmtoff' is member of `struct tm'. */
237 +/* #undef HAVE_STRUCT_TM___TM_GMTOFF */
239 +/* Define to 1 if you have the <sys/limits.h> header file. */
240 +/* #undef HAVE_SYS_LIMITS_H */
242 +/* Define to 1 if you have the <sys/poll.h> header file. */
243 +#ifdef UNX
244 +#define HAVE_SYS_POLL_H 1
245 +#endif
247 +/* Define to 1 if you have the <sys/select.h> header file. */
248 +#ifdef UNX
249 +#define HAVE_SYS_SELECT_H 1
250 +#endif
252 +/* Define to 1 if you have the <sys/socket.h> header file. */
253 +#ifdef UNX
254 +#define HAVE_SYS_SOCKET_H 1
255 +#endif
257 +/* Define to 1 if you have the <sys/stat.h> header file. */
258 +#define HAVE_SYS_STAT_H 1
260 +/* Define to 1 if you have the <sys/time.h> header file. */
261 +#ifdef UNX
262 +#define HAVE_SYS_TIME_H 1
263 +#endif
265 +/* Define to 1 if you have the <sys/types.h> header file. */
266 +#define HAVE_SYS_TYPES_H 1
268 +/* Define if the timezone global is available */
269 +#ifndef MACOSX
270 +#define HAVE_TIMEZONE 1
271 +#endif
273 +/* Use trio printf replacement library */
274 +/* #undef HAVE_TRIO */
276 +/* Define to 1 if you have the <trio.h> header file. */
277 +/* #undef HAVE_TRIO_H */
279 +/* Define to 1 if you have the <unistd.h> header file. */
280 +#ifdef UNX
281 +#define HAVE_UNISTD_H 1
282 +#endif
284 +/* Define to 1 if you have the `usleep' function. */
285 +#ifdef UNX
286 +#define HAVE_USLEEP 1
287 +#endif
289 +/* Define to 1 if you have the `vsnprintf' function. */
290 +#if defined( UNX ) || (defined(_MSC_VER) && (_MSC_VER > 1400))
291 +#define HAVE_VSNPRINTF 1
292 +#endif
294 +#ifdef WIN32
295 +#if (defined(_MSC_VER) && (_MSC_VER < 1500)) || defined(__MINGW32__)
296 +#define vsnprintf _vsnprintf
297 +#endif
298 +#endif
300 +/* Define to be location of localedir */
301 +/* #undef LOCALEDIR */
303 +/* Defined when neon is built as a library */
304 +#define NEON_IS_LIBRARY 1
306 +/* Define to be the neon version string */
307 +#define NEON_VERSION "0.28.2"
309 +/* Define to enable debugging */
310 +/* #undef NE_DEBUGGING */
312 +/* Define to be printf format string for off64_t */
313 +#define NE_FMT_OFF64_T "lld"
315 +/* Define to be printf format string for off_t */
316 +#define NE_FMT_OFF_T "ld"
318 +/* Define to be printf format string for size_t */
319 +#define NE_FMT_SIZE_T "u"
321 +/* Define to be printf format string for ssize_t */
322 +#define NE_FMT_SSIZE_T "d"
324 +/* Define to be printf format string for time_t */
325 +#define NE_FMT_TIME_T "ld"
327 +/* Defined if DAV is supported */
328 +#define NE_HAVE_DAV 1
330 +/* Defined if I18N is supported */
331 +/* #undef NE_HAVE_I18N 1 */
333 +/* Defined if IPV6 is supported */
334 +#define NE_HAVE_IPV6 1
336 +/* Defined if LFS is supported */
337 +#define NE_HAVE_LFS 1
339 +/* Defined if SOCKS is supported */
340 +/* #undef NE_HAVE_SOCKS */
342 +/* Defined if SSL is supported */
343 +/* #undef NE_HAVE_SSL */
344 +#define NE_HAVE_SSL
345 +/* Defined if TS_SSL is supported */
346 +/* #undef NE_HAVE_TS_SSL */
348 +/* Defined if ZLIB is supported */
349 +/* #undef NE_HAVE_ZLIB */
351 +/* Define to be filename of an SSL CA root bundle */
352 +/* #undef NE_SSL_CA_BUNDLE */
354 +/* Define if poll() should be used */
355 +#ifdef UNX
356 +#define NE_USE_POLL 1
357 +#endif
359 +/* Define to be neon library major version */
360 +#define NE_VERSION_MAJOR (0)
362 +/* Define to be neon library minor version */
363 +#define NE_VERSION_MINOR (28)
365 +/* Define to be neon library patch version */
366 +#define NE_VERSION_PATCH (2)
368 +/* Define to the address where bug reports for this package should be sent. */
369 +#define PACKAGE_BUGREPORT "neon@webdav.org"
371 +/* Define to the full name of this package. */
372 +#define PACKAGE_NAME "neon"
374 +/* Define to the full name and version of this package. */
375 +#define PACKAGE_STRING "neon 0.28.2"
377 +/* Define to the one symbol short name of this package. */
378 +#define PACKAGE_TARNAME "neon"
380 +/* Define to the version of this package. */
381 +#define PACKAGE_VERSION "0.28.2"
383 +/* The size of a `int', as computed by sizeof. */
384 +#define SIZEOF_INT 4
386 +/* The size of a `long', as computed by sizeof. */
387 +#define SIZEOF_LONG 4
389 +/* The size of a `long long', as computed by sizeof. */
390 +#define SIZEOF_LONG_LONG 8
392 +/* The size of a `off64_t', as computed by sizeof. */
393 +#define SIZEOF_OFF64_T 8
395 +/* The size of a `off_t', as computed by sizeof. */
396 +#define SIZEOF_OFF_T 4
398 +/* The size of a `size_t', as computed by sizeof. */
399 +#define SIZEOF_SIZE_T 4
401 +/* The size of a `ssize_t', as computed by sizeof. */
402 +#define SIZEOF_SSIZE_T 4
404 +/* The size of a `time_t', as computed by sizeof. */
405 +#define SIZEOF_TIME_T 4
407 +/* Define to 1 if you have the ANSI C header files. */
408 +#ifdef SOLARIS
409 +#define STDC_HEADERS 1
410 +#endif
412 +/* Define to 1 if strerror_r returns char *. */
413 +#ifdef LINUX
414 +#define STRERROR_R_CHAR_P 1
415 +#endif
417 +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
418 +#define TIME_WITH_SYS_TIME 1
420 +/* Define if getaddrinfo supports AI_ADDRCONFIG */
421 +/* #undef USE_GAI_ADDRCONFIG */
423 +/* Define if getaddrinfo() should be used */
424 +#define USE_GETADDRINFO 1
426 +/* Define to 1 if your processor stores words with the most significant byte
427 + first (like Motorola and SPARC, unlike Intel and VAX). */
428 +#if defined (SOLARIS) && defined (SPARC)
429 +#define WORDS_BIGENDIAN 1
430 +#endif
432 +/* Always defined to enable GNU extensions */
433 +#define _GNU_SOURCE 1
435 +/* Define to empty if `const' does not conform to ANSI C. */
436 +/* #undef const */
438 +/* Define if in_addr_t is not available */
439 +/* #undef in_addr_t */
441 +/* Define to `__inline__' or `__inline' if that's what the C compiler
442 + calls it, or to nothing if 'inline' is not supported under any name. */
443 +#ifndef __cplusplus
444 +#if defined (SOLARIS) && defined (__SUNPRO_C)
445 +#define inline
446 +#endif
447 +#endif
449 +/* Define to `long' if <sys/types.h> does not define. */
450 +/* #undef off_t */
452 +/* Define to `int' if <sys/types.h> does not define. */
453 +/* #undef pid_t */
455 +/* Define to `unsigned' if <sys/types.h> does not define. */
456 +/* #undef size_t */
459 +/* Enable leak-tracking versions of ne_*alloc when NEON_MEMLEAK is enabled */
460 +#ifdef NEON_MEMLEAK
461 +# include "memleak.h"
462 +#endif
464 +#if defined(HAVE_STPCPY) && defined(HAVE_DECL_STPCPY) && !HAVE_DECL_STPCPY && !defined(stpcpy)
465 +char *stpcpy(char *, const char *);
466 +#endif
468 +#ifdef WIN32
470 +#include <io.h>
472 +#define HAVE_MEMCPY 1
474 +#define strncasecmp strnicmp
475 +#define inline __inline
476 +#define WIN32_LEAN_AND_MEAN
477 +#define NOUSER
478 +#define NOGDI
479 +#define NONLS
480 +#define NOCRYPT
482 +#endif
484 +#ifdef WIN32
485 +#define HAVE_SSPI 1
486 +#else
487 +#define HAVE_NTLM 1
488 +#endif
489 --- misc/neon-0.28.2/src/makefile.mk 2009-08-30 19:00:56.000000000 +0200
490 +++ misc/build/neon-0.28.2/src/makefile.mk 2009-08-11 09:48:54.000000000 +0200
491 @@ -1 +1,59 @@
492 -dummy
493 +PRJ=..$/..$/..$/..$/..
495 +PRJNAME=neon
496 +TARGET=neon
497 +LIBTARGET=NO
498 +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
500 +# --- Settings -----------------------------------------------------
502 +.INCLUDE : settings.mk
504 +# --- Files --------------------------------------------------------
506 +CDEFS+=-DHAVE_CONFIG_H
508 +.IF "$(SYSTEM_LIBXML)" == "YES"
509 +CFLAGS+=-DSYSTEM_LIBXML $(LIBXML_CFLAGS)
510 +.ENDIF
513 +SLOFILES= \
514 + $(SLO)$/ne_207.obj \
515 + $(SLO)$/ne_acl.obj \
516 + $(SLO)$/ne_alloc.obj \
517 + $(SLO)$/ne_auth.obj \
518 + $(SLO)$/ne_basic.obj \
519 + $(SLO)$/ne_compress.obj \
520 + $(SLO)$/ne_dates.obj \
521 + $(SLO)$/ne_i18n.obj \
522 + $(SLO)$/ne_locks.obj \
523 + $(SLO)$/ne_md5.obj \
524 + $(SLO)$/ne_props.obj \
525 + $(SLO)$/ne_redirect.obj \
526 + $(SLO)$/ne_request.obj \
527 + $(SLO)$/ne_session.obj \
528 + $(SLO)$/ne_socket.obj \
529 + $(SLO)$/ne_string.obj \
530 + $(SLO)$/ne_uri.obj \
531 + $(SLO)$/ne_utils.obj \
532 + $(SLO)$/ne_xml.obj \
533 + $(SLO)$/ne_xmlreq.obj \
534 + $(SLO)$/ne_openssl.obj
536 +.IF "$(OS)"=="WNT"
537 +SLOFILES+=$(SLO)$/ne_sspi.obj
538 +.ELSE
539 +SLOFILES+=$(SLO)$/ne_ntlm.obj
540 +.ENDIF
542 +# $(SLO)$/ne_gnutls.obj \
543 +# $(SLO)$/ne_stubssl.obj
545 +LIB1TARGET=$(SLB)$/$(TARGET).lib
546 +LIB1ARCHIV=$(LB)$/lib$(TARGET).a
547 +LIB1OBJFILES=$(SLOFILES)
549 +# --- Targets ------------------------------------------------------
551 +.INCLUDE : target.mk
552 --- misc/neon-0.28.2/src/ne_auth.c 2008-02-29 17:30:12.000000000 +0100
553 +++ misc/build/neon-0.28.2/src/ne_auth.c 2009-08-24 15:41:32.000000000 +0200
554 @@ -77,6 +77,10 @@
555 #include "ne_sspi.h"
556 #endif
558 +#ifdef HAVE_NTLM
559 +#include "ne_ntlm.h"
560 +#endif
562 #define HOOK_SERVER_ID "http://webdav.org/neon/hooks/server-auth"
563 #define HOOK_PROXY_ID "http://webdav.org/neon/hooks/proxy-auth"
565 @@ -173,6 +177,10 @@
566 char *sspi_token;
567 void *sspi_context;
568 #endif
569 +#ifdef HAVE_NTLM
570 + /* This is used for NTLM auth */
571 + ne_ntlm_context *ntlm_context;
572 +#endif
573 /* These all used for Digest auth */
574 char *realm;
575 char *nonce;
576 @@ -287,6 +295,11 @@
577 ne_sspi_destroy_context(sess->sspi_context);
578 sess->sspi_context = NULL;
579 #endif
580 +#ifdef HAVE_NTLM
581 + ne_ntlm_destroy_context(sess->ntlm_context);
582 + sess->ntlm_context = NULL;
583 +#endif
584 + sess->protocol = NULL;
587 /* Returns client nonce string. */
588 @@ -351,7 +364,7 @@
589 static int get_credentials(auth_session *sess, ne_buffer **errmsg, int attempt,
590 struct auth_challenge *chall, char *pwbuf)
592 - if (chall->handler->creds(chall->handler->userdata, sess->realm,
593 + if (chall->handler->creds(chall->handler->userdata, chall->protocol->name, sess->realm,
594 chall->handler->attempt++, sess->username, pwbuf) == 0) {
595 return 0;
596 } else {
597 @@ -598,9 +611,10 @@
598 int ntlm = ne_strcasecmp(parms->protocol->name, "NTLM") == 0;
599 int status;
600 char *response = NULL;
602 + char password[NE_ABUFSIZ];
604 NE_DEBUG(NE_DBG_HTTPAUTH, "auth: SSPI challenge.\n");
607 if (!sess->sspi_context) {
608 ne_uri uri = {0};
610 @@ -614,8 +628,17 @@
611 return status;
615 + /* Authentification needs more than one http request.
616 + * As long as authentification in progress use the existing credentials.
617 + * Otherwise get new credentials.*/
618 + if (!parms->opaque)
619 + if (get_credentials(sess, errmsg, attempt, parms, password)) {
620 + /* Failed to get credentials */
621 + return -1;
624 - status = ne_sspi_authenticate(sess->sspi_context, parms->opaque, &response);
625 + status = ne_sspi_authenticate(sess->sspi_context, parms->opaque, &response, sess->username, password);
626 if (status) {
627 return status;
629 @@ -685,6 +708,62 @@
630 return invalid;
633 +#ifdef HAVE_NTLM
635 +static char *request_ntlm(auth_session *sess, struct auth_request *request)
637 + char *token = ne_ntlm_getRequestToken(sess->ntlm_context);
638 + if (token) {
639 + char * req = ne_concat(sess->protocol->name, " ", token, "\r\n", NULL);
640 + ne_free(token);
641 + return req;
642 + } else {
643 + return NULL;
647 +static int ntlm_challenge(auth_session *sess, int attempt,
648 + struct auth_challenge *parms,
649 + ne_buffer **errmsg)
651 + int status;
653 + NE_DEBUG(NE_DBG_HTTPAUTH, "auth: NTLM challenge.\n");
655 + if (!parms->opaque) {
656 + char password[NE_ABUFSIZ];
658 + if (get_credentials(sess, errmsg, attempt, parms, password)) {
659 + /* Failed to get credentials */
660 + return -1;
663 + if (sess->ntlm_context) {
664 + status = ne_ntlm_destroy_context(sess->ntlm_context);
665 + sess->ntlm_context = NULL;
666 + if (status) {
667 + return status;
671 + status = ne_ntlm_create_context(&sess->ntlm_context,
672 + sess->username,
673 + password);
674 + if (status) {
675 + return status;
679 + status = ne_ntlm_authenticate(sess->ntlm_context, parms->opaque);
680 + if (status) {
681 + return status;
684 + return 0;
686 +#endif /* HAVE_NTLM */
689 /* Examine a digest challenge: return 0 if it is a valid Digest challenge,
690 * else non-zero. */
691 static int digest_challenge(auth_session *sess, int attempt,
692 @@ -1134,6 +1213,11 @@
693 sspi_challenge, request_sspi, NULL,
694 AUTH_FLAG_OPAQUE_PARAM|AUTH_FLAG_VERIFY_NON40x|AUTH_FLAG_CONN_AUTH },
695 #endif
696 +#ifdef HAVE_NTLM
697 + { NE_AUTH_NEGOTIATE, 30, "NTLM",
698 + ntlm_challenge, request_ntlm, NULL,
699 + AUTH_FLAG_OPAQUE_PARAM|AUTH_FLAG_VERIFY_NON40x|AUTH_FLAG_CONN_AUTH },
700 +#endif
701 { 0 }
704 @@ -1431,6 +1515,11 @@
705 ne_sspi_clear_context(sess->sspi_context);
707 #endif
708 +#ifdef HAVE_NTLM
709 + if (sess->ntlm_context) {
710 + ne_ntlm_clear_context(sess->ntlm_context);
712 +#endif
714 return ret;
716 --- misc/neon-0.28.2/src/ne_auth.h 2007-12-05 17:39:58.000000000 +0100
717 +++ misc/build/neon-0.28.2/src/ne_auth.h 2009-08-24 15:16:22.000000000 +0200
718 @@ -47,8 +47,8 @@
719 * Hint: if you just wish to attempt authentication just once (even if
720 * the user gets the username/password wrong), have the callback
721 * function use 'attempt' value as the function return value. */
722 -typedef int (*ne_auth_creds)(void *userdata, const char *realm, int attempt,
723 - char *username, char *password);
724 +typedef int (*ne_auth_creds)(void *userdata, const char * auth_protocol,
725 + const char *realm, int attempt, char *username, char *password);
727 /* Set callbacks to provide credentials for server and proxy
728 * authentication, using the default set of authentication protocols.
729 --- misc/neon-0.28.2/src/ne_defs.h 2006-10-24 21:40:09.000000000 +0200
730 +++ misc/build/neon-0.28.2/src/ne_defs.h 2009-08-11 09:48:54.000000000 +0200
731 @@ -41,7 +41,7 @@
732 #endif
734 /* define ssize_t for Win32 */
735 -#if defined(WIN32) && !defined(ssize_t)
736 +#if defined(WIN32) && !defined(ssize_t) && !defined(__MINGW32__)
737 #define ssize_t int
738 #endif
740 --- misc/neon-0.28.2/src/ne_locks.h 2006-01-02 12:43:19.000000000 +0100
741 +++ misc/build/neon-0.28.2/src/ne_locks.h 2009-08-11 09:48:54.000000000 +0200
742 @@ -22,6 +22,10 @@
743 #ifndef NE_LOCKS_H
744 #define NE_LOCKS_H
746 +# if defined __GNUC__
747 +# pragma GCC system_header
748 +# endif
750 #include "ne_request.h" /* for ne_session + ne_request */
751 #include "ne_uri.h" /* for ne_uri */
753 --- misc/neon-0.28.2/src/ne_ntlm.c 2009-08-30 19:00:56.000000000 +0200
754 +++ misc/build/neon-0.28.2/src/ne_ntlm.c 2009-08-11 09:48:54.000000000 +0200
755 @@ -1 +1,700 @@
756 -dummy
757 +/*
758 + Handling of NTLM Authentication
759 + Copyright (C) 2003, Daniel Stenberg <daniel@haxx.se>
760 + Copyright (C) 2009, Kai Sommerfeld <kso@openoffice.org>
762 + This library is free software; you can redistribute it and/or
763 + modify it under the terms of the GNU Library General Public
764 + License as published by the Free Software Foundation; either
765 + version 2 of the License, or (at your option) any later version.
767 + This library is distributed in the hope that it will be useful,
768 + but WITHOUT ANY WARRANTY; without even the implied warranty of
769 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
770 + Library General Public License for more details.
772 + You should have received a copy of the GNU Library General Public
773 + License along with this library; if not, write to the Free
774 + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
775 + MA 02111-1307, USA
779 +/* NTLM details:
781 + http://davenport.sourceforge.net/ntlm.html
782 + http://www.innovation.ch/java/ntlm.html
786 +#include "ne_ntlm.h"
788 +#ifdef HAVE_NTLM
790 +#include "ne_string.h"
792 +typedef enum {
793 + NTLMSTATE_NONE,
794 + NTLMSTATE_TYPE1,
795 + NTLMSTATE_TYPE2,
796 + NTLMSTATE_TYPE3,
797 + NTLMSTATE_LAST
798 +} NTLMState;
800 +struct ne_ntlm_context_s {
801 + NTLMState state;
802 + unsigned char nonce[8];
803 + char *user;
804 + char *passwd;
805 + char *requestToken;
808 +typedef enum {
809 + NTLM_NONE, /* not a ntlm */
810 + NTLM_BAD, /* an ntlm, but one we don't like */
811 + NTLM_FIRST, /* the first 401-reply we got with NTLM */
812 + NTLM_FINE, /* an ntlm we act on */
814 + NTLM_LAST /* last entry in this enum, don't use */
815 +} ntlm;
817 +/* Flag bits definitions based on http://davenport.sourceforge.net/ntlm.html */
819 +#define NTLMFLAG_NEGOTIATE_UNICODE (1<<0)
820 +/* Indicates that Unicode strings are supported for use in security buffer
821 + data. */
823 +#define NTLMFLAG_NEGOTIATE_OEM (1<<1)
824 +/* Indicates that OEM strings are supported for use in security buffer data. */
826 +#define NTLMFLAG_REQUEST_TARGET (1<<2)
827 +/* Requests that the server's authentication realm be included in the Type 2
828 + message. */
830 +/* unknown (1<<3) */
831 +#define NTLMFLAG_NEGOTIATE_SIGN (1<<4)
832 +/* Specifies that authenticated communication between the client and server
833 + should carry a digital signature (message integrity). */
835 +#define NTLMFLAG_NEGOTIATE_SEAL (1<<5)
836 +/* Specifies that authenticated communication between the client and server
837 + should be encrypted (message confidentiality). */
839 +#define NTLMFLAG_NEGOTIATE_DATAGRAM_STYLE (1<<6)
840 +/* unknown purpose */
842 +#define NTLMFLAG_NEGOTIATE_LM_KEY (1<<7)
843 +/* Indicates that the LAN Manager session key should be used for signing and
844 + sealing authenticated communications. */
846 +#define NTLMFLAG_NEGOTIATE_NETWARE (1<<8)
847 +/* unknown purpose */
849 +#define NTLMFLAG_NEGOTIATE_NTLM_KEY (1<<9)
850 +/* Indicates that NTLM authentication is being used. */
852 +/* unknown (1<<10) */
853 +/* unknown (1<<11) */
855 +#define NTLMFLAG_NEGOTIATE_DOMAIN_SUPPLIED (1<<12)
856 +/* Sent by the client in the Type 1 message to indicate that a desired
857 + authentication realm is included in the message. */
859 +#define NTLMFLAG_NEGOTIATE_WORKSTATION_SUPPLIED (1<<13)
860 +/* Sent by the client in the Type 1 message to indicate that the client
861 + workstation's name is included in the message. */
863 +#define NTLMFLAG_NEGOTIATE_LOCAL_CALL (1<<14)
864 +/* Sent by the server to indicate that the server and client are on the same
865 + machine. Implies that the client may use a pre-established local security
866 + context rather than responding to the challenge. */
868 +#define NTLMFLAG_NEGOTIATE_ALWAYS_SIGN (1<<15)
869 +/* Indicates that authenticated communication between the client and server
870 + should be signed with a "dummy" signature. */
872 +#define NTLMFLAG_TARGET_TYPE_DOMAIN (1<<16)
873 +/* Sent by the server in the Type 2 message to indicate that the target
874 + authentication realm is a domain. */
876 +#define NTLMFLAG_TARGET_TYPE_SERVER (1<<17)
877 +/* Sent by the server in the Type 2 message to indicate that the target
878 + authentication realm is a server. */
880 +#define NTLMFLAG_TARGET_TYPE_SHARE (1<<18)
881 +/* Sent by the server in the Type 2 message to indicate that the target
882 + authentication realm is a share. Presumably, this is for share-level
883 + authentication. Usage is unclear. */
885 +#define NTLMFLAG_NEGOTIATE_NTLM2_KEY (1<<19)
886 +/* Indicates that the NTLM2 signing and sealing scheme should be used for
887 + protecting authenticated communications. */
889 +#define NTLMFLAG_REQUEST_INIT_RESPONSE (1<<20)
890 +/* unknown purpose */
892 +#define NTLMFLAG_REQUEST_ACCEPT_RESPONSE (1<<21)
893 +/* unknown purpose */
895 +#define NTLMFLAG_REQUEST_NONNT_SESSION_KEY (1<<22)
896 +/* unknown purpose */
898 +#define NTLMFLAG_NEGOTIATE_TARGET_INFO (1<<23)
899 +/* Sent by the server in the Type 2 message to indicate that it is including a
900 + Target Information block in the message. */
902 +/* unknown (1<24) */
903 +/* unknown (1<25) */
904 +/* unknown (1<26) */
905 +/* unknown (1<27) */
906 +/* unknown (1<28) */
908 +#define NTLMFLAG_NEGOTIATE_128 (1<<29)
909 +/* Indicates that 128-bit encryption is supported. */
911 +#define NTLMFLAG_NEGOTIATE_KEY_EXCHANGE (1<<30)
912 +/* unknown purpose */
914 +#define NTLMFLAG_NEGOTIATE_56 (1<<31)
915 +/* Indicates that 56-bit encryption is supported. */
917 +#ifdef HAVE_OPENSSL
918 +/* We need OpenSSL for the crypto lib to provide us with MD4 and DES */
920 +/* -- WIN32 approved -- */
921 +#include <stdio.h>
922 +#include <string.h>
923 +#include <stdarg.h>
924 +#include <stdlib.h>
925 +#include <ctype.h>
927 +#include <openssl/des.h>
928 +#include <openssl/md4.h>
929 +#include <openssl/ssl.h>
931 +#if OPENSSL_VERSION_NUMBER < 0x00907001L
932 +#define DES_key_schedule des_key_schedule
933 +#define DES_cblock des_cblock
934 +#define DES_set_odd_parity des_set_odd_parity
935 +#define DES_set_key des_set_key
936 +#define DES_ecb_encrypt des_ecb_encrypt
938 +/* This is how things were done in the old days */
939 +#define DESKEY(x) x
940 +#define DESKEYARG(x) x
941 +#else
942 +/* Modern version */
943 +#define DESKEYARG(x) *x
944 +#define DESKEY(x) &x
945 +#endif
947 +/* Define this to make the type-3 message include the NT response message */
948 +#define USE_NTRESPONSES 1
951 + (*) = A "security buffer" is a triplet consisting of two shorts and one
952 + long:
954 + 1. a 'short' containing the length of the buffer in bytes
955 + 2. a 'short' containing the allocated space for the buffer in bytes
956 + 3. a 'long' containing the offset to the start of the buffer from the
957 + beginning of the NTLM message, in bytes.
960 +static ntlm ne_input_ntlm(ne_ntlm_context *ctx,
961 + const char *responseToken)
963 + if(responseToken) {
964 + /* We got a type-2 message here:
966 + Index Description Content
967 + 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP"
968 + (0x4e544c4d53535000)
969 + 8 NTLM Message Type long (0x02000000)
970 + 12 Target Name security buffer(*)
971 + 20 Flags long
972 + 24 Challenge 8 bytes
973 + (32) Context (optional) 8 bytes (two consecutive longs)
974 + (40) Target Information (optional) security buffer(*)
975 + 32 (48) start of data block
976 + */
977 + unsigned char * buffer = NULL;
979 + int size = ne_unbase64(responseToken, &buffer);
981 + ctx->state = NTLMSTATE_TYPE2; /* we got a type-2 */
983 + if(size >= 48)
984 + /* the nonce of interest is index [24 .. 31], 8 bytes */
985 + memcpy(ctx->nonce, &buffer[24], 8);
987 + /* at index decimal 20, there's a 32bit NTLM flag field */
989 + if (buffer) ne_free(buffer);
991 + else {
992 + if(ctx->state >= NTLMSTATE_TYPE1)
993 + return NTLM_BAD;
995 + ctx->state = NTLMSTATE_TYPE1; /* we should sent away a type-1 */
997 + return NTLM_FINE;
1001 + * Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The
1002 + * key schedule ks is also set.
1003 + */
1004 +static void setup_des_key(unsigned char *key_56,
1005 + DES_key_schedule DESKEYARG(ks))
1007 + DES_cblock key;
1009 + key[0] = key_56[0];
1010 + key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1);
1011 + key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2);
1012 + key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3);
1013 + key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4);
1014 + key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5);
1015 + key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6);
1016 + key[7] = (key_56[6] << 1) & 0xFF;
1018 + DES_set_odd_parity(&key);
1019 + DES_set_key(&key, ks);
1022 + /*
1023 + * takes a 21 byte array and treats it as 3 56-bit DES keys. The
1024 + * 8 byte plaintext is encrypted with each key and the resulting 24
1025 + * bytes are stored in the results array.
1026 + */
1027 +static void calc_resp(unsigned char *keys,
1028 + unsigned char *plaintext,
1029 + unsigned char *results)
1031 + DES_key_schedule ks;
1033 + setup_des_key(keys, DESKEY(ks));
1034 + DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) results,
1035 + DESKEY(ks), DES_ENCRYPT);
1037 + setup_des_key(keys+7, DESKEY(ks));
1038 + DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results+8),
1039 + DESKEY(ks), DES_ENCRYPT);
1041 + setup_des_key(keys+14, DESKEY(ks));
1042 + DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results+16),
1043 + DESKEY(ks), DES_ENCRYPT);
1047 + * Set up lanmanager and nt hashed passwords
1048 + */
1049 +static void mkhash(char *password,
1050 + unsigned char *nonce, /* 8 bytes */
1051 + unsigned char *lmresp /* must fit 0x18 bytes */
1052 +#ifdef USE_NTRESPONSES
1053 + , unsigned char *ntresp /* must fit 0x18 bytes */
1054 +#endif
1057 + unsigned char lmbuffer[21];
1058 +#ifdef USE_NTRESPONSES
1059 + unsigned char ntbuffer[21];
1060 +#endif
1061 + unsigned char *pw;
1062 + static const unsigned char magic[] = {
1063 + 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25
1064 + };
1065 + int i;
1066 + int len = strlen(password);
1068 + /* make it fit at least 14 bytes */
1069 + pw = malloc(len<7?14:len*2);
1070 + if(!pw)
1071 + return; /* this will lead to a badly generated package */
1073 + if (len > 14)
1074 + len = 14;
1076 + for (i=0; i<len; i++)
1077 + pw[i] = toupper(password[i]);
1079 + for (; i<14; i++)
1080 + pw[i] = 0;
1083 + /* create LanManager hashed password */
1084 + DES_key_schedule ks;
1086 + setup_des_key(pw, DESKEY(ks));
1087 + DES_ecb_encrypt((DES_cblock *)magic, (DES_cblock *)lmbuffer,
1088 + DESKEY(ks), DES_ENCRYPT);
1090 + setup_des_key(pw+7, DESKEY(ks));
1091 + DES_ecb_encrypt((DES_cblock *)magic, (DES_cblock *)(lmbuffer+8),
1092 + DESKEY(ks), DES_ENCRYPT);
1094 + memset(lmbuffer+16, 0, 5);
1096 + /* create LM responses */
1097 + calc_resp(lmbuffer, nonce, lmresp);
1099 +#ifdef USE_NTRESPONSES
1101 + /* create NT hashed password */
1102 + MD4_CTX MD4;
1104 + len = strlen(password);
1106 + for (i=0; i<len; i++) {
1107 + pw[2*i] = password[i];
1108 + pw[2*i+1] = 0;
1111 + MD4_Init(&MD4);
1112 + MD4_Update(&MD4, pw, 2*len);
1113 + MD4_Final(ntbuffer, &MD4);
1115 + memset(ntbuffer+16, 0, 8);
1118 + calc_resp(ntbuffer, nonce, ntresp);
1119 +#endif
1121 + free(pw);
1124 +#define SHORTPAIR(x) ((x) & 0xff), ((x) >> 8)
1125 +#define LONGQUARTET(x) ((x) & 0xff), (((x) >> 8)&0xff), \
1126 + (((x) >>16)&0xff), ((x)>>24)
1128 +/* this is for creating ntlm header output */
1129 +static int ne_output_ntlm(ne_ntlm_context *ctx)
1131 + const char *domain=""; /* empty */
1132 + const char *host=""; /* empty */
1133 + int domlen=strlen(domain);
1134 + int hostlen = strlen(host);
1135 + int hostoff; /* host name offset */
1136 + int domoff; /* domain name offset */
1137 + int size;
1138 + unsigned char ntlmbuf[256]; /* enough, unless the host/domain is very long */
1140 + if(!ctx->user || !ctx->passwd)
1141 + /* no user, no auth */
1142 + return 0; /* OK */
1144 + switch(ctx->state) {
1145 + case NTLMSTATE_TYPE1:
1146 + default: /* for the weird cases we (re)start here */
1147 + hostoff = 32;
1148 + domoff = hostoff + hostlen;
1150 + /* Create and send a type-1 message:
1152 + Index Description Content
1153 + 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP"
1154 + (0x4e544c4d53535000)
1155 + 8 NTLM Message Type long (0x01000000)
1156 + 12 Flags long
1157 + 16 Supplied Domain security buffer(*)
1158 + 24 Supplied Workstation security buffer(*)
1159 + 32 start of data block
1161 + */
1163 + snprintf((char *)ntlmbuf, sizeof(ntlmbuf), "NTLMSSP%c"
1164 + "\x01%c%c%c" /* 32-bit type = 1 */
1165 + "%c%c%c%c" /* 32-bit NTLM flag field */
1166 + "%c%c" /* domain length */
1167 + "%c%c" /* domain allocated space */
1168 + "%c%c" /* domain name offset */
1169 + "%c%c" /* 2 zeroes */
1170 + "%c%c" /* host length */
1171 + "%c%c" /* host allocated space */
1172 + "%c%c" /* host name offset */
1173 + "%c%c" /* 2 zeroes */
1174 + "%s" /* host name */
1175 + "%s", /* domain string */
1176 + 0, /* trailing zero */
1177 + 0,0,0, /* part of type-1 long */
1179 + LONGQUARTET(
1180 + NTLMFLAG_NEGOTIATE_OEM| /* 2 */
1181 + NTLMFLAG_NEGOTIATE_NTLM_KEY /* 200 */
1182 + /* equals 0x0202 */
1183 + ),
1184 + SHORTPAIR(domlen),
1185 + SHORTPAIR(domlen),
1186 + SHORTPAIR(domoff),
1187 + 0,0,
1188 + SHORTPAIR(hostlen),
1189 + SHORTPAIR(hostlen),
1190 + SHORTPAIR(hostoff),
1191 + 0,0,
1192 + host, domain);
1194 + /* initial packet length */
1195 + size = 32 + hostlen + domlen;
1197 + /* now keeper of the base64 encoded package size */
1198 + if (ctx->requestToken) ne_free(ctx->requestToken);
1199 + ctx->requestToken = ne_base64(ntlmbuf, size);
1201 + break;
1203 + case NTLMSTATE_TYPE2:
1204 + /* We received the type-2 already, create a type-3 message:
1206 + Index Description Content
1207 + 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP"
1208 + (0x4e544c4d53535000)
1209 + 8 NTLM Message Type long (0x03000000)
1210 + 12 LM/LMv2 Response security buffer(*)
1211 + 20 NTLM/NTLMv2 Response security buffer(*)
1212 + 28 Domain Name security buffer(*)
1213 + 36 User Name security buffer(*)
1214 + 44 Workstation Name security buffer(*)
1215 + (52) Session Key (optional) security buffer(*)
1216 + (60) Flags (optional) long
1217 + 52 (64) start of data block
1219 + */
1222 + int lmrespoff;
1223 + int ntrespoff;
1224 + int useroff;
1225 + unsigned char lmresp[0x18]; /* fixed-size */
1226 +#ifdef USE_NTRESPONSES
1227 + unsigned char ntresp[0x18]; /* fixed-size */
1228 +#endif
1229 + const char *user;
1230 + int userlen;
1232 + user = strchr(ctx->user, '\\');
1233 + if(!user)
1234 + user = strchr(ctx->user, '/');
1236 + if (user) {
1237 + domain = ctx->user;
1238 + domlen = user - domain;
1239 + user++;
1241 + else
1242 + user = ctx->user;
1243 + userlen = strlen(user);
1245 + mkhash(ctx->passwd, &ctx->nonce[0], lmresp
1246 +#ifdef USE_NTRESPONSES
1247 + , ntresp
1248 +#endif
1249 + );
1251 + domoff = 64; /* always */
1252 + useroff = domoff + domlen;
1253 + hostoff = useroff + userlen;
1254 + lmrespoff = hostoff + hostlen;
1255 + ntrespoff = lmrespoff + 0x18;
1257 + /* Create the big type-3 message binary blob */
1258 + size = snprintf((char *)ntlmbuf, sizeof(ntlmbuf),
1259 + "NTLMSSP%c"
1260 + "\x03%c%c%c" /* type-3, 32 bits */
1262 + "%c%c%c%c" /* LanManager length + allocated space */
1263 + "%c%c" /* LanManager offset */
1264 + "%c%c" /* 2 zeroes */
1266 + "%c%c" /* NT-response length */
1267 + "%c%c" /* NT-response allocated space */
1268 + "%c%c" /* NT-response offset */
1269 + "%c%c" /* 2 zeroes */
1271 + "%c%c" /* domain length */
1272 + "%c%c" /* domain allocated space */
1273 + "%c%c" /* domain name offset */
1274 + "%c%c" /* 2 zeroes */
1276 + "%c%c" /* user length */
1277 + "%c%c" /* user allocated space */
1278 + "%c%c" /* user offset */
1279 + "%c%c" /* 2 zeroes */
1281 + "%c%c" /* host length */
1282 + "%c%c" /* host allocated space */
1283 + "%c%c" /* host offset */
1284 + "%c%c%c%c%c%c" /* 6 zeroes */
1286 + "\xff\xff" /* message length */
1287 + "%c%c" /* 2 zeroes */
1289 + "\x01\x82" /* flags */
1290 + "%c%c" /* 2 zeroes */
1292 + /* domain string */
1293 + /* user string */
1294 + /* host string */
1295 + /* LanManager response */
1296 + /* NT response */
1298 + 0, /* zero termination */
1299 + 0,0,0, /* type-3 long, the 24 upper bits */
1301 + SHORTPAIR(0x18), /* LanManager response length, twice */
1302 + SHORTPAIR(0x18),
1303 + SHORTPAIR(lmrespoff),
1304 + 0x0, 0x0,
1306 +#ifdef USE_NTRESPONSES
1307 + SHORTPAIR(0x18), /* NT-response length, twice */
1308 + SHORTPAIR(0x18),
1309 +#else
1310 + 0x0, 0x0,
1311 + 0x0, 0x0,
1312 +#endif
1313 + SHORTPAIR(ntrespoff),
1314 + 0x0, 0x0,
1316 + SHORTPAIR(domlen),
1317 + SHORTPAIR(domlen),
1318 + SHORTPAIR(domoff),
1319 + 0x0, 0x0,
1321 + SHORTPAIR(userlen),
1322 + SHORTPAIR(userlen),
1323 + SHORTPAIR(useroff),
1324 + 0x0, 0x0,
1326 + SHORTPAIR(hostlen),
1327 + SHORTPAIR(hostlen),
1328 + SHORTPAIR(hostoff),
1329 + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
1331 + 0x0, 0x0,
1333 + 0x0, 0x0);
1335 + /* size is now 64 */
1336 + size=64;
1337 + ntlmbuf[62]=ntlmbuf[63]=0;
1339 + /* Make sure that the user and domain strings fit in the target buffer
1340 + before we copy them there. */
1341 + if(size + userlen + domlen >= sizeof(ntlmbuf)) {
1342 + return -1;
1345 + memcpy(&ntlmbuf[size], domain, domlen);
1346 + size += domlen;
1348 + memcpy(&ntlmbuf[size], user, userlen);
1349 + size += userlen;
1351 + /* we append the binary hashes to the end of the blob */
1352 + if(size < ((int)sizeof(ntlmbuf) - 0x18)) {
1353 + memcpy(&ntlmbuf[size], lmresp, 0x18);
1354 + size += 0x18;
1357 +#ifdef USE_NTRESPONSES
1358 + if(size < ((int)sizeof(ntlmbuf) - 0x18)) {
1359 + memcpy(&ntlmbuf[size], ntresp, 0x18);
1360 + size += 0x18;
1362 +#endif
1364 + ntlmbuf[56] = size & 0xff;
1365 + ntlmbuf[57] = size >> 8;
1367 + /* convert the binary blob into base64 */
1368 + ctx->requestToken = ne_base64(ntlmbuf, size);
1370 + ctx->state = NTLMSTATE_TYPE3; /* we sent a type-3 */
1372 + break;
1374 + case NTLMSTATE_TYPE3:
1375 + /* connection is already authenticated,
1376 + * don't send a header in future requests */
1377 + if (ctx->requestToken) ne_free(ctx->requestToken);
1378 + ctx->requestToken = NULL;
1379 + break;
1382 + return 0; /* OK */
1385 +int ne_ntlm_create_context(ne_ntlm_context **context, const char *userName, const char *password)
1387 + if (context == NULL) {
1388 + return -1;
1389 + } else {
1390 + ne_ntlm_context *ctx = ne_calloc(sizeof(ne_ntlm_context));
1392 + ctx->state = NTLMSTATE_NONE;
1393 + ctx->user = ne_strdup(userName);
1394 + ctx->passwd = ne_strdup(password);
1396 + *context = ctx;
1397 + return 0;
1401 +int ne_ntlm_destroy_context(ne_ntlm_context *context)
1403 + if (context != NULL) {
1404 + if (context->user)
1405 + ne_free(context->user);
1407 + if (context->passwd)
1408 + ne_free(context->passwd);
1410 + if (context->requestToken)
1411 + ne_free(context->requestToken);
1413 + ne_free(context);
1415 + return 0;
1418 +int ne_ntlm_clear_context(ne_ntlm_context *context)
1420 + return 0;
1423 +int ne_ntlm_authenticate(ne_ntlm_context *context, const char *responseToken)
1425 + if (context == NULL) {
1426 + return -1;
1427 + } else {
1428 + if (context->state <= NTLMSTATE_TYPE3) {
1429 + ntlm ntlmstatus = ne_input_ntlm(context, responseToken);
1431 + if (ntlmstatus != NTLM_FINE) {
1432 + return -1;
1436 + return ne_output_ntlm(context);
1439 +char *ne_ntlm_getRequestToken(ne_ntlm_context *context)
1441 + if (context == NULL) {
1442 + return NULL;
1443 + } else {
1444 + if (context->requestToken) {
1445 + char *ret = ne_strdup(context->requestToken);
1446 + ne_free(context->requestToken);
1447 + context->requestToken = NULL;
1448 + return ret;
1449 + } else {
1450 + return NULL;
1455 +#endif /* HAVE_OPENSSL */
1456 +#endif /* HAVE_NTLM */
1457 --- misc/neon-0.28.2/src/ne_ntlm.h 2009-08-30 19:00:56.000000000 +0200
1458 +++ misc/build/neon-0.28.2/src/ne_ntlm.h 2009-08-11 09:48:54.000000000 +0200
1459 @@ -1 +1,44 @@
1460 -dummy
1461 +/*
1462 + Handling of NTLM Authentication
1463 + Copyright (C) 2009, Kai Sommerfeld <kso@openoffice.org>
1465 + This library is free software; you can redistribute it and/or
1466 + modify it under the terms of the GNU Library General Public
1467 + License as published by the Free Software Foundation; either
1468 + version 2 of the License, or (at your option) any later version.
1470 + This library is distributed in the hope that it will be useful,
1471 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1472 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1473 + Library General Public License for more details.
1475 + You should have received a copy of the GNU Library General Public
1476 + License along with this library; if not, write to the Free
1477 + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
1478 + MA 02111-1307, USA
1481 +#ifndef NE_NTLM_H
1482 +#define NE_NTLM_H
1484 +#include "config.h"
1486 +/* PRIVATE TO NEON -- NOT PART OF THE EXTERNAL API. */
1488 +#ifdef HAVE_NTLM
1490 +typedef struct ne_ntlm_context_s ne_ntlm_context;
1492 +int ne_ntlm_create_context(ne_ntlm_context **context, const char *userName, const char *password);
1494 +int ne_ntlm_destroy_context(ne_ntlm_context *context);
1496 +int ne_ntlm_clear_context(ne_ntlm_context *context);
1498 +int ne_ntlm_authenticate(ne_ntlm_context *context, const char *responseToken);
1500 +char *ne_ntlm_getRequestToken(ne_ntlm_context *context);
1502 +#endif /* HAVE_NTLM */
1504 +#endif /* NE_NTLM_H */
1505 --- misc/neon-0.28.2/src/ne_socket.c 2008-02-28 14:19:19.000000000 +0100
1506 +++ misc/build/neon-0.28.2/src/ne_socket.c 2009-08-11 09:48:54.000000000 +0200
1507 @@ -60,6 +60,7 @@
1508 #include <stddef.h>
1509 #ifdef USE_GETADDRINFO
1510 #include <ws2tcpip.h>
1511 +#include <Wspiapi.h>
1512 #endif
1513 #endif
1515 --- misc/neon-0.28.2/src/ne_sspi.c 2007-08-10 17:26:08.000000000 +0200
1516 +++ misc/build/neon-0.28.2/src/ne_sspi.c 2009-08-11 09:48:54.000000000 +0200
1517 @@ -202,9 +202,48 @@
1518 return -1;
1521 + return 0;
1525 + * Simplification wrapper arround AcquireCredentialsHandle as most of
1526 + * the parameters do not change.
1527 + */
1528 +static int acquireCredentialsHandleForUsername(CredHandle * credentials, char *package, const char *username, const char *password)
1530 + SECURITY_STATUS status;
1531 + TimeStamp timestamp;
1533 + const char *domain = "";
1535 + int rc, rcISC;
1536 + SecPkgInfo *secPackInfo;
1537 + SEC_WINNT_AUTH_IDENTITY *nameAndPwd = NULL;
1538 + int bytesReceived = 0, bytesSent = 0;
1540 + nameAndPwd = (SEC_WINNT_AUTH_IDENTITY *) malloc( sizeof(SEC_WINNT_AUTH_IDENTITY) );
1541 + memset( nameAndPwd, '\0', sizeof (*nameAndPwd) );
1542 + nameAndPwd->Domain = (unsigned char *) _strdup( domain? domain: "" );
1543 + nameAndPwd->DomainLength = domain? strlen( domain ): 0;
1544 + nameAndPwd->User = (unsigned char *) _strdup( username? username: "" );
1545 + nameAndPwd->UserLength = username? strlen( username ): 0;
1546 + nameAndPwd->Password = (unsigned char *) _strdup( password? password: "" );
1547 + nameAndPwd->PasswordLength = password? strlen( password ): 0;
1548 + nameAndPwd->Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
1550 + status = pSFT->AcquireCredentialsHandle( NULL, package, SECPKG_CRED_OUTBOUND,
1551 + NULL, nameAndPwd, NULL, NULL, credentials, &timestamp );
1553 + if (status != SEC_E_OK) {
1554 + NE_DEBUG(NE_DBG_HTTPAUTH,
1555 + "sspi: AcquireCredentialsHandle [fail] [%x].\n", status);
1556 + return -1;
1559 return 0;
1564 * Wrapper arround initializeSecurityContext. Supplies several
1565 * default parameters as well as logging in case of errors.
1566 @@ -483,7 +522,7 @@
1567 * Processes received authentication tokens as well as supplies the
1568 * response token.
1570 -int ne_sspi_authenticate(void *context, const char *base64Token, char **responseToken)
1571 +int ne_sspi_authenticate(void *context, const char *base64Token, char **responseToken, const char* username, const char* password)
1573 SecBufferDesc outBufferDesc;
1574 SecBuffer outBuffer;
1575 @@ -560,14 +599,23 @@
1577 /* Reset any existing context since we are starting over */
1578 resetContext(sspiContext);
1580 + if (strlen(username) != 0) {
1581 + if (acquireCredentialsHandleForUsername
1582 + (&sspiContext->credentials, sspiContext->mechanism, username, password) != SEC_E_OK) {
1583 + freeBuffer(&outBufferDesc);
1584 + NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: acquireCredentialsHandleForUsername failed.\n");
1585 + return -1;
1587 + } else {
1588 + if (acquireCredentialsHandle
1589 + (&sspiContext->credentials, sspiContext->mechanism) != SEC_E_OK) {
1590 + freeBuffer(&outBufferDesc);
1591 + NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: acquireCredentialsHandle failed.\n");
1592 + return -1;
1596 - if (acquireCredentialsHandle
1597 - (&sspiContext->credentials, sspiContext->mechanism) != SEC_E_OK) {
1598 - freeBuffer(&outBufferDesc);
1599 - NE_DEBUG(NE_DBG_HTTPAUTH,
1600 - "sspi: acquireCredentialsHandle failed.\n");
1601 - return -1;
1604 securityStatus =
1605 initializeSecurityContext(&sspiContext->credentials, NULL,
1606 --- misc/neon-0.28.2/src/ne_sspi.h 2006-02-12 13:05:14.000000000 +0100
1607 +++ misc/build/neon-0.28.2/src/ne_sspi.h 2009-08-11 09:48:54.000000000 +0200
1608 @@ -41,7 +41,7 @@
1609 int ne_sspi_clear_context(void *context);
1611 int ne_sspi_authenticate(void *context, const char *base64Token,
1612 - char **responseToken);
1613 + char **responseToken, const char* username, const char* password);
1615 #endif /* HAVE_SSPI */
1617 --- misc/neon-0.28.2/src/ne_uri.c 2007-12-05 12:04:47.000000000 +0100
1618 +++ misc/build/neon-0.28.2/src/ne_uri.c 2009-08-11 09:48:54.000000000 +0200
1619 @@ -42,7 +42,7 @@
1620 #include "ne_alloc.h"
1621 #include "ne_uri.h"
1623 -/* URI ABNF from RFC 3986: */
1624 +/* URI ABNF from RFC 3986: (TKR: SharePoint is contradictory to this RFC. So I fix it here. )*/
1626 #define PS (0x0001) /* "+" */
1627 #define PC (0x0002) /* "%" */
1628 @@ -67,6 +67,9 @@
1630 #define OT (0x4000) /* others */
1632 +/* TKR new symbol */
1633 +#define WS (0x8000) /* Whitespaces ( Space, Tab ) */
1635 #define URI_ALPHA (AL)
1636 #define URI_DIGIT (DG)
1638 @@ -83,20 +86,21 @@
1639 /* pchar = unreserved / pct-encoded / sub-delims / ":" / "@" */
1640 #define URI_PCHAR (URI_UNRESERVED | PC | URI_SUBDELIM | CL | AT)
1641 /* invented: segchar = pchar / "/" */
1642 -#define URI_SEGCHAR (URI_PCHAR | FS)
1643 +/* (TKR) WS added */
1644 +#define URI_SEGCHAR (URI_PCHAR | FS | WS)
1645 /* query = *( pchar / "/" / "?" ) */
1646 #define URI_QUERY (URI_PCHAR | FS | QU)
1647 /* fragment == query */
1648 #define URI_FRAGMENT URI_QUERY
1650 /* any characters which should be path-escaped: */
1651 -#define URI_ESCAPE ((URI_GENDELIM & ~(FS)) | URI_SUBDELIM | OT | PC)
1652 +#define URI_ESCAPE ((URI_GENDELIM & ~(FS)) | URI_SUBDELIM | OT | WS | PC)
1654 static const unsigned int uri_chars[256] = {
1655 /* 0xXX x0 x2 x4 x6 x8 xA xC xE */
1656 -/* 0x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
1657 +/* 0x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, WS, OT, OT, OT, OT, OT, OT,
1658 /* 1x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
1659 -/* 2x */ OT, SD, OT, GD, SD, PC, SD, SD, SD, SD, SD, PS, SD, DS, DT, FS,
1660 +/* 2x */ WS, SD, OT, GD, SD, PC, SD, SD, SD, SD, SD, PS, SD, DS, DT, FS,
1661 /* 3x */ DG, DG, DG, DG, DG, DG, DG, DG, DG, DG, CL, SD, OT, SD, OT, QU,
1662 /* 4x */ AT, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL,
1663 /* 5x */ AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, GD, OT, GD, OT, US,
1664 --- misc/neon-0.28.2/src/ne_utils.c 2006-03-07 10:36:43.000000000 +0100
1665 +++ misc/build/neon-0.28.2/src/ne_utils.c 2009-08-30 18:55:04.000000000 +0200
1666 @@ -118,6 +118,9 @@
1667 #ifdef HAVE_GNUTLS
1668 ", GNU TLS " LIBGNUTLS_VERSION
1669 #endif /* HAVE_GNUTLS */
1670 +#ifdef HAVE_SSPI
1671 + ", SSPI"
1672 +#endif /* HAVE_SSPI */
1676 @@ -137,7 +140,7 @@
1677 switch (feature) {
1678 #if defined(NE_HAVE_SSL) || defined(NE_HAVE_ZLIB) || defined(NE_HAVE_IPV6) \
1679 || defined(NE_HAVE_SOCKS) || defined(NE_HAVE_LFS) \
1680 - || defined(NE_HAVE_TS_SSL) || defined(NE_HAVE_I18N)
1681 + || defined(NE_HAVE_TS_SSL) || defined(NE_HAVE_I18N) || defined(HAVE_SSPI)
1682 #ifdef NE_HAVE_SSL
1683 case NE_FEATURE_SSL:
1684 #endif
1685 @@ -159,6 +162,9 @@
1686 #ifdef NE_HAVE_I18N
1687 case NE_FEATURE_I18N:
1688 #endif
1689 +#ifdef HAVE_SSPI
1690 + case NE_FEATURE_SSPI:
1691 +#endif
1692 return 1;
1693 #endif /* NE_HAVE_* */
1694 default:
1695 --- misc/neon-0.28.2/src/ne_utils.h 2007-07-16 08:54:57.000000000 +0200
1696 +++ misc/build/neon-0.28.2/src/ne_utils.h 2009-08-24 15:47:03.000000000 +0200
1697 @@ -54,6 +54,7 @@
1698 #define NE_FEATURE_SOCKS (5) /* SOCKSv5 support */
1699 #define NE_FEATURE_TS_SSL (6) /* Thread-safe SSL/TLS support */
1700 #define NE_FEATURE_I18N (7) /* i18n error message support */
1701 +#define NE_FEATURE_SSPI (8) /* NTLM/Negotiate authentication protocol via SSPI */
1703 /* Returns non-zero if library is built with support for the given
1704 * NE_FEATURE_* feature code 'code'. */