The branch, master has been updated
       via  f8f878285d348e43a22385c1907dff3e120d4b59 (commit)
       via  ad6e9c60124ed30ee035cd522db3c4e561e4543a (commit)
      from  9176cfe0658c6be066582bd9d372c73b8714b44b (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f8f878285d348e43a22385c1907dff3e120d4b59
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Jan 9 18:32:20 2009 +0100

    Add derpc_transport_string_by_transport(), apply some const

commit ad6e9c60124ed30ee035cd522db3c4e561e4543a
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 6 19:09:57 2009 +0100

    start rpcclient epmapper

-----------------------------------------------------------------------

Summary of changes:
 librpc/rpc/binding.c             |   20 ++++--
 source3/Makefile.in              |    2 +-
 source3/include/proto.h          |    3 +-
 source3/rpcclient/cmd_epmapper.c |  133 ++++++++++++++++++++++++++++++++++++++
 source3/rpcclient/rpcclient.c    |    2 +
 source4/librpc/rpc/dcerpc.h      |    3 +-
 6 files changed, 154 insertions(+), 9 deletions(-)
 create mode 100644 source3/rpcclient/cmd_epmapper.c


Changeset truncated at 500 lines:

diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c
index dff2426..ba99239 100644
--- a/librpc/rpc/binding.c
+++ b/librpc/rpc/binding.c
@@ -176,11 +176,7 @@ _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, 
const struct dcerpc_bi
        const char *t_name = NULL;
 
        if (b->transport != NCA_UNKNOWN) {
-               for (i=0;i<ARRAY_SIZE(transports);i++) {
-                       if (transports[i].transport == b->transport) {
-                               t_name = transports[i].name;
-                       }
-               }
+               t_name = derpc_transport_string_by_transport(b->transport);
                if (!t_name) {
                        return NULL;
                }
@@ -572,7 +568,7 @@ enum dcerpc_transport_t 
dcerpc_transport_by_endpoint_protocol(int prot)
        return (unsigned int)-1;
 }
 
-_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower 
*tower)
+_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(const struct 
epm_tower *tower)
 {
        int i;
 
@@ -598,6 +594,18 @@ _PUBLIC_ enum dcerpc_transport_t 
dcerpc_transport_by_tower(struct epm_tower *tow
        return (unsigned int)-1;
 }
 
+_PUBLIC_ const char *derpc_transport_string_by_transport(enum 
dcerpc_transport_t t)
+{
+       int i;
+
+       for (i=0; i<ARRAY_SIZE(transports); i++) {
+               if (t == transports[i].transport) {
+                       return transports[i].name;
+               }
+       }
+       return NULL;
+}
+
 _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
                                   struct epm_tower *tower, 
                                   struct dcerpc_binding **b_out)
diff --git a/source3/Makefile.in b/source3/Makefile.in
index d693bb5..624156b 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -795,7 +795,7 @@ DISPLAY_SEC_OBJ= lib/display_sec.o
 RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \
                 rpcclient/cmd_samr.o rpcclient/cmd_spoolss.o \
                 rpcclient/cmd_netlogon.o rpcclient/cmd_srvsvc.o \
-                rpcclient/cmd_dfs.o \
+                rpcclient/cmd_dfs.o rpcclient/cmd_epmapper.o \
                 rpcclient/cmd_dssetup.o rpcclient/cmd_echo.o \
                 rpcclient/cmd_shutdown.o rpcclient/cmd_test.o \
                 rpcclient/cmd_wkssvc.o rpcclient/cmd_ntsvcs.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2a75473..e65369e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2292,7 +2292,8 @@ _PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(const struct 
epm_floor *epm_floor,
                                            struct ndr_syntax_id *syntax);
 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor 
*epm_floor);
 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
-_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower 
*tower);
+_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(const struct 
epm_tower *tower);
+_PUBLIC_ const char *derpc_transport_string_by_transport(enum 
dcerpc_transport_t t);
 _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
                                   struct epm_tower *tower, 
                                   struct dcerpc_binding **b_out);
diff --git a/source3/rpcclient/cmd_epmapper.c b/source3/rpcclient/cmd_epmapper.c
new file mode 100644
index 0000000..cb33416
--- /dev/null
+++ b/source3/rpcclient/cmd_epmapper.c
@@ -0,0 +1,133 @@
+/*
+   Unix SMB/CIFS implementation.
+   RPC pipe client
+
+   Copyright (C) Volker Lendecke 2009
+
+   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 "rpcclient.h"
+
+static NTSTATUS cmd_epmapper_map(struct rpc_pipe_client *p,
+                                TALLOC_CTX *mem_ctx,
+                                int argc, const char **argv)
+{
+       struct dcerpc_binding map_binding;
+       struct epm_twr_t map_tower;
+       struct epm_twr_t res_tower;
+       struct epm_twr_p_t towers;
+       struct policy_handle entry_handle;
+       struct ndr_syntax_id abstract_syntax;
+       uint32_t num_towers;
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
+       NTSTATUS status;
+
+       abstract_syntax = ndr_table_lsarpc.syntax_id;
+
+       map_binding.transport = NCACN_NP;
+        map_binding.object = abstract_syntax;
+        map_binding.host = "127.0.0.1"; /* needed? */
+        map_binding.endpoint = "0"; /* correct? needed? */
+
+       status = dcerpc_binding_build_tower(tmp_ctx, &map_binding,
+                                           &map_tower.tower);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_fprintf(stderr, "dcerpc_binding_build_tower returned %s\n",
+                         nt_errstr(status));
+               return status;
+       }
+
+       towers.twr = &res_tower;
+
+       ZERO_STRUCT(entry_handle);
+       status = rpccli_epm_Map(
+               p, tmp_ctx, &abstract_syntax.uuid,
+               &map_tower, &entry_handle, 1,
+               &num_towers, &towers);
+
+       return status;
+}
+
+static NTSTATUS cmd_epmapper_lookup(struct rpc_pipe_client *p,
+                                   TALLOC_CTX *mem_ctx,
+                                   int argc, const char **argv)
+{
+       struct policy_handle entry_handle;
+
+       ZERO_STRUCT(entry_handle);
+
+       while (true) {
+               TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+               uint32_t num_entries;
+               struct epm_entry_t entry;
+               NTSTATUS status;
+               char *guid_string;
+               struct dcerpc_binding *binding;
+
+               status = rpccli_epm_Lookup(p, tmp_ctx,
+                                  0, /* rpc_c_ep_all */
+                                  NULL,
+                                  NULL,
+                                  0, /* rpc_c_vers_all */
+                                  &entry_handle,
+                                  1, /* max_ents */
+                                  &num_entries, &entry);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_fprintf(stderr, "rpccli_epm_Lookup returned %s\n",
+                                 nt_errstr(status));
+                       break;
+               }
+
+               if (num_entries != 1) {
+                       d_fprintf(stderr, "rpccli_epm_Lookup returned %d "
+                                 "entries, expected one\n", (int)num_entries);
+                       break;
+               }
+
+               guid_string = GUID_string(tmp_ctx, &entry.object);
+               if (guid_string == NULL) {
+                       break;
+               }
+
+               status = dcerpc_binding_from_tower(tmp_ctx, &entry.tower->tower,
+                                                  &binding);
+               if (!NT_STATUS_IS_OK(status)) {
+                       break;
+               }
+
+               d_printf("%s %s: %s\n", guid_string,
+                        dcerpc_binding_string(tmp_ctx, binding),
+                        entry.annotation);
+
+               TALLOC_FREE(tmp_ctx);
+       }
+
+       return NT_STATUS_OK;
+}
+
+
+/* List of commands exported by this module */
+
+struct cmd_set epmapper_commands[] = {
+
+       { "EPMAPPER" },
+
+       { "epmmap", RPC_RTYPE_NTSTATUS, cmd_epmapper_map,     NULL,
+         &ndr_table_epmapper.syntax_id, NULL, "Map a binding", "" },
+       { "epmlookup", RPC_RTYPE_NTSTATUS, cmd_epmapper_lookup,     NULL,
+         &ndr_table_epmapper.syntax_id, NULL, "Lookup bindings", "" },
+       { NULL }
+};
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 640d5b3..7e31862 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -516,6 +516,7 @@ extern struct cmd_set srvsvc_commands[];
 extern struct cmd_set dfs_commands[];
 extern struct cmd_set ds_commands[];
 extern struct cmd_set echo_commands[];
+extern struct cmd_set epmapper_commands[];
 extern struct cmd_set shutdown_commands[];
 extern struct cmd_set test_commands[];
 extern struct cmd_set wkssvc_commands[];
@@ -533,6 +534,7 @@ static struct cmd_set *rpcclient_command_list[] = {
        srvsvc_commands,
        dfs_commands,
        echo_commands,
+       epmapper_commands,
        shutdown_commands,
        test_commands,
        wkssvc_commands,
diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h
index 248b4f9..b2e3a8c 100644
--- a/source4/librpc/rpc/dcerpc.h
+++ b/source4/librpc/rpc/dcerpc.h
@@ -359,7 +359,8 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx,
 
 NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor, struct 
ndr_syntax_id *syntax);
 
-enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower);
+enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower 
*tower);
+const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
 
 NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p,
                            const struct GUID *object,


-- 
Samba Shared Repository

Reply via email to