spoolss: rename spoolss_RpcDeleteJobNamedProperty to spoolss_DeleteJobNamedProperty
[amitay/samba.git] / source3 / rpc_server / rpc_config.c
1 /*
2    Unix SMB/Netbios implementation.
3    Generic infrastructure for RPC Daemons
4    Copyright (C) Simo Sorce 2011
5    Copyright (C) Andreas Schneider 2011
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 3 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, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "rpc_server/rpc_config.h"
23
24 /* the default is "embedded" so this table
25  * lists only services that are not using
26  * the default in order to keep enumerating it
27  * in rpc_service_mode() as short as possible
28  */
29 struct rpc_service_defaults {
30         const char *name;
31         const char *def_mode;
32 } rpc_service_defaults[] = {
33         { "epmapper", "disabled" },
34         { "mdssvc", "disabled" },
35         /* { "spoolss", "embedded" }, */
36         /* { "lsarpc", "embedded" }, */
37         /* { "samr", "embedded" }, */
38         /* { "netlogon", "embedded" }, */
39         { "fssagentrpc", "external" },
40
41         { NULL, NULL }
42 };
43
44 enum rpc_service_mode_e rpc_service_mode(const char *name)
45 {
46         const char *pipe_name = name;
47         const char *rpcsrv_type;
48         enum rpc_service_mode_e state;
49         const char *def;
50         int i;
51
52         /* Handle pipes with multiple names */
53         if (strcmp(pipe_name, "lsass") == 0) {
54                 pipe_name = "lsarpc";
55         } else if (strcmp(pipe_name, "plugplay") == 0) {
56                 pipe_name = "ntsvcs";
57         }
58
59         def = lp_parm_const_string(GLOBAL_SECTION_SNUM,
60                                    "rpc_server", "default", NULL);
61         if (def == NULL) {
62                 for (i = 0; rpc_service_defaults[i].name; i++) {
63                         if (strcasecmp_m(pipe_name, rpc_service_defaults[i].name) == 0) {
64                                 def = rpc_service_defaults[i].def_mode;
65                                 break;
66                         }
67                 }
68                 /* if the default is unspecified then use 'embedded' */
69                 if (def == NULL) {
70                         def = "embedded";
71                 }
72         }
73
74         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
75                                            "rpc_server", pipe_name, def);
76
77         if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
78                 state = RPC_SERVICE_MODE_EMBEDDED;
79         } else if (strcasecmp_m(rpcsrv_type, "external") == 0) {
80                 state = RPC_SERVICE_MODE_EXTERNAL;
81         } else {
82                 state = RPC_SERVICE_MODE_DISABLED;
83         }
84
85         return state;
86 }
87
88
89 /* the default is "embedded" so this table
90  * lists only daemons that are not using
91  * the default in order to keep enumerating it
92  * in rpc_daemon_type() as short as possible
93  */
94 struct rpc_daemon_defaults {
95         const char *name;
96         const char *def_type;
97 } rpc_daemon_defaults[] = {
98         { "epmd", "disabled" },
99         /* { "spoolssd", "embedded" }, */
100         /* { "lsasd", "embedded" }, */
101         { "fssd", "disabled" },
102
103         { NULL, NULL }
104 };
105
106 enum rpc_daemon_type_e rpc_daemon_type(const char *name)
107 {
108         const char *rpcsrv_type;
109         enum rpc_daemon_type_e type;
110         const char *def;
111         int i;
112
113         def = "embedded";
114         for (i = 0; rpc_daemon_defaults[i].name; i++) {
115                 if (strcasecmp_m(name, rpc_daemon_defaults[i].name) == 0) {
116                         def = rpc_daemon_defaults[i].def_type;
117                 }
118         }
119
120         rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
121                                            "rpc_daemon", name, def);
122
123         if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
124                 type = RPC_DAEMON_EMBEDDED;
125         } else if (strcasecmp_m(rpcsrv_type, "fork") == 0) {
126                 type = RPC_DAEMON_FORK;
127         } else {
128                 type = RPC_DAEMON_DISABLED;
129         }
130
131         return type;
132 }