diff options
author | Jeremy Allison <jra@samba.org> | 2008-10-20 16:38:25 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-10-20 16:38:25 -0700 |
commit | 29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9 (patch) | |
tree | 761e1b6c8172470d651c7760806ce5081f5ee55f /librpc | |
parent | 6aba3516769b944e7960d27f10799bb8a8898d2d (diff) | |
parent | cefe4c66970b8ca243595cdb940a7c1a26765a08 (diff) | |
download | samba-29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9.tar.gz samba-29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9.tar.bz2 samba-29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9.zip |
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/ndr/ndr_misc.c | 9 | ||||
-rw-r--r-- | librpc/ndr/ndr_orpc.c | 173 | ||||
-rw-r--r-- | librpc/ndr/ndr_table.c | 2 | ||||
-rw-r--r-- | librpc/ndr/ndr_table.h | 1 | ||||
-rw-r--r-- | librpc/ndr/ndr_wmi.c | 60 | ||||
-rw-r--r-- | librpc/ndr/ndr_wmi.h | 3 | ||||
-rw-r--r-- | librpc/tools/ndrdump.c | 5 |
7 files changed, 239 insertions, 14 deletions
diff --git a/librpc/ndr/ndr_misc.c b/librpc/ndr/ndr_misc.c index 2e5ecbac6d..c4a1adb3ea 100644 --- a/librpc/ndr/ndr_misc.c +++ b/librpc/ndr/ndr_misc.c @@ -24,15 +24,6 @@ #include "system/network.h" #include "librpc/ndr/libndr.h" -_PUBLIC_ void ndr_print_in_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip) -{ - struct in_addr ip; - - ip.s_addr = htonl(_ip->s_addr); - - ndr->print(ndr, "%-25s: %s", name, inet_ntoa(ip)); -} - _PUBLIC_ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); diff --git a/librpc/ndr/ndr_orpc.c b/librpc/ndr/ndr_orpc.c new file mode 100644 index 0000000000..6a55048e43 --- /dev/null +++ b/librpc/ndr/ndr_orpc.c @@ -0,0 +1,173 @@ +/* + Unix SMB/CIFS implementation. + + routines for marshalling/unmarshalling DCOM string arrays + + Copyright (C) Jelmer Vernooij 2004 + + 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 "librpc/gen_ndr/ndr_orpc.h" + +enum ndr_err_code ndr_pull_DUALSTRINGARRAY(struct ndr_pull *ndr, int ndr_flags, struct DUALSTRINGARRAY *ar) +{ + uint16_t num_entries, security_offset; + uint16_t towerid; + uint32_t towernum = 0, conformant_size; + + if (!(ndr_flags & NDR_SCALARS)) { + return NDR_ERR_SUCCESS; + } + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &conformant_size)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &num_entries)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &security_offset)); + + ar->stringbindings = talloc_array(ndr, struct STRINGBINDING *, num_entries); + ar->stringbindings[0] = NULL; + + do { + /* 'Peek' */ + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid)); + + if (towerid > 0) { + ndr->offset -= 2; + ar->stringbindings = talloc_realloc(ndr, ar->stringbindings, struct STRINGBINDING *, towernum+2); + ar->stringbindings[towernum] = talloc(ndr, struct STRINGBINDING); + NDR_CHECK(ndr_pull_STRINGBINDING(ndr, ndr_flags, ar->stringbindings[towernum])); + towernum++; + } + } while (towerid != 0); + + ar->stringbindings[towernum] = NULL; + towernum = 0; + + ar->securitybindings = talloc_array(ndr, struct SECURITYBINDING *, num_entries); + ar->securitybindings[0] = NULL; + + do { + /* 'Peek' */ + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid)); + + if (towerid > 0) { + ndr->offset -= 2; + ar->securitybindings = talloc_realloc(ndr, ar->securitybindings, struct SECURITYBINDING *, towernum+2); + ar->securitybindings[towernum] = talloc(ndr, struct SECURITYBINDING); + NDR_CHECK(ndr_pull_SECURITYBINDING(ndr, ndr_flags, ar->securitybindings[towernum])); + towernum++; + } + } while (towerid != 0); + + ar->securitybindings[towernum] = NULL; + + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_push_DUALSTRINGARRAY(struct ndr_push *ndr, int ndr_flags, const struct DUALSTRINGARRAY *ar) +{ + return ndr_push_error(ndr, NDR_ERR_STRING, "ndr_push_DUALSTRINGARRAY not implemented"); +} + +/* + print a dom_sid +*/ +void ndr_print_DUALSTRINGARRAY(struct ndr_print *ndr, const char *name, const struct DUALSTRINGARRAY *ar) +{ + int i; + ndr->print(ndr, "%-25s: DUALSTRINGARRAY", name); + ndr->depth++; + ndr->print(ndr, "STRING BINDINGS"); + ndr->depth++; + for (i=0;ar->stringbindings[i];i++) { + char *idx = NULL; + asprintf(&idx, "[%d]", i); + if (idx) { + ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]); + free(idx); + } + } + ndr->depth--; + ndr->print(ndr, "SECURITY BINDINGS"); + ndr->depth++; + for (i=0;ar->securitybindings[i];i++) { + char *idx = NULL; + asprintf(&idx, "[%d]", i); + if (idx) { + ndr_print_SECURITYBINDING(ndr, idx, ar->securitybindings[i]); + free(idx); + } + } + ndr->depth--; +} + +enum ndr_err_code ndr_pull_STRINGARRAY(struct ndr_pull *ndr, int ndr_flags, struct STRINGARRAY *ar) +{ + uint16_t towerid; + uint32_t towernum = 0; + uint16_t num_entries; + + if (!(ndr_flags & NDR_SCALARS)) { + return NDR_ERR_SUCCESS; + } + + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &num_entries)); + + ar->stringbindings = talloc_array(ndr, struct STRINGBINDING *, 1); + ar->stringbindings[0] = NULL; + + do { + /* 'Peek' */ + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid)); + + if (towerid > 0) { + ndr->offset -= 2; + ar->stringbindings = talloc_realloc(ndr, ar->stringbindings, struct STRINGBINDING *, towernum+2); + ar->stringbindings[towernum] = talloc(ndr, struct STRINGBINDING); + NDR_CHECK(ndr_pull_STRINGBINDING(ndr, ndr_flags, ar->stringbindings[towernum])); + towernum++; + } + } while (towerid != 0); + + ar->stringbindings[towernum] = NULL; + towernum = 0; + + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_push_STRINGARRAY(struct ndr_push *ndr, int ndr_flags, const struct STRINGARRAY *ar) +{ + return ndr_push_error(ndr, NDR_ERR_STRING, "ndr_push_STRINGARRAY not implemented"); +} + +/* + print a dom_sid +*/ +void ndr_print_STRINGARRAY(struct ndr_print *ndr, const char *name, const struct STRINGARRAY *ar) +{ + int i; + ndr->print(ndr, "%-25s: STRINGARRAY", name); + ndr->depth++; + for (i=0;ar->stringbindings[i];i++) { + char *idx = NULL; + asprintf(&idx, "[%d]", i); + if (idx) { + ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]); + free(idx); + } + } + ndr->depth--; +} diff --git a/librpc/ndr/ndr_table.c b/librpc/ndr/ndr_table.c index f7c381f22e..7ca04173f7 100644 --- a/librpc/ndr/ndr_table.c +++ b/librpc/ndr/ndr_table.c @@ -120,8 +120,6 @@ const struct ndr_interface_list *ndr_table_list(void) } -NTSTATUS ndr_table_register_builtin_tables(void); - NTSTATUS ndr_table_init(void) { static bool initialized = false; diff --git a/librpc/ndr/ndr_table.h b/librpc/ndr/ndr_table.h index 905c2e5e43..9e8fea1db6 100644 --- a/librpc/ndr/ndr_table.h +++ b/librpc/ndr/ndr_table.h @@ -8,6 +8,7 @@ const struct ndr_interface_table *ndr_table_by_name(const char *name); const struct ndr_interface_table *ndr_table_by_uuid(const struct GUID *uuid); const struct ndr_interface_list *ndr_table_list(void); NTSTATUS ndr_table_init(void); +NTSTATUS ndr_table_register_builtin_tables(void); #endif /* _NDR_TABLE_PROTO_H_ */ diff --git a/librpc/ndr/ndr_wmi.c b/librpc/ndr/ndr_wmi.c new file mode 100644 index 0000000000..2c122decf4 --- /dev/null +++ b/librpc/ndr/ndr_wmi.c @@ -0,0 +1,60 @@ +/* + Unix SMB/CIFS implementation. + + routines for marshalling/unmarshalling DCOM string arrays + + Copyright (C) Jelmer Vernooij 2004 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +//#define NDR_CHECK_DEBUG +#include "includes.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/gen_ndr/ndr_wmi.h" +#include "librpc/ndr/ndr_wmi.h" + +// Just for debugging +int NDR_CHECK_depth = 0; +int NDR_CHECK_shift = 0x18; + +enum ndr_err_code ndr_push_BSTR(struct ndr_push *ndr, int ndr_flags, const struct BSTR *r) +{ + uint32_t len; + uint32_t flags; + enum ndr_err_code status; + len = strlen(r->data); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x72657355)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, len)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2*len)); + flags = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NOTERM | LIBNDR_FLAG_STR_SIZE4); + status = ndr_push_string(ndr, NDR_SCALARS, r->data); + ndr->flags = flags; + return status; + } + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_BSTR(struct ndr_pull *ndr, int ndr_flags, struct BSTR *r) +{ + return NDR_ERR_BAD_SWITCH; +} + +void ndr_print_BSTR(struct ndr_print *ndr, const char *name, const struct BSTR *r) +{ + ndr->print(ndr, "%-25s: BSTR(\"%s\")", name, r->data); +} diff --git a/librpc/ndr/ndr_wmi.h b/librpc/ndr/ndr_wmi.h new file mode 100644 index 0000000000..539b9e882b --- /dev/null +++ b/librpc/ndr/ndr_wmi.h @@ -0,0 +1,3 @@ +typedef const char *CIMSTRING; +enum ndr_err_code ndr_pull_CIMSTRING(struct ndr_pull *ndr, int ndr_flags, CIMSTRING *r); +enum ndr_err_code ndr_push_CIMSTRING(struct ndr_push *ndr, int ndr_flags, const CIMSTRING *r); diff --git a/librpc/tools/ndrdump.c b/librpc/tools/ndrdump.c index 3d7c644902..69b304dc9c 100644 --- a/librpc/tools/ndrdump.c +++ b/librpc/tools/ndrdump.c @@ -171,7 +171,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) }; ndr_table_init(); -#if (_SAMBA_BUILD_ >= 3) + /* Initialise samba stuff */ load_case_tables(); @@ -179,8 +179,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) dbf = x_stderr; - setup_logging(argv[0],True); -#endif + setup_logging(argv[0], true); pc = poptGetContext("ndrdump", argc, argv, long_options, 0); |