first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[kai/samba.git] / source / lsarpcd / lsarpcd.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    Main SMB server routines
5    Copyright (C) Andrew Tridgell 1992-1998
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 fstring pipe_name;
25
26 pstring servicesf = CONFIGFILE;
27 extern pstring debugf;
28 extern BOOL append_log;
29 extern int DEBUGLEVEL;
30
31 void msrpc_service_init(void)
32 {
33         if (!pwdb_initialise(True))
34         {
35                 exit(-1);
36         }
37
38         if(!initialise_sam_password_db())
39         {
40                 exit(-1);
41         }
42
43         if(!initialise_passgrp_db())
44         {
45                 exit(-1);
46         }
47
48         if(!initialise_group_db())
49         {
50                 exit(-1);
51         }
52
53         if(!initialise_alias_db())
54         {
55                 exit(-1);
56         }
57
58         if(!initialise_builtin_db())
59         {
60                 exit(-1);
61         }
62
63         if (!get_member_domain_sid())
64         {
65                 DEBUG(0,("ERROR: Samba cannot obtain PDC SID from PDC(s) %s.\n",
66                           lp_passwordserver()));
67                 exit(-1);
68         }
69 }
70
71 /****************************************************************************
72   reload the services file
73   **************************************************************************/
74 BOOL reload_services(BOOL test)
75 {
76         BOOL ret;
77
78         if (lp_loaded()) {
79                 pstring fname;
80                 pstrcpy(fname,lp_configfile());
81                 if (file_exist(fname,NULL) && !strcsequal(fname,servicesf)) {
82                         pstrcpy(servicesf,fname);
83                         test = False;
84                 }
85         }
86
87         reopen_logs();
88
89         if (test && !lp_file_list_changed())
90                 return(True);
91
92         lp_killunused(NULL);
93
94         ret = lp_load(servicesf,False,False,True);
95
96         /* perhaps the config filename is now set */
97         if (!test)
98                 reload_services(True);
99
100         reopen_logs();
101
102         load_interfaces();
103
104         return(ret);
105 }
106
107 /****************************************************************************
108   main program
109 ****************************************************************************/
110  int main(int argc,char *argv[])
111 {
112 #ifdef HAVE_SET_AUTH_PARAMETERS
113         set_auth_parameters(argc,argv);
114 #endif
115
116 #ifdef HAVE_SETLUID
117         /* needed for SecureWare on SCO */
118         setluid(0);
119 #endif
120
121         append_log = True;
122
123         TimeInit();
124
125         fstrcpy(pipe_name, "lsarpc");
126         setup_logging(argv[0],False);
127         slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name);
128         add_msrpc_command_processor( pipe_name, argv[0], api_ntlsa_rpc );
129
130         return msrpc_main(argc, argv);
131 }