s3-rpc_server: Add helper to define/retrieve daemons configuration
authorSimo Sorce <idra@samba.org>
Wed, 10 Aug 2011 19:02:24 +0000 (15:02 -0400)
committerSimo Sorce <idra@samba.org>
Sun, 21 Aug 2011 13:05:03 +0000 (09:05 -0400)
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 <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
source3/rpc_server/rpc_server.c
source3/rpc_server/rpc_server.h

index 2e6bfa53e23571d8232ae9e18c1c0313d7727f54..5136fb82a359c12576f0aeb9edd1aa1d2d645fce 100644 (file)
 #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)
 {
index 1d368c324ce20815d2d92ee1d56e6c4c25ab9924..79c15deaed5d2dc831f880bd5a2f3e46ef994687 100644 (file)
 #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);