Blame SOURCES/openchange-2.3-samba-4.4.patch

17a85d
diff -up openchange-openchange-2.3-VULCAN/configure.ac.samba44 openchange-openchange-2.3-VULCAN/configure.ac
17a85d
--- openchange-openchange-2.3-VULCAN/configure.ac.samba44	2016-02-09 11:51:31.089982153 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/configure.ac	2016-02-09 12:04:55.985948047 +0100
17a85d
@@ -657,10 +657,11 @@ AC_CHECK_LIB([popt], [poptFreeContext],
17a85d
 	       enable_libpopt="no"
17a85d
              ])
17a85d
 
17a85d
+mapitest=0
17a85d
 if test x"$enable_libpopt" = x"yes"; then
17a85d
    	if test x"$enable_libmapiadmin" = x"yes"; then
17a85d
 	   openchangepfadmin=1
17a85d
-	   mapitest=1
17a85d
+	   mapitest=0
17a85d
 	fi
17a85d
 
17a85d
 	if test x"$enable_libocpf" = x"yes"; then
17a85d
@@ -692,7 +693,7 @@ OC_RULE_ADD(mapipropsdump, TOOLS)
17a85d
 OC_RULE_ADD(exchange2ical, TOOLS)
17a85d
 #OC_RULE_ADD(rpcextract, TOOLS)
17a85d
 OC_RULE_ADD(openchangepfadmin, TOOLS)
17a85d
-OC_RULE_ADD(mapitest, TOOLS)
17a85d
+#OC_RULE_ADD(mapitest, TOOLS)
17a85d
 OC_RULE_ADD(mapiprofile, TOOLS)
17a85d
 OC_RULE_ADD(openchangemapidump, TOOLS)
17a85d
 OC_RULE_ADD(schemaIDGUID, TOOLS)
17a85d
diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c
17a85d
--- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44	2016-02-09 11:46:45.211994266 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c	2016-02-09 12:04:07.330950109 +0100
17a85d
@@ -22,6 +22,37 @@
17a85d
 #include "libexchange2ical/libexchange2ical.h"
17a85d
 #include <ldb.h>
17a85d
 
17a85d
+static void openchange_all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
17a85d
+{
17a85d
+	char *p;
17a85d
+	ssize_t ls,lp,li;
17a85d
+
17a85d
+	if (!insert || !pattern || !s)
17a85d
+		return;
17a85d
+
17a85d
+	ls = (ssize_t)strlen(s);
17a85d
+	lp = (ssize_t)strlen(pattern);
17a85d
+	li = (ssize_t)strlen(insert);
17a85d
+
17a85d
+	if (!*pattern)
17a85d
+		return;
17a85d
+
17a85d
+	if (len == 0)
17a85d
+		len = ls + 1; /* len is number of *bytes* */
17a85d
+
17a85d
+	while (lp <= ls && (p = strstr_m(s,pattern))) {
17a85d
+		if (ls + (li-lp) >= len) {
17a85d
+			break;
17a85d
+		}
17a85d
+		if (li != lp) {
17a85d
+			memmove(p+li,p+lp,strlen(p+lp)+1);
17a85d
+		}
17a85d
+		memcpy(p, insert, li);
17a85d
+		s = p + li;
17a85d
+		ls += (li-lp);
17a85d
+	}
17a85d
+}
17a85d
+
17a85d
 struct RRULE_byday {
17a85d
 	uint16_t	DayOfWeek;
17a85d
 	const char	*DayName;
17a85d
@@ -1019,7 +1050,7 @@ void ical_property_RESOURCES(struct exch
17a85d
 	if (!exchange2ical->NonSendableBcc) return;
17a85d
 	
17a85d
 	NonSendableBcc = talloc_strdup(exchange2ical->mem_ctx, exchange2ical->NonSendableBcc);
17a85d
-	all_string_sub(NonSendableBcc, ";", ",", 0);
17a85d
+	openchange_all_string_sub(NonSendableBcc, ";", ",", 0);
17a85d
 	prop = icalproperty_new_resources(NonSendableBcc);
17a85d
 	icalcomponent_add_property(exchange2ical->vevent, prop);
17a85d
 	talloc_free(NonSendableBcc);
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c
17a85d
--- openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44	2015-05-16 17:22:04.000000000 +0200
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c	2016-02-08 22:19:17.750956440 +0100
17a85d
@@ -24,19 +24,251 @@
17a85d
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17a85d
  */
17a85d
 
17a85d
+#include <ldb.h>
17a85d
+
17a85d
 #include "libmapiadmin/libmapiadmin.h"
17a85d
 
17a85d
 #include <param.h>
17a85d
 #include <credentials.h>
17a85d
+#include <ctype.h>
17a85d
 #include <ldb_errors.h>
17a85d
 #include <ldb_wrap.h>
17a85d
-#include <ldap_ndr.h>
17a85d
 
17a85d
 #include <gen_ndr/ndr_samr.h>
17a85d
 #include <gen_ndr/ndr_samr_c.h>
17a85d
 
17a85d
 #include <time.h>
17a85d
 
17a85d
+static ssize_t openchange_sys_read(int fd, void *buf, size_t count)
17a85d
+{
17a85d
+	ssize_t ret;
17a85d
+
17a85d
+	do {
17a85d
+		ret = read(fd, buf, count);
17a85d
+	} while (ret == -1 && (errno == EINTR || errno == EAGAIN ||
17a85d
+			       errno == EWOULDBLOCK));
17a85d
+
17a85d
+	return ret;
17a85d
+}
17a85d
+
17a85d
+static ssize_t openchange_read_data(int fd, void *buffer, size_t n)
17a85d
+{
17a85d
+	ssize_t nread;
17a85d
+
17a85d
+	nread = 0;
17a85d
+
17a85d
+	while (nread < n) {
17a85d
+		ssize_t ret;
17a85d
+		ret = openchange_sys_read(fd, ((char *)buffer) + nread, n - nread);
17a85d
+		if (ret <= 0) {
17a85d
+			return ret;
17a85d
+		}
17a85d
+		nread += ret;
17a85d
+	}
17a85d
+
17a85d
+	return nread;
17a85d
+}
17a85d
+
17a85d
+static int openchange_urand_fd = -1;
17a85d
+static void openchange_open_urandom(void)
17a85d
+{
17a85d
+	if (openchange_urand_fd != -1) {
17a85d
+		return;
17a85d
+	}
17a85d
+	openchange_urand_fd = open( "/dev/urandom", O_RDONLY,0);
17a85d
+	if (openchange_urand_fd == -1) {
17a85d
+		abort();
17a85d
+	}
17a85d
+}
17a85d
+
17a85d
+static void openchange_generate_random_buffer(uint8_t *out, int len)
17a85d
+{
17a85d
+	ssize_t rw_ret;
17a85d
+
17a85d
+	openchange_open_urandom();
17a85d
+
17a85d
+	rw_ret = openchange_read_data(openchange_urand_fd, out, len);
17a85d
+	if (rw_ret != len) {
17a85d
+		abort();
17a85d
+	}
17a85d
+}
17a85d
+
17a85d
+static enum ndr_err_code openchange_ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *r)
17a85d
+{
17a85d
+	uint32_t cntr_sub_auths_0;
17a85d
+	if (ndr_flags & NDR_SCALARS) {
17a85d
+		NDR_CHECK(ndr_push_align(ndr, 4));
17a85d
+		NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->sid_rev_num));
17a85d
+		NDR_CHECK(ndr_push_int8(ndr, NDR_SCALARS, r->num_auths));
17a85d
+		NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6));
17a85d
+		if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) {
17a85d
+			return ndr_push_error(ndr, NDR_ERR_RANGE, "value out of range");
17a85d
+		}
17a85d
+		for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) {
17a85d
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sub_auths[cntr_sub_auths_0]));
17a85d
+		}
17a85d
+	}
17a85d
+	return NDR_ERR_SUCCESS;
17a85d
+}
17a85d
+
17a85d
+static char *openchange_ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
17a85d
+{
17a85d
+#undef ldb_val
17a85d
+	DATA_BLOB blob;
17a85d
+	struct ldb_val val;
17a85d
+	enum ndr_err_code ndr_err;
17a85d
+	char *ret;
17a85d
+	ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid,
17a85d
+				       (ndr_push_flags_fn_t)openchange_ndr_push_dom_sid);
17a85d
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
17a85d
+		return NULL;
17a85d
+	}
17a85d
+	val.data = blob.data;
17a85d
+	val.length = blob.length;
17a85d
+	ret = ldb_binary_encode(mem_ctx, val);
17a85d
+	data_blob_free(&blob;;
17a85d
+	return ret;
17a85d
+}
17a85d
+
17a85d
+static bool openchange_check_password_quality(const char *pwd)
17a85d
+{
17a85d
+	size_t ofs = 0;
17a85d
+	size_t num_chars = 0;
17a85d
+	size_t num_digits = 0;
17a85d
+	size_t num_upper = 0;
17a85d
+	size_t num_lower = 0;
17a85d
+	size_t num_nonalpha = 0;
17a85d
+	size_t num_unicode = 0;
17a85d
+	size_t num_categories = 0;
17a85d
+
17a85d
+	if (pwd == NULL) {
17a85d
+		return false;
17a85d
+	}
17a85d
+
17a85d
+	while (true) {
17a85d
+		const char *s = &pwd[ofs];
17a85d
+		size_t len = 0;
17a85d
+		codepoint_t c;
17a85d
+
17a85d
+		c = next_codepoint(s, &len;;
17a85d
+		if (c == INVALID_CODEPOINT) {
17a85d
+			return false;
17a85d
+		} else if (c == 0) {
17a85d
+			break;
17a85d
+		}
17a85d
+		ofs += len;
17a85d
+		num_chars += 1;
17a85d
+
17a85d
+		if (len == 1) {
17a85d
+			const char *na = "~!@#$%^&*_-+=`|\\(){}[]:;\"'<>,.?/";
17a85d
+
17a85d
+			if (isdigit(c)) {
17a85d
+				num_digits += 1;
17a85d
+				continue;
17a85d
+			}
17a85d
+
17a85d
+			if (isupper(c)) {
17a85d
+				num_upper += 1;
17a85d
+				continue;
17a85d
+			}
17a85d
+
17a85d
+			if (islower(c)) {
17a85d
+				num_lower += 1;
17a85d
+				continue;
17a85d
+			}
17a85d
+
17a85d
+			if (strchr(na, c)) {
17a85d
+				num_nonalpha += 1;
17a85d
+				continue;
17a85d
+			}
17a85d
+
17a85d
+			/*
17a85d
+			 * the rest does not belong to
17a85d
+			 * a category.
17a85d
+			 */
17a85d
+			continue;
17a85d
+		}
17a85d
+
17a85d
+		if (isupper_m(c)) {
17a85d
+			num_upper += 1;
17a85d
+			continue;
17a85d
+		}
17a85d
+
17a85d
+		if (islower_m(c)) {
17a85d
+			num_lower += 1;
17a85d
+			continue;
17a85d
+		}
17a85d
+
17a85d
+		/*
17a85d
+		 * Note: for now do not check if the unicode category is
17a85d
+		 *       alphabetic character
17a85d
+		 *
17a85d
+		 * We would have to import the details from
17a85d
+		 * ftp://ftp.unicode.org/Public/6.3.0/ucd/UnicodeData-6.3.0d1.txt
17a85d
+		 */
17a85d
+		num_unicode += 1;
17a85d
+		continue;
17a85d
+	}
17a85d
+
17a85d
+	if (num_digits > 0) {
17a85d
+		num_categories += 1;
17a85d
+	}
17a85d
+	if (num_upper > 0) {
17a85d
+		num_categories += 1;
17a85d
+	}
17a85d
+	if (num_lower > 0) {
17a85d
+		num_categories += 1;
17a85d
+	}
17a85d
+	if (num_nonalpha > 0) {
17a85d
+		num_categories += 1;
17a85d
+	}
17a85d
+	if (num_unicode > 0) {
17a85d
+		num_categories += 1;
17a85d
+	}
17a85d
+
17a85d
+	if (num_categories >= 3) {
17a85d
+		return true;
17a85d
+	}
17a85d
+
17a85d
+	return false;
17a85d
+}
17a85d
+
17a85d
+static char *openchange_generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list)
17a85d
+{
17a85d
+	size_t i;
17a85d
+	size_t list_len = strlen(list);
17a85d
+
17a85d
+	char *retstr = talloc_array(mem_ctx, char, len + 1);
17a85d
+	if (!retstr) return NULL;
17a85d
+
17a85d
+	openchange_generate_random_buffer((uint8_t *)retstr, len);
17a85d
+	for (i = 0; i < len; i++) {
17a85d
+		retstr[i] = list[retstr[i] % list_len];
17a85d
+	}
17a85d
+	retstr[i] = '\0';
17a85d
+
17a85d
+	return retstr;
17a85d
+}
17a85d
+
17a85d
+static char *openchange_generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
17a85d
+{
17a85d
+	char *retstr;
17a85d
+	const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
17a85d
+
17a85d
+again:
17a85d
+	retstr = openchange_generate_random_str_list(mem_ctx, len, c_list);
17a85d
+	if (!retstr) return NULL;
17a85d
+
17a85d
+	/* we need to make sure the random string passes basic quality tests
17a85d
+	   or it might be rejected by windows as a password */
17a85d
+	if (len >= 7 && !openchange_check_password_quality(retstr)) {
17a85d
+		talloc_free(retstr);
17a85d
+		goto again;
17a85d
+	}
17a85d
+
17a85d
+	return retstr;
17a85d
+}
17a85d
+
17a85d
 /**
17a85d
 	\file
17a85d
 	User management functions for mapiadmin
17a85d
@@ -232,10 +464,10 @@ _PUBLIC_ enum MAPISTATUS mapiadmin_user_
17a85d
 	/* Search the user_dn */
17a85d
 	account_dn = samdb_search_dn(remote_ldb, mem_ctx, NULL, 
17a85d
 				     "(&(objectSid=%s)(objectClass=user))", 
17a85d
-				     ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
17a85d
+				     openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
17a85d
 
17a85d
 	ret = ldb_search(remote_ldb, mem_ctx, &res, account_dn, LDB_SCOPE_SUBTREE, dom_attrs, "(objectSid=%s)",
17a85d
-			 ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
17a85d
+			 openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
17a85d
 	MAPI_RETVAL_IF(ret != LDB_SUCCESS, MAPI_E_NOT_FOUND, mem_ctx);
17a85d
 	MAPI_RETVAL_IF(res->count != 1, MAPI_E_NOT_FOUND, mem_ctx);
17a85d
 
17a85d
@@ -422,7 +654,7 @@ again:
17a85d
 	}
17a85d
 
17a85d
 	if (!mapiadmin_ctx->password) {
17a85d
-		mapiadmin_ctx->password = generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
17a85d
+		mapiadmin_ctx->password = openchange_generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
17a85d
 	}
17a85d
 
17a85d
 	OC_DEBUG(3, "Setting account password '%s'", mapiadmin_ctx->password);
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapidump.c
17a85d
--- openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44	2016-02-09 11:03:18.565104717 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapi/mapidump.c	2016-02-09 11:03:29.508104254 +0100
17a85d
@@ -119,7 +119,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
17a85d
 		data = get_SPropValue_data(&lpProp);
17a85d
 		if (data) {
17a85d
 			printf("%s%s:\n", sep?sep:"", proptag);
17a85d
-			dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
17a85d
+			oc_dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
17a85d
 		} else {
17a85d
 			printf("%s%s: (NULL)\n", sep?sep:"", proptag);
17a85d
 		}
17a85d
@@ -153,7 +153,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
17a85d
 		printf("%s%s: ARRAY(%d)\n", sep?sep:"", proptag, BinaryArray_r->cValues);
17a85d
 		for (i = 0; i < BinaryArray_r->cValues; i++) {
17a85d
 			printf("\tPT_MV_BINARY [%d]:\n", i);
17a85d
-			dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
17a85d
+			oc_dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
17a85d
 		}
17a85d
 		break;
17a85d
 	default:
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c
17a85d
--- openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44	2016-02-09 11:02:57.062105628 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c	2016-02-09 11:03:01.012105461 +0100
17a85d
@@ -412,7 +412,7 @@ _PUBLIC_ enum MAPISTATUS mapi_object_boo
17a85d
 	while (bookmark) {
17a85d
 		OC_DEBUG(0, "mapi_object_bookmark {");
17a85d
 		OC_DEBUG(0, ".index == %u", bookmark->index);
17a85d
-		dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
17a85d
+		oc_dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
17a85d
 		OC_DEBUG(0, "};");
17a85d
 
17a85d
 		bookmark = bookmark->next;
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.c
17a85d
--- openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44	2016-02-09 10:49:20.292140237 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.c	2016-02-09 11:30:13.912036271 +0100
17a85d
@@ -21,6 +21,12 @@
17a85d
 
17a85d
 #include "libmapi/libmapi.h"
17a85d
 #include <stdio.h>
17a85d
+#include <stdlib.h>
17a85d
+#include <ctype.h>
17a85d
+
17a85d
+#ifndef MIN
17a85d
+#define MIN(a,b) ((a)<(b)?(a):(b))
17a85d
+#endif
17a85d
 
17a85d
 int _oc_log_samba_level = 0;
17a85d
 
17a85d
@@ -84,3 +90,119 @@ void oc_log_init_server(const char *prog
17a85d
 {
17a85d
 	setup_logging(progname, DEBUG_FILE);
17a85d
 }
17a85d
+
17a85d
+void oc_panic(const char *why)
17a85d
+{
17a85d
+	if (why) {
17a85d
+		fprintf(stderr, "PANIC: %s\n", why);
17a85d
+		fflush(stderr);
17a85d
+	}
17a85d
+
17a85d
+	abort();
17a85d
+}
17a85d
+static void oc_debugadd_cb(const char *buf, void *private_data)
17a85d
+{
17a85d
+	int *plevel = (int *)private_data;
17a85d
+	if (plevel && *plevel <= _oc_log_samba_level) {
17a85d
+		printf ("%s", buf);
17a85d
+	}
17a85d
+}
17a85d
+
17a85d
+static void oc_print_asc_cb(const uint8_t *buf, int len,
17a85d
+			    void (*cb)(const char *buf, void *private_data),
17a85d
+			    void *private_data)
17a85d
+{
17a85d
+	int i;
17a85d
+	char s[2];
17a85d
+	s[1] = 0;
17a85d
+
17a85d
+	for (i=0; i
17a85d
+		s[0] = isprint(buf[i]) ? buf[i] : '.';
17a85d
+		cb(s, private_data);
17a85d
+	}
17a85d
+}
17a85d
+
17a85d
+static void oc_dump_data_cb(const uint8_t *buf, int len,
17a85d
+			    bool omit_zero_bytes,
17a85d
+			    void (*cb)(const char *buf, void *private_data),
17a85d
+			    void *private_data)
17a85d
+{
17a85d
+	int i=0;
17a85d
+	static const uint8_t empty[16] = { 0, };
17a85d
+	bool skipped = false;
17a85d
+	char tmp[16];
17a85d
+
17a85d
+	if (len<=0) return;
17a85d
+
17a85d
+	for (i=0;i
17a85d
+
17a85d
+		if (i%16 == 0) {
17a85d
+			if ((omit_zero_bytes == true) &&
17a85d
+			    (i > 0) &&
17a85d
+			    (len > i+16) &&
17a85d
+			    (memcmp(&buf[i], &empty, 16) == 0))
17a85d
+			{
17a85d
+				i +=16;
17a85d
+				continue;
17a85d
+			}
17a85d
+
17a85d
+			if (i
17a85d
+				snprintf(tmp, sizeof(tmp), "[%04X] ", i);
17a85d
+				cb(tmp, private_data);
17a85d
+			}
17a85d
+		}
17a85d
+
17a85d
+		snprintf(tmp, sizeof(tmp), "%02X ", (int)buf[i]);
17a85d
+		cb(tmp, private_data);
17a85d
+		i++;
17a85d
+		if (i%8 == 0) {
17a85d
+			cb("  ", private_data);
17a85d
+		}
17a85d
+		if (i%16 == 0) {
17a85d
+
17a85d
+			oc_print_asc_cb(&buf[i-16], 8, cb, private_data);
17a85d
+			cb(" ", private_data);
17a85d
+			oc_print_asc_cb(&buf[i-8], 8, cb, private_data);
17a85d
+			cb("\n", private_data);
17a85d
+
17a85d
+			if ((omit_zero_bytes == true) &&
17a85d
+			    (len > i+16) &&
17a85d
+			    (memcmp(&buf[i], &empty, 16) == 0)) {
17a85d
+				if (!skipped) {
17a85d
+					cb("skipping zero buffer bytes\n",
17a85d
+					   private_data);
17a85d
+					skipped = true;
17a85d
+				}
17a85d
+			}
17a85d
+		}
17a85d
+	}
17a85d
+
17a85d
+	if (i%16) {
17a85d
+		int n;
17a85d
+		n = 16 - (i%16);
17a85d
+		cb("  ", private_data);
17a85d
+		if (n>8) {
17a85d
+			cb(" ", private_data);
17a85d
+		}
17a85d
+		while (n--) {
17a85d
+			cb("   ", private_data);
17a85d
+		}
17a85d
+		n = MIN(8,i%16);
17a85d
+		oc_print_asc_cb(&buf[i-(i%16)], n, cb, private_data);
17a85d
+		cb(" ", private_data);
17a85d
+		n = (i%16) - n;
17a85d
+		if (n>0) {
17a85d
+			oc_print_asc_cb(&buf[i-n], n, cb, private_data);
17a85d
+		}
17a85d
+		cb("\n", private_data);
17a85d
+	}
17a85d
+
17a85d
+}
17a85d
+
17a85d
+void oc_dump_data(int level, const uint8_t *buf,int len)
17a85d
+{
17a85d
+	if (_oc_log_samba_level < level || !buf || !len)
17a85d
+		return;
17a85d
+
17a85d
+	oc_dump_data_cb(buf, len, false, oc_debugadd_cb, &level);
17a85d
+}
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.h
17a85d
--- openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44	2016-02-09 10:49:16.132140414 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.h	2016-02-09 10:51:57.121133592 +0100
17a85d
@@ -79,4 +79,7 @@ void oc_log_init_server(const char *prog
17a85d
 
17a85d
 extern int _oc_log_samba_level; /* Private, do not change it other than by SetMAPIDebugLevel() */
17a85d
 
17a85d
+void oc_panic(const char *why);
17a85d
+void oc_dump_data(int level, const uint8_t *buf,int len);
17a85d
+
17a85d
 #endif /* _OC_LOG_H_ */
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/property.c
17a85d
--- openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44	2016-02-09 10:46:51.040146561 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapi/property.c	2016-02-09 10:48:47.626141621 +0100
17a85d
@@ -777,7 +777,7 @@ _PUBLIC_ void mapi_copy_spropvalues(TALL
17a85d
 				// TODO: Replace this with OC_PANIC() macro when it gets visible in libmapi too
17a85d
 				OC_DEBUG(0, "Unexpected multi-value property type: %s.",
17a85d
 						get_proptag_name(source_value->ulPropTag));
17a85d
-				smb_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
17a85d
+				oc_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
17a85d
 			}
17a85d
 		}
17a85d
 	}
17a85d
diff -up openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c
17a85d
--- openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44	2016-02-09 11:09:43.147088421 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c	2016-02-09 11:31:47.664032298 +0100
17a85d
@@ -90,6 +90,213 @@ static void add_interface(TALLOC_CTX *me
17a85d
 	OC_DEBUG(2, "added interface ip=%s nmask=%s", iface->ip_s, iface->nmask_s);
17a85d
 }
17a85d
 
17a85d
+enum oc_protocol_types {
17a85d
+	PROTOCOL_DEFAULT=-1,
17a85d
+	PROTOCOL_NONE=0,
17a85d
+	PROTOCOL_CORE,
17a85d
+	PROTOCOL_COREPLUS,
17a85d
+	PROTOCOL_LANMAN1,
17a85d
+	PROTOCOL_LANMAN2,
17a85d
+	PROTOCOL_NT1,
17a85d
+	PROTOCOL_SMB2_02,
17a85d
+	PROTOCOL_SMB2_10,
17a85d
+	PROTOCOL_SMB2_22,
17a85d
+	PROTOCOL_SMB2_24,
17a85d
+	PROTOCOL_SMB3_00,
17a85d
+	PROTOCOL_SMB3_02,
17a85d
+	PROTOCOL_SMB3_10,
17a85d
+	PROTOCOL_SMB3_11
17a85d
+};
17a85d
+
17a85d
+static int openchange_null_match(const char *p)
17a85d
+{
17a85d
+	for (;*p;p++) {
17a85d
+		if (*p != '*' &&
17a85d
+		    *p != '<' &&
17a85d
+		    *p != '"' &&
17a85d
+		    *p != '>') return -1;
17a85d
+	}
17a85d
+	return 0;
17a85d
+}
17a85d
+
17a85d
+/*
17a85d
+  the max_n structure is purely for efficiency, it doesn't contribute
17a85d
+  to the matching algorithm except by ensuring that the algorithm does
17a85d
+  not grow exponentially
17a85d
+*/
17a85d
+struct max_n {
17a85d
+	const char *predot;
17a85d
+	const char *postdot;
17a85d
+};
17a85d
+
17a85d
+
17a85d
+/*
17a85d
+  p and n are the pattern and string being matched. The max_n array is
17a85d
+  an optimisation only. The ldot pointer is NULL if the string does
17a85d
+  not contain a '.', otherwise it points at the last dot in 'n'.
17a85d
+*/
17a85d
+static int openchange_ms_fnmatch_core(const char *p, const char *n, 
17a85d
+				      struct max_n *max_n, const char *ldot)
17a85d
+{
17a85d
+	codepoint_t c, c2;
17a85d
+	int i;
17a85d
+	size_t size, size_n;
17a85d
+
17a85d
+	while ((c = next_codepoint(p, &size))) {
17a85d
+		p += size;
17a85d
+
17a85d
+		switch (c) {
17a85d
+		case '*':
17a85d
+			/* a '*' matches zero or more characters of any type */
17a85d
+			if (max_n->predot && max_n->predot <= n) {
17a85d
+				return openchange_null_match(p);
17a85d
+			}
17a85d
+			for (i=0; n[i]; i += size_n) {
17a85d
+				next_codepoint(n+i, &size_n);
17a85d
+				if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
17a85d
+					return 0;
17a85d
+				}
17a85d
+			}
17a85d
+			if (!max_n->predot || max_n->predot > n) max_n->predot = n;
17a85d
+			return openchange_null_match(p);
17a85d
+
17a85d
+		case '<':
17a85d
+			/* a '<' matches zero or more characters of
17a85d
+			   any type, but stops matching at the last
17a85d
+			   '.' in the string. */
17a85d
+			if (max_n->predot && max_n->predot <= n) {
17a85d
+				return openchange_null_match(p);
17a85d
+			}
17a85d
+			if (max_n->postdot && max_n->postdot <= n && n <= ldot) {
17a85d
+				return -1;
17a85d
+			}
17a85d
+			for (i=0; n[i]; i += size_n) {
17a85d
+				next_codepoint(n+i, &size_n);
17a85d
+				if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
17a85d
+				if (n+i == ldot) {
17a85d
+					if (openchange_ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
17a85d
+					if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
17a85d
+					return -1;
17a85d
+				}
17a85d
+			}
17a85d
+			if (!max_n->predot || max_n->predot > n) max_n->predot = n;
17a85d
+			return openchange_null_match(p);
17a85d
+
17a85d
+		case '?':
17a85d
+			/* a '?' matches any single character */
17a85d
+			if (! *n) {
17a85d
+				return -1;
17a85d
+			}
17a85d
+			next_codepoint(n, &size_n);
17a85d
+			n += size_n;
17a85d
+			break;
17a85d
+
17a85d
+		case '>':
17a85d
+			/* a '?' matches any single character, but
17a85d
+			   treats '.' specially */
17a85d
+			if (n[0] == '.') {
17a85d
+				if (! n[1] && openchange_null_match(p) == 0) {
17a85d
+					return 0;
17a85d
+				}
17a85d
+				break;
17a85d
+			}
17a85d
+			if (! *n) return openchange_null_match(p);
17a85d
+			next_codepoint(n, &size_n);
17a85d
+			n += size_n;
17a85d
+			break;
17a85d
+
17a85d
+		case '"':
17a85d
+			/* a bit like a soft '.' */
17a85d
+			if (*n == 0 && openchange_null_match(p) == 0) {
17a85d
+				return 0;
17a85d
+			}
17a85d
+			if (*n != '.') return -1;
17a85d
+			next_codepoint(n, &size_n);
17a85d
+			n += size_n;
17a85d
+			break;
17a85d
+
17a85d
+		default:
17a85d
+			c2 = next_codepoint(n, &size_n);
17a85d
+			if (c != c2 && codepoint_cmpi(c, c2) != 0) {
17a85d
+				return -1;
17a85d
+			}
17a85d
+			n += size_n;
17a85d
+			break;
17a85d
+		}
17a85d
+	}
17a85d
+	
17a85d
+	if (! *n) {
17a85d
+		return 0;
17a85d
+	}
17a85d
+	
17a85d
+	return -1;
17a85d
+}
17a85d
+
17a85d
+static int openchange_ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
17a85d
+{
17a85d
+	int ret, count, i;
17a85d
+	struct max_n *max_n = NULL;
17a85d
+
17a85d
+	if (strcmp(string, "..") == 0) {
17a85d
+		string = ".";
17a85d
+	}
17a85d
+
17a85d
+	if (strpbrk(pattern, "<>*?\"") == NULL) {
17a85d
+		/* this is not just an optimisation - it is essential
17a85d
+		   for LANMAN1 correctness */
17a85d
+		return strcasecmp_m(pattern, string);
17a85d
+	}
17a85d
+
17a85d
+	if (protocol <= PROTOCOL_LANMAN2) {
17a85d
+		char *p = talloc_strdup(NULL, pattern);
17a85d
+		if (p == NULL) {
17a85d
+			return -1;
17a85d
+		}
17a85d
+		/*
17a85d
+		  for older negotiated protocols it is possible to
17a85d
+		  translate the pattern to produce a "new style"
17a85d
+		  pattern that exactly matches w2k behaviour
17a85d
+		*/
17a85d
+		for (i=0;p[i];i++) {
17a85d
+			if (p[i] == '?') {
17a85d
+				p[i] = '>';
17a85d
+			} else if (p[i] == '.' && 
17a85d
+				   (p[i+1] == '?' || 
17a85d
+				    p[i+1] == '*' ||
17a85d
+				    p[i+1] == 0)) {
17a85d
+				p[i] = '"';
17a85d
+			} else if (p[i] == '*' && 
17a85d
+				   p[i+1] == '.') {
17a85d
+				p[i] = '<';
17a85d
+			}
17a85d
+		}
17a85d
+		ret = openchange_ms_fnmatch_protocol(p, string, PROTOCOL_NT1);
17a85d
+		talloc_free(p);
17a85d
+		return ret;
17a85d
+	}
17a85d
+
17a85d
+	for (count=i=0;pattern[i];i++) {
17a85d
+		if (pattern[i] == '*' || pattern[i] == '<') count++;
17a85d
+	}
17a85d
+
17a85d
+	max_n = talloc_zero_array(NULL, struct max_n, count);
17a85d
+	if (max_n == NULL) {
17a85d
+		return -1;
17a85d
+	}
17a85d
+
17a85d
+	ret = openchange_ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
17a85d
+
17a85d
+	talloc_free(max_n);
17a85d
+
17a85d
+	return ret;
17a85d
+}
17a85d
+
17a85d
+
17a85d
+/** a generic fnmatch function - uses for non-CIFS pattern matching */
17a85d
+static int openchange_gen_fnmatch(const char *pattern, const char *string)
17a85d
+{
17a85d
+	return openchange_ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1);
17a85d
+}
17a85d
 
17a85d
 
17a85d
 /**
17a85d
@@ -119,7 +326,7 @@ static void interpret_interface(TALLOC_C
17a85d
 	
17a85d
 	/* first check if it is an interface name */
17a85d
 	for (i=0;i
17a85d
-		if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
17a85d
+		if (openchange_gen_fnmatch(token, probed_ifaces[i].name) == 0) {
17a85d
 			add_interface(mem_ctx, probed_ifaces[i].ip,
17a85d
 				      probed_ifaces[i].netmask,
17a85d
 				      local_interfaces);
17a85d
diff -up openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44 openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c
17a85d
--- openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44	2015-05-16 17:22:04.000000000 +0200
17a85d
+++ openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c	2016-02-08 17:43:52.578645298 +0100
17a85d
@@ -31,8 +31,6 @@
17a85d
 #include "mapiproxy/libmapiserver/libmapiserver.h"
17a85d
 #include "mapiproxy/libmapiproxy/fault_util.h"
17a85d
 
17a85d
-#include <ldap_ndr.h>
17a85d
-
17a85d
 /* Expose samdb_connect prototype */
17a85d
 struct ldb_context *samdb_connect(TALLOC_CTX *, struct tevent_context *,
17a85d
 				  struct loadparm_context *,
17a85d
diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 openchange-openchange-2.3-VULCAN/ndr_mapi.c
17a85d
--- openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44	2016-02-09 11:04:30.054101688 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/ndr_mapi.c	2016-02-09 11:04:49.763100853 +0100
17a85d
@@ -1616,7 +1616,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
17a85d
 				if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
17a85d
 					ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
17a85d
 				} else {
17a85d
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
 					talloc_free(mapi_request);
17a85d
 					break;
17a85d
 				}
17a85d
@@ -1662,7 +1662,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
17a85d
 				if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
17a85d
 					ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
17a85d
 				} else {
17a85d
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
 					talloc_free(mapi_response);
17a85d
 					break;
17a85d
 				}
17a85d
@@ -1735,7 +1735,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
17a85d
 				if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
17a85d
 					ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
17a85d
 				} else {
17a85d
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
 					talloc_free(mapi_request);
17a85d
 					return;
17a85d
 				}
17a85d
@@ -1786,7 +1786,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
17a85d
 				if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
17a85d
 					ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
17a85d
 				} else {
17a85d
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
17a85d
 					talloc_free(mapi_response);
17a85d
 					break;
17a85d
 				}
17a85d
@@ -2041,7 +2041,7 @@ _PUBLIC_ void ndr_print_SBinary_short(st
17a85d
 		uint32_t _flags_save_STRUCT = ndr->flags;
17a85d
 		ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
17a85d
 		ndr->depth++;
17a85d
-		dump_data(0, r->lpb, r->cb);
17a85d
+		oc_dump_data(0, r->lpb, r->cb);
17a85d
 		ndr->depth--;
17a85d
 		ndr->flags = _flags_save_STRUCT;
17a85d
 	}
17a85d
@@ -2054,7 +2054,7 @@ _PUBLIC_ void ndr_print_Binary_r(struct
17a85d
 		uint32_t _flags_save_STRUCT = ndr->flags;
17a85d
 		ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
17a85d
 		ndr->depth++;
17a85d
-		dump_data(0, r->lpb, r->cb);
17a85d
+		oc_dump_data(0, r->lpb, r->cb);
17a85d
 		ndr->depth--;
17a85d
 		ndr->flags = _flags_save_STRUCT;
17a85d
 	}
17a85d
diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c
17a85d
--- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44	2015-05-16 17:22:04.000000000 +0200
17a85d
+++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c	2016-02-09 10:35:42.207174902 +0100
17a85d
@@ -24,6 +24,9 @@
17a85d
 #include "gen_ndr/ndr_exchange.h"
17a85d
 #include <popt.h>
17a85d
 #include <dlfcn.h>
17a85d
+#include <sys/types.h>
17a85d
+#include <sys/stat.h>
17a85d
+#include <unistd.h>
17a85d
 
17a85d
 #define	PLUGIN		"libmapi.so"
17a85d
 #define	FUNCTION	0xB
17a85d
@@ -97,6 +100,51 @@ static const const struct ndr_interface_
17a85d
 	return p;
17a85d
 }
17a85d
 
17a85d
+static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
17a85d
+{
17a85d
+	struct stat sbuf;
17a85d
+	char *p;
17a85d
+	size_t size;
17a85d
+
17a85d
+	if (fstat(fd, &sbuf) != 0) return NULL;
17a85d
+
17a85d
+	size = sbuf.st_size;
17a85d
+
17a85d
+	if (maxsize) {
17a85d
+		size = size < maxsize ? size : maxsize;
17a85d
+	}
17a85d
+
17a85d
+	p = (char *)talloc_size(mem_ctx, size+1);
17a85d
+	if (!p) return NULL;
17a85d
+
17a85d
+	if (read(fd, p, size) != size) {
17a85d
+		talloc_free(p);
17a85d
+		return NULL;
17a85d
+	}
17a85d
+	p[size] = 0;
17a85d
+
17a85d
+	if (psize) *psize = size;
17a85d
+
17a85d
+	return p;
17a85d
+}
17a85d
+
17a85d
+static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
17a85d
+{
17a85d
+	int fd;
17a85d
+	char *p;
17a85d
+
17a85d
+	if (!fname || !*fname) return NULL;
17a85d
+
17a85d
+	fd = open(fname,O_RDONLY);
17a85d
+	if (fd == -1) return NULL;
17a85d
+
17a85d
+	p = openchange_fd_load(fd, size, maxsize, mem_ctx);
17a85d
+
17a85d
+	close(fd);
17a85d
+
17a85d
+	return p;
17a85d
+}
17a85d
+
17a85d
 static struct SPropTagArray *process_request(TALLOC_CTX *mem_ctx,
17a85d
 					     const struct ndr_interface_call *f,
17a85d
 					     const char *filename,
17a85d
@@ -123,7 +171,7 @@ static struct SPropTagArray *process_req
17a85d
 		return NULL;
17a85d
 	}
17a85d
 
17a85d
-	data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
17a85d
+	data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
17a85d
 	if (!data) {
17a85d
 		perror(filename);
17a85d
 		return NULL;
17a85d
@@ -224,7 +272,7 @@ static int process_response(TALLOC_CTX *
17a85d
 		return -1;
17a85d
 	}
17a85d
 
17a85d
-	data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
17a85d
+	data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
17a85d
 	if (!data) {
17a85d
 		perror(filename);
17a85d
 		return -1;
17a85d
diff -up openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c
17a85d
--- openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44	2016-02-09 11:06:00.717097846 +0100
17a85d
+++ openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c	2016-02-09 11:48:38.200989479 +0100
17a85d
@@ -19,11 +19,61 @@
17a85d
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17a85d
 */
17a85d
 
17a85d
+#include <sys/types.h>
17a85d
+#include <sys/stat.h>
17a85d
+#include <unistd.h>
17a85d
+
17a85d
 #include "utils/mapitest/mapitest.h"
17a85d
 #include "utils/mapitest/proto.h"
17a85d
 #include "gen_ndr/ndr_exchange.h"
17a85d
+#include "libmapi/libmapi.h"
17a85d
 #include "libmapi/libmapi_private.h"
17a85d
 
17a85d
+static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
17a85d
+{
17a85d
+	struct stat sbuf;
17a85d
+	char *p;
17a85d
+	size_t size;
17a85d
+
17a85d
+	if (fstat(fd, &sbuf) != 0) return NULL;
17a85d
+
17a85d
+	size = sbuf.st_size;
17a85d
+
17a85d
+	if (maxsize) {
17a85d
+		size = size < maxsize ? size : maxsize;
17a85d
+	}
17a85d
+
17a85d
+	p = (char *)talloc_size(mem_ctx, size+1);
17a85d
+	if (!p) return NULL;
17a85d
+
17a85d
+	if (read(fd, p, size) != size) {
17a85d
+		talloc_free(p);
17a85d
+		return NULL;
17a85d
+	}
17a85d
+	p[size] = 0;
17a85d
+
17a85d
+	if (psize) *psize = size;
17a85d
+
17a85d
+	return p;
17a85d
+}
17a85d
+
17a85d
+static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
17a85d
+{
17a85d
+	int fd;
17a85d
+	char *p;
17a85d
+
17a85d
+	if (!fname || !*fname) return NULL;
17a85d
+
17a85d
+	fd = open(fname,O_RDONLY);
17a85d
+	if (fd == -1) return NULL;
17a85d
+
17a85d
+	p = openchange_fd_load(fd, size, maxsize, mem_ctx);
17a85d
+
17a85d
+	close(fd);
17a85d
+
17a85d
+	return p;
17a85d
+}
17a85d
+
17a85d
 /**
17a85d
    \file module_lzxpress.c
17a85d
 
17a85d
@@ -51,7 +101,7 @@ _PUBLIC_ bool mapitest_lzxpress_validate
17a85d
 	/* Step 1. Load Test File 001_Outlook_2007_in_ModifyRecipients_comp.dat */
17a85d
 	filename = talloc_asprintf(mt->mem_ctx, "%s/001_Outlook_2007_in_ModifyRecipients_comp.dat", LZXPRESS_DATADIR);
17a85d
 /* 	filename = talloc_asprintf(mt->mem_ctx, "%s/002_Outlook_2007_in_Tables_operations_comp.dat", LZXPRESS_DATADIR); */
17a85d
-	data = (uint8_t *)file_load(filename, &size, 0, mt->mem_ctx);
17a85d
+	data = (uint8_t *)openchange_file_load(filename, &size, 0, mt->mem_ctx);
17a85d
 	if (!data) {
17a85d
 		perror(filename);
17a85d
 		mapitest_print_retval_fmt(mt, "lzxpress_validate", "Error while loading %s", filename);
17a85d
@@ -137,12 +187,12 @@ _PUBLIC_ bool mapitest_lzxpress_validate
17a85d
 
17a85d
 	mapitest_print(mt, "Compressed rgbIn by Outlook\n");
17a85d
 	mapitest_print(mt, "==============================\n");
17a85d
-	dump_data(0, r.in.rgbIn, r.in.cbIn);
17a85d
+	oc_dump_data(0, r.in.rgbIn, r.in.cbIn);
17a85d
 	mapitest_print(mt, "==============================\n");
17a85d
 
17a85d
 	mapitest_print(mt, "Compressed rgbIn by OpenChange\n");
17a85d
 	mapitest_print(mt, "==============================\n");
17a85d
-	dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
17a85d
+	oc_dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
17a85d
 	mapitest_print(mt, "==============================\n");
17a85d
 
17a85d
 	talloc_free(ndr_rgbIn);
17a85d
diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 openchange-openchange-2.3-VULCAN/utils/openchangeclient.c
17a85d
--- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44	2015-05-16 17:22:04.000000000 +0200
17a85d
+++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c	2016-02-08 22:24:59.212942206 +0100
17a85d
@@ -97,6 +97,52 @@ static void init_oclient(struct oclient
17a85d
 	oclient->ocpf_dump = NULL;
17a85d
 }
17a85d
 
17a85d
+static char **openchange_str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
17a85d
+{
17a85d
+	int num_elements = 0;
17a85d
+	char **ret = NULL;
17a85d
+
17a85d
+	if (sep == NULL) {
17a85d
+		sep = " \t,\n\r";
17a85d
+	}
17a85d
+
17a85d
+	ret = talloc_array(mem_ctx, char *, 1);
17a85d
+	if (ret == NULL) {
17a85d
+		return NULL;
17a85d
+	}
17a85d
+
17a85d
+	while (string && *string) {
17a85d
+		size_t len = strcspn(string, sep);
17a85d
+		char **ret2;
17a85d
+		
17a85d
+		if (len == 0) {
17a85d
+			string += strspn(string, sep);
17a85d
+			continue;
17a85d
+		}
17a85d
+
17a85d
+		ret2 = talloc_realloc(mem_ctx, ret, char *,
17a85d
+			num_elements+2);
17a85d
+		if (ret2 == NULL) {
17a85d
+			talloc_free(ret);
17a85d
+			return NULL;
17a85d
+		}
17a85d
+		ret = ret2;
17a85d
+
17a85d
+		ret[num_elements] = talloc_strndup(ret, string, len);
17a85d
+		if (ret[num_elements] == NULL) {
17a85d
+			talloc_free(ret);
17a85d
+			return NULL;
17a85d
+		}
17a85d
+
17a85d
+		num_elements++;
17a85d
+		string += len;
17a85d
+	}
17a85d
+
17a85d
+	ret[num_elements] = NULL;
17a85d
+
17a85d
+	return ret;
17a85d
+}
17a85d
+
17a85d
 static enum MAPISTATUS openchangeclient_getdir(TALLOC_CTX *mem_ctx,
17a85d
 					       mapi_object_t *obj_container,
17a85d
 					       mapi_object_t *obj_child,
17a85d
@@ -115,7 +161,7 @@ static enum MAPISTATUS openchangeclient_
17a85d
 	uint32_t		i;
17a85d
 
17a85d
 	/* Step 1. Extract the folder list from full path */
17a85d
-	folder = str_list_make(mem_ctx, path, "/");
17a85d
+	folder = openchange_str_list_make(mem_ctx, path, "/");
17a85d
 	mapi_object_copy(&obj_folder, obj_container);
17a85d
 
17a85d
 	for (i = 0; folder[i]; i++) {