proper job on set secret stuff. added idle function to msrpc fn table.
[gd/samba/.git] / source / svcctld / svcctld.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
30 /*****************************************************************************
31  initialise srv_auth_fns array
32  *****************************************************************************/
33 static void auth_init(rpcsrv_struct *l)
34 {
35 }
36
37 /*************************************************************************
38  initialise an msrpc service
39  *************************************************************************/
40 static void service_init(char* service_name)
41 {
42         add_msrpc_command_processor( pipe_name, service_name, api_svcctl_rpc );
43 }
44
45 /****************************************************************************
46   reload the services file
47   **************************************************************************/
48 static BOOL reload_msrpc(BOOL test)
49 {
50         BOOL ret;
51
52         if (lp_loaded()) {
53                 pstring fname;
54                 pstrcpy(fname,lp_configfile());
55                 if (file_exist(fname,NULL) && !strcsequal(fname,servicesf)) {
56                         pstrcpy(servicesf,fname);
57                         test = False;
58                 }
59         }
60
61         reopen_logs();
62
63         if (test && !lp_file_list_changed())
64                 return(True);
65
66         lp_killunused(NULL);
67
68         ret = lp_load(servicesf,False,False,True);
69
70         /* perhaps the config filename is now set */
71         if (!test)
72                 reload_msrpc(True);
73
74         reopen_logs();
75
76         load_interfaces();
77
78         return(ret);
79 }
80
81 /****************************************************************************
82   main program
83 ****************************************************************************/
84 static int main_init(int argc,char *argv[])
85 {
86 #ifdef HAVE_SET_AUTH_PARAMETERS
87         set_auth_parameters(argc,argv);
88 #endif
89
90 #ifdef HAVE_SETLUID
91         /* needed for SecureWare on SCO */
92         setluid(0);
93 #endif
94
95         append_log = True;
96
97         TimeInit();
98
99         setup_logging(argv[0],False);
100         fstrcpy(pipe_name, "svcctl");
101         slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name);
102
103         return 0;
104 }
105
106 static msrpc_service_fns fn_table =
107 {
108         auth_init,
109         service_init,
110         reload_msrpc,
111         main_init,
112         NULL
113 };
114
115 msrpc_service_fns *get_service_fns(void)
116 {
117         return &fn_table;
118 }