[PATCH-v6] samba 3.0.37 update
[openwrt/svn-archive/archive.git] / net / samba3 / patches / 100-avm.patch
1 Index: samba-3.0.37/source/auth/auth_util.c
2 ===================================================================
3 --- samba-3.0.37.orig/source/auth/auth_util.c 2009-09-30 14:21:56.000000000 +0200
4 +++ samba-3.0.37/source/auth/auth_util.c 2011-08-09 00:02:34.854444169 +0200
5 @@ -2284,18 +2284,20 @@
6 /* The only other possible result is that winbind is not up
7 and running. We need to update the trustdom_cache
8 ourselves */
9 -
10 +#ifndef AVM_SMALLER
11 update_trustdom_cache();
12 +#endif
13 }
14
15 /* now the trustdom cache should be available a DC could still
16 * have a transitive trust so fall back to the cache of trusted
17 * domains (like a domain member would use */
18
19 +#ifndef AVM_SMALLER
20 if ( trustdom_cache_fetch(dom_name, &trustdom_sid) ) {
21 return True;
22 }
23 -
24 +#endif
25 return False;
26 }
27
28 Index: samba-3.0.37/source/include/local.h
29 ===================================================================
30 --- samba-3.0.37.orig/source/include/local.h 2009-09-30 14:21:56.000000000 +0200
31 +++ samba-3.0.37/source/include/local.h 2011-08-09 00:02:34.854444169 +0200
32 @@ -49,7 +49,8 @@
33 #define MAX_DIRECTORY_HANDLES 2048
34
35 /* maximum number of file caches per smbd */
36 -#define MAX_WRITE_CACHES 10
37 +/* #define MAX_WRITE_CACHES 10 */
38 +#define MAX_WRITE_CACHES 2 /* AVM */
39
40 /* define what facility to use for syslog */
41 #ifndef SYSLOG_FACILITY
42 Index: samba-3.0.37/source/lib/iconv.c
43 ===================================================================
44 --- samba-3.0.37.orig/source/lib/iconv.c 2009-09-30 14:21:56.000000000 +0200
45 +++ samba-3.0.37/source/lib/iconv.c 2011-08-09 00:02:34.854444169 +0200
46 @@ -385,7 +385,10 @@
47
48 while (*inbytesleft >= 2 && *outbytesleft >= 1) {
49 (*outbuf)[0] = (*inbuf)[0];
50 - if ((*inbuf)[1]) ir_count++;
51 + if ((*inbuf)[1]) {
52 + ir_count++;
53 + (*outbuf)[0] = '_'; // AVM
54 + }
55 (*inbytesleft) -= 2;
56 (*outbytesleft) -= 1;
57 (*inbuf) += 2;
58 Index: samba-3.0.37/source/lib/pidfile.c
59 ===================================================================
60 --- samba-3.0.37.orig/source/lib/pidfile.c 2009-09-30 14:21:56.000000000 +0200
61 +++ samba-3.0.37/source/lib/pidfile.c 2011-08-09 00:02:34.854444169 +0200
62 @@ -87,6 +87,7 @@
63 pstring pidFile;
64 pid_t pid;
65
66 +#if 0 /* AVM */
67 /* Add a suffix to the program name if this is a process with a
68 * none default configuration file name. */
69 if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) {
70 @@ -103,6 +104,9 @@
71 slprintf( name, sizeof( name)-1, "%s-%s", program_name,
72 short_configfile );
73 }
74 +#else
75 + strncpy( name, program_name, sizeof( name)-1);
76 +#endif
77
78 slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name);
79
80 Index: samba-3.0.37/source/lib/system.c
81 ===================================================================
82 --- samba-3.0.37.orig/source/lib/system.c 2009-09-30 14:21:56.000000000 +0200
83 +++ samba-3.0.37/source/lib/system.c 2011-08-09 00:02:34.864444169 +0200
84 @@ -1499,7 +1499,11 @@
85 void *sys_dlopen(const char *name, int flags)
86 {
87 #if defined(HAVE_DLOPEN)
88 +#if 1 /* FRITZBOX */
89 + return NULL;
90 +#else
91 return dlopen(name, flags);
92 +#endif
93 #else
94 return NULL;
95 #endif
96 Index: samba-3.0.37/source/lib/util.c
97 ===================================================================
98 --- samba-3.0.37.orig/source/lib/util.c 2009-09-30 14:21:56.000000000 +0200
99 +++ samba-3.0.37/source/lib/util.c 2011-08-09 00:02:34.864444169 +0200
100 @@ -301,7 +301,11 @@
101 char *p;
102 if ((p = getenv("TMPDIR")))
103 return p;
104 +#if 0 /* AVM */
105 + return "/var/tmp";
106 +#else
107 return "/tmp";
108 +#endif
109 }
110
111 /****************************************************************************
112 Index: samba-3.0.37/source/libsmb/clifile.c
113 ===================================================================
114 --- samba-3.0.37.orig/source/libsmb/clifile.c 2009-09-30 14:21:56.000000000 +0200
115 +++ samba-3.0.37/source/libsmb/clifile.c 2011-08-09 00:02:34.864444169 +0200
116 @@ -21,6 +21,8 @@
117
118 #include "includes.h"
119
120 +#ifndef AVM_SMALLER
121 +
122 /****************************************************************************
123 Hard/Symlink a file (UNIX extensions).
124 Creates new name (sym)linked to oldname.
125 @@ -71,6 +73,9 @@
126 return True;
127 }
128
129 +#endif /* AVM_SMALLER */
130 +
131 +
132 /****************************************************************************
133 Map standard UNIX permissions onto wire representations.
134 ****************************************************************************/
135 @@ -165,6 +170,9 @@
136 }
137 }
138
139 +
140 +#ifndef AVM_SMALLER
141 +
142 /****************************************************************************
143 Do a POSIX getfacl (UNIX extensions).
144 ****************************************************************************/
145 @@ -647,6 +655,7 @@
146
147 return True;
148 }
149 +#endif /* AVM_SMALLER */
150
151 /****************************************************************************
152 Open a file - exposing the full horror of the NT API :-).
153 @@ -718,6 +727,7 @@
154 FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0);
155 }
156
157 +#ifndef AVM_SMALLER
158 /****************************************************************************
159 Open a file
160 WARNING: if you open with O_WRONLY then getattrE won't work!
161 @@ -796,6 +806,7 @@
162
163 return SVAL(cli->inbuf,smb_vwv2);
164 }
165 +#endif /* AVM_SMALLER */
166
167 /****************************************************************************
168 Close a file.
169 @@ -823,6 +834,7 @@
170 return !cli_is_error(cli);
171 }
172
173 +#ifndef AVM_SMALLER
174
175 /****************************************************************************
176 send a lock with a specified locktype
177 @@ -1972,3 +1984,6 @@
178 {
179 return cli_posix_unlink_internal(cli, fname, True);
180 }
181 +
182 +#endif /* AVM_SMALLER */
183 +
184 Index: samba-3.0.37/source/libsmb/namequery.c
185 ===================================================================
186 --- samba-3.0.37.orig/source/libsmb/namequery.c 2009-09-30 14:21:56.000000000 +0200
187 +++ samba-3.0.37/source/libsmb/namequery.c 2011-08-09 00:02:34.864444169 +0200
188 @@ -1114,6 +1114,7 @@
189 const char *sitename,
190 struct ip_service **return_iplist, int *return_count)
191 {
192 +#ifdef HAVE_ADS
193 int i, j;
194 NTSTATUS status;
195 TALLOC_CTX *ctx;
196 @@ -1194,6 +1195,9 @@
197
198 talloc_destroy(ctx);
199 return True;
200 +#else /* HAVE_ADS */
201 + return False;
202 +#endif
203 }
204
205 /*******************************************************************
206 Index: samba-3.0.37/source/libsmb/namequery_dc.c
207 ===================================================================
208 --- samba-3.0.37.orig/source/libsmb/namequery_dc.c 2009-09-30 14:21:56.000000000 +0200
209 +++ samba-3.0.37/source/libsmb/namequery_dc.c 2011-08-09 00:02:34.864444169 +0200
210 @@ -52,6 +52,9 @@
211 struct in_addr *dc_ip,
212 fstring srv_name)
213 {
214 +#if 1 /* AVM */
215 + return False;
216 +#else
217 ADS_STRUCT *ads;
218 char *sitename;
219 int i;
220 @@ -139,6 +142,7 @@
221 srv_name, inet_ntoa(*dc_ip)));
222
223 return True;
224 +#endif /* AVM */
225 }
226
227 /****************************************************************************
228 Index: samba-3.0.37/source/modules/vfs_default.c
229 ===================================================================
230 --- samba-3.0.37.orig/source/modules/vfs_default.c 2009-09-30 14:21:56.000000000 +0200
231 +++ samba-3.0.37/source/modules/vfs_default.c 2011-08-09 14:13:37.593167315 +0200
232 @@ -24,6 +24,78 @@
233 #undef DBGC_CLASS
234 #define DBGC_CLASS DBGC_VFS
235
236 +// AVM_SEC - avoid following NTFS symbolic links to "not allowed places"
237 +// #define AVM_SEC
238 +
239 +
240 +#ifdef AVM_SEC
241 +static int IsAllowed(const char *pa)
242 +{
243 + // only allow access below /var/media/ftp/
244 +
245 + if (!pa) return 0;
246 +
247 +Log(("IsAllowed: checking %s", pa));
248 +
249 + char *path = strdup(pa);
250 + if (!path) goto no;
251 +
252 + char buf[4096];
253 + int ret;
254 + char *p = &path[strlen(path)];
255 + char c = *p;
256 + do {
257 + if (path[0] == '\0') {
258 + if (0 == getcwd(buf, sizeof(buf))) {
259 + *p = c;
260 + goto no; // failed - not allowed
261 + }
262 + ret = 0;
263 + } else {
264 + if (0 == realpath(path, buf)) ret = -1;
265 + else ret = 0;
266 + }
267 + if (ret) {
268 + // realpath failed - remove prev path component
269 + *p = c;
270 + while(p > path && *(p-1) != '/') p--;
271 + if (p <= path) {
272 + p = path;
273 + } else {
274 + p--;
275 + }
276 + c = *p;
277 + *p = '\0';
278 + }
279 + } while(ret);
280 +
281 + *p = c;
282 +
283 +#if 0 // TODO
284 + // weitere pfadkompontenen // /./ und /../ auswerten
285 + // assert (*p ist '\0' oder '/')
286 + while(*p != '\0') {
287 + xxx
288 + }
289 +#endif
290 +
291 + if (buf != strstr(buf, "/var/media/ftp")) goto no;
292 + c = buf[strlen("/var/media/ftp")];
293 + if (c != '/' && c != '\0') goto no;
294 +
295 +Log(("IsAllowed: %s ok", pa));
296 + if (path) free(path);
297 + return 1;
298 +
299 +no:
300 + Log(("IsAllowed: %s not allowed", pa ? pa : "(null)"));
301 + if (path) free(path);
302 + return 0;
303 +}
304 +#endif
305 +
306 +
307 +
308 /* Check for NULL pointer parameters in vfswrap_* functions */
309
310 /* We don't want to have NULL function pointers lying around. Someone
311 @@ -88,6 +160,10 @@
312
313 static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf)
314 {
315 +#ifdef AVM_SEC
316 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
317 +#endif
318 +
319 return sys_statvfs(path, statbuf);
320 }
321
322 @@ -97,6 +173,10 @@
323 {
324 SMB_STRUCT_DIR *result;
325
326 +#ifdef AVM_SEC
327 + if (!IsAllowed(fname)) { errno = EACCES; return 0; }
328 +#endif
329 +
330 START_PROFILE(syscall_opendir);
331 result = sys_opendir(fname);
332 END_PROFILE(syscall_opendir);
333 @@ -141,6 +221,10 @@
334 int result;
335 BOOL has_dacl = False;
336
337 +#ifdef AVM_SEC
338 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
339 +#endif
340 +
341 START_PROFILE(syscall_mkdir);
342
343 if (lp_inherit_acls(SNUM(handle->conn)) && (has_dacl = directory_has_default_acl(handle->conn, parent_dirname(path))))
344 @@ -169,6 +253,10 @@
345 {
346 int result;
347
348 +#ifdef AVM_SEC
349 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
350 +#endif
351 +
352 START_PROFILE(syscall_rmdir);
353 result = rmdir(path);
354 END_PROFILE(syscall_rmdir);
355 @@ -192,6 +280,10 @@
356 {
357 int result;
358
359 +#ifdef AVM_SEC
360 + if (!IsAllowed(fname)) { errno = EACCES; return -1; }
361 +#endif
362 +
363 START_PROFILE(syscall_open);
364 result = sys_open(fname, flags, mode);
365 END_PROFILE(syscall_open);
366 @@ -361,6 +453,11 @@
367 int ifd = -1;
368 int ofd = -1;
369
370 +#ifdef AVM_SEC
371 + if (!IsAllowed(source)) { errno = EACCES; return -1; }
372 + if (!IsAllowed(dest)) { errno = EACCES; return -1; }
373 +#endif
374 +
375 if (sys_lstat (source, &source_stats) == -1)
376 return -1;
377
378 @@ -442,6 +539,11 @@
379 {
380 int result;
381
382 +#ifdef AVM_SEC
383 + if (!IsAllowed(oldname)) { errno = EACCES; return -1; }
384 + if (!IsAllowed(newname)) { errno = EACCES; return -1; }
385 +#endif
386 +
387 START_PROFILE(syscall_rename);
388 result = rename(oldname, newname);
389 if ((result == -1) && (errno == EXDEV)) {
390 @@ -471,6 +573,10 @@
391 {
392 int result;
393
394 +#ifdef AVM_SEC
395 + if (!IsAllowed(fname)) { errno = EACCES; return -1; }
396 +#endif
397 +
398 START_PROFILE(syscall_stat);
399 result = sys_stat(fname, sbuf);
400 END_PROFILE(syscall_stat);
401 @@ -491,6 +597,10 @@
402 {
403 int result;
404
405 +#ifdef AVM_SEC
406 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
407 +#endif
408 +
409 START_PROFILE(syscall_lstat);
410 result = sys_lstat(path, sbuf);
411 END_PROFILE(syscall_lstat);
412 @@ -501,6 +611,10 @@
413 {
414 int result;
415
416 +#ifdef AVM_SEC
417 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
418 +#endif
419 +
420 START_PROFILE(syscall_unlink);
421 result = unlink(path);
422 END_PROFILE(syscall_unlink);
423 @@ -511,6 +625,10 @@
424 {
425 int result;
426
427 +#ifdef AVM_SEC
428 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
429 +#endif
430 +
431 START_PROFILE(syscall_chmod);
432
433 /*
434 @@ -572,6 +690,10 @@
435 {
436 int result;
437
438 +#ifdef AVM_SEC
439 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
440 +#endif
441 +
442 START_PROFILE(syscall_chown);
443 result = sys_chown(path, uid, gid);
444 END_PROFILE(syscall_chown);
445 @@ -597,6 +719,10 @@
446 {
447 int result;
448
449 +#ifdef AVM_SEC
450 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
451 +#endif
452 +
453 START_PROFILE(syscall_chdir);
454 result = chdir(path);
455 END_PROFILE(syscall_chdir);
456 @@ -717,6 +843,44 @@
457 return result;
458 }
459
460 +#if 1 // AVM patch - don't growth the file (too much time and RAM for copy of large files to USB1.1 FAT filesystem)
461 + {
462 + SMB_BIG_UINT big_len = len;
463 +
464 + result = SMB_VFS_FSTAT(fsp,fsp->fh->fd,&st);
465 + if (result == -1) {
466 + goto done;
467 + }
468 +
469 + if (big_len == (SMB_BIG_UINT)st.st_size) {
470 + result = 0;
471 + goto done;
472 + }
473 +
474 + if (big_len > (SMB_BIG_UINT)st.st_size) {
475 + SMB_BIG_UINT space_avail;
476 + SMB_BIG_UINT bsize,dfree,dsize;
477 + big_len -= st.st_size;
478 + big_len /= 1024; /* Len is now number of 1k blocks needed. */
479 + space_avail = SMB_VFS_DISK_FREE(fsp->conn ,fsp->fsp_name,False,&bsize,&dfree,&dsize);
480 + if (space_avail == (SMB_BIG_UINT)-1) {
481 + result = -1;
482 + goto done;
483 + }
484 +
485 + if (big_len > space_avail) {
486 + errno = ENOSPC;
487 + result = -1;
488 + goto done;
489 + }
490 +
491 + // do nothing to be fast!
492 + result = 0;
493 + goto done;
494 + }
495 + } // block
496 +#endif // AVM Patch
497 +
498 /* we used to just check HAVE_FTRUNCATE_EXTEND and only use
499 sys_ftruncate if the system supports it. Then I discovered that
500 you can have some filesystems that support ftruncate
501 @@ -830,6 +994,11 @@
502 {
503 int result;
504
505 +#ifdef AVM_SEC
506 + if (!IsAllowed(oldpath)) { errno = EACCES; return -1; }
507 + if (!IsAllowed(newpath)) { errno = EACCES; return -1; }
508 +#endif
509 +
510 START_PROFILE(syscall_symlink);
511 result = sys_symlink(oldpath, newpath);
512 END_PROFILE(syscall_symlink);
513 @@ -840,6 +1009,10 @@
514 {
515 int result;
516
517 +#ifdef AVM_SEC
518 + if (!IsAllowed(path)) { errno = EACCES; return -1; }
519 +#endif
520 +
521 START_PROFILE(syscall_readlink);
522 result = sys_readlink(path, buf, bufsiz);
523 END_PROFILE(syscall_readlink);
524 @@ -850,6 +1023,11 @@
525 {
526 int result;
527
528 +#ifdef AVM_SEC
529 + if (!IsAllowed(oldpath)) { errno = EACCES; return -1; }
530 + if (!IsAllowed(newpath)) { errno = EACCES; return -1; }
531 +#endif
532 +
533 START_PROFILE(syscall_link);
534 result = sys_link(oldpath, newpath);
535 END_PROFILE(syscall_link);
536 @@ -860,6 +1038,9 @@
537 {
538 int result;
539
540 +#ifdef AVM_SEC
541 + if (!IsAllowed(pathname)) { errno = EACCES; return -1; }
542 +#endif
543 START_PROFILE(syscall_mknod);
544 result = sys_mknod(pathname, mode, dev);
545 END_PROFILE(syscall_mknod);
546 @@ -870,6 +1051,9 @@
547 {
548 char *result;
549
550 +#ifdef AVM_SEC
551 + if (!IsAllowed(path)) { errno = EACCES; return 0; }
552 +#endif
553 START_PROFILE(syscall_realpath);
554 result = sys_realpath(path, resolved_path);
555 END_PROFILE(syscall_realpath);
556 Index: samba-3.0.37/source/param/loadparm.c
557 ===================================================================
558 --- samba-3.0.37.orig/source/param/loadparm.c 2009-09-30 14:21:56.000000000 +0200
559 +++ samba-3.0.37/source/param/loadparm.c 2011-08-09 00:02:34.874444169 +0200
560 @@ -2713,8 +2713,11 @@
561
562 slprintf(comment, sizeof(comment) - 1,
563 "IPC Service (%s)", Globals.szServerString);
564 -
565 +#if 0 /* AVM */
566 + string_set(&ServicePtrs[i]->szPath, "/var/media/ftp");
567 +#else
568 string_set(&ServicePtrs[i]->szPath, tmpdir());
569 +#endif
570 string_set(&ServicePtrs[i]->szUsername, "");
571 string_set(&ServicePtrs[i]->comment, comment);
572 string_set(&ServicePtrs[i]->fstype, "IPC");
573 Index: samba-3.0.37/source/registry/reg_frontend.c
574 ===================================================================
575 --- samba-3.0.37.orig/source/registry/reg_frontend.c 2009-09-30 14:21:56.000000000 +0200
576 +++ samba-3.0.37/source/registry/reg_frontend.c 2011-08-09 00:02:34.874444169 +0200
577 @@ -35,9 +35,11 @@
578
579 REGISTRY_HOOK reg_hooks[] = {
580 #ifndef REG_TDB_ONLY
581 +#ifndef AVM_NO_PRINTING
582 { KEY_PRINTING, &printing_ops },
583 { KEY_PRINTING_2K, &printing_ops },
584 { KEY_PRINTING_PORTS, &printing_ops },
585 +#endif
586 { KEY_SHARES, &shares_reg_ops },
587 #endif
588 { NULL, NULL }
589 Index: samba-3.0.37/source/rpc_client/cli_pipe.c
590 ===================================================================
591 --- samba-3.0.37.orig/source/rpc_client/cli_pipe.c 2009-09-30 14:21:56.000000000 +0200
592 +++ samba-3.0.37/source/rpc_client/cli_pipe.c 2011-08-09 00:02:34.874444169 +0200
593 @@ -619,7 +619,11 @@
594
595 DEBUG(1, ("cli_pipe_validate_current_pdu: RPC fault code %s received from remote machine %s "
596 "pipe %s fnum 0x%x!\n",
597 +#if 1 /* AVM */
598 + "ERRSTR-REPLACEMENT",
599 +#else
600 dcerpc_errstr(NT_STATUS_V(fault_resp.status)),
601 +#endif
602 cli->cli->desthost,
603 cli->pipe_name,
604 (unsigned int)cli->fnum));
605 Index: samba-3.0.37/source/rpc_parse/parse_prs.c
606 ===================================================================
607 --- samba-3.0.37.orig/source/rpc_parse/parse_prs.c 2009-09-30 14:21:56.000000000 +0200
608 +++ samba-3.0.37/source/rpc_parse/parse_prs.c 2011-08-09 00:02:34.874444169 +0200
609 @@ -796,7 +796,12 @@
610 }
611
612 DEBUG(5,("%s%04x %s: %s\n", tab_depth(depth), ps->data_offset, name,
613 - dcerpc_errstr(NT_STATUS_V(*status))));
614 +#if 1 /* AVM */
615 + "ERRSTR-REPLACEMENT"
616 +#else
617 + dcerpc_errstr(NT_STATUS_V(*status))
618 +#endif
619 + ));
620
621 ps->data_offset += sizeof(uint32);
622
623 Index: samba-3.0.37/source/rpc_parse/parse_sec.c
624 ===================================================================
625 --- samba-3.0.37.orig/source/rpc_parse/parse_sec.c 2009-09-30 14:21:56.000000000 +0200
626 +++ samba-3.0.37/source/rpc_parse/parse_sec.c 2011-08-09 00:02:34.874444169 +0200
627 @@ -104,7 +104,7 @@
628 for you as it reads them.
629 ********************************************************************/
630
631 -BOOL sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth)
632 +static BOOL sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth)
633 {
634 unsigned int i;
635 uint32 old_offset;
636 Index: samba-3.0.37/source/rpc_parse/parse_spoolss.c
637 ===================================================================
638 --- samba-3.0.37.orig/source/rpc_parse/parse_spoolss.c 2009-09-30 14:21:56.000000000 +0200
639 +++ samba-3.0.37/source/rpc_parse/parse_spoolss.c 2011-08-09 00:02:34.874444169 +0200
640 @@ -227,8 +227,13 @@
641 if(!prs_uint32("count2", ps, depth, &type->count2))
642 return False;
643
644 - if (type->count2 != type->count)
645 + if (type->count2 != type->count) {
646 DEBUG(4,("What a mess, count was %x now is %x !\n", type->count, type->count2));
647 + return False;
648 + }
649 + if (type->count2 > MAX_NOTIFY_TYPE_FOR_NOW) {
650 + return False;
651 + }
652
653 if (type->count2 > MAX_NOTIFY_TYPE_FOR_NOW) {
654 return False;
655 Index: samba-3.0.37/source/rpc_server/srv_pipe.c
656 ===================================================================
657 --- samba-3.0.37.orig/source/rpc_server/srv_pipe.c 2009-09-30 14:21:56.000000000 +0200
658 +++ samba-3.0.37/source/rpc_server/srv_pipe.c 2011-08-09 00:02:34.884444169 +0200
659 @@ -2335,6 +2335,7 @@
660 int n_cmds = 0;
661
662 switch ( idx ) {
663 +#ifndef AVM_SMALLER
664 case PI_LSARPC:
665 lsa_get_pipe_fns( &cmds, &n_cmds );
666 break;
667 @@ -2347,12 +2348,14 @@
668 case PI_NETLOGON:
669 netlog_get_pipe_fns( &cmds, &n_cmds );
670 break;
671 +#endif /* AVM_SMALLER */
672 case PI_SRVSVC:
673 srvsvc_get_pipe_fns( &cmds, &n_cmds );
674 break;
675 case PI_WKSSVC:
676 wkssvc_get_pipe_fns( &cmds, &n_cmds );
677 break;
678 +#ifndef AVM_SMALLER
679 case PI_WINREG:
680 reg_get_pipe_fns( &cmds, &n_cmds );
681 break;
682 @@ -2371,6 +2374,8 @@
683 case PI_NTSVCS:
684 ntsvcs_get_pipe_fns( &cmds, &n_cmds );
685 break;
686 +#endif /* AVM_SMALLER */
687 +
688 #ifdef DEVELOPER
689 case PI_ECHO:
690 echo_get_pipe_fns( &cmds, &n_cmds );
691 Index: samba-3.0.37/source/smbd/change_trust_pw.c
692 ===================================================================
693 --- samba-3.0.37.orig/source/smbd/change_trust_pw.c 2009-09-30 14:21:56.000000000 +0200
694 +++ samba-3.0.37/source/smbd/change_trust_pw.c 2011-08-09 00:02:34.884444169 +0200
695 @@ -30,6 +30,10 @@
696
697 NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine)
698 {
699 +#ifdef AVM_SMALLER
700 + return NT_STATUS_UNSUCCESSFUL;
701 +#else
702 +
703 NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
704 struct in_addr pdc_ip;
705 fstring dc_name;
706 @@ -97,4 +101,5 @@
707 DEBUG(5,("change_trust_account_password: sucess!\n"));
708
709 return nt_status;
710 +#endif /* AVM_SMALLER */
711 }
712 Index: samba-3.0.37/source/smbd/close.c
713 ===================================================================
714 --- samba-3.0.37.orig/source/smbd/close.c 2009-09-30 14:21:56.000000000 +0200
715 +++ samba-3.0.37/source/smbd/close.c 2011-08-09 00:02:34.884444169 +0200
716 @@ -353,7 +353,9 @@
717 saved_status2 = close_filestruct(fsp);
718
719 if (fsp->print_file) {
720 +#ifndef AVM_NO_PRINTING
721 print_fsp_end(fsp, close_type);
722 +#endif
723 file_free(fsp);
724 return NT_STATUS_OK;
725 }
726 Index: samba-3.0.37/source/smbd/conn.c
727 ===================================================================
728 --- samba-3.0.37.orig/source/smbd/conn.c 2009-09-30 14:21:56.000000000 +0200
729 +++ samba-3.0.37/source/smbd/conn.c 2011-08-09 00:02:34.884444169 +0200
730 @@ -216,9 +216,12 @@
731 * idle with a handle open.
732 */
733
734 +
735 +#ifndef AVM_SMALLER
736 for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist))
737 if (plist->pipe_handles && plist->pipe_handles->count)
738 allidle = False;
739 +#endif
740
741 return allidle;
742 }
743 Index: samba-3.0.37/source/smbd/dfree.c
744 ===================================================================
745 --- samba-3.0.37.orig/source/smbd/dfree.c 2009-09-30 14:21:56.000000000 +0200
746 +++ samba-3.0.37/source/smbd/dfree.c 2011-08-09 00:02:34.884444169 +0200
747 @@ -130,11 +130,13 @@
748 }
749 }
750
751 +#if 0 /* AVM */
752 if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
753 (*bsize) = bsize_q;
754 (*dfree) = MIN(*dfree,dfree_q);
755 (*dsize) = MIN(*dsize,dsize_q);
756 }
757 +#endif
758
759 /* FIXME : Any reason for this assumption ? */
760 if (*bsize < 256) {
761 Index: samba-3.0.37/source/smbd/dosmode.c
762 ===================================================================
763 --- samba-3.0.37.orig/source/smbd/dosmode.c 2009-09-30 14:21:56.000000000 +0200
764 +++ samba-3.0.37/source/smbd/dosmode.c 2011-08-09 00:02:34.884444169 +0200
765 @@ -40,12 +40,15 @@
766 if (ISDOT(path) || ISDOTDOT(path)) {
767 return 0;
768 }
769 -
770 +#ifdef AVM_SMALLER
771 + return 0;
772 +#else
773 if (!lp_dmapi_support(SNUM(conn)) || !dmapi_have_session()) {
774 return 0;
775 }
776
777 return dmapi_file_flags(path);
778 +#endif
779 }
780
781 /****************************************************************************
782 Index: samba-3.0.37/source/smbd/fileio.c
783 ===================================================================
784 --- samba-3.0.37.orig/source/smbd/fileio.c 2009-09-30 14:21:56.000000000 +0200
785 +++ samba-3.0.37/source/smbd/fileio.c 2011-08-09 00:02:34.884444169 +0200
786 @@ -176,6 +176,8 @@
787
788 static int wcp_file_size_change(files_struct *fsp)
789 {
790 +/* AVM: Fuer Pruefung des freien Speichers auf dem Datentraeger wird
791 + SMB_VFS_FTRUNCATE aufgerufen, auch falls es langsam sein sollte */
792 int ret;
793 write_cache *wcp = fsp->wcp;
794
795 @@ -199,6 +201,10 @@
796 int write_path = -1;
797
798 if (fsp->print_file) {
799 +#ifdef AVM_NO_PRINTING
800 + errno = EBADF;
801 + return -1;
802 +#else
803 fstring sharename;
804 uint32 jobid;
805
806 @@ -210,6 +216,7 @@
807 }
808
809 return print_job_write(SNUM(fsp->conn), jobid, data, pos, n);
810 +#endif /* AVM_NO_PRINTING */
811 }
812
813 if (!fsp->can_write) {
814 Index: samba-3.0.37/source/smbd/files.c
815 ===================================================================
816 --- samba-3.0.37.orig/source/smbd/files.c 2009-09-30 14:21:56.000000000 +0200
817 +++ samba-3.0.37/source/smbd/files.c 2011-08-09 00:02:34.884444169 +0200
818 @@ -203,10 +203,12 @@
819 exit_server("out of memory in file_init");
820 }
821
822 +#ifndef AVM_SMALLER
823 /*
824 * Ensure that pipe_handle_oppset is set correctly.
825 */
826 set_pipe_handle_offset(real_max_open_files);
827 +#endif
828 }
829
830 /****************************************************************************
831 Index: samba-3.0.37/source/smbd/lanman.c
832 ===================================================================
833 --- samba-3.0.37.orig/source/smbd/lanman.c 2009-09-30 14:21:56.000000000 +0200
834 +++ samba-3.0.37/source/smbd/lanman.c 2011-08-09 00:02:34.884444169 +0200
835 @@ -400,6 +400,7 @@
836 PACK(desc,t,v);
837 }
838
839 +#ifndef AVM_NO_PRINTING
840 /****************************************************************************
841 Get a print queue.
842 ****************************************************************************/
843 @@ -781,6 +782,7 @@
844
845 return result;
846 }
847 +#endif /* AVM_NO_PRINTING */
848
849 static BOOL api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid,
850 char *param, int tpscnt,
851 @@ -789,6 +791,9 @@
852 char **rdata,char **rparam,
853 int *rdata_len,int *rparam_len)
854 {
855 +#ifdef AVM_NO_PRINTING
856 +return False;
857 +#else
858 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
859 char *str2 = skip_string(param,tpscnt,str1);
860 char *p = skip_string(param,tpscnt,str2);
861 @@ -901,6 +906,7 @@
862 SAFE_FREE(tmpdata);
863
864 return(True);
865 +#endif /* AVM_NO_PRINTING */
866 }
867
868 /****************************************************************************
869 @@ -914,6 +920,9 @@
870 char **rdata, char** rparam,
871 int *rdata_len, int *rparam_len)
872 {
873 +#ifdef AVM_NO_PRINTING
874 +return False;
875 +#else
876 char *param_format = get_safe_str_ptr(param,tpscnt,param,2);
877 char *output_format1 = skip_string(param,tpscnt,param_format);
878 char *p = skip_string(param,tpscnt,output_format1);
879 @@ -1046,6 +1055,7 @@
880 SAFE_FREE(status);
881
882 return False;
883 +#endif /* AVM_NO_PRINTING */
884 }
885
886 /****************************************************************************
887 @@ -2539,6 +2549,9 @@
888 char **rdata,char **rparam,
889 int *rdata_len,int *rparam_len)
890 {
891 +#ifdef AVM_NO_PRINTING
892 +return False;
893 +#else
894 int function = get_safe_SVAL(param,tpscnt,param,0,0);
895 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
896 char *str2 = skip_string(param,tpscnt,str1);
897 @@ -2609,6 +2622,7 @@
898 SSVAL(*rparam,2,0); /* converter word */
899
900 return(True);
901 +#endif
902 }
903
904 /****************************************************************************
905 @@ -2622,6 +2636,9 @@
906 char **rdata,char **rparam,
907 int *rdata_len,int *rparam_len)
908 {
909 +#ifdef AVM_NO_PRINTING
910 +return False;
911 +#else
912 int function = get_safe_SVAL(param,tpscnt,param,0,0);
913 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
914 char *str2 = skip_string(param,tpscnt,str1);
915 @@ -2674,6 +2691,7 @@
916 SSVAL(*rparam,2,0); /* converter word */
917
918 return(True);
919 +#endif
920 }
921
922 /****************************************************************************
923 @@ -2714,6 +2732,9 @@
924 char **rdata,char **rparam,
925 int *rdata_len,int *rparam_len)
926 {
927 +#ifdef AVM_NO_PRINTING
928 +return False;
929 +#else
930 struct pack_desc desc;
931 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
932 char *str2 = skip_string(param,tpscnt,str1);
933 @@ -2788,6 +2809,7 @@
934 SSVAL(*rparam,2,0); /* converter word */
935
936 return(True);
937 +#endif
938 }
939
940
941 @@ -3579,6 +3601,9 @@
942 char **rdata,char **rparam,
943 int *rdata_len,int *rparam_len)
944 {
945 +#ifdef AVM_NO_PRINTING
946 +return False;
947 +#else
948 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
949 char *str2 = skip_string(param,tpscnt,str1);
950 char *p = skip_string(param,tpscnt,str2);
951 @@ -3669,6 +3694,7 @@
952 DEBUG(4,("WPrintJobGetInfo: errorcode %d\n",desc.errcode));
953
954 return True;
955 +#endif
956 }
957
958 static BOOL api_WPrintJobEnumerate(connection_struct *conn, uint16 vuid,
959 @@ -3678,6 +3704,9 @@
960 char **rdata,char **rparam,
961 int *rdata_len,int *rparam_len)
962 {
963 +#ifdef AVM_NO_PRINTING
964 +return False;
965 +#else
966 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
967 char *str2 = skip_string(param,tpscnt,str1);
968 char *p = skip_string(param,tpscnt,str2);
969 @@ -3760,6 +3789,7 @@
970 DEBUG(4,("WPrintJobEnumerate: errorcode %d\n",desc.errcode));
971
972 return True;
973 +#endif
974 }
975
976 static int check_printdest_info(struct pack_desc* desc,
977 @@ -3835,6 +3865,9 @@
978 char **rdata,char **rparam,
979 int *rdata_len,int *rparam_len)
980 {
981 +#ifdef AVM_NO_PRINTING
982 +return False;
983 +#else
984 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
985 char *str2 = skip_string(param,tpscnt,str1);
986 char *p = skip_string(param,tpscnt,str2);
987 @@ -3906,6 +3939,7 @@
988 SAFE_FREE(tmpdata);
989
990 return True;
991 +#endif
992 }
993
994 static BOOL api_WPrintDestEnum(connection_struct *conn, uint16 vuid,
995 @@ -3915,6 +3949,9 @@
996 char **rdata,char **rparam,
997 int *rdata_len,int *rparam_len)
998 {
999 +#ifdef AVM_NO_PRINTING
1000 +return False;
1001 +#else
1002 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
1003 char *str2 = skip_string(param,tpscnt,str1);
1004 char *p = skip_string(param,tpscnt,str2);
1005 @@ -3987,6 +4024,7 @@
1006 DEBUG(4,("WPrintDestEnumerate: errorcode %d\n",desc.errcode));
1007
1008 return True;
1009 +#endif
1010 }
1011
1012 static BOOL api_WPrintDriverEnum(connection_struct *conn, uint16 vuid,
1013 @@ -3996,6 +4034,9 @@
1014 char **rdata,char **rparam,
1015 int *rdata_len,int *rparam_len)
1016 {
1017 +#ifdef AVM_NO_PRINTING
1018 +return False;
1019 +#else
1020 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
1021 char *str2 = skip_string(param,tpscnt,str1);
1022 char *p = skip_string(param,tpscnt,str2);
1023 @@ -4050,6 +4091,7 @@
1024 DEBUG(4,("WPrintDriverEnum: errorcode %d\n",desc.errcode));
1025
1026 return True;
1027 +#endif
1028 }
1029
1030 static BOOL api_WPrintQProcEnum(connection_struct *conn, uint16 vuid,
1031 @@ -4059,6 +4101,9 @@
1032 char **rdata,char **rparam,
1033 int *rdata_len,int *rparam_len)
1034 {
1035 +#ifdef AVM_NO_PRINTING
1036 +return False;
1037 +#else
1038 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
1039 char *str2 = skip_string(param,tpscnt,str1);
1040 char *p = skip_string(param,tpscnt,str2);
1041 @@ -4113,6 +4158,7 @@
1042 DEBUG(4,("WPrintQProcEnum: errorcode %d\n",desc.errcode));
1043
1044 return True;
1045 +#endif
1046 }
1047
1048 static BOOL api_WPrintPortEnum(connection_struct *conn, uint16 vuid,
1049 @@ -4122,6 +4168,9 @@
1050 char **rdata,char **rparam,
1051 int *rdata_len,int *rparam_len)
1052 {
1053 +#ifdef AVM_NO_PRINTING
1054 +return False;
1055 +#else
1056 char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
1057 char *str2 = skip_string(param,tpscnt,str1);
1058 char *p = skip_string(param,tpscnt,str2);
1059 @@ -4178,6 +4227,7 @@
1060 DEBUG(4,("WPrintPortEnum: errorcode %d\n",desc.errcode));
1061
1062 return True;
1063 +#endif
1064 }
1065
1066 /****************************************************************************
1067 Index: samba-3.0.37/source/smbd/open.c
1068 ===================================================================
1069 --- samba-3.0.37.orig/source/smbd/open.c 2009-09-30 14:21:56.000000000 +0200
1070 +++ samba-3.0.37/source/smbd/open.c 2011-08-09 00:02:34.884444169 +0200
1071 @@ -1155,8 +1155,11 @@
1072 }
1073
1074 DEBUG(10, ("open_file_ntcreate: printer open fname=%s\n", fname));
1075 -
1076 +#ifdef AVM_NO_PRINTING
1077 + return NT_STATUS_OK;
1078 +#else
1079 return print_fsp_open(conn, fname, result);
1080 +#endif
1081 }
1082
1083 if (!parent_dirname_talloc(tmp_talloc_ctx(), fname, &parent_dir,
1084 Index: samba-3.0.37/source/smbd/process.c
1085 ===================================================================
1086 --- samba-3.0.37.orig/source/smbd/process.c 2009-09-30 14:21:56.000000000 +0200
1087 +++ samba-3.0.37/source/smbd/process.c 2011-08-09 00:02:34.894444169 +0200
1088 @@ -1028,7 +1028,9 @@
1089
1090 chain_size = 0;
1091 file_chain_reset();
1092 +#ifndef AVM_SMALLER
1093 reset_chain_p();
1094 +#endif
1095
1096 if (msg_type != 0)
1097 return(reply_special(inbuf,outbuf));
1098 @@ -1268,9 +1270,11 @@
1099
1100 select_timeout = blocking_locks_timeout_ms(SMBD_SELECT_TIMEOUT*1000);
1101
1102 +#ifndef AVM_NO_PRINTING
1103 if (print_notify_messages_pending()) {
1104 select_timeout = MIN(select_timeout, 1000);
1105 }
1106 +#endif
1107
1108 return select_timeout;
1109 }
1110 @@ -1461,9 +1465,10 @@
1111 */
1112 process_blocking_lock_queue();
1113
1114 +#ifndef AVM_NO_PRINTING
1115 /* update printer queue caches if necessary */
1116 -
1117 update_monitored_printq_cache();
1118 +#endif
1119
1120 /*
1121 * Now we are root, check if the log files need pruning.
1122 @@ -1472,9 +1477,10 @@
1123 force_check_log_size();
1124 check_log_size();
1125
1126 +#ifndef AVM_NO_PRINTING
1127 /* Send any queued printer notify message to interested smbd's. */
1128 -
1129 print_notify_send_messages(0);
1130 +#endif
1131
1132 /*
1133 * Modify the select timeout depending upon
1134 Index: samba-3.0.37/source/smbd/reply.c
1135 ===================================================================
1136 --- samba-3.0.37.orig/source/smbd/reply.c 2009-09-30 14:21:56.000000000 +0200
1137 +++ samba-3.0.37/source/smbd/reply.c 2011-08-09 00:02:34.894444169 +0200
1138 @@ -3606,7 +3606,10 @@
1139 NTSTATUS status;
1140
1141 START_PROFILE(SMBsplopen);
1142 -
1143 +#ifdef AVM_NO_PRINTING
1144 + END_PROFILE(SMBsplopen);
1145 + return ERROR_DOS(ERRDOS,ERRnoaccess);
1146 +#else
1147 if (!CAN_PRINT(conn)) {
1148 END_PROFILE(SMBsplopen);
1149 return ERROR_DOS(ERRDOS,ERRnoaccess);
1150 @@ -3628,6 +3631,7 @@
1151
1152 END_PROFILE(SMBsplopen);
1153 return(outsize);
1154 +#endif
1155 }
1156
1157 /****************************************************************************
1158 @@ -3644,6 +3648,10 @@
1159
1160 CHECK_FSP(fsp,conn);
1161
1162 +#ifdef AVM_NO_PRINTING
1163 + END_PROFILE(SMBsplretq);
1164 + return ERROR_DOS(ERRDOS,ERRnoaccess);
1165 +#else
1166 if (!CAN_PRINT(conn)) {
1167 END_PROFILE(SMBsplclose);
1168 return ERROR_NT(NT_STATUS_DOS(ERRSRV, ERRerror));
1169 @@ -3661,6 +3669,7 @@
1170
1171 END_PROFILE(SMBsplclose);
1172 return(outsize);
1173 +#endif
1174 }
1175
1176 /****************************************************************************
1177 @@ -3670,6 +3679,10 @@
1178 int reply_printqueue(connection_struct *conn,
1179 char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
1180 {
1181 +#ifdef AVM_NO_PRINTING
1182 + END_PROFILE(SMBsplretq);
1183 + return ERROR_DOS(ERRDOS,ERRnoaccess);
1184 +#else
1185 int outsize = set_message(outbuf,2,3,True);
1186 int max_count = SVAL(inbuf,smb_vwv0);
1187 int start_index = SVAL(inbuf,smb_vwv1);
1188 @@ -3732,6 +3745,7 @@
1189
1190 END_PROFILE(SMBsplretq);
1191 return(outsize);
1192 +#endif
1193 }
1194
1195 /****************************************************************************
1196 Index: samba-3.0.37/source/smbd/server.c
1197 ===================================================================
1198 --- samba-3.0.37.orig/source/smbd/server.c 2009-09-30 14:21:56.000000000 +0200
1199 +++ samba-3.0.37/source/smbd/server.c 2011-08-09 00:02:34.894444169 +0200
1200 @@ -22,7 +22,7 @@
1201
1202 #include "includes.h"
1203
1204 -static_decl_rpc;
1205 +/* AVM ???? static_decl_rpc; */
1206
1207 static int am_parent = 1;
1208
1209 @@ -617,6 +617,7 @@
1210 **************************************************************************/
1211 void reload_printers(void)
1212 {
1213 +#ifndef AVM_NO_PRINTING
1214 int snum;
1215 int n_services = lp_numservices();
1216 int pnum = lp_servicenumber(PRINTERS_NAME);
1217 @@ -643,6 +644,7 @@
1218 }
1219
1220 load_printers();
1221 +#endif /* AVM_NO_PRINTING */
1222 }
1223
1224 /****************************************************************************
1225 @@ -725,7 +727,9 @@
1226
1227 invalidate_all_vuids();
1228
1229 +#ifndef AVM_NO_PRINTING
1230 print_notify_send_messages(3); /* 3 second timeout. */
1231 +#endif
1232
1233 /* delete our entry in the connections database. */
1234 yield_connection(NULL,"");
1235 @@ -739,7 +743,9 @@
1236 #endif
1237
1238 locking_end();
1239 +#ifndef AVM_NO_PRINTING
1240 printing_end();
1241 +#endif
1242
1243 if (how != SERVER_EXIT_NORMAL) {
1244 int oldlevel = DEBUGLEVEL;
1245 @@ -820,7 +826,9 @@
1246 mkproto.h. Mixing $(builddir) and $(srcdir) source files in the current
1247 prototype generation system is too complicated. */
1248
1249 +#if 0 /* AVM */
1250 extern void build_options(BOOL screen);
1251 +#endif
1252
1253 int main(int argc,const char *argv[])
1254 {
1255 @@ -833,6 +841,13 @@
1256 static char *ports = NULL;
1257 static char *profile_level = NULL;
1258 int opt;
1259 +
1260 +#if 0 // AVM DEBUG
1261 + extern void crashdump_init(char*);
1262 + crashdump_init("smbd");
1263 +#endif
1264 +
1265 +#ifndef AVM_NO_POPT
1266 poptContext pc;
1267
1268 struct poptOption long_options[] = {
1269 @@ -842,7 +857,9 @@
1270 {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools, etc.)" },
1271 {"no-process-group", '\0', POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
1272 {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
1273 +#if 0 /* AVM */
1274 {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
1275 +#endif
1276 {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
1277 {"profiling-level", 'P', POPT_ARG_STRING, &profile_level, 0, "Set profiling level","PROFILE_LEVEL"},
1278 POPT_COMMON_SAMBA
1279 @@ -861,21 +878,31 @@
1280 pc = poptGetContext("smbd", argc, argv, long_options, 0);
1281
1282 while((opt = poptGetNextOpt(pc)) != -1) {
1283 +#if 0 /* AVM */
1284 switch (opt) {
1285 case 'b':
1286 build_options(True); /* Display output to screen as well as debug */
1287 exit(0);
1288 break;
1289 }
1290 +#endif
1291 }
1292
1293 poptFreeContext(pc);
1294 +#else
1295 + load_case_tables();
1296 +#endif /* AVM_NO_POPT */
1297 +
1298
1299 #ifdef HAVE_SETLUID
1300 /* needed for SecureWare on SCO */
1301 setluid(0);
1302 #endif
1303
1304 +#if 1 /* AVM */
1305 + setpriority(PRIO_PROCESS, 0, 19); /* be nice */
1306 +#endif
1307 +
1308 sec_init();
1309
1310 set_remote_machine_name("smbd", False);
1311 @@ -903,6 +930,16 @@
1312 /* make absolutely sure we run as root - to handle cases where people
1313 are crazy enough to have it setuid */
1314
1315 + generate_random_buffer(NULL, 0);
1316 +
1317 + /* make absolutely sure we run as root - to handle cases where people
1318 + are crazy enough to have it setuid */
1319 +
1320 + gain_root_privilege();
1321 + gain_root_group_privilege();
1322 +
1323 + fault_setup((void (*)(void *))exit_server_fault);
1324 + dump_core_setup("smbd");
1325 gain_root_privilege();
1326 gain_root_group_privilege();
1327
1328 @@ -945,8 +982,10 @@
1329 DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n",
1330 (int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid()));
1331
1332 +#if 0 /* AVM */
1333 /* Output the build options to the debug log */
1334 build_options(False);
1335 +#endif
1336
1337 if (sizeof(uint16) < 2 || sizeof(uint32) < 4) {
1338 DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n"));
1339 @@ -1042,16 +1081,20 @@
1340
1341 namecache_enable();
1342
1343 +#ifndef AVM_SMALLER
1344 if (!init_registry())
1345 exit(1);
1346 +#endif
1347
1348 #if 0
1349 if (!init_svcctl_db())
1350 exit(1);
1351 #endif
1352
1353 +#ifndef AVM_NO_PRINTING
1354 if (!print_backend_init())
1355 exit(1);
1356 +#endif
1357
1358 if (!init_guest_info()) {
1359 DEBUG(0,("ERROR: failed to setup guest info.\n"));
1360 @@ -1068,14 +1111,18 @@
1361 smbd is launched via inetd and we fork a copy of
1362 ourselves here */
1363
1364 +#ifndef AVM_NO_PRINTING
1365 if ( is_daemon && !interactive )
1366 start_background_queue();
1367 +#endif
1368
1369 +#if 0 /* AVM */
1370 /* Always attempt to initialize DMAPI. We will only use it later if
1371 * lp_dmapi_support is set on the share, but we need a single global
1372 * session to work with.
1373 */
1374 dmapi_init_session();
1375 +#endif
1376
1377 if (!open_sockets_smbd(is_daemon, interactive, ports))
1378 exit(1);
1379 @@ -1084,7 +1131,12 @@
1380 * everything after this point is run after the fork()
1381 */
1382
1383 +#if 0 /* AVM */
1384 static_init_rpc;
1385 +#else
1386 + rpc_wkssvc_init();
1387 + rpc_srv_init();
1388 +#endif
1389
1390 init_modules();
1391
1392 Index: samba-3.0.37/source/smbd/service.c
1393 ===================================================================
1394 --- samba-3.0.37.orig/source/smbd/service.c 2009-09-30 14:21:56.000000000 +0200
1395 +++ samba-3.0.37/source/smbd/service.c 2011-08-09 00:02:34.894444169 +0200
1396 @@ -288,6 +288,7 @@
1397 iService = add_home_service(service,service /* 'username' */, phome_dir);
1398 }
1399
1400 +#ifndef AVM_NO_PRINTING
1401 /* If we still don't have a service, attempt to add it as a printer. */
1402 if (iService < 0) {
1403 int iPrinterService;
1404 @@ -307,6 +308,7 @@
1405 }
1406 }
1407 }
1408 +#endif /* AVM_NO_PRINTING */
1409
1410 /* Check for default vfs service? Unsure whether to implement this */
1411 if (iService < 0) {
1412 @@ -1225,7 +1227,9 @@
1413 void close_cnum(connection_struct *conn, uint16 vuid)
1414 {
1415 if (IS_IPC(conn)) {
1416 +#ifndef AVM_SMALLER
1417 pipe_close_conn(conn);
1418 +#endif
1419 } else {
1420 file_close_conn(conn);
1421 dptr_closecnum(conn);
1422 Index: samba-3.0.37/source/smbd/trans2.c
1423 ===================================================================
1424 --- samba-3.0.37.orig/source/smbd/trans2.c 2009-09-30 14:21:56.000000000 +0200
1425 +++ samba-3.0.37/source/smbd/trans2.c 2011-08-09 00:02:34.904444169 +0200
1426 @@ -2878,11 +2878,14 @@
1427 /* unknown_2 6 NULL bytes follow*/
1428
1429 /* now set the quotas */
1430 +#if 1 /* AVM */
1431 + return ERROR_DOS(ERRSRV,ERRerror);
1432 +#else
1433 if (vfs_set_ntquota(fsp, SMB_USER_FS_QUOTA_TYPE, NULL, &quotas)!=0) {
1434 DEBUG(0,("vfs_set_ntquota() failed for service [%s]\n",lp_servicename(SNUM(conn))));
1435 return ERROR_DOS(ERRSRV,ERRerror);
1436 }
1437 -
1438 +#endif
1439 break;
1440 }
1441 default:
1442 Index: samba-3.0.37/source/utils/avm_smbpasswd.c
1443 ===================================================================
1444 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1445 +++ samba-3.0.37/source/utils/avm_smbpasswd.c 2011-08-09 00:02:34.904444169 +0200
1446 @@ -0,0 +1,212 @@
1447 +/*
1448 + * Unix SMB/CIFS implementation.
1449 + * Copyright (C) Jeremy Allison 1995-1998
1450 + * Copyright (C) Tim Potter 2001
1451 + *
1452 + * This program is free software; you can redistribute it and/or modify it
1453 + * under the terms of the GNU General Public License as published by the
1454 + * Free Software Foundation; either version 2 of the License, or (at your
1455 + * option) any later version.
1456 + *
1457 + * This program is distributed in the hope that it will be useful, but WITHOUT
1458 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1459 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1460 + * more details.
1461 + *
1462 + * You should have received a copy of the GNU General Public License along with
1463 + * this program; if not, write to the Free Software Foundation, Inc., 675
1464 + * Mass Ave, Cambridge, MA 02139, USA. */
1465 +
1466 +#include "includes.h"
1467 +
1468 +
1469 +void E_md4hash(const char *passwd, uchar p16[16])
1470 +{
1471 + int len;
1472 + smb_ucs2_t wpwd[129];
1473 + int i;
1474 +
1475 +
1476 + /* Password must be converted to NT unicode - null terminated. */
1477 + len = strlen(passwd);
1478 +#if 0
1479 + push_ucs2(NULL, wpwd, (const char *)passwd, 256, STR_UNICODE|STR_NOALIGN|STR_TERMINATE);
1480 +#else
1481 + for (i = 0; i < len; i++) {
1482 + wpwd[i] = (unsigned char)passwd[i];
1483 + }
1484 + wpwd[i] = 0; // termination
1485 +#endif
1486 + /* Calculate length in bytes */
1487 + len = len /*strlen_w(wpwd)*/ * sizeof(int16);
1488 +
1489 + mdfour(p16, (unsigned char *)wpwd, len);
1490 + ZERO_STRUCT(wpwd);
1491 +}
1492 +
1493 +/**
1494 + * Creates the DES forward-only Hash of the users password in DOS ASCII charset
1495 + * @param passwd password in 'unix' charset.
1496 + * @param p16 return password hashed with DES, caller allocated 16 byte buffer
1497 + * @return False if password was > 14 characters, and therefore may be incorrect, otherwise True
1498 + * @note p16 is filled in regardless
1499 + */
1500 +
1501 +BOOL E_deshash(const char *passwd, uchar p16[16])
1502 +{
1503 + BOOL ret = True;
1504 + char dospwd[256+2];
1505 + int i;
1506 + int len;
1507 +
1508 + /* Password must be converted to DOS charset - null terminated, uppercase. */
1509 +// push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE);
1510 + len = strlen(passwd);
1511 + for (i = 0; i < len; i++) {
1512 + char c = passwd[i];
1513 + if (islower(c)) c = toupper(c);
1514 + dospwd[i] = c;
1515 + }
1516 + dospwd[i] = 0;
1517 +
1518 + /* Only the fisrt 14 chars are considered, password need not be null terminated. */
1519 + E_P16((const unsigned char *)dospwd, p16);
1520 +
1521 + if (strlen(dospwd) > 14) {
1522 + ret = False;
1523 + }
1524 +
1525 + memset(dospwd, 0, sizeof(dospwd));
1526 + // ZERO_STRUCT(dospwd);
1527 +
1528 + return ret;
1529 +}
1530 +
1531 +static void my_pdb_sethexpwd(char *p, const unsigned char *pwd)
1532 +{
1533 + if (pwd != NULL) {
1534 + int i;
1535 + for (i = 0; i < 16; i++)
1536 + slprintf(&p[i*2], 3, "%02X", pwd[i]);
1537 + } else {
1538 + strncpy(p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 32);
1539 + }
1540 +}
1541 +
1542 +static void crypt_password (const char *user_name,
1543 + const char *new_passwd, char *new_lanman_p16, char *new_nt_p16)
1544 +{
1545 + /* Calculate the MD4 hash (NT compatible) of the password */
1546 + E_md4hash(new_passwd, new_nt_p16);
1547 +
1548 + if (!E_deshash(new_passwd, new_lanman_p16)) {
1549 + /* E_deshash returns false for 'long' passwords (> 14
1550 + DOS chars). This allows us to match Win2k, which
1551 + does not store a LM hash for these passwords (which
1552 + would reduce the effective password length to 14 */
1553 +
1554 + memset(new_lanman_p16, 0, LM_HASH_LEN);
1555 + }
1556 +}
1557 +
1558 +/*
1559 +ftpuser:1000:8C6F5D02DEB21501AAD3B435B51404EE:E0FBA38268D0EC66EF1CB452D5885E53:[UX ]:LCT-00000000:
1560 +*/
1561 +
1562 +/*********************************************************
1563 + Start here.
1564 +**********************************************************/
1565 +int main(int argc, char **argv)
1566 +{
1567 + char *passwd_filename = "/var/samba/private/smbpasswd";
1568 + char *cleartext_filename = "/var/tmp/smbpasswd.cleartext";
1569 +
1570 + if (argc != 1) {
1571 + fprintf(stderr, "use: smbpasswd\n");
1572 + fprintf(stderr, " file %s will be encrypted to %s\n", cleartext_filename, passwd_filename);
1573 + return -9;
1574 + }
1575 +
1576 + FILE *fp = fopen(passwd_filename, "w");
1577 +
1578 + if (fp == NULL) {
1579 + fprintf(stderr, "can't write %s\n", passwd_filename);
1580 + return -10;
1581 + }
1582 + /* Make sure it is only rw by the owner */
1583 + chmod(passwd_filename, 0600);
1584 +
1585 +
1586 + FILE *fp_in = fopen(cleartext_filename, "r");
1587 + if (!fp_in) {
1588 + fprintf(stderr, "can't read %s\n", cleartext_filename);
1589 + fclose(fp);
1590 + return -11;
1591 + }
1592 +
1593 +
1594 + char line[512];
1595 +
1596 + unsigned nusers = 0;
1597 + while(line == fgets(line, sizeof(line)-1, fp_in)) {
1598 + char *username, *passwd, *extra;
1599 + unsigned uid;
1600 + uchar new_lanman_p16[LM_HASH_LEN];
1601 + uchar new_nt_p16[NT_HASH_LEN];
1602 + char ascii_p16[32+1];
1603 + char *p;
1604 +
1605 + line[sizeof(line)-1] = '\0';
1606 + if (strlen(line)) {
1607 + p = &line[strlen(line)-1];
1608 + while(p >= line) {
1609 + if (*p != '\n' && *p != '\r') break;
1610 + *p = '\0';
1611 + p--;
1612 + }
1613 + }
1614 +
1615 + p = line;
1616 + char *p2 = strchr(p, ':');
1617 + if (!p2) goto err;
1618 + *p2 = 0;
1619 + username = p;
1620 +
1621 + p = p2 + 1;
1622 + p2 = strchr(p, ':');
1623 + if (!p2) goto err;
1624 + *p2 = 0;
1625 + uid = atoi(p);
1626 +
1627 + p = p2 + 1;
1628 + p2 = strchr(p, ':');
1629 + if (!p2) goto err;
1630 + *p2 = 0;
1631 + passwd = p;
1632 +
1633 + extra = p2 + 1;
1634 +
1635 + crypt_password(username, passwd, new_lanman_p16, new_nt_p16);
1636 +
1637 + fprintf(fp, "%s:%u:", username, uid);
1638 +
1639 + my_pdb_sethexpwd(ascii_p16, new_lanman_p16);
1640 + ascii_p16[32] = '\0';
1641 + fprintf(fp, "%s:", ascii_p16);
1642 +
1643 + my_pdb_sethexpwd(ascii_p16, new_nt_p16);
1644 + ascii_p16[32] = '\0';
1645 + fprintf(fp, "%s:", ascii_p16);
1646 +
1647 + fprintf(fp, "%s\n", extra);
1648 +
1649 + nusers++;
1650 + } // while
1651 +
1652 +err:
1653 + fclose(fp_in);
1654 + fclose(fp);
1655 +
1656 +fprintf(stderr, "%u samba users written to %s\n", nusers, passwd_filename);
1657 + return 0;
1658 +}
1659 Index: samba-3.0.37/source/Makefile.in
1660 ===================================================================
1661 --- samba-3.0.37.orig/source/Makefile.in 2009-09-30 14:21:56.000000000 +0200
1662 +++ samba-3.0.37/source/Makefile.in 2011-08-09 14:13:50.623167315 +0200
1663 @@ -257,7 +257,7 @@
1664 lib/adt_tree.o lib/gencache.o $(TDB_OBJ) \
1665 lib/module.o lib/events.o lib/ldap_escape.o @CHARSET_STATIC@ \
1666 lib/secdesc.o lib/util_seaccess.o lib/secace.o lib/secacl.o \
1667 - libads/krb5_errs.o lib/system_smbd.o lib/audit.o
1668 + lib/system_smbd.o lib/audit.o
1669
1670 LIB_OBJ = $(LIB_WITHOUT_PROTO_OBJ) $(LIB_WITH_PROTO_OBJ)
1671
1672 @@ -272,7 +272,7 @@
1673
1674 PARAM_OBJ = dynconfig.o param/loadparm.o param/params.o lib/sharesec.o lib/ldap_debug_handler.o
1675
1676 -KRBCLIENT_OBJ = libads/kerberos.o libads/ads_status.o
1677 +KRBCLIENT_OBJ = libads/ads_status.o
1678
1679 LIBADDNS_OBJ0 = libaddns/dnsrecord.o libaddns/dnsutils.o libaddns/dnssock.o \
1680 libaddns/dnsgss.o libaddns/dnsmarshall.o
1681 @@ -282,14 +282,9 @@
1682 libgpo/gpo_fetch.o libgpo/gpo_filesync.o
1683 LIBGPO_OBJ = $(LIBGPO_OBJ0)
1684
1685 -LIBADS_OBJ = libads/ldap.o libads/ldap_printer.o libads/sasl.o \
1686 - libads/krb5_setpw.o libads/ldap_user.o \
1687 - libads/ads_struct.o libads/kerberos_keytab.o \
1688 - libads/disp_sec.o libads/ads_utils.o libads/ldap_utils.o \
1689 - libads/authdata.o libads/cldap.o libads/util.o
1690 +LIBADS_OBJ =
1691
1692 -LIBADS_SERVER_OBJ = libads/kerberos_verify.o \
1693 - libads/ldap_schema.o
1694 +LIBADS_SERVER_OBJ =
1695
1696 SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o
1697
1698 @@ -471,7 +466,7 @@
1699 printing/printfsp.o lib/sysquotas.o lib/sysquotas_linux.o \
1700 lib/sysquotas_xfs.o lib/sysquotas_4A.o \
1701 smbd/change_trust_pw.o smbd/fake_file.o \
1702 - smbd/quotas.o smbd/ntquotas.o $(AFS_OBJ) smbd/msdfs.o \
1703 + smbd/ntquotas.o $(AFS_OBJ) smbd/msdfs.o \
1704 $(AFS_SETTOKEN_OBJ) smbd/aio.o smbd/statvfs.o \
1705 smbd/dmapi.o $(MANGLE_OBJ) @VFS_STATIC@
1706
1707 @@ -821,9 +816,9 @@
1708 NTLM_AUTH_OBJ1 = utils/ntlm_auth.o utils/ntlm_auth_diagnostics.o
1709
1710 NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \
1711 - libsmb/asn1.o libsmb/spnego.o libsmb/clikrb5.o libads/kerberos.o \
1712 - libads/kerberos_verify.o $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) \
1713 - libads/authdata.o $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
1714 + libsmb/asn1.o libsmb/spnego.o libsmb/clikrb5.o \
1715 + $(SECRETS_OBJ) $(SERVER_MUTEX_OBJ) \
1716 + $(RPC_PARSE_OBJ1) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
1717 $(SMBLDAP_OBJ) $(DOSERR_OBJ) rpc_parse/parse_net.o $(LIBNMB_OBJ) \
1718 $(LDB_OBJ) libsmb/errormap.o
1719