s3-rpc_server: Move config helpers in one place.
authorSimo Sorce <idra@samba.org>
Wed, 10 Aug 2011 20:33:22 +0000 (16:33 -0400)
committerSimo Sorce <idra@samba.org>
Sun, 21 Aug 2011 13:05:03 +0000 (09:05 -0400)
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
source3/Makefile.in
source3/rpc_server/rpc_config.c [new file with mode: 0644]
source3/rpc_server/rpc_config.h [new file with mode: 0644]
source3/rpc_server/rpc_server.c
source3/rpc_server/rpc_server.h
source3/rpc_server/rpc_service_setup.c
source3/rpc_server/rpc_service_setup.h
source3/rpc_server/wscript_build [changed mode: 0644->0755]

index 197aa1d87e87fd0ebeca76d45660d325c63ae7a1..0332508d027bd460d59bdcaa653cdc64297f77da 100644 (file)
@@ -738,6 +738,8 @@ RPC_NCACN_NP = rpc_server/srv_pipe_register.o rpc_server/rpc_ncacn_np.o \
               rpc_server/rpc_handles.o rpc_server/rpc_contexts.o \
               rpc_server/srv_access_check.o
 
+RPC_CONFIG = rpc_server/rpc_config.o
+
 RPC_SERVICE = rpc_server/rpc_server.o
 
 RPC_CRYPTO = rpc_server/dcesrv_ntlmssp.o \
@@ -745,7 +747,7 @@ RPC_CRYPTO = rpc_server/dcesrv_ntlmssp.o \
                rpc_server/dcesrv_spnego.o
 
 RPC_PIPE_OBJ = rpc_server/srv_pipe.o rpc_server/srv_pipe_hnd.o \
-              $(RPC_NCACN_NP) $(RPC_SERVICE) $(RPC_CRYPTO)
+              $(RPC_CONFIG) $(RPC_NCACN_NP) $(RPC_SERVICE) $(RPC_CRYPTO)
 
 RPC_RPCECHO_OBJ = rpc_server/echo/srv_echo_nt.o librpc/gen_ndr/srv_echo.o
 
@@ -1465,7 +1467,8 @@ WINBINDD_OBJ = \
                $(PROFILE_OBJ) $(SLCACHE_OBJ) $(SMBLDAP_OBJ) \
                $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \
                $(DCUTIL_OBJ) $(IDMAP_OBJ) $(NSS_INFO_OBJ) \
-               $(RPC_NCACN_NP) $(RPC_SAMR_OBJ) $(RPC_LSARPC_OBJ) \
+               $(RPC_CONFIG) $(RPC_NCACN_NP) \
+               $(RPC_SAMR_OBJ) $(RPC_LSARPC_OBJ) \
                $(NPA_TSTREAM_OBJ) \
                $(AFS_OBJ) $(AFS_SETTOKEN_OBJ) \
                $(LIBADS_SERVER_OBJ) \
diff --git a/source3/rpc_server/rpc_config.c b/source3/rpc_server/rpc_config.c
new file mode 100644 (file)
index 0000000..a706a11
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+   Unix SMB/Netbios implementation.
+   Generic infrstructure for RPC Daemons
+   Copyright (C) Simo Sorce 2011
+   Copyright (C) Andreas Schneider 2011
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "rpc_server/rpc_config.h"
+
+/* the default is "embedded" so this table
+ * lists only services that are not using
+ * the default in order to keep enumerating it
+ * in rpc_service_mode() as short as possible
+ */
+struct rpc_service_defaults {
+       const char *name;
+       const char *def_mode;
+} rpc_service_defaults[] = {
+       { "epmapper", "external" },
+       /* { "spoolss", "embedded" }, */
+       /* { "lsarpc", "embedded" }, */
+       /* { "samr", "embedded" }, */
+       /* { "netlogon", "embedded" }, */
+
+       { NULL, NULL }
+};
+
+enum rpc_service_mode_e rpc_service_mode(const char *name)
+{
+       const char *rpcsrv_type;
+       enum rpc_service_mode_e state;
+       const char *def;
+       int i;
+
+       def = "embedded";
+       for (i = 0; rpc_service_defaults[i].name; i++) {
+               if (strcasecmp_m(name, rpc_service_defaults[i].name) == 0) {
+                       def = rpc_service_defaults[i].def_mode;
+               }
+       }
+
+       rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+                                          "rpc_server", name, def);
+
+       if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
+               state = RPC_SERVICE_MODE_EMBEDDED;
+       } else if (strcasecmp_m(rpcsrv_type, "external") == 0) {
+               state = RPC_SERVICE_MODE_EXTERNAL;
+       } else if (strcasecmp(rpcsrv_type, "daemon") == 0) {
+               state = RPC_SERVICE_MODE_DAEMON;
+       } else {
+               state = RPC_SERVICE_MODE_DISABLED;
+       }
+
+       return state;
+}
+
+
+/* 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;
+}
diff --git a/source3/rpc_server/rpc_config.h b/source3/rpc_server/rpc_config.h
new file mode 100644 (file)
index 0000000..4d85d59
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *
+ *  SMBD RPC service config
+ *
+ *  Copyright (c) 2011      Andreas Schneider <asn@samba.org>
+ *  Copyright (C) 2011      Simo Sorce <idra@samba.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _RPC_CONFIG_H
+#define _RPC_CONFIG_H
+
+enum rpc_service_mode_e {
+       RPC_SERVICE_MODE_DISABLED = 0,
+       RPC_SERVICE_MODE_EMBEDDED,
+       RPC_SERVICE_MODE_EXTERNAL,
+       RPC_SERVICE_MODE_DAEMON
+};
+
+/**
+ * @brief Get the mode in which service pipes are configured.
+ *
+ * @param name         Name of the service
+ * @param def_mode     The default mode for the service
+ *
+ * @return The actual configured mode.
+ */
+enum rpc_service_mode_e rpc_service_mode(const char *name);
+
+#define rpc_epmapper_mode() rpc_service_mode("epmapper")
+#define rpc_spoolss_mode() rpc_service_mode("spoolss")
+#define rpc_lsarpc_mode() rpc_service_mode("lsarpc")
+#define rpc_samr_mode() rpc_service_mode("samr")
+#define rpc_netlogon_mode() rpc_service_mode("netlogon")
+
+
+
+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")
+
+#endif /* _RPC_CONFIG_H */
index 5136fb82a359c12576f0aeb9edd1aa1d2d645fce..43f1b3d605ce6eccae5e25d6957d531f3ce57b48 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "rpc_server/rpc_pipes.h"
 #include "rpc_server/rpc_server.h"
+#include "rpc_server/rpc_config.h"
 #include "rpc_dce.h"
 #include "librpc/gen_ndr/netlogon.h"
 #include "librpc/gen_ndr/auth.h"
 #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 79c15deaed5d2dc831f880bd5a2f3e46ef994687..1d368c324ce20815d2d92ee1d56e6c4c25ab9924 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);
index 06002625432fd39d5ea13788b5f5af3608cdee69..1314d111fe9c912370e8d3282f765b53fd959d82 100644 (file)
 #include "rpc_server/rpc_service_setup.h"
 #include "rpc_server/rpc_ep_register.h"
 #include "rpc_server/rpc_server.h"
+#include "rpc_server/rpc_config.h"
 #include "rpc_server/epmapper/srv_epmapper.h"
 
-/* the default is "embedded" so this table
- * lists only services that are not using
- * the default in order to keep enumerating it
- * in rpc_service_mode() as short as possible
- */
-struct rpc_service_defaults {
-       const char *name;
-       const char *def_mode;
-} rpc_service_defaults[] = {
-       { "epmapper", "external" },
-       /* { "spoolss", "embedded" }, */
-       /* { "lsarpc", "embedded" }, */
-       /* { "samr", "embedded" }, */
-       /* { "netlogon", "embedded" }, */
-
-       { NULL, NULL }
-};
-
-enum rpc_service_mode_e rpc_service_mode(const char *name)
-{
-       const char *rpcsrv_type;
-       enum rpc_service_mode_e state;
-       const char *def;
-       int i;
-
-       def = "embedded";
-       for (i = 0; rpc_service_defaults[i].name; i++) {
-               if (strcasecmp_m(name, rpc_service_defaults[i].name) == 0) {
-                       def = rpc_service_defaults[i].def_mode;
-               }
-       }
-
-       rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
-                                          "rpc_server", name, def);
-
-       if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
-               state = RPC_SERVICE_MODE_EMBEDDED;
-       } else if (strcasecmp_m(rpcsrv_type, "external") == 0) {
-               state = RPC_SERVICE_MODE_EXTERNAL;
-       } else if (strcasecmp(rpcsrv_type, "daemon") == 0) {
-               state = RPC_SERVICE_MODE_DAEMON;
-       } else {
-               state = RPC_SERVICE_MODE_DISABLED;
-       }
-
-       return state;
-}
-
 static bool rpc_setup_epmapper(struct tevent_context *ev_ctx,
                               struct messaging_context *msg_ctx)
 {
index 908c0e48b84149e156d10dc4454f30c8893cc949..2e27995261d589d162891c5d540ec79614356256 100644 (file)
 
 struct ndr_interface_table;
 
-enum rpc_service_mode_e {
-       RPC_SERVICE_MODE_DISABLED = 0,
-       RPC_SERVICE_MODE_EMBEDDED,
-       RPC_SERVICE_MODE_EXTERNAL,
-       RPC_SERVICE_MODE_DAEMON
-};
-
-/**
- * @brief Get the mode in which a service is started.
- *
- * @param name         Name of the service
- * @param def_mode     The default mode for the service
- *
- * @return The actual configured mode.
- */
-enum rpc_service_mode_e rpc_service_mode(const char *name);
-
-#define rpc_epmapper_mode() rpc_service_mode("epmapper")
-#define rpc_spoolss_mode() rpc_service_mode("spoolss")
-#define rpc_lsarpc_mode() rpc_service_mode("lsarpc")
-#define rpc_samr_mode() rpc_service_mode("samr")
-#define rpc_netlogon_mode() rpc_service_mode("netlogon")
-
 /**
  * @brief Register an endpoint at the endpoint mapper.
  *
old mode 100644 (file)
new mode 100755 (executable)
index 894f393..b15e3d1
@@ -25,9 +25,12 @@ bld.SAMBA3_SUBSYSTEM('rpc',
                     deps='RPC_PIPE_REGISTER',
                     vars=locals())
 
+bld.SAMBA3_SUBSYSTEM('RPC_CONFIG',
+                    source='rpc_config.c')
+
 bld.SAMBA3_SUBSYSTEM('RPC_NCACN_NP',
                     source='rpc_ncacn_np.c rpc_handles.c rpc_contexts.c',
-                    deps='auth auth_sam_reply RPC_PIPE_REGISTER npa_tstream')
+                    deps='RPC_CONFIG auth auth_sam_reply RPC_PIPE_REGISTER npa_tstream')
 
 bld.SAMBA3_SUBSYSTEM('RPC_SERVICE',
                     source='rpc_server.c',
@@ -130,7 +133,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_EPMAPPER',
 
 bld.SAMBA3_SUBSYSTEM('RPC_SERVER',
                     source='srv_pipe_hnd.c srv_pipe.c rpc_sock_helper.c rpc_service_setup.c',
-                    deps='''RPC_NCACN_NP RPC_SERVICE RPC_CRYPTO
+                    deps='''RPC_CONFIG RPC_NCACN_NP RPC_SERVICE RPC_CRYPTO
                           RPC_SAMR RPC_LSARPC RPC_WINREG RPC_INITSHUTDOWN
                           RPC_DSSETUP RPC_WKSSVC RPC_SVCCTL RPC_NTSVCS
                           RPC_NETLOGON RPC_NETDFS RPC_SRVSVC RPC_SPOOLSS