lib: Make genrand independent
[Samba.git] / source3 / rpc_server / rpc_config.c
blobefc6668e91b2d9b9c8348a97a10f062f1ca1117c
1 /*
2 Unix SMB/Netbios implementation.
3 Generic infrastructure for RPC Daemons
4 Copyright (C) Simo Sorce 2011
5 Copyright (C) Andreas Schneider 2011
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.
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.
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/>.
21 #include "includes.h"
22 #include "rpc_server/rpc_config.h"
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
29 struct rpc_service_defaults {
30 const char *name;
31 const char *def_mode;
32 } rpc_service_defaults[] = {
33 { "epmapper", "disabled" },
34 /* { "spoolss", "embedded" }, */
35 /* { "lsarpc", "embedded" }, */
36 /* { "samr", "embedded" }, */
37 /* { "netlogon", "embedded" }, */
38 { "fssagentrpc", "external" },
40 { NULL, NULL }
43 enum rpc_service_mode_e rpc_service_mode(const char *name)
45 const char *pipe_name = name;
46 const char *rpcsrv_type;
47 enum rpc_service_mode_e state;
48 const char *def;
49 int i;
51 /* Handle pipes with multiple names */
52 if (strcmp(pipe_name, "lsass") == 0) {
53 pipe_name = "lsarpc";
54 } else if (strcmp(pipe_name, "plugplay") == 0) {
55 pipe_name = "ntsvcs";
58 def = lp_parm_const_string(GLOBAL_SECTION_SNUM,
59 "rpc_server", "default", NULL);
60 if (def == NULL) {
61 for (i = 0; rpc_service_defaults[i].name; i++) {
62 if (strcasecmp_m(pipe_name, rpc_service_defaults[i].name) == 0) {
63 def = rpc_service_defaults[i].def_mode;
64 break;
67 /* if the default is unspecified then use 'embedded' */
68 if (def == NULL) {
69 def = "embedded";
73 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
74 "rpc_server", pipe_name, def);
76 if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
77 state = RPC_SERVICE_MODE_EMBEDDED;
78 } else if (strcasecmp_m(rpcsrv_type, "external") == 0) {
79 state = RPC_SERVICE_MODE_EXTERNAL;
80 } else {
81 state = RPC_SERVICE_MODE_DISABLED;
84 return state;
88 /* the default is "embedded" so this table
89 * lists only daemons that are not using
90 * the default in order to keep enumerating it
91 * in rpc_daemon_type() as short as possible
93 struct rpc_daemon_defaults {
94 const char *name;
95 const char *def_type;
96 } rpc_daemon_defaults[] = {
97 { "epmd", "disabled" },
98 /* { "spoolssd", "embedded" }, */
99 /* { "lsasd", "embedded" }, */
100 { "fssd", "disabled" },
102 { NULL, NULL }
105 enum rpc_daemon_type_e rpc_daemon_type(const char *name)
107 const char *rpcsrv_type;
108 enum rpc_daemon_type_e type;
109 const char *def;
110 int i;
112 def = "embedded";
113 for (i = 0; rpc_daemon_defaults[i].name; i++) {
114 if (strcasecmp_m(name, rpc_daemon_defaults[i].name) == 0) {
115 def = rpc_daemon_defaults[i].def_type;
119 rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
120 "rpc_daemon", name, def);
122 if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
123 type = RPC_DAEMON_EMBEDDED;
124 } else if (strcasecmp_m(rpcsrv_type, "fork") == 0) {
125 type = RPC_DAEMON_FORK;
126 } else {
127 type = RPC_DAEMON_DISABLED;
130 return type;