]>
Commit | Line | Data |
---|---|---|
1b9a9805 JB |
1 | --- openchange-openchange-2.3-VULCAN/configure.ac.orig 2021-03-26 18:49:09.587370999 +0100 |
2 | +++ openchange-openchange-2.3-VULCAN/configure.ac 2021-03-26 18:50:40.332056045 +0100 | |
db79d4b2 JR |
3 | @@ -657,10 +657,11 @@ AC_CHECK_LIB([popt], [poptFreeContext], |
4 | enable_libpopt="no" | |
5 | ]) | |
6 | ||
7 | +mapitest=0 | |
8 | if test x"$enable_libpopt" = x"yes"; then | |
9 | if test x"$enable_libmapiadmin" = x"yes"; then | |
10 | openchangepfadmin=1 | |
11 | - mapitest=1 | |
12 | + mapitest=0 | |
13 | fi | |
14 | ||
15 | if test x"$enable_libocpf" = x"yes"; then | |
16 | @@ -692,7 +693,7 @@ OC_RULE_ADD(mapipropsdump, TOOLS) | |
17 | OC_RULE_ADD(exchange2ical, TOOLS) | |
1b9a9805 | 18 | OC_RULE_ADD(rpcextract, TOOLS) |
db79d4b2 JR |
19 | OC_RULE_ADD(openchangepfadmin, TOOLS) |
20 | -OC_RULE_ADD(mapitest, TOOLS) | |
21 | +#OC_RULE_ADD(mapitest, TOOLS) | |
22 | OC_RULE_ADD(mapiprofile, TOOLS) | |
23 | OC_RULE_ADD(openchangemapidump, TOOLS) | |
24 | OC_RULE_ADD(schemaIDGUID, TOOLS) | |
25 | diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c | |
26 | --- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 2016-02-09 11:46:45.211994266 +0100 | |
27 | +++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c 2016-02-09 12:04:07.330950109 +0100 | |
28 | @@ -22,6 +22,37 @@ | |
29 | #include "libexchange2ical/libexchange2ical.h" | |
30 | #include <ldb.h> | |
31 | ||
32 | +static void openchange_all_string_sub(char *s,const char *pattern,const char *insert, size_t len) | |
33 | +{ | |
34 | + char *p; | |
35 | + ssize_t ls,lp,li; | |
36 | + | |
37 | + if (!insert || !pattern || !s) | |
38 | + return; | |
39 | + | |
40 | + ls = (ssize_t)strlen(s); | |
41 | + lp = (ssize_t)strlen(pattern); | |
42 | + li = (ssize_t)strlen(insert); | |
43 | + | |
44 | + if (!*pattern) | |
45 | + return; | |
46 | + | |
47 | + if (len == 0) | |
48 | + len = ls + 1; /* len is number of *bytes* */ | |
49 | + | |
50 | + while (lp <= ls && (p = strstr_m(s,pattern))) { | |
51 | + if (ls + (li-lp) >= len) { | |
52 | + break; | |
53 | + } | |
54 | + if (li != lp) { | |
55 | + memmove(p+li,p+lp,strlen(p+lp)+1); | |
56 | + } | |
57 | + memcpy(p, insert, li); | |
58 | + s = p + li; | |
59 | + ls += (li-lp); | |
60 | + } | |
61 | +} | |
62 | + | |
63 | struct RRULE_byday { | |
64 | uint16_t DayOfWeek; | |
65 | const char *DayName; | |
66 | @@ -1019,7 +1050,7 @@ void ical_property_RESOURCES(struct exch | |
67 | if (!exchange2ical->NonSendableBcc) return; | |
68 | ||
69 | NonSendableBcc = talloc_strdup(exchange2ical->mem_ctx, exchange2ical->NonSendableBcc); | |
70 | - all_string_sub(NonSendableBcc, ";", ",", 0); | |
71 | + openchange_all_string_sub(NonSendableBcc, ";", ",", 0); | |
72 | prop = icalproperty_new_resources(NonSendableBcc); | |
73 | icalcomponent_add_property(exchange2ical->vevent, prop); | |
74 | talloc_free(NonSendableBcc); | |
75 | diff -up openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c | |
76 | --- openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 2015-05-16 17:22:04.000000000 +0200 | |
77 | +++ openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c 2016-02-08 22:19:17.750956440 +0100 | |
78 | @@ -24,19 +24,251 @@ | |
79 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
80 | */ | |
81 | ||
82 | +#include <ldb.h> | |
83 | + | |
84 | #include "libmapiadmin/libmapiadmin.h" | |
85 | ||
86 | #include <param.h> | |
87 | #include <credentials.h> | |
88 | +#include <ctype.h> | |
89 | #include <ldb_errors.h> | |
90 | #include <ldb_wrap.h> | |
91 | -#include <ldap_ndr.h> | |
92 | ||
93 | #include <gen_ndr/ndr_samr.h> | |
94 | #include <gen_ndr/ndr_samr_c.h> | |
95 | ||
96 | #include <time.h> | |
97 | ||
98 | +static ssize_t openchange_sys_read(int fd, void *buf, size_t count) | |
99 | +{ | |
100 | + ssize_t ret; | |
101 | + | |
102 | + do { | |
103 | + ret = read(fd, buf, count); | |
104 | + } while (ret == -1 && (errno == EINTR || errno == EAGAIN || | |
105 | + errno == EWOULDBLOCK)); | |
106 | + | |
107 | + return ret; | |
108 | +} | |
109 | + | |
110 | +static ssize_t openchange_read_data(int fd, void *buffer, size_t n) | |
111 | +{ | |
112 | + ssize_t nread; | |
113 | + | |
114 | + nread = 0; | |
115 | + | |
116 | + while (nread < n) { | |
117 | + ssize_t ret; | |
118 | + ret = openchange_sys_read(fd, ((char *)buffer) + nread, n - nread); | |
119 | + if (ret <= 0) { | |
120 | + return ret; | |
121 | + } | |
122 | + nread += ret; | |
123 | + } | |
124 | + | |
125 | + return nread; | |
126 | +} | |
127 | + | |
128 | +static int openchange_urand_fd = -1; | |
129 | +static void openchange_open_urandom(void) | |
130 | +{ | |
131 | + if (openchange_urand_fd != -1) { | |
132 | + return; | |
133 | + } | |
134 | + openchange_urand_fd = open( "/dev/urandom", O_RDONLY,0); | |
135 | + if (openchange_urand_fd == -1) { | |
136 | + abort(); | |
137 | + } | |
138 | +} | |
139 | + | |
140 | +static void openchange_generate_random_buffer(uint8_t *out, int len) | |
141 | +{ | |
142 | + ssize_t rw_ret; | |
143 | + | |
144 | + openchange_open_urandom(); | |
145 | + | |
146 | + rw_ret = openchange_read_data(openchange_urand_fd, out, len); | |
147 | + if (rw_ret != len) { | |
148 | + abort(); | |
149 | + } | |
150 | +} | |
151 | + | |
152 | +static enum ndr_err_code openchange_ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *r) | |
153 | +{ | |
154 | + uint32_t cntr_sub_auths_0; | |
155 | + if (ndr_flags & NDR_SCALARS) { | |
156 | + NDR_CHECK(ndr_push_align(ndr, 4)); | |
157 | + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->sid_rev_num)); | |
158 | + NDR_CHECK(ndr_push_int8(ndr, NDR_SCALARS, r->num_auths)); | |
159 | + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6)); | |
160 | + if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) { | |
161 | + return ndr_push_error(ndr, NDR_ERR_RANGE, "value out of range"); | |
162 | + } | |
163 | + for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) { | |
164 | + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sub_auths[cntr_sub_auths_0])); | |
165 | + } | |
166 | + } | |
167 | + return NDR_ERR_SUCCESS; | |
168 | +} | |
169 | + | |
170 | +static char *openchange_ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) | |
171 | +{ | |
172 | +#undef ldb_val | |
173 | + DATA_BLOB blob; | |
174 | + struct ldb_val val; | |
175 | + enum ndr_err_code ndr_err; | |
176 | + char *ret; | |
177 | + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid, | |
178 | + (ndr_push_flags_fn_t)openchange_ndr_push_dom_sid); | |
179 | + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { | |
180 | + return NULL; | |
181 | + } | |
182 | + val.data = blob.data; | |
183 | + val.length = blob.length; | |
184 | + ret = ldb_binary_encode(mem_ctx, val); | |
185 | + data_blob_free(&blob); | |
186 | + return ret; | |
187 | +} | |
188 | + | |
189 | +static bool openchange_check_password_quality(const char *pwd) | |
190 | +{ | |
191 | + size_t ofs = 0; | |
192 | + size_t num_chars = 0; | |
193 | + size_t num_digits = 0; | |
194 | + size_t num_upper = 0; | |
195 | + size_t num_lower = 0; | |
196 | + size_t num_nonalpha = 0; | |
197 | + size_t num_unicode = 0; | |
198 | + size_t num_categories = 0; | |
199 | + | |
200 | + if (pwd == NULL) { | |
201 | + return false; | |
202 | + } | |
203 | + | |
204 | + while (true) { | |
205 | + const char *s = &pwd[ofs]; | |
206 | + size_t len = 0; | |
207 | + codepoint_t c; | |
208 | + | |
209 | + c = next_codepoint(s, &len); | |
210 | + if (c == INVALID_CODEPOINT) { | |
211 | + return false; | |
212 | + } else if (c == 0) { | |
213 | + break; | |
214 | + } | |
215 | + ofs += len; | |
216 | + num_chars += 1; | |
217 | + | |
218 | + if (len == 1) { | |
219 | + const char *na = "~!@#$%^&*_-+=`|\\(){}[]:;\"'<>,.?/"; | |
220 | + | |
221 | + if (isdigit(c)) { | |
222 | + num_digits += 1; | |
223 | + continue; | |
224 | + } | |
225 | + | |
226 | + if (isupper(c)) { | |
227 | + num_upper += 1; | |
228 | + continue; | |
229 | + } | |
230 | + | |
231 | + if (islower(c)) { | |
232 | + num_lower += 1; | |
233 | + continue; | |
234 | + } | |
235 | + | |
236 | + if (strchr(na, c)) { | |
237 | + num_nonalpha += 1; | |
238 | + continue; | |
239 | + } | |
240 | + | |
241 | + /* | |
242 | + * the rest does not belong to | |
243 | + * a category. | |
244 | + */ | |
245 | + continue; | |
246 | + } | |
247 | + | |
248 | + if (isupper_m(c)) { | |
249 | + num_upper += 1; | |
250 | + continue; | |
251 | + } | |
252 | + | |
253 | + if (islower_m(c)) { | |
254 | + num_lower += 1; | |
255 | + continue; | |
256 | + } | |
257 | + | |
258 | + /* | |
259 | + * Note: for now do not check if the unicode category is | |
260 | + * alphabetic character | |
261 | + * | |
262 | + * We would have to import the details from | |
263 | + * ftp://ftp.unicode.org/Public/6.3.0/ucd/UnicodeData-6.3.0d1.txt | |
264 | + */ | |
265 | + num_unicode += 1; | |
266 | + continue; | |
267 | + } | |
268 | + | |
269 | + if (num_digits > 0) { | |
270 | + num_categories += 1; | |
271 | + } | |
272 | + if (num_upper > 0) { | |
273 | + num_categories += 1; | |
274 | + } | |
275 | + if (num_lower > 0) { | |
276 | + num_categories += 1; | |
277 | + } | |
278 | + if (num_nonalpha > 0) { | |
279 | + num_categories += 1; | |
280 | + } | |
281 | + if (num_unicode > 0) { | |
282 | + num_categories += 1; | |
283 | + } | |
284 | + | |
285 | + if (num_categories >= 3) { | |
286 | + return true; | |
287 | + } | |
288 | + | |
289 | + return false; | |
290 | +} | |
291 | + | |
292 | +static char *openchange_generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list) | |
293 | +{ | |
294 | + size_t i; | |
295 | + size_t list_len = strlen(list); | |
296 | + | |
297 | + char *retstr = talloc_array(mem_ctx, char, len + 1); | |
298 | + if (!retstr) return NULL; | |
299 | + | |
300 | + openchange_generate_random_buffer((uint8_t *)retstr, len); | |
301 | + for (i = 0; i < len; i++) { | |
302 | + retstr[i] = list[retstr[i] % list_len]; | |
303 | + } | |
304 | + retstr[i] = '\0'; | |
305 | + | |
306 | + return retstr; | |
307 | +} | |
308 | + | |
309 | +static char *openchange_generate_random_str(TALLOC_CTX *mem_ctx, size_t len) | |
310 | +{ | |
311 | + char *retstr; | |
312 | + const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,"; | |
313 | + | |
314 | +again: | |
315 | + retstr = openchange_generate_random_str_list(mem_ctx, len, c_list); | |
316 | + if (!retstr) return NULL; | |
317 | + | |
318 | + /* we need to make sure the random string passes basic quality tests | |
319 | + or it might be rejected by windows as a password */ | |
320 | + if (len >= 7 && !openchange_check_password_quality(retstr)) { | |
321 | + talloc_free(retstr); | |
322 | + goto again; | |
323 | + } | |
324 | + | |
325 | + return retstr; | |
326 | +} | |
327 | + | |
328 | /** | |
329 | \file | |
330 | User management functions for mapiadmin | |
331 | @@ -232,10 +464,10 @@ _PUBLIC_ enum MAPISTATUS mapiadmin_user_ | |
332 | /* Search the user_dn */ | |
333 | account_dn = samdb_search_dn(remote_ldb, mem_ctx, NULL, | |
334 | "(&(objectSid=%s)(objectClass=user))", | |
335 | - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid)); | |
336 | + openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid)); | |
337 | ||
338 | ret = ldb_search(remote_ldb, mem_ctx, &res, account_dn, LDB_SCOPE_SUBTREE, dom_attrs, "(objectSid=%s)", | |
339 | - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid)); | |
340 | + openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid)); | |
341 | MAPI_RETVAL_IF(ret != LDB_SUCCESS, MAPI_E_NOT_FOUND, mem_ctx); | |
342 | MAPI_RETVAL_IF(res->count != 1, MAPI_E_NOT_FOUND, mem_ctx); | |
343 | ||
344 | @@ -422,7 +654,7 @@ again: | |
345 | } | |
346 | ||
347 | if (!mapiadmin_ctx->password) { | |
348 | - mapiadmin_ctx->password = generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len)); | |
349 | + mapiadmin_ctx->password = openchange_generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len)); | |
350 | } | |
351 | ||
352 | OC_DEBUG(3, "Setting account password '%s'", mapiadmin_ctx->password); | |
353 | diff -up openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapidump.c | |
354 | --- openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 2016-02-09 11:03:18.565104717 +0100 | |
355 | +++ openchange-openchange-2.3-VULCAN/libmapi/mapidump.c 2016-02-09 11:03:29.508104254 +0100 | |
356 | @@ -119,7 +119,7 @@ _PUBLIC_ void mapidump_SPropValue(struct | |
357 | data = get_SPropValue_data(&lpProp); | |
358 | if (data) { | |
359 | printf("%s%s:\n", sep?sep:"", proptag); | |
360 | - dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb); | |
361 | + oc_dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb); | |
362 | } else { | |
363 | printf("%s%s: (NULL)\n", sep?sep:"", proptag); | |
364 | } | |
365 | @@ -153,7 +153,7 @@ _PUBLIC_ void mapidump_SPropValue(struct | |
366 | printf("%s%s: ARRAY(%d)\n", sep?sep:"", proptag, BinaryArray_r->cValues); | |
367 | for (i = 0; i < BinaryArray_r->cValues; i++) { | |
368 | printf("\tPT_MV_BINARY [%d]:\n", i); | |
369 | - dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb); | |
370 | + oc_dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb); | |
371 | } | |
372 | break; | |
373 | default: | |
374 | diff -up openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c | |
375 | --- openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 2016-02-09 11:02:57.062105628 +0100 | |
376 | +++ openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c 2016-02-09 11:03:01.012105461 +0100 | |
377 | @@ -412,7 +412,7 @@ _PUBLIC_ enum MAPISTATUS mapi_object_boo | |
378 | while (bookmark) { | |
379 | OC_DEBUG(0, "mapi_object_bookmark {"); | |
380 | OC_DEBUG(0, ".index == %u", bookmark->index); | |
381 | - dump_data(0, bookmark->bin.lpb, bookmark->bin.cb); | |
382 | + oc_dump_data(0, bookmark->bin.lpb, bookmark->bin.cb); | |
383 | OC_DEBUG(0, "};"); | |
384 | ||
385 | bookmark = bookmark->next; | |
386 | diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.c | |
387 | --- openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 2016-02-09 10:49:20.292140237 +0100 | |
388 | +++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.c 2016-02-09 11:30:13.912036271 +0100 | |
389 | @@ -21,6 +21,12 @@ | |
390 | ||
391 | #include "libmapi/libmapi.h" | |
392 | #include <stdio.h> | |
393 | +#include <stdlib.h> | |
394 | +#include <ctype.h> | |
395 | + | |
396 | +#ifndef MIN | |
397 | +#define MIN(a,b) ((a)<(b)?(a):(b)) | |
398 | +#endif | |
399 | ||
400 | int _oc_log_samba_level = 0; | |
401 | ||
402 | @@ -84,3 +90,119 @@ void oc_log_init_server(const char *prog | |
403 | { | |
404 | setup_logging(progname, DEBUG_FILE); | |
405 | } | |
406 | + | |
407 | +void oc_panic(const char *why) | |
408 | +{ | |
409 | + if (why) { | |
410 | + fprintf(stderr, "PANIC: %s\n", why); | |
411 | + fflush(stderr); | |
412 | + } | |
413 | + | |
414 | + abort(); | |
415 | +} | |
416 | +static void oc_debugadd_cb(const char *buf, void *private_data) | |
417 | +{ | |
418 | + int *plevel = (int *)private_data; | |
419 | + if (plevel && *plevel <= _oc_log_samba_level) { | |
420 | + printf ("%s", buf); | |
421 | + } | |
422 | +} | |
423 | + | |
424 | +static void oc_print_asc_cb(const uint8_t *buf, int len, | |
425 | + void (*cb)(const char *buf, void *private_data), | |
426 | + void *private_data) | |
427 | +{ | |
428 | + int i; | |
429 | + char s[2]; | |
430 | + s[1] = 0; | |
431 | + | |
432 | + for (i=0; i<len; i++) { | |
433 | + s[0] = isprint(buf[i]) ? buf[i] : '.'; | |
434 | + cb(s, private_data); | |
435 | + } | |
436 | +} | |
437 | + | |
438 | +static void oc_dump_data_cb(const uint8_t *buf, int len, | |
439 | + bool omit_zero_bytes, | |
440 | + void (*cb)(const char *buf, void *private_data), | |
441 | + void *private_data) | |
442 | +{ | |
443 | + int i=0; | |
444 | + static const uint8_t empty[16] = { 0, }; | |
445 | + bool skipped = false; | |
446 | + char tmp[16]; | |
447 | + | |
448 | + if (len<=0) return; | |
449 | + | |
450 | + for (i=0;i<len;) { | |
451 | + | |
452 | + if (i%16 == 0) { | |
453 | + if ((omit_zero_bytes == true) && | |
454 | + (i > 0) && | |
455 | + (len > i+16) && | |
456 | + (memcmp(&buf[i], &empty, 16) == 0)) | |
457 | + { | |
458 | + i +=16; | |
459 | + continue; | |
460 | + } | |
461 | + | |
462 | + if (i<len) { | |
463 | + snprintf(tmp, sizeof(tmp), "[%04X] ", i); | |
464 | + cb(tmp, private_data); | |
465 | + } | |
466 | + } | |
467 | + | |
468 | + snprintf(tmp, sizeof(tmp), "%02X ", (int)buf[i]); | |
469 | + cb(tmp, private_data); | |
470 | + i++; | |
471 | + if (i%8 == 0) { | |
472 | + cb(" ", private_data); | |
473 | + } | |
474 | + if (i%16 == 0) { | |
475 | + | |
476 | + oc_print_asc_cb(&buf[i-16], 8, cb, private_data); | |
477 | + cb(" ", private_data); | |
478 | + oc_print_asc_cb(&buf[i-8], 8, cb, private_data); | |
479 | + cb("\n", private_data); | |
480 | + | |
481 | + if ((omit_zero_bytes == true) && | |
482 | + (len > i+16) && | |
483 | + (memcmp(&buf[i], &empty, 16) == 0)) { | |
484 | + if (!skipped) { | |
485 | + cb("skipping zero buffer bytes\n", | |
486 | + private_data); | |
487 | + skipped = true; | |
488 | + } | |
489 | + } | |
490 | + } | |
491 | + } | |
492 | + | |
493 | + if (i%16) { | |
494 | + int n; | |
495 | + n = 16 - (i%16); | |
496 | + cb(" ", private_data); | |
497 | + if (n>8) { | |
498 | + cb(" ", private_data); | |
499 | + } | |
500 | + while (n--) { | |
501 | + cb(" ", private_data); | |
502 | + } | |
503 | + n = MIN(8,i%16); | |
504 | + oc_print_asc_cb(&buf[i-(i%16)], n, cb, private_data); | |
505 | + cb(" ", private_data); | |
506 | + n = (i%16) - n; | |
507 | + if (n>0) { | |
508 | + oc_print_asc_cb(&buf[i-n], n, cb, private_data); | |
509 | + } | |
510 | + cb("\n", private_data); | |
511 | + } | |
512 | + | |
513 | +} | |
514 | + | |
515 | +void oc_dump_data(int level, const uint8_t *buf,int len) | |
516 | +{ | |
517 | + if (_oc_log_samba_level < level || !buf || !len) | |
518 | + return; | |
519 | + | |
520 | + oc_dump_data_cb(buf, len, false, oc_debugadd_cb, &level); | |
521 | +} | |
522 | diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.h | |
523 | --- openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 2016-02-09 10:49:16.132140414 +0100 | |
524 | +++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.h 2016-02-09 10:51:57.121133592 +0100 | |
525 | @@ -79,4 +79,7 @@ void oc_log_init_server(const char *prog | |
526 | ||
527 | extern int _oc_log_samba_level; /* Private, do not change it other than by SetMAPIDebugLevel() */ | |
528 | ||
529 | +void oc_panic(const char *why); | |
530 | +void oc_dump_data(int level, const uint8_t *buf,int len); | |
531 | + | |
532 | #endif /* _OC_LOG_H_ */ | |
533 | diff -up openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/property.c | |
534 | --- openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 2016-02-09 10:46:51.040146561 +0100 | |
535 | +++ openchange-openchange-2.3-VULCAN/libmapi/property.c 2016-02-09 10:48:47.626141621 +0100 | |
536 | @@ -777,7 +777,7 @@ _PUBLIC_ void mapi_copy_spropvalues(TALL | |
537 | // TODO: Replace this with OC_PANIC() macro when it gets visible in libmapi too | |
538 | OC_DEBUG(0, "Unexpected multi-value property type: %s.", | |
539 | get_proptag_name(source_value->ulPropTag)); | |
540 | - smb_panic("Unexpected multi-value property type while copying 'struct SPropValue'"); | |
541 | + oc_panic("Unexpected multi-value property type while copying 'struct SPropValue'"); | |
542 | } | |
543 | } | |
544 | } | |
545 | diff -up openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c | |
546 | --- openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 2016-02-09 11:09:43.147088421 +0100 | |
547 | +++ openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c 2016-02-09 11:31:47.664032298 +0100 | |
548 | @@ -90,6 +90,213 @@ static void add_interface(TALLOC_CTX *me | |
549 | OC_DEBUG(2, "added interface ip=%s nmask=%s", iface->ip_s, iface->nmask_s); | |
550 | } | |
551 | ||
552 | +enum oc_protocol_types { | |
553 | + PROTOCOL_DEFAULT=-1, | |
554 | + PROTOCOL_NONE=0, | |
555 | + PROTOCOL_CORE, | |
556 | + PROTOCOL_COREPLUS, | |
557 | + PROTOCOL_LANMAN1, | |
558 | + PROTOCOL_LANMAN2, | |
559 | + PROTOCOL_NT1, | |
560 | + PROTOCOL_SMB2_02, | |
561 | + PROTOCOL_SMB2_10, | |
562 | + PROTOCOL_SMB2_22, | |
563 | + PROTOCOL_SMB2_24, | |
564 | + PROTOCOL_SMB3_00, | |
565 | + PROTOCOL_SMB3_02, | |
566 | + PROTOCOL_SMB3_10, | |
567 | + PROTOCOL_SMB3_11 | |
568 | +}; | |
569 | + | |
570 | +static int openchange_null_match(const char *p) | |
571 | +{ | |
572 | + for (;*p;p++) { | |
573 | + if (*p != '*' && | |
574 | + *p != '<' && | |
575 | + *p != '"' && | |
576 | + *p != '>') return -1; | |
577 | + } | |
578 | + return 0; | |
579 | +} | |
580 | + | |
581 | +/* | |
582 | + the max_n structure is purely for efficiency, it doesn't contribute | |
583 | + to the matching algorithm except by ensuring that the algorithm does | |
584 | + not grow exponentially | |
585 | +*/ | |
586 | +struct max_n { | |
587 | + const char *predot; | |
588 | + const char *postdot; | |
589 | +}; | |
590 | + | |
591 | + | |
592 | +/* | |
593 | + p and n are the pattern and string being matched. The max_n array is | |
594 | + an optimisation only. The ldot pointer is NULL if the string does | |
595 | + not contain a '.', otherwise it points at the last dot in 'n'. | |
596 | +*/ | |
597 | +static int openchange_ms_fnmatch_core(const char *p, const char *n, | |
598 | + struct max_n *max_n, const char *ldot) | |
599 | +{ | |
600 | + codepoint_t c, c2; | |
601 | + int i; | |
602 | + size_t size, size_n; | |
603 | + | |
604 | + while ((c = next_codepoint(p, &size))) { | |
605 | + p += size; | |
606 | + | |
607 | + switch (c) { | |
608 | + case '*': | |
609 | + /* a '*' matches zero or more characters of any type */ | |
610 | + if (max_n->predot && max_n->predot <= n) { | |
611 | + return openchange_null_match(p); | |
612 | + } | |
613 | + for (i=0; n[i]; i += size_n) { | |
614 | + next_codepoint(n+i, &size_n); | |
615 | + if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) { | |
616 | + return 0; | |
617 | + } | |
618 | + } | |
619 | + if (!max_n->predot || max_n->predot > n) max_n->predot = n; | |
620 | + return openchange_null_match(p); | |
621 | + | |
622 | + case '<': | |
623 | + /* a '<' matches zero or more characters of | |
624 | + any type, but stops matching at the last | |
625 | + '.' in the string. */ | |
626 | + if (max_n->predot && max_n->predot <= n) { | |
627 | + return openchange_null_match(p); | |
628 | + } | |
629 | + if (max_n->postdot && max_n->postdot <= n && n <= ldot) { | |
630 | + return -1; | |
631 | + } | |
632 | + for (i=0; n[i]; i += size_n) { | |
633 | + next_codepoint(n+i, &size_n); | |
634 | + if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0; | |
635 | + if (n+i == ldot) { | |
636 | + if (openchange_ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0; | |
637 | + if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n; | |
638 | + return -1; | |
639 | + } | |
640 | + } | |
641 | + if (!max_n->predot || max_n->predot > n) max_n->predot = n; | |
642 | + return openchange_null_match(p); | |
643 | + | |
644 | + case '?': | |
645 | + /* a '?' matches any single character */ | |
646 | + if (! *n) { | |
647 | + return -1; | |
648 | + } | |
649 | + next_codepoint(n, &size_n); | |
650 | + n += size_n; | |
651 | + break; | |
652 | + | |
653 | + case '>': | |
654 | + /* a '?' matches any single character, but | |
655 | + treats '.' specially */ | |
656 | + if (n[0] == '.') { | |
657 | + if (! n[1] && openchange_null_match(p) == 0) { | |
658 | + return 0; | |
659 | + } | |
660 | + break; | |
661 | + } | |
662 | + if (! *n) return openchange_null_match(p); | |
663 | + next_codepoint(n, &size_n); | |
664 | + n += size_n; | |
665 | + break; | |
666 | + | |
667 | + case '"': | |
668 | + /* a bit like a soft '.' */ | |
669 | + if (*n == 0 && openchange_null_match(p) == 0) { | |
670 | + return 0; | |
671 | + } | |
672 | + if (*n != '.') return -1; | |
673 | + next_codepoint(n, &size_n); | |
674 | + n += size_n; | |
675 | + break; | |
676 | + | |
677 | + default: | |
678 | + c2 = next_codepoint(n, &size_n); | |
679 | + if (c != c2 && codepoint_cmpi(c, c2) != 0) { | |
680 | + return -1; | |
681 | + } | |
682 | + n += size_n; | |
683 | + break; | |
684 | + } | |
685 | + } | |
686 | + | |
687 | + if (! *n) { | |
688 | + return 0; | |
689 | + } | |
690 | + | |
691 | + return -1; | |
692 | +} | |
693 | + | |
694 | +static int openchange_ms_fnmatch_protocol(const char *pattern, const char *string, int protocol) | |
695 | +{ | |
696 | + int ret, count, i; | |
697 | + struct max_n *max_n = NULL; | |
698 | + | |
699 | + if (strcmp(string, "..") == 0) { | |
700 | + string = "."; | |
701 | + } | |
702 | + | |
703 | + if (strpbrk(pattern, "<>*?\"") == NULL) { | |
704 | + /* this is not just an optimisation - it is essential | |
705 | + for LANMAN1 correctness */ | |
706 | + return strcasecmp_m(pattern, string); | |
707 | + } | |
708 | + | |
709 | + if (protocol <= PROTOCOL_LANMAN2) { | |
710 | + char *p = talloc_strdup(NULL, pattern); | |
711 | + if (p == NULL) { | |
712 | + return -1; | |
713 | + } | |
714 | + /* | |
715 | + for older negotiated protocols it is possible to | |
716 | + translate the pattern to produce a "new style" | |
717 | + pattern that exactly matches w2k behaviour | |
718 | + */ | |
719 | + for (i=0;p[i];i++) { | |
720 | + if (p[i] == '?') { | |
721 | + p[i] = '>'; | |
722 | + } else if (p[i] == '.' && | |
723 | + (p[i+1] == '?' || | |
724 | + p[i+1] == '*' || | |
725 | + p[i+1] == 0)) { | |
726 | + p[i] = '"'; | |
727 | + } else if (p[i] == '*' && | |
728 | + p[i+1] == '.') { | |
729 | + p[i] = '<'; | |
730 | + } | |
731 | + } | |
732 | + ret = openchange_ms_fnmatch_protocol(p, string, PROTOCOL_NT1); | |
733 | + talloc_free(p); | |
734 | + return ret; | |
735 | + } | |
736 | + | |
737 | + for (count=i=0;pattern[i];i++) { | |
738 | + if (pattern[i] == '*' || pattern[i] == '<') count++; | |
739 | + } | |
740 | + | |
741 | + max_n = talloc_zero_array(NULL, struct max_n, count); | |
742 | + if (max_n == NULL) { | |
743 | + return -1; | |
744 | + } | |
745 | + | |
746 | + ret = openchange_ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.')); | |
747 | + | |
748 | + talloc_free(max_n); | |
749 | + | |
750 | + return ret; | |
751 | +} | |
752 | + | |
753 | + | |
754 | +/** a generic fnmatch function - uses for non-CIFS pattern matching */ | |
755 | +static int openchange_gen_fnmatch(const char *pattern, const char *string) | |
756 | +{ | |
757 | + return openchange_ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1); | |
758 | +} | |
759 | ||
760 | ||
761 | /** | |
762 | @@ -119,7 +326,7 @@ static void interpret_interface(TALLOC_C | |
763 | ||
764 | /* first check if it is an interface name */ | |
765 | for (i=0;i<total_probed;i++) { | |
766 | - if (gen_fnmatch(token, probed_ifaces[i].name) == 0) { | |
767 | + if (openchange_gen_fnmatch(token, probed_ifaces[i].name) == 0) { | |
768 | add_interface(mem_ctx, probed_ifaces[i].ip, | |
769 | probed_ifaces[i].netmask, | |
770 | local_interfaces); | |
771 | 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 | |
772 | --- openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44 2015-05-16 17:22:04.000000000 +0200 | |
773 | +++ openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c 2016-02-08 17:43:52.578645298 +0100 | |
774 | @@ -31,8 +31,6 @@ | |
775 | #include "mapiproxy/libmapiserver/libmapiserver.h" | |
776 | #include "mapiproxy/libmapiproxy/fault_util.h" | |
777 | ||
778 | -#include <ldap_ndr.h> | |
779 | - | |
780 | /* Expose samdb_connect prototype */ | |
781 | struct ldb_context *samdb_connect(TALLOC_CTX *, struct tevent_context *, | |
782 | struct loadparm_context *, | |
783 | diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 openchange-openchange-2.3-VULCAN/ndr_mapi.c | |
784 | --- openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 2016-02-09 11:04:30.054101688 +0100 | |
785 | +++ openchange-openchange-2.3-VULCAN/ndr_mapi.c 2016-02-09 11:04:49.763100853 +0100 | |
786 | @@ -1616,7 +1616,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc | |
787 | if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) { | |
788 | ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request); | |
789 | } else { | |
790 | - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
791 | + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
792 | talloc_free(mapi_request); | |
793 | break; | |
794 | } | |
795 | @@ -1662,7 +1662,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc | |
796 | if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) { | |
797 | ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response); | |
798 | } else { | |
799 | - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
800 | + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
801 | talloc_free(mapi_response); | |
802 | break; | |
803 | } | |
804 | @@ -1735,7 +1735,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru | |
805 | if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) { | |
806 | ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request); | |
807 | } else { | |
808 | - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
809 | + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
810 | talloc_free(mapi_request); | |
811 | return; | |
812 | } | |
813 | @@ -1786,7 +1786,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru | |
814 | if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) { | |
815 | ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response); | |
816 | } else { | |
817 | - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
818 | + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset); | |
819 | talloc_free(mapi_response); | |
820 | break; | |
821 | } | |
822 | @@ -2041,7 +2041,7 @@ _PUBLIC_ void ndr_print_SBinary_short(st | |
823 | uint32_t _flags_save_STRUCT = ndr->flags; | |
824 | ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); | |
825 | ndr->depth++; | |
826 | - dump_data(0, r->lpb, r->cb); | |
827 | + oc_dump_data(0, r->lpb, r->cb); | |
828 | ndr->depth--; | |
829 | ndr->flags = _flags_save_STRUCT; | |
830 | } | |
831 | @@ -2054,7 +2054,7 @@ _PUBLIC_ void ndr_print_Binary_r(struct | |
832 | uint32_t _flags_save_STRUCT = ndr->flags; | |
833 | ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); | |
834 | ndr->depth++; | |
835 | - dump_data(0, r->lpb, r->cb); | |
836 | + oc_dump_data(0, r->lpb, r->cb); | |
837 | ndr->depth--; | |
838 | ndr->flags = _flags_save_STRUCT; | |
839 | } | |
840 | diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c | |
841 | --- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 2015-05-16 17:22:04.000000000 +0200 | |
842 | +++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c 2016-02-09 10:35:42.207174902 +0100 | |
843 | @@ -24,6 +24,9 @@ | |
844 | #include "gen_ndr/ndr_exchange.h" | |
845 | #include <popt.h> | |
846 | #include <dlfcn.h> | |
847 | +#include <sys/types.h> | |
848 | +#include <sys/stat.h> | |
849 | +#include <unistd.h> | |
850 | ||
851 | #define PLUGIN "libmapi.so" | |
852 | #define FUNCTION 0xB | |
853 | @@ -97,6 +100,51 @@ static const const struct ndr_interface_ | |
854 | return p; | |
855 | } | |
856 | ||
857 | +static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx) | |
858 | +{ | |
859 | + struct stat sbuf; | |
860 | + char *p; | |
861 | + size_t size; | |
862 | + | |
863 | + if (fstat(fd, &sbuf) != 0) return NULL; | |
864 | + | |
865 | + size = sbuf.st_size; | |
866 | + | |
867 | + if (maxsize) { | |
868 | + size = size < maxsize ? size : maxsize; | |
869 | + } | |
870 | + | |
871 | + p = (char *)talloc_size(mem_ctx, size+1); | |
872 | + if (!p) return NULL; | |
873 | + | |
874 | + if (read(fd, p, size) != size) { | |
875 | + talloc_free(p); | |
876 | + return NULL; | |
877 | + } | |
878 | + p[size] = 0; | |
879 | + | |
880 | + if (psize) *psize = size; | |
881 | + | |
882 | + return p; | |
883 | +} | |
884 | + | |
885 | +static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx) | |
886 | +{ | |
887 | + int fd; | |
888 | + char *p; | |
889 | + | |
890 | + if (!fname || !*fname) return NULL; | |
891 | + | |
892 | + fd = open(fname,O_RDONLY); | |
893 | + if (fd == -1) return NULL; | |
894 | + | |
895 | + p = openchange_fd_load(fd, size, maxsize, mem_ctx); | |
896 | + | |
897 | + close(fd); | |
898 | + | |
899 | + return p; | |
900 | +} | |
901 | + | |
902 | static struct SPropTagArray *process_request(TALLOC_CTX *mem_ctx, | |
903 | const struct ndr_interface_call *f, | |
904 | const char *filename, | |
905 | @@ -123,7 +171,7 @@ static struct SPropTagArray *process_req | |
906 | return NULL; | |
907 | } | |
908 | ||
909 | - data = (uint8_t *) file_load(filename, &size, 0, mem_ctx); | |
910 | + data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx); | |
911 | if (!data) { | |
912 | perror(filename); | |
913 | return NULL; | |
914 | @@ -224,7 +272,7 @@ static int process_response(TALLOC_CTX * | |
915 | return -1; | |
916 | } | |
917 | ||
918 | - data = (uint8_t *) file_load(filename, &size, 0, mem_ctx); | |
919 | + data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx); | |
920 | if (!data) { | |
921 | perror(filename); | |
922 | return -1; | |
923 | 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 | |
924 | --- openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44 2016-02-09 11:06:00.717097846 +0100 | |
925 | +++ openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c 2016-02-09 11:48:38.200989479 +0100 | |
926 | @@ -19,11 +19,61 @@ | |
927 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
928 | */ | |
929 | ||
930 | +#include <sys/types.h> | |
931 | +#include <sys/stat.h> | |
932 | +#include <unistd.h> | |
933 | + | |
934 | #include "utils/mapitest/mapitest.h" | |
935 | #include "utils/mapitest/proto.h" | |
936 | #include "gen_ndr/ndr_exchange.h" | |
937 | +#include "libmapi/libmapi.h" | |
938 | #include "libmapi/libmapi_private.h" | |
939 | ||
940 | +static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx) | |
941 | +{ | |
942 | + struct stat sbuf; | |
943 | + char *p; | |
944 | + size_t size; | |
945 | + | |
946 | + if (fstat(fd, &sbuf) != 0) return NULL; | |
947 | + | |
948 | + size = sbuf.st_size; | |
949 | + | |
950 | + if (maxsize) { | |
951 | + size = size < maxsize ? size : maxsize; | |
952 | + } | |
953 | + | |
954 | + p = (char *)talloc_size(mem_ctx, size+1); | |
955 | + if (!p) return NULL; | |
956 | + | |
957 | + if (read(fd, p, size) != size) { | |
958 | + talloc_free(p); | |
959 | + return NULL; | |
960 | + } | |
961 | + p[size] = 0; | |
962 | + | |
963 | + if (psize) *psize = size; | |
964 | + | |
965 | + return p; | |
966 | +} | |
967 | + | |
968 | +static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx) | |
969 | +{ | |
970 | + int fd; | |
971 | + char *p; | |
972 | + | |
973 | + if (!fname || !*fname) return NULL; | |
974 | + | |
975 | + fd = open(fname,O_RDONLY); | |
976 | + if (fd == -1) return NULL; | |
977 | + | |
978 | + p = openchange_fd_load(fd, size, maxsize, mem_ctx); | |
979 | + | |
980 | + close(fd); | |
981 | + | |
982 | + return p; | |
983 | +} | |
984 | + | |
985 | /** | |
986 | \file module_lzxpress.c | |
987 | ||
988 | @@ -51,7 +101,7 @@ _PUBLIC_ bool mapitest_lzxpress_validate | |
989 | /* Step 1. Load Test File 001_Outlook_2007_in_ModifyRecipients_comp.dat */ | |
990 | filename = talloc_asprintf(mt->mem_ctx, "%s/001_Outlook_2007_in_ModifyRecipients_comp.dat", LZXPRESS_DATADIR); | |
991 | /* filename = talloc_asprintf(mt->mem_ctx, "%s/002_Outlook_2007_in_Tables_operations_comp.dat", LZXPRESS_DATADIR); */ | |
992 | - data = (uint8_t *)file_load(filename, &size, 0, mt->mem_ctx); | |
993 | + data = (uint8_t *)openchange_file_load(filename, &size, 0, mt->mem_ctx); | |
994 | if (!data) { | |
995 | perror(filename); | |
996 | mapitest_print_retval_fmt(mt, "lzxpress_validate", "Error while loading %s", filename); | |
997 | @@ -137,12 +187,12 @@ _PUBLIC_ bool mapitest_lzxpress_validate | |
998 | ||
999 | mapitest_print(mt, "Compressed rgbIn by Outlook\n"); | |
1000 | mapitest_print(mt, "==============================\n"); | |
1001 | - dump_data(0, r.in.rgbIn, r.in.cbIn); | |
1002 | + oc_dump_data(0, r.in.rgbIn, r.in.cbIn); | |
1003 | mapitest_print(mt, "==============================\n"); | |
1004 | ||
1005 | mapitest_print(mt, "Compressed rgbIn by OpenChange\n"); | |
1006 | mapitest_print(mt, "==============================\n"); | |
1007 | - dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset); | |
1008 | + oc_dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset); | |
1009 | mapitest_print(mt, "==============================\n"); | |
1010 | ||
1011 | talloc_free(ndr_rgbIn); | |
1012 | diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 openchange-openchange-2.3-VULCAN/utils/openchangeclient.c | |
1013 | --- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 2015-05-16 17:22:04.000000000 +0200 | |
1014 | +++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c 2016-02-08 22:24:59.212942206 +0100 | |
1015 | @@ -97,6 +97,52 @@ static void init_oclient(struct oclient | |
1016 | oclient->ocpf_dump = NULL; | |
1017 | } | |
1018 | ||
1019 | +static char **openchange_str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) | |
1020 | +{ | |
1021 | + int num_elements = 0; | |
1022 | + char **ret = NULL; | |
1023 | + | |
1024 | + if (sep == NULL) { | |
1025 | + sep = " \t,\n\r"; | |
1026 | + } | |
1027 | + | |
1028 | + ret = talloc_array(mem_ctx, char *, 1); | |
1029 | + if (ret == NULL) { | |
1030 | + return NULL; | |
1031 | + } | |
1032 | + | |
1033 | + while (string && *string) { | |
1034 | + size_t len = strcspn(string, sep); | |
1035 | + char **ret2; | |
1036 | + | |
1037 | + if (len == 0) { | |
1038 | + string += strspn(string, sep); | |
1039 | + continue; | |
1040 | + } | |
1041 | + | |
1042 | + ret2 = talloc_realloc(mem_ctx, ret, char *, | |
1043 | + num_elements+2); | |
1044 | + if (ret2 == NULL) { | |
1045 | + talloc_free(ret); | |
1046 | + return NULL; | |
1047 | + } | |
1048 | + ret = ret2; | |
1049 | + | |
1050 | + ret[num_elements] = talloc_strndup(ret, string, len); | |
1051 | + if (ret[num_elements] == NULL) { | |
1052 | + talloc_free(ret); | |
1053 | + return NULL; | |
1054 | + } | |
1055 | + | |
1056 | + num_elements++; | |
1057 | + string += len; | |
1058 | + } | |
1059 | + | |
1060 | + ret[num_elements] = NULL; | |
1061 | + | |
1062 | + return ret; | |
1063 | +} | |
1064 | + | |
1065 | static enum MAPISTATUS openchangeclient_getdir(TALLOC_CTX *mem_ctx, | |
1066 | mapi_object_t *obj_container, | |
1067 | mapi_object_t *obj_child, | |
1068 | @@ -115,7 +161,7 @@ static enum MAPISTATUS openchangeclient_ | |
1069 | uint32_t i; | |
1070 | ||
1071 | /* Step 1. Extract the folder list from full path */ | |
1072 | - folder = str_list_make(mem_ctx, path, "/"); | |
1073 | + folder = openchange_str_list_make(mem_ctx, path, "/"); | |
1074 | mapi_object_copy(&obj_folder, obj_container); | |
1075 | ||
1076 | for (i = 0; folder[i]; i++) { |