diff options
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/config.mk | 4 | ||||
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 67 | ||||
-rw-r--r-- | source4/librpc/ndr/libndr.h | 4 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 26 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_compression.c | 6 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss_buf.c | 13 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_string.c | 23 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc.c | 23 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc.h | 2 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc.py | 59 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_connect.c | 9 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_secondary.c | 3 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_sock.c | 7 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_util.c | 7 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_wrap.c | 26 | ||||
-rw-r--r-- | source4/librpc/tools/ndrdump.c | 9 |
16 files changed, 194 insertions, 94 deletions
diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 187ba9f309..2b2f39b650 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -487,7 +487,9 @@ PRIVATE_DEPENDENCIES = \ samba-socket LIBCLI_RESOLVE LIBCLI_SMB LIBCLI_SMB2 \ LIBNDR NDR_DCERPC RPC_NDR_EPMAPPER \ NDR_SCHANNEL RPC_NDR_NETLOGON \ - gensec LIBCLI_AUTH LIBCLI_RAW CREDENTIALS + gensec LIBCLI_AUTH LIBCLI_RAW \ + LP_RESOLVE +PUBLIC_DEPENDENCIES = CREDENTIALS # End SUBSYSTEM dcerpc ################################################ diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index 8224976a26..9c26b14892 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -1313,6 +1313,67 @@ import "security.idl", "winreg.idl"; [case(1)] spoolss_UserLevel1 *level1; } spoolss_UserLevel; + typedef bitmap { + SERVER_ACCESS_ADMINISTER = 0x00000001, + SERVER_ACCESS_ENUMERATE = 0x00000002, + PRINTER_ACCESS_ADMINISTER = 0x00000004, + PRINTER_ACCESS_USE = 0x00000008, + JOB_ACCESS_ADMINISTER = 0x00000010 + } spoolss_AccessRights; + + /* Access rights for print servers */ + const int SERVER_ALL_ACCESS = SEC_STD_REQUIRED | + SERVER_ACCESS_ADMINISTER | + SERVER_ACCESS_ENUMERATE; + + const int SERVER_READ = SEC_STD_READ_CONTROL | + SERVER_ACCESS_ENUMERATE; + + const int SERVER_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | + SERVER_ACCESS_ADMINISTER | + SERVER_ACCESS_ENUMERATE; + + const int SERVER_EXECUTE = SEC_STD_READ_CONTROL | + SERVER_ACCESS_ENUMERATE; + + /* Access rights for printers */ + const int PRINTER_ALL_ACCESS = SEC_STD_REQUIRED | + PRINTER_ACCESS_ADMINISTER | + PRINTER_ACCESS_USE; + + const int PRINTER_READ = SEC_STD_READ_CONTROL | + PRINTER_ACCESS_USE; + + const int PRINTER_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | + PRINTER_ACCESS_USE; + + const int PRINTER_EXECUTE = SEC_STD_READ_CONTROL | + PRINTER_ACCESS_USE; + + /* Access rights for jobs */ + const int JOB_ALL_ACCESS = SEC_STD_REQUIRED | + JOB_ACCESS_ADMINISTER; + + const int JOB_READ = SEC_STD_READ_CONTROL | + JOB_ACCESS_ADMINISTER; + + const int JOB_WRITE = STANDARD_RIGHTS_WRITE_ACCESS | + JOB_ACCESS_ADMINISTER; + + const int JOB_EXECUTE = SEC_STD_READ_CONTROL | + JOB_ACCESS_ADMINISTER; + + /* ACE masks for various print permissions */ + const int PRINTER_ACE_FULL_CONTROL = SEC_GENERIC_ALL | + PRINTER_ALL_ACCESS; + + const int PRINTER_ACE_MANAGE_DOCUMENTS = SEC_GENERIC_ALL | + READ_CONTROL_ACCESS; + + const int PRINTER_ACE_PRINT = GENERIC_EXECUTE_ACCESS | + READ_CONTROL_ACCESS | + PRINTER_ACCESS_USE; + /******************/ /* Function: 0x45 */ [public] WERROR spoolss_OpenPrinterEx( @@ -1416,9 +1477,9 @@ import "security.idl", "winreg.idl"; [public] WERROR spoolss_EnumPrinterKey( [in, ref] policy_handle *handle, [in] [string,charset(UTF16)] uint16 key_name[], - [out, ref] uint32 *key_buffer_size, - [out] uint8 key_buffer[*key_buffer_size], - [in,out,ref] uint32 *needed + [out] uint32 key_buffer_size, + [out] uint16 key_buffer[key_buffer_size], + [in,out] uint32 needed ); /******************/ diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index 2ac0b86f57..1ecc6f3c38 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -52,6 +52,8 @@ struct ndr_pull { uint32_t data_size; uint32_t offset; + struct smb_iconv_convenience *iconv_convenience; + uint32_t relative_base_offset; struct ndr_token_list *relative_base_list; @@ -84,6 +86,8 @@ struct ndr_push { /* this is used to ensure we generate unique reference IDs */ uint32_t ptr_count; + + struct smb_iconv_convenience *iconv_convenience; }; /* structure passed to functions that print IDL structures */ diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 40afeacebf..0dafda7086 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -30,6 +30,7 @@ #include "librpc/ndr/libndr.h" #include "lib/util/dlinklist.h" #include "librpc/gen_ndr/dcerpc.h" +#include "param/param.h" #define NDR_BASE_MARSHALL_SIZE 1024 @@ -56,7 +57,7 @@ _PUBLIC_ size_t ndr_align_size(uint32_t offset, size_t n) /* initialise a ndr parse structure from a data blob */ -_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx) +_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience) { struct ndr_pull *ndr; @@ -66,6 +67,7 @@ _PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX * ndr->data = blob->data; ndr->data_size = blob->length; + ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience); return ndr; } @@ -99,7 +101,7 @@ static enum ndr_err_code ndr_pull_set_offset(struct ndr_pull *ndr, uint32_t ofs) } /* create a ndr_push structure, ready for some marshalling */ -_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx) +_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience) { struct ndr_push *ndr; @@ -114,6 +116,7 @@ _PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx) if (!ndr->data) { return NULL; } + ndr->iconv_convenience = talloc_reference(ndr, iconv_convenience); return ndr; } @@ -438,6 +441,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr, subndr->data = ndr->data + ndr->offset; subndr->offset = 0; subndr->data_size = r_content_size; + subndr->iconv_convenience = talloc_reference(subndr, ndr->iconv_convenience); *_subndr = subndr; return NDR_ERR_SUCCESS; @@ -467,7 +471,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr, { struct ndr_push *subndr; - subndr = ndr_push_init_ctx(ndr); + subndr = ndr_push_init_ctx(ndr, ndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(subndr); subndr->flags = ndr->flags; @@ -690,7 +694,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CT ndr_pull_flags_fn_t fn) { struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); + ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm)); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); return NDR_ERR_SUCCESS; @@ -703,7 +707,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO ndr_pull_flags_fn_t fn) { struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); + ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm)); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); if (ndr->offset < ndr->data_size) { @@ -721,7 +725,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX uint32_t level, ndr_pull_flags_fn_t fn) { struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); + ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm)); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level)); NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); @@ -736,7 +740,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC uint32_t level, ndr_pull_flags_fn_t fn) { struct ndr_pull *ndr; - ndr = ndr_pull_init_blob(blob, mem_ctx); + ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm)); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level)); NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); @@ -755,7 +759,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem ndr_push_flags_fn_t fn) { struct ndr_push *ndr; - ndr = ndr_push_init_ctx(mem_ctx); + ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); @@ -774,7 +778,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ uint32_t level, ndr_push_flags_fn_t fn) { struct ndr_push *ndr; - ndr = ndr_push_init_ctx(mem_ctx); + ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); NDR_ERR_HAVE_NO_MEMORY(ndr); NDR_CHECK(ndr_push_set_switch_value(ndr, p, level)); @@ -799,7 +803,7 @@ _PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t pu /* avoid recursion */ if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0; - ndr = ndr_push_init_ctx(NULL); + ndr = ndr_push_init_ctx(NULL, lp_iconv_convenience(global_loadparm)); if (!ndr) return 0; ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p)); @@ -824,7 +828,7 @@ _PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_pus /* avoid recursion */ if (flags & LIBNDR_FLAG_NO_NDR_SIZE) return 0; - ndr = ndr_push_init_ctx(NULL); + ndr = ndr_push_init_ctx(NULL, lp_iconv_convenience(global_loadparm)); if (!ndr) return 0; ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE; diff --git a/source4/librpc/ndr/ndr_compression.c b/source4/librpc/ndr/ndr_compression.c index 411d4a17e2..310f8c4ce4 100644 --- a/source4/librpc/ndr/ndr_compression.c +++ b/source4/librpc/ndr/ndr_compression.c @@ -86,7 +86,7 @@ static enum ndr_err_code ndr_pull_compression_mszip(struct ndr_pull *subndr, struct decomp_state *decomp_state; bool last = false; - ndrpush = ndr_push_init_ctx(subndr); + ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(ndrpush); decomp_state = ZIPdecomp_state(subndr); @@ -197,7 +197,7 @@ static enum ndr_err_code ndr_pull_compression_xpress(struct ndr_pull *subndr, DATA_BLOB uncompressed; bool last = false; - ndrpush = ndr_push_init_ctx(subndr); + ndrpush = ndr_push_init_ctx(subndr, subndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(ndrpush); while (!last) { @@ -264,7 +264,7 @@ enum ndr_err_code ndr_push_compression_start(struct ndr_push *subndr, { struct ndr_push *comndr; - comndr = ndr_push_init_ctx(subndr); + comndr = ndr_push_init_ctx(subndr, subndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(comndr); comndr->flags = subndr->flags; diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c index 9800430203..e01c5fd225 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ b/source4/librpc/ndr/ndr_spoolss_buf.c @@ -23,6 +23,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_spoolss.h" +#include "param/param.h" #define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ if (!r->in.buffer && r->in.offered != 0) {\ @@ -55,7 +56,7 @@ }\ if (r->in.buffer) {\ DATA_BLOB _data_blob_info;\ - _ndr_info = ndr_push_init_ctx(ndr);\ + _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\ NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ _ndr_info->flags= ndr->flags;\ if (r->out.info) {\ @@ -120,7 +121,7 @@ r->out.count = _r.out.count;\ r->out.result = _r.out.result;\ if (_r.out.info) {\ - struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr);\ + struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr, ndr->iconv_convenience);\ NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ _ndr_info->flags= ndr->flags;\ if (r->in.offered != _ndr_info->data_size) {\ @@ -164,7 +165,7 @@ #define NDR_SPOOLSS_SIZE_ENUM(fn) do { \ struct __##fn __r;\ DATA_BLOB _data_blob_info;\ - struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx);\ + struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm));\ if (!_ndr_info) return 0;\ _ndr_info->flags|=0;\ __r.in.level = level;\ @@ -414,7 +415,7 @@ enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flag _r.out.result = r->out.result; { struct __spoolss_GetPrinterData __r; - _ndr_info = ndr_push_init_ctx(ndr); + _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(_ndr_info); _ndr_info->flags= ndr->flags; __r.in.type = r->out.type; @@ -469,7 +470,7 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag } if (_r.out.data.length > 0 && r->out.needed <= _r.out.data.length) { struct __spoolss_GetPrinterData __r; - struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr); + struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr, ndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(_ndr_data); _ndr_data->flags= ndr->flags; __r.in.type = r->out.type; @@ -494,7 +495,7 @@ enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flag struct __spoolss_SetPrinterData __r; DATA_BLOB _data_blob_data; - _ndr_data = ndr_push_init_ctx(ndr); + _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience); NDR_ERR_HAVE_NO_MEMORY(_ndr_data); _ndr_data->flags= ndr->flags; diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 7e84211e87..69a7eca1a8 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -82,7 +82,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, chset, CH_UNIX, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len2 + c_len_term)*byte_mul, (void **)&as); @@ -119,7 +119,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len1 + c_len_term)*byte_mul, @@ -158,7 +158,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len1 + c_len_term)*byte_mul, @@ -193,7 +193,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, (len3 + c_len_term)*byte_mul, @@ -226,7 +226,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len3, @@ -247,7 +247,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, chset, CH_UNIX, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, (void **)&as); @@ -264,7 +264,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1*byte_mul, @@ -290,7 +290,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, as = talloc_strdup(ndr->current_mem_ctx, ""); } else { ret = convert_string_talloc(ndr->current_mem_ctx, - global_smb_iconv_convenience, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, len1, @@ -355,7 +355,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, LIBNDR_FLAG_STR_FIXLEN32))) { s_len++; } - d_len = convert_string_talloc(ndr, global_smb_iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest); + d_len = convert_string_talloc(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest); if (d_len == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); @@ -689,7 +689,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, NDR_PULL_NEED_BYTES(ndr, length*byte_mul); - ret = convert_string_talloc(ndr->current_mem_ctx, global_smb_iconv_convenience, + ret = convert_string_talloc(ndr->current_mem_ctx, + ndr->iconv_convenience, chset, CH_UNIX, ndr->data+ndr->offset, length*byte_mul, @@ -714,7 +715,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, required = byte_mul * length; NDR_PUSH_NEED_BYTES(ndr, required); - ret = convert_string(global_smb_iconv_convenience, CH_UNIX, chset, + ret = convert_string(ndr->iconv_convenience, CH_UNIX, chset, var, strlen(var), ndr->data+ndr->offset, required); if (ret == -1) { diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index 74dc2562ed..f5eae1b09a 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -164,13 +164,13 @@ void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v) } -/* +/** setup for a ndr pull, also setting up any flags from the binding string */ static struct ndr_pull *ndr_pull_init_flags(struct dcerpc_connection *c, DATA_BLOB *blob, TALLOC_CTX *mem_ctx) { - struct ndr_pull *ndr = ndr_pull_init_blob(blob, mem_ctx); + struct ndr_pull *ndr = ndr_pull_init_blob(blob, mem_ctx, lp_iconv_convenience(global_loadparm)); if (ndr == NULL) return ndr; @@ -350,7 +350,7 @@ static NTSTATUS ncacn_push_request_sign(struct dcerpc_connection *c, return ncacn_push_auth(blob, mem_ctx, pkt, c->security_state.auth_info); } - ndr = ndr_push_init_ctx(mem_ctx); + ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); if (!ndr) { return NT_STATUS_NO_MEMORY; } @@ -1194,7 +1194,7 @@ static NTSTATUS dcerpc_ndr_validate_in(struct dcerpc_connection *c, return ndr_map_error2ntstatus(ndr_err); } - push = ndr_push_init_ctx(mem_ctx); + push = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); if (!push) { return NT_STATUS_NO_MEMORY; } @@ -1252,7 +1252,7 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcerpc_connection *c, } memcpy(st, struct_ptr, struct_size); - push = ndr_push_init_ctx(mem_ctx); + push = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); if (!push) { return NT_STATUS_NO_MEMORY; } @@ -1283,7 +1283,7 @@ static NTSTATUS dcerpc_ndr_validate_out(struct dcerpc_connection *c, return ndr_map_error2ntstatus(ndr_err); } - push = ndr_push_init_ctx(mem_ctx); + push = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); if (!push) { return NT_STATUS_NO_MEMORY; } @@ -1354,7 +1354,7 @@ struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p, call = &table->calls[opnum]; /* setup for a ndr_push_* call */ - push = ndr_push_init_ctx(mem_ctx); + push = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); if (!push) { return NULL; } @@ -1521,10 +1521,13 @@ NTSTATUS dcerpc_ndr_request(struct dcerpc_pipe *p, */ const char *dcerpc_server_name(struct dcerpc_pipe *p) { - if (!p->conn->transport.peer_name) { - return ""; + if (!p->conn->transport.target_hostname) { + if (!p->conn->transport.peer_name) { + return ""; + } + return p->conn->transport.peer_name(p->conn); } - return p->conn->transport.peer_name(p->conn); + return p->conn->transport.target_hostname(p->conn); } diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h index ff827e50f2..9936ebe001 100644 --- a/source4/librpc/rpc/dcerpc.h +++ b/source4/librpc/rpc/dcerpc.h @@ -177,7 +177,7 @@ struct dcerpc_pipe_connect { const char *pipe_name; const struct ndr_interface_table *interface; struct cli_credentials *creds; - const char **name_resolve_order; + struct resolve_context *resolve_ctx; }; diff --git a/source4/librpc/rpc/dcerpc.py b/source4/librpc/rpc/dcerpc.py index b2edb17f33..da3664d80e 100644 --- a/source4/librpc/rpc/dcerpc.py +++ b/source4/librpc/rpc/dcerpc.py @@ -2,7 +2,6 @@ # Version 1.3.33 # # Don't modify this file, modify the SWIG interface instead. -# This file is compatible with both classic and new-style classes. import _dcerpc import new @@ -48,36 +47,40 @@ except AttributeError: del types -class Credentials(_object): - __swig_setmethods__ = {} - __setattr__ = lambda self, name, value: _swig_setattr(self, Credentials, name, value) - __swig_getmethods__ = {} - __getattr__ = lambda self, name: _swig_getattr(self, Credentials, name) +def _swig_setattr_nondynamic_method(set): + def set_attr(self,name,value): + if (name == "thisown"): return self.this.own(value) + if hasattr(self,name) or (name == "this"): + set(self,name,value) + else: + raise AttributeError("You cannot add attributes to %s" % self) + return set_attr + + +class Credentials(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') __repr__ = _swig_repr def __init__(self, *args, **kwargs): - this = _dcerpc.new_Credentials(*args, **kwargs) - try: self.this.append(this) - except: self.this = this + _dcerpc.Credentials_swiginit(self,_dcerpc.new_Credentials(*args, **kwargs)) __swig_destroy__ = _dcerpc.delete_Credentials - __del__ = lambda self : None; - def get_username(*args, **kwargs): return _dcerpc.Credentials_get_username(*args, **kwargs) - def set_username(*args, **kwargs): return _dcerpc.Credentials_set_username(*args, **kwargs) - def get_password(*args, **kwargs): return _dcerpc.Credentials_get_password(*args, **kwargs) - def set_password(*args, **kwargs): return _dcerpc.Credentials_set_password(*args, **kwargs) - def get_domain(*args, **kwargs): return _dcerpc.Credentials_get_domain(*args, **kwargs) - def set_domain(*args, **kwargs): return _dcerpc.Credentials_set_domain(*args, **kwargs) - def get_realm(*args, **kwargs): return _dcerpc.Credentials_get_realm(*args, **kwargs) - def set_realm(*args, **kwargs): return _dcerpc.Credentials_set_realm(*args, **kwargs) - def parse_string(*args, **kwargs): return _dcerpc.Credentials_parse_string(*args, **kwargs) - def get_bind_dn(*args, **kwargs): return _dcerpc.Credentials_get_bind_dn(*args, **kwargs) - def set_bind_dn(*args, **kwargs): return _dcerpc.Credentials_set_bind_dn(*args, **kwargs) - def get_workstation(*args, **kwargs): return _dcerpc.Credentials_get_workstation(*args, **kwargs) - def set_workstation(*args, **kwargs): return _dcerpc.Credentials_set_workstation(*args, **kwargs) - def guess(*args, **kwargs): return _dcerpc.Credentials_guess(*args, **kwargs) - def is_anonymous(*args, **kwargs): return _dcerpc.Credentials_is_anonymous(*args, **kwargs) - def get_nt_hash(*args, **kwargs): return _dcerpc.Credentials_get_nt_hash(*args, **kwargs) - def authentication_requested(*args, **kwargs): return _dcerpc.Credentials_authentication_requested(*args, **kwargs) - def wrong_password(*args, **kwargs): return _dcerpc.Credentials_wrong_password(*args, **kwargs) +Credentials.get_username = new_instancemethod(_dcerpc.Credentials_get_username,None,Credentials) +Credentials.set_username = new_instancemethod(_dcerpc.Credentials_set_username,None,Credentials) +Credentials.get_password = new_instancemethod(_dcerpc.Credentials_get_password,None,Credentials) +Credentials.set_password = new_instancemethod(_dcerpc.Credentials_set_password,None,Credentials) +Credentials.get_domain = new_instancemethod(_dcerpc.Credentials_get_domain,None,Credentials) +Credentials.set_domain = new_instancemethod(_dcerpc.Credentials_set_domain,None,Credentials) +Credentials.get_realm = new_instancemethod(_dcerpc.Credentials_get_realm,None,Credentials) +Credentials.set_realm = new_instancemethod(_dcerpc.Credentials_set_realm,None,Credentials) +Credentials.parse_string = new_instancemethod(_dcerpc.Credentials_parse_string,None,Credentials) +Credentials.get_bind_dn = new_instancemethod(_dcerpc.Credentials_get_bind_dn,None,Credentials) +Credentials.set_bind_dn = new_instancemethod(_dcerpc.Credentials_set_bind_dn,None,Credentials) +Credentials.get_workstation = new_instancemethod(_dcerpc.Credentials_get_workstation,None,Credentials) +Credentials.set_workstation = new_instancemethod(_dcerpc.Credentials_set_workstation,None,Credentials) +Credentials.guess = new_instancemethod(_dcerpc.Credentials_guess,None,Credentials) +Credentials.is_anonymous = new_instancemethod(_dcerpc.Credentials_is_anonymous,None,Credentials) +Credentials.get_nt_hash = new_instancemethod(_dcerpc.Credentials_get_nt_hash,None,Credentials) +Credentials.authentication_requested = new_instancemethod(_dcerpc.Credentials_authentication_requested,None,Credentials) +Credentials.wrong_password = new_instancemethod(_dcerpc.Credentials_wrong_password,None,Credentials) Credentials_swigregister = _dcerpc.Credentials_swigregister Credentials_swigregister(Credentials) diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index e6244fe229..8fd783fb83 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -32,6 +32,7 @@ #include "librpc/rpc/dcerpc.h" #include "auth/credentials/credentials.h" #include "param/param.h" +#include "libcli/resolve/resolve.h" struct pipe_np_smb_state { @@ -110,7 +111,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT /* prepare smb connection parameters: we're connecting to IPC$ share on remote rpc server */ conn->in.dest_host = s->io.binding->host; - conn->in.port = 0; + conn->in.dest_ports = lp_smb_ports(global_loadparm); if (s->io.binding->target_hostname == NULL) conn->in.called_name = "*SMBSERVER"; /* FIXME: This is invalid */ else @@ -236,7 +237,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send( /* send smb2 connect request */ conn_req = smb2_connect_send(mem_ctx, s->io.binding->host, "IPC$", - s->io.name_resolve_order, + s->io.resolve_ctx, s->io.creds, c->event_ctx); composite_continue(c, conn_req, continue_smb2_connect, c); @@ -308,7 +309,7 @@ static struct composite_context* dcerpc_pipe_connect_ncacn_ip_tcp_send(TALLOC_CT /* send pipe open request on tcp/ip */ pipe_req = dcerpc_pipe_open_tcp_send(s->io.pipe->conn, s->host, s->target_hostname, - s->port, io->name_resolve_order); + s->port, io->resolve_ctx); composite_continue(c, pipe_req, continue_pipe_open_ncacn_ip_tcp, c); return c; } @@ -521,7 +522,7 @@ static void continue_connect(struct composite_context *c, struct pipe_connect_st pc.binding = s->binding; pc.interface = s->table; pc.creds = s->credentials; - pc.name_resolve_order = lp_name_resolve_order(global_loadparm); + pc.resolve_ctx = lp_resolve_context(global_loadparm); /* connect dcerpc pipe depending on required transport */ switch (s->binding->transport) { diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c index 0aa38d55ed..5e8dd955d3 100644 --- a/source4/librpc/rpc/dcerpc_secondary.c +++ b/source4/librpc/rpc/dcerpc_secondary.c @@ -29,6 +29,7 @@ #include "librpc/rpc/dcerpc.h" #include "auth/credentials/credentials.h" #include "param/param.h" +#include "libcli/resolve/resolve.h" struct sec_conn_state { @@ -93,7 +94,7 @@ struct composite_context* dcerpc_secondary_connection_send(struct dcerpc_pipe *p s->binding->host, s->binding->target_hostname, atoi(s->binding->endpoint), - lp_name_resolve_order(global_loadparm)); + lp_resolve_context(global_loadparm)); composite_continue(c, pipe_tcp_req, continue_open_tcp, c); return c; diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 327b1bf419..2e5a8388a1 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -332,7 +332,8 @@ static struct composite_context *dcerpc_pipe_open_socket_send(TALLOC_CTX *mem_ct talloc_steal(s->sock, s->socket_ctx); - conn_req = socket_connect_send(s->socket_ctx, NULL, s->server, 0, lp_name_resolve_order(global_loadparm), + conn_req = socket_connect_send(s->socket_ctx, NULL, s->server, 0, + lp_resolve_context(global_loadparm), c->event_ctx); composite_continue(c, conn_req, continue_socket_connect, c); return c; @@ -454,7 +455,7 @@ struct composite_context* dcerpc_pipe_open_tcp_send(struct dcerpc_connection *co const char *server, const char *target_hostname, uint32_t port, - const char **name_resolve_order) + struct resolve_context *resolve_ctx) { struct composite_context *c; struct pipe_tcp_state *s; @@ -480,7 +481,7 @@ struct composite_context* dcerpc_pipe_open_tcp_send(struct dcerpc_connection *co s->conn = conn; make_nbt_name_server(&name, server); - resolve_req = resolve_name_send(&name, c->event_ctx, name_resolve_order); + resolve_req = resolve_name_send(resolve_ctx, &name, c->event_ctx); composite_continue(c, resolve_req, continue_ip_resolve_name, c); return c; } diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index 32cee4308e..ecc6f19e8c 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -56,7 +56,7 @@ NTSTATUS ncacn_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct ndr_push *ndr; enum ndr_err_code ndr_err; - ndr = ndr_push_init_ctx(mem_ctx); + ndr = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(global_loadparm)); if (!ndr) { return NT_STATUS_NO_MEMORY; } @@ -439,7 +439,7 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax) { TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data"); - struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx); + struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx, NULL); enum ndr_err_code ndr_err; uint16_t if_version=0; @@ -466,7 +466,7 @@ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_synta static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax) { - struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx); + struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL); ndr->flags |= LIBNDR_FLAG_NOALIGN; @@ -939,7 +939,6 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx, /* anonymous credentials for rpc connection used to get endpoint mapping */ anon_creds = cli_credentials_init(mem_ctx); cli_credentials_set_event_context(anon_creds, ev); - cli_credentials_set_conf(anon_creds, global_loadparm); cli_credentials_set_anonymous(anon_creds); /* diff --git a/source4/librpc/rpc/dcerpc_wrap.c b/source4/librpc/rpc/dcerpc_wrap.c index c9eb72fb9e..c60fef9e9d 100644 --- a/source4/librpc/rpc/dcerpc_wrap.c +++ b/source4/librpc/rpc/dcerpc_wrap.c @@ -9,7 +9,7 @@ * ----------------------------------------------------------------------------- */ #define SWIGPYTHON -#define SWIG_PYTHON_DIRECTOR_NO_VTABLE +#define SWIG_PYTHON_NO_BUILD_NONE /* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. @@ -2476,6 +2476,19 @@ static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0}; # error "This python version requires swig to be run with the '-classic' option" # endif #endif +#if (PY_VERSION_HEX <= 0x02020000) +# error "This python version requires swig to be run with the '-nomodern' option" +#endif +#if (PY_VERSION_HEX <= 0x02020000) +# error "This python version requires swig to be run with the '-nomodernargs' option" +#endif +#ifndef METH_O +# error "This python version requires swig to be run with the '-nofastunpack' option" +#endif +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery +#endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery /*----------------------------------------------- @(target):= _dcerpc.so @@ -2775,7 +2788,7 @@ SWIGINTERN PyObject *_wrap_new_Credentials(PyObject *SWIGUNUSEDPARM(self), PyObj PyObject *resultobj = 0; cli_credentials *result = 0 ; - if (!PyArg_ParseTuple(args,(char *)":new_Credentials")) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args,"new_Credentials",0,0,0)) SWIG_fail; result = (cli_credentials *)new_cli_credentials(); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_cli_credentials, SWIG_POINTER_NEW | 0 ); return resultobj; @@ -3535,11 +3548,15 @@ fail: SWIGINTERN PyObject *Credentials_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; - if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; SWIG_TypeNewClientData(SWIGTYPE_p_cli_credentials, SWIG_NewClientData(obj)); return SWIG_Py_Void(); } +SWIGINTERN PyObject *Credentials_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + SWIGINTERN PyObject *_wrap_pipe_connect(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ; @@ -3665,7 +3682,7 @@ fail: static PyMethodDef SwigMethods[] = { - { (char *)"new_Credentials", _wrap_new_Credentials, METH_VARARGS, NULL}, + { (char *)"new_Credentials", (PyCFunction)_wrap_new_Credentials, METH_NOARGS, NULL}, { (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, NULL}, @@ -3686,6 +3703,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"Credentials_authentication_requested", (PyCFunction) _wrap_Credentials_authentication_requested, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"Credentials_swigregister", Credentials_swigregister, METH_VARARGS, NULL}, + { (char *)"Credentials_swiginit", Credentials_swiginit, METH_VARARGS, NULL}, { (char *)"pipe_connect", (PyCFunction) _wrap_pipe_connect, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"dcerpc_server_name", (PyCFunction) _wrap_dcerpc_server_name, METH_VARARGS | METH_KEYWORDS, NULL}, { NULL, NULL, 0, NULL } diff --git a/source4/librpc/tools/ndrdump.c b/source4/librpc/tools/ndrdump.c index a86b349aa9..bc1436916f 100644 --- a/source4/librpc/tools/ndrdump.c +++ b/source4/librpc/tools/ndrdump.c @@ -25,6 +25,7 @@ #include "system/locale.h" #include "librpc/ndr/libndr.h" #include "librpc/ndr/ndr_table.h" +#include "param/param.h" #endif static const struct ndr_interface_call *find_function( @@ -303,7 +304,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) blob.data = data; blob.length = size; - ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_pull, NDR_IN, st); @@ -340,7 +341,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) blob.data = data; blob.length = size; - ndr_pull = ndr_pull_init_blob(&blob, mem_ctx); + ndr_pull = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_pull, flags, st); @@ -379,7 +380,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) uint8_t byte_a, byte_b; bool differ; - ndr_v_push = ndr_push_init_ctx(mem_ctx); + ndr_v_push = ndr_push_init_ctx(mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_err = f->ndr_push(ndr_v_push, flags, st); status = ndr_map_error2ntstatus(ndr_err); @@ -396,7 +397,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force) ndrdump_data(v_blob.data, v_blob.length, dumpdata); } - ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx); + ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx, lp_iconv_convenience(cmdline_lp_ctx)); ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC; ndr_err = f->ndr_pull(ndr_v_pull, flags, v_st); |