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