From 5a4e0dd853d2e5fb12031a59665966d14d07bbfc Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 10 Aug 2011 15:02:24 -0400 Subject: [PATCH] s3-rpc_server: Add helper to define/retrieve daemons configuration Wtith this set of helper functions we make it easy to configure if we want to use an embedded rpc server, or if we want to fork one. Or even just disable it and let a third party server be used when the service is configured as "external". Signed-off-by: Andreas Schneider Signed-off-by: Simo Sorce --- source3/rpc_server/rpc_server.c | 44 +++++++++++++++++++++++++++++++++ source3/rpc_server/rpc_server.h | 21 ++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index 2e6bfa53e23..5136fb82a35 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -36,6 +36,50 @@ #define SERVER_TCP_LOW_PORT 1024 #define SERVER_TCP_HIGH_PORT 1300 +/* the default is "embedded" so this table + * lists only daemons that are not using + * the default in order to keep enumerating it + * in rpc_daemon_type() as short as possible + */ +struct rpc_daemon_defaults { + const char *name; + const char *def_type; +} rpc_daemon_defaults[] = { + { "epmd", "fork" }, + /* { "spoolssd", "embedded" }, */ + /* { "lsasd", "embedded" }, */ + + { NULL, NULL } +}; + +enum rpc_daemon_type_e rpc_daemon_type(const char *name) +{ + const char *rpcsrv_type; + enum rpc_daemon_type_e type; + const char *def; + int i; + + def = "embedded"; + for (i = 0; rpc_daemon_defaults[i].name; i++) { + if (strcasecmp_m(name, rpc_daemon_defaults[i].name) == 0) { + def = rpc_daemon_defaults[i].def_type; + } + } + + rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM, + "rpc_daemon", name, def); + + if (strcasecmp_m(rpcsrv_type, "embedded") == 0) { + type = RPC_DAEMON_EMBEDDED; + } else if (strcasecmp_m(rpcsrv_type, "fork") == 0) { + type = RPC_DAEMON_FORK; + } else { + type = RPC_DAEMON_DISABLED; + } + + return type; +} + static NTSTATUS auth_anonymous_session_info(TALLOC_CTX *mem_ctx, struct auth_session_info **session_info) { diff --git a/source3/rpc_server/rpc_server.h b/source3/rpc_server/rpc_server.h index 1d368c324ce..79c15deaed5 100644 --- a/source3/rpc_server/rpc_server.h +++ b/source3/rpc_server/rpc_server.h @@ -20,6 +20,27 @@ #ifndef _RPC_SERVER_H_ #define _RPC_SERVER_H_ +enum rpc_daemon_type_e { + RPC_DAEMON_DISABLED = 0, + RPC_DAEMON_EMBEDDED, + RPC_DAEMON_FORK +}; + +/** + * @brief Get the mode in which a server is started. + * + * @param name Name of the rpc server + * @param def_type The default type for the server + * + * @return The actual configured type. + */ +enum rpc_daemon_type_e rpc_daemon_type(const char *name); + +#define rpc_epmapper_daemon() rpc_daemon_type("epmd") +#define rpc_spoolss_daemon() rpc_daemon_type("spoolssd") +#define rpc_lsasd_daemon() rpc_daemon_type("lsasd") + + struct pipes_struct; typedef bool (*dcerpc_ncacn_disconnect_fn)(struct pipes_struct *p); -- 2.34.1