[PATCH 2/5] s3-rpc: add skeleton mgmt RPC server

David Disseldorp ddiss at samba.org
Sun Jan 5 22:20:05 MST 2014


Minimal stubbed implementation of the DCE-RPC Remote Management
Interface.

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/param/loadparm.c               |  1 +
 source3/rpc_server/mgmt/srv_mgmt_nt.c  | 70 ++++++++++++++++++++++++++++++++++
 source3/rpc_server/rpc_service_setup.c | 24 ++++++++++++
 source3/rpc_server/wscript_build       |  6 +++
 4 files changed, 101 insertions(+)
 create mode 100644 source3/rpc_server/mgmt/srv_mgmt_nt.c

diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 1396a34..ccea89b 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -4939,6 +4939,7 @@ static bool lp_load_ex(const char *pszFname,
 		lp_do_parameter(-1, "rpc_server:default", "external");
 		lp_do_parameter(-1, "rpc_server:svcctl", "embedded");
 		lp_do_parameter(-1, "rpc_server:srvsvc", "embedded");
+		lp_do_parameter(-1, "rpc_server:mgmt", "embedded");
 		lp_do_parameter(-1, "rpc_server:eventlog", "embedded");
 		lp_do_parameter(-1, "rpc_server:ntsvcs", "embedded");
 		lp_do_parameter(-1, "rpc_server:winreg", "embedded");
diff --git a/source3/rpc_server/mgmt/srv_mgmt_nt.c b/source3/rpc_server/mgmt/srv_mgmt_nt.c
new file mode 100644
index 0000000..c0a4122
--- /dev/null
+++ b/source3/rpc_server/mgmt/srv_mgmt_nt.c
@@ -0,0 +1,70 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * mgmt RPC handlers
+ *
+ * Copyright (C) David Disseldorp	2013
+ *
+ * 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 "ntdomain.h"
+#include "include/messages.h"
+#include "include/auth.h"
+#include "../libcli/security/security.h"
+#include "../lib/tsocket/tsocket.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "../lib/smbconf/smbconf.h"
+#include "smbd/proto.h"
+#include "lib/smbconf/smbconf_init.h"
+#include "librpc/gen_ndr/srv_mgmt.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_RPC_SRV
+
+WERROR _mgmt_inq_if_ids(struct pipes_struct *p,
+			struct mgmt_inq_if_ids *r)
+{
+	p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
+	return WERR_NOT_SUPPORTED;
+}
+
+WERROR _mgmt_inq_stats(struct pipes_struct *p,
+		       struct mgmt_inq_stats *r)
+{
+	p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
+	return WERR_NOT_SUPPORTED;
+}
+
+uint32_t _mgmt_is_server_listening(struct pipes_struct *p,
+				   struct mgmt_is_server_listening *r)
+{
+	*r->out.status = 0;
+	return 1;
+}
+
+WERROR _mgmt_stop_server_listening(struct pipes_struct *p,
+				   struct mgmt_stop_server_listening *r)
+{
+	p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
+	return WERR_NOT_SUPPORTED;
+}
+
+WERROR _mgmt_inq_princ_name(struct pipes_struct *p,
+			    struct mgmt_inq_princ_name *r)
+{
+	p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
+	return WERR_NOT_SUPPORTED;
+}
diff --git a/source3/rpc_server/rpc_service_setup.c b/source3/rpc_server/rpc_service_setup.c
index b8bb8ae..e0c7e43 100644
--- a/source3/rpc_server/rpc_service_setup.c
+++ b/source3/rpc_server/rpc_service_setup.c
@@ -32,6 +32,7 @@
 #include "../librpc/gen_ndr/srv_eventlog.h"
 #include "../librpc/gen_ndr/srv_initshutdown.h"
 #include "../librpc/gen_ndr/srv_lsa.h"
+#include "../librpc/gen_ndr/srv_mgmt.h"
 #include "../librpc/gen_ndr/srv_netlogon.h"
 #include "../librpc/gen_ndr/srv_ntsvcs.h"
 #include "../librpc/gen_ndr/srv_samr.h"
@@ -443,6 +444,24 @@ static bool rpc_setup_initshutdown(struct tevent_context *ev_ctx,
 	return rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL);
 }
 
+static bool rpc_setup_mgmt(struct tevent_context *ev_ctx,
+			   struct messaging_context *msg_ctx)
+{
+	const struct ndr_interface_table *t = &ndr_table_mgmt;
+	NTSTATUS status;
+	enum rpc_service_mode_e service_mode = rpc_service_mode(t->name);
+	if (service_mode != RPC_SERVICE_MODE_EMBEDDED) {
+		return true;
+	}
+
+	status = rpc_mgmt_init(NULL);
+	if (!NT_STATUS_IS_OK(status)) {
+		return false;
+	}
+
+	return rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL);
+}
+
 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
 		     struct messaging_context *msg_ctx)
 {
@@ -526,6 +545,11 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
 		goto done;
 	}
 
+	ok = rpc_setup_mgmt(ev_ctx, msg_ctx);
+	if (!ok) {
+		goto done;
+	}
+
 done:
 	talloc_free(tmp_ctx);
 	return ok;
diff --git a/source3/rpc_server/wscript_build b/source3/rpc_server/wscript_build
index 061bdd6..5bdad5c 100755
--- a/source3/rpc_server/wscript_build
+++ b/source3/rpc_server/wscript_build
@@ -119,6 +119,11 @@ bld.SAMBA3_SUBSYSTEM('RPC_WKSSVC',
                     ../../librpc/gen_ndr/srv_wkssvc.c''',
                     deps='LIBNET')
 
+bld.SAMBA3_SUBSYSTEM('RPC_MGMT',
+                    source='''mgmt/srv_mgmt_nt.c
+                    ../../librpc/gen_ndr/srv_mgmt.c''',
+                    deps='samba-util')
+
 # RPC_SERVICE
 bld.SAMBA3_SUBSYSTEM('RPC_SERVER_REGISTER',
                     source='rpc_ep_register.c ../librpc/rpc/dcerpc_ep.c',
@@ -145,6 +150,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_SERVICE',
                     RPC_RPCECHO
                     RPC_SERVER
                     RPC_EPMAPPER
+		    RPC_MGMT
                     ''')
 
 # RPC_DAEMONS
-- 
1.8.1.4



More information about the samba-technical mailing list