r4728: split up server_services into:
[bbaumbach/samba-autobuild/.git] / source4 / smbd / rewrite.c
1 #include "includes.h"
2 #include "dynconfig.h"
3
4
5 /*
6  * initialize an smb process. Guaranteed to be called only once per
7  * smbd instance (so it can assume it is starting from scratch, and
8  * delete temporary files etc)
9  */
10 void smbd_process_init(void)
11 {
12         /* possibly reload the services file. */
13         reload_services(NULL, True);
14
15         if (*lp_rootdir()) {
16                 if (sys_chroot(lp_rootdir()) == 0)
17                         DEBUG(2,("Changed root to %s\n", lp_rootdir()));
18         }
19
20         service_cleanup_tmp_files();
21 }
22
23 void init_subsystems(void)
24 {
25         /* Do *not* remove this, until you have removed
26          * passdb/secrets.c, and proved that Samba still builds... */
27
28         /* Setup the SECRETS subsystem */
29         if (!secrets_init()) {
30                 exit(1);
31         }
32
33         smbd_init_subsystems;
34 }
35
36 /****************************************************************************
37  Reload the services file.
38 **************************************************************************/
39 BOOL reload_services(struct smbsrv_connection *smb, BOOL test)
40 {
41         BOOL ret;
42         
43         if (lp_loaded()) {
44                 pstring fname;
45                 pstrcpy(fname,lp_configfile());
46                 if (file_exist(fname, NULL) &&
47                     !strcsequal(fname, dyn_CONFIGFILE)) {
48                         pstrcpy(dyn_CONFIGFILE, fname);
49                         test = False;
50                 }
51         }
52
53         reopen_logs();
54
55         if (test && !lp_file_list_changed())
56                 return(True);
57
58         ret = lp_load(dyn_CONFIGFILE, False, False, True);
59
60         /* perhaps the config filename is now set */
61         if (!test)
62                 reload_services(smb, True);
63
64         reopen_logs();
65
66         load_interfaces();
67
68         return(ret);
69 }
70