From a83f6314b64f25a201e1d4fd4766c957d5ca1035 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 17:33:19 +0100 Subject: Fix IDL for lsa_OpenAccount. Guenther (This used to be commit ad392fcf7847df151c2ba56668bfdd0bf1f93971) --- source3/librpc/idl/lsa.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index fc36689a19..dc1d1a1264 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -431,9 +431,9 @@ import "security.idl"; /* Function: 0x11 */ NTSTATUS lsa_OpenAccount ( [in] policy_handle *handle, - [in] dom_sid2 *sid, + [in,ref] dom_sid2 *sid, [in] uint32 access_mask, - [out] policy_handle *acct_handle + [out] policy_handle **acct_handle ); -- cgit From 026dddcbcd630a0f919af0e79fab9f8cf5c81e6c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 22:44:04 +0100 Subject: Re-run make idl. Guenther (This used to be commit eaead9ea470c296ff0ace353104a0ef31f11311c) --- source3/librpc/gen_ndr/cli_lsa.c | 2 +- source3/librpc/gen_ndr/cli_lsa.h | 2 +- source3/librpc/gen_ndr/lsa.h | 2 +- source3/librpc/gen_ndr/ndr_lsa.c | 27 ++++++++++++++++++++++++--- source3/librpc/gen_ndr/srv_lsa.c | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 227ae809c9..edc7549011 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -762,7 +762,7 @@ NTSTATUS rpccli_lsa_OpenAccount(struct rpc_pipe_client *cli, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t access_mask, - struct policy_handle *acct_handle) + struct policy_handle **acct_handle) { struct lsa_OpenAccount r; NTSTATUS status; diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index ec9abaf568..233154530f 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -95,7 +95,7 @@ NTSTATUS rpccli_lsa_OpenAccount(struct rpc_pipe_client *cli, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t access_mask, - struct policy_handle *acct_handle); + struct policy_handle **acct_handle); NTSTATUS rpccli_lsa_EnumPrivsAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 810ce945da..03ffdd08ab 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -829,7 +829,7 @@ struct lsa_OpenAccount { } in; struct { - struct policy_handle *acct_handle;/* [ref] */ + struct policy_handle **acct_handle;/* [ref] */ NTSTATUS result; } out; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 8c863085a9..4e23040151 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -6208,7 +6208,10 @@ static enum ndr_err_code ndr_push_lsa_OpenAccount(struct ndr_push *ndr, int flag if (r->out.acct_handle == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.acct_handle)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.acct_handle)); + if (*r->out.acct_handle) { + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.acct_handle)); + } NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -6216,9 +6219,11 @@ static enum ndr_err_code ndr_push_lsa_OpenAccount(struct ndr_push *ndr, int flag static enum ndr_err_code ndr_pull_lsa_OpenAccount(struct ndr_pull *ndr, int flags, struct lsa_OpenAccount *r) { + uint32_t _ptr_acct_handle; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_sid_0; TALLOC_CTX *_mem_save_acct_handle_0; + TALLOC_CTX *_mem_save_acct_handle_1; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -6246,7 +6251,18 @@ static enum ndr_err_code ndr_pull_lsa_OpenAccount(struct ndr_pull *ndr, int flag } _mem_save_acct_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.acct_handle, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.acct_handle)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_acct_handle)); + if (_ptr_acct_handle) { + NDR_PULL_ALLOC(ndr, *r->out.acct_handle); + } else { + *r->out.acct_handle = NULL; + } + if (*r->out.acct_handle) { + _mem_save_acct_handle_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.acct_handle, 0); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.acct_handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_acct_handle_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_acct_handle_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } @@ -6279,7 +6295,12 @@ _PUBLIC_ void ndr_print_lsa_OpenAccount(struct ndr_print *ndr, const char *name, ndr->depth++; ndr_print_ptr(ndr, "acct_handle", r->out.acct_handle); ndr->depth++; - ndr_print_policy_handle(ndr, "acct_handle", r->out.acct_handle); + ndr_print_ptr(ndr, "acct_handle", *r->out.acct_handle); + ndr->depth++; + if (*r->out.acct_handle) { + ndr_print_policy_handle(ndr, "acct_handle", *r->out.acct_handle); + } + ndr->depth--; ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index 9d41be35a8..f8ef1ad26b 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -1372,7 +1372,7 @@ static bool api_lsa_OpenAccount(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.acct_handle = talloc_zero(r, struct policy_handle); + r->out.acct_handle = talloc_zero(r, struct policy_handle *); if (r->out.acct_handle == NULL) { talloc_free(r); return false; -- cgit From 02abf612c8d7d6c9672df1f8ce02659737dc9254 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 19:19:29 +0100 Subject: Use pidl for _lsa_OpenAccount(). Guenther (This used to be commit e1968880a88ad2a56c5fef7d416646dcb96965ef) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 19 +++++++------------ 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5811d8535b..739508869e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -316,29 +316,7 @@ static bool api_lsa_create_account(pipes_struct *p) static bool api_lsa_open_account(pipes_struct *p) { - LSA_Q_OPENACCOUNT q_u; - LSA_R_OPENACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_open_account("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_open_account(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_account("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_OPENACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c197f20bfe..7b4de95ed6 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1655,16 +1655,17 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, /*************************************************************************** - Lsa Open Account + _lsa_OpenAccount ***************************************************************************/ -NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) +NTSTATUS _lsa_OpenAccount(pipes_struct *p, + struct lsa_OpenAccount *r) { struct lsa_info *handle; struct lsa_info *info; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1686,11 +1687,11 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = q_u->sid.sid; - info->access = q_u->access; + info->sid = *r->in.sid; + info->access = r->in.access_mask; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, *r->out.acct_handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -2240,12 +2241,6 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct lsa_OpenAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r) { p->rng_fault_state = True; -- cgit From ba00160eb865c93b5de3dc105260dda1fe2c952b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 19:31:00 +0100 Subject: Use rpccli_lsa_OpenAccount() in rpcclient. Guenther (This used to be commit 04d7977905d57dc2a45c221eee7f9edf659dbdf4) --- source3/rpcclient/cmd_lsarpc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index fb8ca76d3b..f71a6d6263 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -632,7 +632,7 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, const char **argv) { POLICY_HND dom_pol; - POLICY_HND user_pol; + POLICY_HND *user_pol = NULL; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32 access_desired = 0x000f000f; @@ -657,12 +657,16 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_open_account(cli, mem_ctx, &dom_pol, &sid, access_desired, &user_pol); + result = rpccli_lsa_OpenAccount(cli, mem_ctx, + &dom_pol, + &sid, + access_desired, + &user_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set); + result = rpccli_lsa_enum_privsaccount(cli, mem_ctx, user_pol, &count, &set); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From 5c23f7d73cfe96147c6b0d2069241b946843d5ec Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 19:34:40 +0100 Subject: Remove unused marshalling for LSA_OPENACCOUNT. Guenther (This used to be commit bb8e77eb74c9d178a6c77f2f9c69eb1778fb5e10) --- source3/include/rpc_lsa.h | 13 ---------- source3/rpc_client/cli_lsarpc.c | 38 ----------------------------- source3/rpc_parse/parse_lsa.c | 54 ----------------------------------------- 3 files changed, 105 deletions(-) diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index 902d1e20b2..ba1e5a3d57 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -689,19 +689,6 @@ typedef struct lsa_r_unk_get_connuser } LSA_R_UNK_GET_CONNUSER; -typedef struct lsa_q_openaccount -{ - POLICY_HND pol; /* policy handle */ - DOM_SID2 sid; - uint32 access; /* desired access */ -} LSA_Q_OPENACCOUNT; - -typedef struct lsa_r_openaccount -{ - POLICY_HND pol; /* policy handle */ - NTSTATUS status; -} LSA_R_OPENACCOUNT; - typedef struct lsa_q_enumprivsaccount { POLICY_HND pol; /* policy handle */ diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 514b8f5dfd..150d55d1c3 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -721,44 +721,6 @@ NTSTATUS rpccli_lsa_enum_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return result; } -/** Open a LSA user handle - * - * @param cli Handle on an initialised SMB connection */ - -NTSTATUS rpccli_lsa_open_account(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *dom_pol, DOM_SID *sid, uint32 des_access, - POLICY_HND *user_pol) -{ - prs_struct qbuf, rbuf; - LSA_Q_OPENACCOUNT q; - LSA_R_OPENACCOUNT r; - NTSTATUS result; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialise input parameters */ - - init_lsa_q_open_account(&q, dom_pol, sid, des_access); - - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_OPENACCOUNT, - q, r, - qbuf, rbuf, - lsa_io_q_open_account, - lsa_io_r_open_account, - NT_STATUS_UNSUCCESSFUL); - - /* Return output parameters */ - - result = r.status; - - if (NT_STATUS_IS_OK(result)) { - *user_pol = r.pol; - } - - return result; -} - /** Enumerate user privileges * * @param cli Handle on an initialised SMB connection */ diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index ef54b4a30d..4c13c58125 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -1985,60 +1985,6 @@ bool lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *out, pr return True; } -void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access) -{ - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - - init_dom_sid2(&trn->sid, sid); - trn->access = desired_access; -} - -/******************************************************************* - Reads or writes an LSA_Q_OPENACCOUNT structure. -********************************************************************/ - -bool lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_open_account"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */ - return False; - - if(!prs_uint32("access", ps, depth, &out->access)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_OPENACCOUNT structure. -********************************************************************/ - -bool lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_open_account"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - - void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd) { memcpy(&trn->pol, hnd, sizeof(trn->pol)); -- cgit From 61661480598cdb9ddd1fa27026947aff1834dd62 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:29:03 +0100 Subject: Fill in IDL for lsa_SetSystemAccessAccount (based from samba3) Guenther (This used to be commit 02c96047f1f37b213fe473cc8b2b1bc1459cc709) --- source3/librpc/idl/lsa.idl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index dc1d1a1264..54d9b2f1f0 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -481,8 +481,12 @@ import "security.idl"; /* Function: 0x17 */ NTSTATUS lsa_GetSystemAccessAccount(); + /* Function: 0x18 */ - NTSTATUS lsa_SetSystemAccessAccount(); + NTSTATUS lsa_SetSystemAccessAccount( + [in] policy_handle *handle, + [in] uint32 access_mask + ); /* Function: 0x19 */ NTSTATUS lsa_OpenTrustedDomain( -- cgit From 023ea6fe026a1c355fef54fdaa3c6290cdead1f3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 22:51:34 +0100 Subject: Re-run make idl. Guenther (This used to be commit 71bc06fd5581aeb02f91aeae68d9572452b8ac1e) --- source3/librpc/gen_ndr/cli_lsa.c | 6 +++++- source3/librpc/gen_ndr/cli_lsa.h | 4 +++- source3/librpc/gen_ndr/lsa.h | 5 +++++ source3/librpc/gen_ndr/ndr_lsa.c | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index edc7549011..779f3e73aa 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -1041,12 +1041,16 @@ NTSTATUS rpccli_lsa_GetSystemAccessAccount(struct rpc_pipe_client *cli, } NTSTATUS rpccli_lsa_SetSystemAccessAccount(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t access_mask) { struct lsa_SetSystemAccessAccount r; NTSTATUS status; /* In parameters */ + r.in.handle = handle; + r.in.access_mask = access_mask; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_SetSystemAccessAccount, &r); diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index 233154530f..26a37de7c7 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -116,7 +116,9 @@ NTSTATUS rpccli_lsa_SetQuotasForAccount(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_GetSystemAccessAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_lsa_SetSystemAccessAccount(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t access_mask); NTSTATUS rpccli_lsa_OpenTrustedDomain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 03ffdd08ab..131110c8e8 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -901,6 +901,11 @@ struct lsa_GetSystemAccessAccount { struct lsa_SetSystemAccessAccount { + struct { + struct policy_handle *handle;/* [ref] */ + uint32_t access_mask; + } in; + struct { NTSTATUS result; } out; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 4e23040151..8ca4b65f0a 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -6674,6 +6674,11 @@ _PUBLIC_ void ndr_print_lsa_GetSystemAccessAccount(struct ndr_print *ndr, const static enum ndr_err_code ndr_push_lsa_SetSystemAccessAccount(struct ndr_push *ndr, int flags, const struct lsa_SetSystemAccessAccount *r) { if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); @@ -6683,7 +6688,16 @@ static enum ndr_err_code ndr_push_lsa_SetSystemAccessAccount(struct ndr_push *nd static enum ndr_err_code ndr_pull_lsa_SetSystemAccessAccount(struct ndr_pull *ndr, int flags, struct lsa_SetSystemAccessAccount *r) { + TALLOC_CTX *_mem_save_handle_0; if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); } if (flags & NDR_OUT) { NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); @@ -6701,6 +6715,11 @@ _PUBLIC_ void ndr_print_lsa_SetSystemAccessAccount(struct ndr_print *ndr, const if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_SetSystemAccessAccount"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "access_mask", r->in.access_mask); ndr->depth--; } if (flags & NDR_OUT) { -- cgit From 9049db8ffb88508e73849d3c40ac93907c58fb80 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:32:05 +0100 Subject: Use pidl for _lsa_SetSystemAccessAccount(). Guenther (This used to be commit 478612b79d11fa1ad3bf16e317d63c2a00e1957a) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 12 +++--------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 739508869e..057c8f691c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -388,29 +388,7 @@ static bool api_lsa_getsystemaccount(pipes_struct *p) static bool api_lsa_setsystemaccount(pipes_struct *p) { - LSA_Q_SETSYSTEMACCOUNT q_u; - LSA_R_SETSYSTEMACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_SETSYSTEMACCESSACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7b4de95ed6..dd1ee3d357 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1766,14 +1766,14 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA update the systemaccount information ***************************************************************************/ -NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA_R_SETSYSTEMACCOUNT *r_u) +NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, + struct lsa_SetSystemAccessAccount *r) { struct lsa_info *info=NULL; GROUP_MAP map; - r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -2277,12 +2277,6 @@ NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccess return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, struct lsa_SetSystemAccessAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r) { p->rng_fault_state = True; -- cgit From 5120373cc8d22a26502d0d74cea9f9b473080129 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:33:41 +0100 Subject: Remove unused marshalling for LSA_SETSYSTEMACCOUNT. Guenther (This used to be commit ddefdc5bd70620dcb94660ba5d55520e136d8d0f) --- source3/include/rpc_lsa.h | 11 ----------- source3/rpc_parse/parse_lsa.c | 40 ---------------------------------------- 2 files changed, 51 deletions(-) diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index ba1e5a3d57..a4c855a11f 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -714,17 +714,6 @@ typedef struct lsa_r_getsystemaccount } LSA_R_GETSYSTEMACCOUNT; -typedef struct lsa_q_setsystemaccount -{ - POLICY_HND pol; /* policy handle */ - uint32 access; -} LSA_Q_SETSYSTEMACCOUNT; - -typedef struct lsa_r_setsystemaccount -{ - NTSTATUS status; -} LSA_R_SETSYSTEMACCOUNT; - typedef struct { UNIHDR hdr; UNISTR2 unistring; diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 4c13c58125..0e4cc9fb2e 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -2180,46 +2180,6 @@ bool lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *out, p } -/******************************************************************* - Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure. -********************************************************************/ - -bool lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - if(!prs_uint32("access", ps, depth, &out->access)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_SETSYSTEMACCOUNT structure. -********************************************************************/ - -bool lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - - void init_lsa_string( LSA_STRING *uni, const char *string ) { init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE); -- cgit From 5bece0e1e181ab0ef7f0532feb75bebefb260d94 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:36:19 +0100 Subject: Fill in IDL for lsa_GetSystemAccessAccount (based on samba3). Guenther (This used to be commit ac21838d74fa51a73c93272a2be8fac0bc492b49) --- source3/librpc/idl/lsa.idl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 54d9b2f1f0..9db4c83211 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -480,7 +480,10 @@ import "security.idl"; NTSTATUS lsa_SetQuotasForAccount(); /* Function: 0x17 */ - NTSTATUS lsa_GetSystemAccessAccount(); + NTSTATUS lsa_GetSystemAccessAccount( + [in] policy_handle *handle, + [out,ref] uint32 *access_mask + ); /* Function: 0x18 */ NTSTATUS lsa_SetSystemAccessAccount( -- cgit From 5431ff4f6673be3aad3f6b230b5b9aa5a3591d0f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 22:54:28 +0100 Subject: Re-run make idl. Guenther (This used to be commit 5af6bf31d515c18b0b53237bf78f6c65c2606ca5) --- source3/librpc/gen_ndr/cli_lsa.c | 6 +++++- source3/librpc/gen_ndr/cli_lsa.h | 4 +++- source3/librpc/gen_ndr/lsa.h | 5 +++++ source3/librpc/gen_ndr/ndr_lsa.c | 36 ++++++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/srv_lsa.c | 7 +++++++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 779f3e73aa..9f963db49a 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -1004,12 +1004,15 @@ NTSTATUS rpccli_lsa_SetQuotasForAccount(struct rpc_pipe_client *cli, } NTSTATUS rpccli_lsa_GetSystemAccessAccount(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t *access_mask) { struct lsa_GetSystemAccessAccount r; NTSTATUS status; /* In parameters */ + r.in.handle = handle; if (DEBUGLEVEL >= 10) { NDR_PRINT_IN_DEBUG(lsa_GetSystemAccessAccount, &r); @@ -1035,6 +1038,7 @@ NTSTATUS rpccli_lsa_GetSystemAccessAccount(struct rpc_pipe_client *cli, } /* Return variables */ + *access_mask = *r.out.access_mask; /* Return result */ return r.out.result; diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index 26a37de7c7..63e4d0288d 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -114,7 +114,9 @@ NTSTATUS rpccli_lsa_GetQuotasForAccount(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_SetQuotasForAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_lsa_GetSystemAccessAccount(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx); + TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + uint32_t *access_mask); NTSTATUS rpccli_lsa_SetSystemAccessAccount(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 131110c8e8..8c2bab164d 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -894,6 +894,11 @@ struct lsa_SetQuotasForAccount { struct lsa_GetSystemAccessAccount { struct { + struct policy_handle *handle;/* [ref] */ + } in; + + struct { + uint32_t *access_mask;/* [ref] */ NTSTATUS result; } out; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 8ca4b65f0a..0d477eea6e 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -6633,8 +6633,16 @@ _PUBLIC_ void ndr_print_lsa_SetQuotasForAccount(struct ndr_print *ndr, const cha static enum ndr_err_code ndr_push_lsa_GetSystemAccessAccount(struct ndr_push *ndr, int flags, const struct lsa_GetSystemAccessAccount *r) { if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); } if (flags & NDR_OUT) { + if (r->out.access_mask == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.access_mask)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -6642,9 +6650,29 @@ static enum ndr_err_code ndr_push_lsa_GetSystemAccessAccount(struct ndr_push *nd static enum ndr_err_code ndr_pull_lsa_GetSystemAccessAccount(struct ndr_pull *ndr, int flags, struct lsa_GetSystemAccessAccount *r) { + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_access_mask_0; if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.access_mask); + ZERO_STRUCTP(r->out.access_mask); } if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.access_mask); + } + _mem_save_access_mask_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.access_mask, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.access_mask)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_access_mask_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -6660,11 +6688,19 @@ _PUBLIC_ void ndr_print_lsa_GetSystemAccessAccount(struct ndr_print *ndr, const if (flags & NDR_IN) { ndr_print_struct(ndr, "in", "lsa_GetSystemAccessAccount"); ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "lsa_GetSystemAccessAccount"); ndr->depth++; + ndr_print_ptr(ndr, "access_mask", r->out.access_mask); + ndr->depth++; + ndr_print_uint32(ndr, "access_mask", *r->out.access_mask); + ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; } diff --git a/source3/librpc/gen_ndr/srv_lsa.c b/source3/librpc/gen_ndr/srv_lsa.c index f8ef1ad26b..874cf4c410 100644 --- a/source3/librpc/gen_ndr/srv_lsa.c +++ b/source3/librpc/gen_ndr/srv_lsa.c @@ -1823,6 +1823,13 @@ static bool api_lsa_GetSystemAccessAccount(pipes_struct *p) NDR_PRINT_IN_DEBUG(lsa_GetSystemAccessAccount, r); } + ZERO_STRUCT(r->out); + r->out.access_mask = talloc_zero(r, uint32_t); + if (r->out.access_mask == NULL) { + talloc_free(r); + return false; + } + r->out.result = _lsa_GetSystemAccessAccount(p, r); if (p->rng_fault_state) { -- cgit From 3dab928081bf80cb88fa4a56352ae063a5f82a43 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:54:02 +0100 Subject: Use pidl for _lsa_GetSystemAccessAccount(). Guenther (This used to be commit aaf662a724f1bae5333666caf8b2fbe908f13992) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 057c8f691c..24bc65c51a 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -356,29 +356,7 @@ static bool api_lsa_enum_privsaccount(pipes_struct *p) static bool api_lsa_getsystemaccount(pipes_struct *p) { - LSA_Q_GETSYSTEMACCOUNT q_u; - LSA_R_GETSYSTEMACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_GETSYSTEMACCESSACCOUNT); } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index dd1ee3d357..247a52df46 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1733,16 +1733,17 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVS } /*************************************************************************** - + _lsa_GetSystemAccessAccount ***************************************************************************/ -NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) +NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, + struct lsa_GetSystemAccessAccount *r) { struct lsa_info *info=NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL)) @@ -1757,7 +1758,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA they can be ORed together */ - r_u->access = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK; + *r->out.access_mask = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK; return NT_STATUS_OK; } @@ -2271,12 +2272,6 @@ NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccoun return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccessAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r) { p->rng_fault_state = True; -- cgit From 7a425d69dd0953620a6fe289d52ba4ad673a6d97 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:54:38 +0100 Subject: Remove unused marshalling for LSA_GETSYSTEMACCOUNT. Guenther (This used to be commit cf3a76bf19bfeb35800e0fc31e90dc4ea5c0ff85) --- source3/include/rpc_lsa.h | 12 ------------ source3/rpc_parse/parse_lsa.c | 42 ------------------------------------------ 2 files changed, 54 deletions(-) diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h index a4c855a11f..5cdcd21251 100644 --- a/source3/include/rpc_lsa.h +++ b/source3/include/rpc_lsa.h @@ -702,18 +702,6 @@ typedef struct lsa_r_enumprivsaccount NTSTATUS status; } LSA_R_ENUMPRIVSACCOUNT; -typedef struct lsa_q_getsystemaccount -{ - POLICY_HND pol; /* policy handle */ -} LSA_Q_GETSYSTEMACCOUNT; - -typedef struct lsa_r_getsystemaccount -{ - uint32 access; - NTSTATUS status; -} LSA_R_GETSYSTEMACCOUNT; - - typedef struct { UNIHDR hdr; UNISTR2 unistring; diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index 0e4cc9fb2e..5f22a28082 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -2138,48 +2138,6 @@ bool lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, p return True; } - - -/******************************************************************* - Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure. -********************************************************************/ - -bool lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure. -********************************************************************/ - -bool lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("access", ps, depth, &out->access)) - return False; - - if(!prs_ntstatus("status", ps, depth, &out->status)) - return False; - - return True; -} - - void init_lsa_string( LSA_STRING *uni, const char *string ) { init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE); -- cgit From 14774d17ecefcc0fd5e39a77fa8d505a9ed5f541 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 17:58:52 +0100 Subject: Fix IDL for lsa_QueryTrustedDomainInfoByName. Guenther (This used to be commit 1a84985e0267b82318cfab4cb32a9d5a48e551a9) --- source3/librpc/idl/lsa.idl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source3/librpc/idl/lsa.idl b/source3/librpc/idl/lsa.idl index 9db4c83211..df1da31c97 100644 --- a/source3/librpc/idl/lsa.idl +++ b/source3/librpc/idl/lsa.idl @@ -771,10 +771,10 @@ import "security.idl"; /**********************/ /* Function 0x30 */ NTSTATUS lsa_QueryTrustedDomainInfoByName( - [in] policy_handle *handle, - [in] lsa_String trusted_domain, - [in] lsa_TrustDomInfoEnum level, - [out,unique,switch_is(level)] lsa_TrustedDomainInfo *info + [in] policy_handle *handle, + [in,ref] lsa_String *trusted_domain, + [in] lsa_TrustDomInfoEnum level, + [out,ref,switch_is(level)] lsa_TrustedDomainInfo *info ); /**********************/ -- cgit From 96e41bbf61101519b6b37a5a4bf5e723b4464bdc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 22:57:47 +0100 Subject: Re-run make idl. Guenther (This used to be commit 0bfaf68e9fa6345511623132917debe2016cf29a) --- source3/librpc/gen_ndr/cli_lsa.c | 6 ++--- source3/librpc/gen_ndr/cli_lsa.h | 2 +- source3/librpc/gen_ndr/lsa.h | 4 +-- source3/librpc/gen_ndr/ndr_lsa.c | 53 +++++++++++++++++++++++----------------- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_lsa.c b/source3/librpc/gen_ndr/cli_lsa.c index 9f963db49a..64da84d55f 100644 --- a/source3/librpc/gen_ndr/cli_lsa.c +++ b/source3/librpc/gen_ndr/cli_lsa.c @@ -2093,7 +2093,7 @@ NTSTATUS rpccli_lsa_SetInfoPolicy2(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_QueryTrustedDomainInfoByName(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, - struct lsa_String trusted_domain, + struct lsa_String *trusted_domain, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) { @@ -2129,9 +2129,7 @@ NTSTATUS rpccli_lsa_QueryTrustedDomainInfoByName(struct rpc_pipe_client *cli, } /* Return variables */ - if (info && r.out.info) { - *info = *r.out.info; - } + *info = *r.out.info; /* Return result */ return r.out.result; diff --git a/source3/librpc/gen_ndr/cli_lsa.h b/source3/librpc/gen_ndr/cli_lsa.h index 63e4d0288d..396debaca8 100644 --- a/source3/librpc/gen_ndr/cli_lsa.h +++ b/source3/librpc/gen_ndr/cli_lsa.h @@ -233,7 +233,7 @@ NTSTATUS rpccli_lsa_SetInfoPolicy2(struct rpc_pipe_client *cli, NTSTATUS rpccli_lsa_QueryTrustedDomainInfoByName(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, - struct lsa_String trusted_domain, + struct lsa_String *trusted_domain, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info); NTSTATUS rpccli_lsa_SetTrustedDomainInfoByName(struct rpc_pipe_client *cli, diff --git a/source3/librpc/gen_ndr/lsa.h b/source3/librpc/gen_ndr/lsa.h index 8c2bab164d..06f714acc8 100644 --- a/source3/librpc/gen_ndr/lsa.h +++ b/source3/librpc/gen_ndr/lsa.h @@ -1233,12 +1233,12 @@ struct lsa_SetInfoPolicy2 { struct lsa_QueryTrustedDomainInfoByName { struct { struct policy_handle *handle;/* [ref] */ - struct lsa_String trusted_domain; + struct lsa_String *trusted_domain;/* [ref] */ enum lsa_TrustDomInfoEnum level; } in; struct { - union lsa_TrustedDomainInfo *info;/* [unique,switch_is(level)] */ + union lsa_TrustedDomainInfo *info;/* [ref,switch_is(level)] */ NTSTATUS result; } out; diff --git a/source3/librpc/gen_ndr/ndr_lsa.c b/source3/librpc/gen_ndr/ndr_lsa.c index 0d477eea6e..5ac4cbcb59 100644 --- a/source3/librpc/gen_ndr/ndr_lsa.c +++ b/source3/librpc/gen_ndr/ndr_lsa.c @@ -9014,15 +9014,18 @@ static enum ndr_err_code ndr_push_lsa_QueryTrustedDomainInfoByName(struct ndr_pu return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); - NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.trusted_domain)); + if (r->in.trusted_domain == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.trusted_domain)); NDR_CHECK(ndr_push_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, r->in.level)); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); - if (r->out.info) { - NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.info, r->in.level)); - NDR_CHECK(ndr_push_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + if (r->out.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } + NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.info, r->in.level)); + NDR_CHECK(ndr_push_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info)); NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -9030,8 +9033,8 @@ static enum ndr_err_code ndr_push_lsa_QueryTrustedDomainInfoByName(struct ndr_pu static enum ndr_err_code ndr_pull_lsa_QueryTrustedDomainInfoByName(struct ndr_pull *ndr, int flags, struct lsa_QueryTrustedDomainInfoByName *r) { - uint32_t _ptr_info; TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_trusted_domain_0; TALLOC_CTX *_mem_save_info_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -9043,23 +9046,26 @@ static enum ndr_err_code ndr_pull_lsa_QueryTrustedDomainInfoByName(struct ndr_pu NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.handle)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.trusted_domain)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.trusted_domain); + } + _mem_save_trusted_domain_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.trusted_domain, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.trusted_domain)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_trusted_domain_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_lsa_TrustDomInfoEnum(ndr, NDR_SCALARS, &r->in.level)); + NDR_PULL_ALLOC(ndr, r->out.info); + ZERO_STRUCTP(r->out.info); } if (flags & NDR_OUT) { - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); - if (_ptr_info) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.info); - } else { - r->out.info = NULL; - } - if (r->out.info) { - _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); - NDR_CHECK(ndr_pull_set_switch_value(ndr, r->out.info, r->in.level)); - NDR_CHECK(ndr_pull_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->out.info, r->in.level)); + NDR_CHECK(ndr_pull_lsa_TrustedDomainInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); } return NDR_ERR_SUCCESS; @@ -9079,7 +9085,10 @@ _PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfoByName(struct ndr_print *ndr, ndr->depth++; ndr_print_policy_handle(ndr, "handle", r->in.handle); ndr->depth--; - ndr_print_lsa_String(ndr, "trusted_domain", &r->in.trusted_domain); + ndr_print_ptr(ndr, "trusted_domain", r->in.trusted_domain); + ndr->depth++; + ndr_print_lsa_String(ndr, "trusted_domain", r->in.trusted_domain); + ndr->depth--; ndr_print_lsa_TrustDomInfoEnum(ndr, "level", r->in.level); ndr->depth--; } @@ -9088,10 +9097,8 @@ _PUBLIC_ void ndr_print_lsa_QueryTrustedDomainInfoByName(struct ndr_print *ndr, ndr->depth++; ndr_print_ptr(ndr, "info", r->out.info); ndr->depth++; - if (r->out.info) { - ndr_print_set_switch_value(ndr, r->out.info, r->in.level); - ndr_print_lsa_TrustedDomainInfo(ndr, "info", r->out.info); - } + ndr_print_set_switch_value(ndr, r->out.info, r->in.level); + ndr_print_lsa_TrustedDomainInfo(ndr, "info", r->out.info); ndr->depth--; ndr_print_NTSTATUS(ndr, "result", r->out.result); ndr->depth--; -- cgit From 2b1d74981b435da3e48ae4b5652020147b54ae8b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:02:57 +0100 Subject: Fix rpccli_lsa_QueryTrustedDomainInfoByName() caller in rpcclient. Guenther (This used to be commit bdda909777dac08977a1d484d4e6e15e5dbfbba6) --- source3/rpcclient/cmd_lsarpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index f71a6d6263..54791f143c 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -1012,7 +1012,7 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli, result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx, &pol, - trusted_domain, + &trusted_domain, info_class, &info); if (!NT_STATUS_IS_OK(result)) -- cgit From 13d9373019bf9ef49c70f6c43f3e67229668739e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 22:26:42 +0100 Subject: Fix IDL for samr_EnumDomains. Guenther (This used to be commit 911b5f1feb08840198f57f361bcd2b19d9f3bf0d) --- source3/librpc/idl/samr.idl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/librpc/idl/samr.idl b/source3/librpc/idl/samr.idl index 1c18b2604f..6841420151 100644 --- a/source3/librpc/idl/samr.idl +++ b/source3/librpc/idl/samr.idl @@ -160,10 +160,10 @@ import "misc.idl", "lsa.idl", "security.idl"; } samr_SamArray; NTSTATUS samr_EnumDomains ( - [in,ref] policy_handle *connect_handle, + [in] policy_handle *connect_handle, [in,out,ref] uint32 *resume_handle, + [out,ref] samr_SamArray **sam, [in] uint32 buf_size, - [out,ref] samr_SamArray *sam, [out,ref] uint32 *num_entries ); -- cgit From b98f927fabb7218ac84e0c888707f5ef2a86286e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 23:01:09 +0100 Subject: Re-run make idl. Guenther (This used to be commit 10ce833cf0413811db13d9849b9c23fcc27f4526) --- source3/librpc/gen_ndr/cli_samr.c | 2 +- source3/librpc/gen_ndr/cli_samr.h | 2 +- source3/librpc/gen_ndr/ndr_samr.c | 27 ++++++++++++++++++++++++--- source3/librpc/gen_ndr/samr.h | 2 +- source3/librpc/gen_ndr/srv_samr.c | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_samr.c b/source3/librpc/gen_ndr/cli_samr.c index c3cb5ad273..efedb00078 100644 --- a/source3/librpc/gen_ndr/cli_samr.c +++ b/source3/librpc/gen_ndr/cli_samr.c @@ -261,8 +261,8 @@ NTSTATUS rpccli_samr_EnumDomains(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *connect_handle, uint32_t *resume_handle, + struct samr_SamArray **sam, uint32_t buf_size, - struct samr_SamArray *sam, uint32_t *num_entries) { struct samr_EnumDomains r; diff --git a/source3/librpc/gen_ndr/cli_samr.h b/source3/librpc/gen_ndr/cli_samr.h index 5df5e3a70c..9eac177001 100644 --- a/source3/librpc/gen_ndr/cli_samr.h +++ b/source3/librpc/gen_ndr/cli_samr.h @@ -31,8 +31,8 @@ NTSTATUS rpccli_samr_EnumDomains(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *connect_handle, uint32_t *resume_handle, + struct samr_SamArray **sam, uint32_t buf_size, - struct samr_SamArray *sam, uint32_t *num_entries); NTSTATUS rpccli_samr_OpenDomain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_samr.c b/source3/librpc/gen_ndr/ndr_samr.c index f257c17864..8c97ea1d95 100644 --- a/source3/librpc/gen_ndr/ndr_samr.c +++ b/source3/librpc/gen_ndr/ndr_samr.c @@ -5788,7 +5788,10 @@ static enum ndr_err_code ndr_push_samr_EnumDomains(struct ndr_push *ndr, int fla if (r->out.sam == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_samr_SamArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sam)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.sam)); + if (*r->out.sam) { + NDR_CHECK(ndr_push_samr_SamArray(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sam)); + } if (r->out.num_entries == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -5800,9 +5803,11 @@ static enum ndr_err_code ndr_push_samr_EnumDomains(struct ndr_push *ndr, int fla static enum ndr_err_code ndr_pull_samr_EnumDomains(struct ndr_pull *ndr, int flags, struct samr_EnumDomains *r) { + uint32_t _ptr_sam; TALLOC_CTX *_mem_save_connect_handle_0; TALLOC_CTX *_mem_save_resume_handle_0; TALLOC_CTX *_mem_save_sam_0; + TALLOC_CTX *_mem_save_sam_1; TALLOC_CTX *_mem_save_num_entries_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -5842,7 +5847,18 @@ static enum ndr_err_code ndr_pull_samr_EnumDomains(struct ndr_pull *ndr, int fla } _mem_save_sam_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.sam, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_samr_SamArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.sam)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sam)); + if (_ptr_sam) { + NDR_PULL_ALLOC(ndr, *r->out.sam); + } else { + *r->out.sam = NULL; + } + if (*r->out.sam) { + _mem_save_sam_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.sam, 0); + NDR_CHECK(ndr_pull_samr_SamArray(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.sam)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sam_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sam_0, LIBNDR_FLAG_REF_ALLOC); if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.num_entries); @@ -5886,7 +5902,12 @@ _PUBLIC_ void ndr_print_samr_EnumDomains(struct ndr_print *ndr, const char *name ndr->depth--; ndr_print_ptr(ndr, "sam", r->out.sam); ndr->depth++; - ndr_print_samr_SamArray(ndr, "sam", r->out.sam); + ndr_print_ptr(ndr, "sam", *r->out.sam); + ndr->depth++; + if (*r->out.sam) { + ndr_print_samr_SamArray(ndr, "sam", *r->out.sam); + } + ndr->depth--; ndr->depth--; ndr_print_ptr(ndr, "num_entries", r->out.num_entries); ndr->depth++; diff --git a/source3/librpc/gen_ndr/samr.h b/source3/librpc/gen_ndr/samr.h index 376feae5d1..2d6126a3f4 100644 --- a/source3/librpc/gen_ndr/samr.h +++ b/source3/librpc/gen_ndr/samr.h @@ -837,7 +837,7 @@ struct samr_EnumDomains { } in; struct { - struct samr_SamArray *sam;/* [ref] */ + struct samr_SamArray **sam;/* [ref] */ uint32_t *num_entries;/* [ref] */ uint32_t *resume_handle;/* [ref] */ NTSTATUS result; diff --git a/source3/librpc/gen_ndr/srv_samr.c b/source3/librpc/gen_ndr/srv_samr.c index 374df34a96..3312964178 100644 --- a/source3/librpc/gen_ndr/srv_samr.c +++ b/source3/librpc/gen_ndr/srv_samr.c @@ -507,7 +507,7 @@ static bool api_samr_EnumDomains(pipes_struct *p) ZERO_STRUCT(r->out); r->out.resume_handle = r->in.resume_handle; - r->out.sam = talloc_zero(r, struct samr_SamArray); + r->out.sam = talloc_zero(r, struct samr_SamArray *); if (r->out.sam == NULL) { talloc_free(r); return false; -- cgit From ab346de34029e423f54bb7d902fc6d2ceef2ce5f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 20:26:54 +0100 Subject: Add cmd_samr_enum_domains command to rpcclient. Guenther (This used to be commit f429153de299a1144bdf4fc4f9753fff0140c3bf) --- source3/rpcclient/cmd_samr.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index edc3c9d4b2..5170fb37bb 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1046,6 +1046,72 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli, return result; } +/* Enumerate domains */ + +static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + POLICY_HND connect_pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + uint32 start_idx, size, num_entries, i; + uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + bool got_connect_pol = false; + struct samr_SamArray *sam = NULL; + + if ((argc < 1) || (argc > 2)) { + printf("Usage: %s [access mask]\n", argv[0]); + return NT_STATUS_OK; + } + + if (argc > 2) { + sscanf(argv[2], "%x", &access_mask); + } + + /* Get sam policy handle */ + + result = try_samr_connects(cli, mem_ctx, + access_mask, + &connect_pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + got_connect_pol = true; + + /* Enumerate alias groups */ + + start_idx = 0; + size = 0xffff; + + do { + result = rpccli_samr_EnumDomains(cli, mem_ctx, + &connect_pol, + &start_idx, + &sam, + size, + &num_entries); + + if (NT_STATUS_IS_OK(result) || + NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) { + + for (i = 0; i < num_entries; i++) + printf("name:[%s] idx:[0x%x]\n", + sam->entries[i].name.string, + sam->entries[i].idx); + } + } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)); + + done: + if (got_connect_pol) { + rpccli_samr_Close(cli, mem_ctx, &connect_pol); + } + + return result; +} + + /* Query alias membership */ static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli, @@ -2485,6 +2551,7 @@ struct cmd_set samr_commands[] = { { "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" }, { "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" }, { "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, NULL, "Enumerate alias groups", "" }, + { "enumdomains", RPC_RTYPE_NTSTATUS, cmd_samr_enum_domains, NULL, PI_SAMR, NULL, "Enumerate domains", "" }, { "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, NULL, "Create domain user", "" }, { "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, NULL, "Create domain group", "" }, -- cgit From f621c1a9ab2344cd8548c676e1e15d6d04915b82 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 19:42:23 +0100 Subject: Pure cosmetics, breaking some very long lines. Guenther (This used to be commit 25c030136f62e48471acc0492907ac44e4316e19) --- source3/rpc_server/srv_samr_nt.c | 88 ++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9ed7014bff..4c242dc323 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -586,8 +586,9 @@ NTSTATUS _samr_OpenDomain(pipes_struct *p, if ( !find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info) ) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function( info->acc_granted, - SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_OpenDomain" ); + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_SAM_OPEN_DOMAIN, + "_samr_OpenDomain" ); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -728,7 +729,9 @@ NTSTATUS _samr_SetSecurity(pipes_struct *p, return NT_STATUS_ACCESS_DENIED; } - status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_SetSecurity"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_USER_SET_ATTRIBUTES, + "_samr_SetSecurity"); if (NT_STATUS_IS_OK(status)) { become_root(); status = pdb_update_sam_account(sampass); @@ -1550,9 +1553,9 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, /******************************************************************* _samr_ChangePasswordUser2 ********************************************************************/ + NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, struct samr_ChangePasswordUser2 *r) - { NTSTATUS status; fstring user_name; @@ -1577,8 +1580,12 @@ NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, * is case insensitive. */ - status = pass_oem_change(user_name, r->in.lm_password->data, r->in.lm_verifier->hash, - r->in.nt_password->data, r->in.nt_verifier->hash, NULL); + status = pass_oem_change(user_name, + r->in.lm_password->data, + r->in.lm_verifier->hash, + r->in.nt_password->data, + r->in.nt_verifier->hash, + NULL); DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__)); @@ -1825,8 +1832,9 @@ NTSTATUS _samr_OpenUser(pipes_struct *p, if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; - nt_status = access_check_samr_function( acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenUser" ); + nt_status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_OpenUser" ); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -2940,6 +2948,7 @@ NTSTATUS _samr_Connect5(pipes_struct *p, /********************************************************************** _samr_LookupDomain **********************************************************************/ + NTSTATUS _samr_LookupDomain(pipes_struct *p, struct samr_LookupDomain *r) { @@ -3079,7 +3088,8 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenAlias"); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_OpenAlias"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -3894,8 +3904,12 @@ NTSTATUS _samr_GetAliasMembership(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_GetAliasMembership"); - ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_GetAliasMembership"); + ntstatus1 = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, + "_samr_GetAliasMembership"); + ntstatus2 = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_GetAliasMembership"); if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && @@ -3960,7 +3974,9 @@ NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_GetMembersInAlias"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_GET_MEMBERS, + "_samr_GetMembersInAlias"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4026,7 +4042,9 @@ NTSTATUS _samr_QueryGroupMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_QueryGroupMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_GET_MEMBERS, + "_samr_QueryGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4088,7 +4106,9 @@ NTSTATUS _samr_AddAliasMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_AddAliasMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_ADD_MEMBER, + "_samr_AddAliasMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4135,7 +4155,9 @@ NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_DeleteAliasMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_REMOVE_MEMBER, + "_samr_DeleteAliasMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4184,7 +4206,9 @@ NTSTATUS _samr_AddGroupMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_AddGroupMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_ADD_MEMBER, + "_samr_AddGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4242,7 +4266,9 @@ NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_DeleteGroupMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_REMOVE_MEMBER, + "_samr_DeleteGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4294,7 +4320,9 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &user_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteUser"); + status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_DeleteUser"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4379,7 +4407,9 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomainGroup"); + status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_DeleteDomainGroup"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4446,7 +4476,9 @@ NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, memcpy(r->out.alias_handle, r->in.alias_handle, sizeof(r->out.alias_handle)); - status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomAlias"); + status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_DeleteDomAlias"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4513,7 +4545,9 @@ NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_CreateDomainGroup"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_CREATE_GROUP, + "_samr_CreateDomainGroup"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4593,7 +4627,9 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - result = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_CreateDomAlias"); + result = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_CREATE_ALIAS, + "_samr_CreateDomAlias"); if (!NT_STATUS_IS_OK(result)) { return result; } @@ -4982,7 +5018,8 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenGroup"); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_OpenGroup"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -5053,8 +5090,9 @@ NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, - "_samr_RemoveMemberFromForeignDomain"); + result = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_RemoveMemberFromForeignDomain"); if (!NT_STATUS_IS_OK(result)) return result; -- cgit From 3038a77f40b1ac64c99b0249533329c425283460 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 22:21:57 +0100 Subject: Minor fix for querydispinfo display in rpcclient. Guenther (This used to be commit 6cb59410c247c2e994150e051c7e065aa6521ac4) --- source3/rpcclient/cmd_samr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 5170fb37bb..4f0e45ec74 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -245,7 +245,7 @@ static void display_sam_info_1(struct samr_DispEntryGeneral *r) { printf("index: 0x%x ", r->idx); printf("RID: 0x%x ", r->rid); - printf("acb: 0x%x ", r->acct_flags); + printf("acb: 0x%08x ", r->acct_flags); printf("Account: %s\t", r->account_name.string); printf("Name: %s\t", r->full_name.string); printf("Desc: %s\n", r->description.string); @@ -255,7 +255,7 @@ static void display_sam_info_2(struct samr_DispEntryFull *r) { printf("index: 0x%x ", r->idx); printf("RID: 0x%x ", r->rid); - printf("acb: 0x%x ", r->acct_flags); + printf("acb: 0x%08x ", r->acct_flags); printf("Account: %s\t", r->account_name.string); printf("Desc: %s\n", r->description.string); } @@ -264,7 +264,7 @@ static void display_sam_info_3(struct samr_DispEntryFullGroup *r) { printf("index: 0x%x ", r->idx); printf("RID: 0x%x ", r->rid); - printf("acb: 0x%x ", r->acct_flags); + printf("acb: 0x%08x ", r->acct_flags); printf("Account: %s\t", r->account_name.string); printf("Desc: %s\n", r->description.string); } -- cgit From 409e4fef400af167b2e6dd301160572aa873edb6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 23:36:01 +0100 Subject: Fix IDL for netr_DsRGetDCName. Guenther (This used to be commit 51c629f902f5c949c3004f162055d03b18514765) --- source3/librpc/idl/netlogon.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/librpc/idl/netlogon.idl b/source3/librpc/idl/netlogon.idl index 5b84452e3f..ae16884896 100644 --- a/source3/librpc/idl/netlogon.idl +++ b/source3/librpc/idl/netlogon.idl @@ -982,7 +982,7 @@ interface netlogon [in,unique] GUID *domain_guid, [in,unique] GUID *site_guid, [in] netr_DsRGetDCName_flags flags, - [out,ref] netr_DsRGetDCNameInfo *info + [out,ref] netr_DsRGetDCNameInfo **info ); /*****************/ -- cgit From 559d6587a1d98246883f14bca633c3e660d2a4e8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 23:37:45 +0100 Subject: Re-run make idl. Guenther (This used to be commit f113c340c80f8ecbec37fa8e8c59c7e36777ca64) --- source3/librpc/gen_ndr/cli_netlogon.c | 2 +- source3/librpc/gen_ndr/cli_netlogon.h | 2 +- source3/librpc/gen_ndr/ndr_netlogon.c | 27 ++++++++++++++++++++++++--- source3/librpc/gen_ndr/netlogon.h | 2 +- source3/librpc/gen_ndr/srv_netlogon.c | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_netlogon.c b/source3/librpc/gen_ndr/cli_netlogon.c index cac3962073..de04c21dc5 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.c +++ b/source3/librpc/gen_ndr/cli_netlogon.c @@ -1057,7 +1057,7 @@ NTSTATUS rpccli_netr_DsRGetDCName(struct rpc_pipe_client *cli, struct GUID *domain_guid, struct GUID *site_guid, uint32_t flags, - struct netr_DsRGetDCNameInfo *info, + struct netr_DsRGetDCNameInfo **info, WERROR *werror) { struct netr_DsRGetDCName r; diff --git a/source3/librpc/gen_ndr/cli_netlogon.h b/source3/librpc/gen_ndr/cli_netlogon.h index fa043233ea..4aa0f9fa73 100644 --- a/source3/librpc/gen_ndr/cli_netlogon.h +++ b/source3/librpc/gen_ndr/cli_netlogon.h @@ -178,7 +178,7 @@ NTSTATUS rpccli_netr_DsRGetDCName(struct rpc_pipe_client *cli, struct GUID *domain_guid, struct GUID *site_guid, uint32_t flags, - struct netr_DsRGetDCNameInfo *info, + struct netr_DsRGetDCNameInfo **info, WERROR *werror); NTSTATUS rpccli_netr_NETRLOGONDUMMYROUTINE1(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/librpc/gen_ndr/ndr_netlogon.c b/source3/librpc/gen_ndr/ndr_netlogon.c index eabbc337fc..dd1d2cf387 100644 --- a/source3/librpc/gen_ndr/ndr_netlogon.c +++ b/source3/librpc/gen_ndr/ndr_netlogon.c @@ -10983,7 +10983,10 @@ static enum ndr_err_code ndr_push_netr_DsRGetDCName(struct ndr_push *ndr, int fl if (r->out.info == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } - NDR_CHECK(ndr_push_netr_DsRGetDCNameInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.info)); + if (*r->out.info) { + NDR_CHECK(ndr_push_netr_DsRGetDCNameInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info)); + } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } return NDR_ERR_SUCCESS; @@ -10995,11 +10998,13 @@ static enum ndr_err_code ndr_pull_netr_DsRGetDCName(struct ndr_pull *ndr, int fl uint32_t _ptr_domain_name; uint32_t _ptr_domain_guid; uint32_t _ptr_site_guid; + uint32_t _ptr_info; TALLOC_CTX *_mem_save_server_unc_0; TALLOC_CTX *_mem_save_domain_name_0; TALLOC_CTX *_mem_save_domain_guid_0; TALLOC_CTX *_mem_save_site_guid_0; TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_info_1; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -11073,7 +11078,18 @@ static enum ndr_err_code ndr_pull_netr_DsRGetDCName(struct ndr_pull *ndr, int fl } _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC); - NDR_CHECK(ndr_pull_netr_DsRGetDCNameInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, *r->out.info); + } else { + *r->out.info = NULL; + } + if (*r->out.info) { + _mem_save_info_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.info, 0); + NDR_CHECK(ndr_pull_netr_DsRGetDCNameInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_1, 0); + } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); } @@ -11122,7 +11138,12 @@ _PUBLIC_ void ndr_print_netr_DsRGetDCName(struct ndr_print *ndr, const char *nam ndr->depth++; ndr_print_ptr(ndr, "info", r->out.info); ndr->depth++; - ndr_print_netr_DsRGetDCNameInfo(ndr, "info", r->out.info); + ndr_print_ptr(ndr, "info", *r->out.info); + ndr->depth++; + if (*r->out.info) { + ndr_print_netr_DsRGetDCNameInfo(ndr, "info", *r->out.info); + } + ndr->depth--; ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); ndr->depth--; diff --git a/source3/librpc/gen_ndr/netlogon.h b/source3/librpc/gen_ndr/netlogon.h index 612e30914a..ef2218c0f2 100644 --- a/source3/librpc/gen_ndr/netlogon.h +++ b/source3/librpc/gen_ndr/netlogon.h @@ -1181,7 +1181,7 @@ struct netr_DsRGetDCName { } in; struct { - struct netr_DsRGetDCNameInfo *info;/* [ref] */ + struct netr_DsRGetDCNameInfo **info;/* [ref] */ WERROR result; } out; diff --git a/source3/librpc/gen_ndr/srv_netlogon.c b/source3/librpc/gen_ndr/srv_netlogon.c index b9e6ae69b1..673f9503df 100644 --- a/source3/librpc/gen_ndr/srv_netlogon.c +++ b/source3/librpc/gen_ndr/srv_netlogon.c @@ -1679,7 +1679,7 @@ static bool api_netr_DsRGetDCName(pipes_struct *p) } ZERO_STRUCT(r->out); - r->out.info = talloc_zero(r, struct netr_DsRGetDCNameInfo); + r->out.info = talloc_zero(r, struct netr_DsRGetDCNameInfo *); if (r->out.info == NULL) { talloc_free(r); return false; -- cgit From e88eb3ed16ce5ddcf795322cfd2bd6ac555ce5d5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 23:28:02 +0100 Subject: Use rpccli_netr_DsRGetDCName() in rpcclient and winbindd. Guenther (This used to be commit 4f3e97cbae3df8e12db37b8a8a0eaee947fa723a) --- source3/rpcclient/cmd_netlogon.c | 26 ++++++++++++++++---------- source3/winbindd/winbindd_cm.c | 25 +++++++++++++------------ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ecd033f39d..a752003e8d 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -126,13 +126,14 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - WERROR result; + NTSTATUS result; + WERROR werr = WERR_OK; uint32 flags = DS_RETURN_DNS_NAME; const char *server_name = cli->cli->desthost; const char *domain_name; struct GUID domain_guid = GUID_zero(); struct GUID site_guid = GUID_zero(); - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; if (argc < 2) { fprintf(stderr, "Usage: %s [domain_name] [domain_guid] " @@ -160,20 +161,25 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, debug_dsdcinfo_flags(1,flags); - result = rpccli_netlogon_dsr_getdcname(cli, mem_ctx, server_name, domain_name, - &domain_guid, &site_guid, flags, - &info); + result = rpccli_netr_DsRGetDCName(cli, mem_ctx, + server_name, + domain_name, + &domain_guid, + &site_guid, + flags, + &info, + &werr); - if (W_ERROR_IS_OK(result)) { - d_printf("DsGetDcName gave\n"); - display_ds_domain_controller_info(mem_ctx, info); + if (W_ERROR_IS_OK(werr)) { + d_printf("DsGetDcName gave: %s\n", + NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info)); return WERR_OK; } printf("rpccli_netlogon_dsr_getdcname returned %s\n", - dos_errstr(result)); + dos_errstr(werr)); - return result; + return werr; } static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index dbdab65f70..0f536cdfb8 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -602,19 +602,20 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain, orig_timeout = cli_set_timeout(netlogon_pipe->cli, 35000); if (our_domain->active_directory) { - struct DS_DOMAIN_CONTROLLER_INFO *domain_info = NULL; - - werr = rpccli_netlogon_dsr_getdcname(netlogon_pipe, - mem_ctx, - our_domain->dcname, - domain->name, - NULL, - NULL, - DS_RETURN_DNS_NAME, - &domain_info); + struct netr_DsRGetDCNameInfo *domain_info = NULL; + + result = rpccli_netr_DsRGetDCName(netlogon_pipe, + mem_ctx, + our_domain->dcname, + domain->name, + NULL, + NULL, + DS_RETURN_DNS_NAME, + &domain_info, + &werr); if (W_ERROR_IS_OK(werr)) { tmp = talloc_strdup( - mem_ctx, domain_info->domain_controller_name); + mem_ctx, domain_info->dc_unc); if (tmp == NULL) { DEBUG(0, ("talloc_strdup failed\n")); talloc_destroy(mem_ctx); @@ -626,7 +627,7 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain, } if (strlen(domain->forest_name) == 0) { fstrcpy(domain->forest_name, - domain_info->dns_forest_name); + domain_info->forest_name); } } } else { -- cgit From 5da927716a857ce686f3b75476671d32f047d2c0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 23:33:52 +0100 Subject: Remove unused marshalling for NET_DSR_GETDCNAME. Guenther (This used to be commit 65c2aa344e45064cbfddd87715862d60f7ac2a8a) --- source3/include/rpc_netlogon.h | 33 ------ source3/rpc_client/cli_netlogon.c | 136 ---------------------- source3/rpc_parse/parse_net.c | 236 -------------------------------------- 3 files changed, 405 deletions(-) diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index 21dd42d77e..bab2caaf61 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -1029,37 +1029,4 @@ struct DS_DOMAIN_CONTROLLER_INFO { const char *client_site_name; }; -/* NET_Q_DSR_GETDCNAME */ -typedef struct net_q_dsr_getdcname { - uint32 ptr_server_unc; - UNISTR2 uni_server_unc; - uint32 ptr_domain_name; - UNISTR2 uni_domain_name; - uint32 ptr_domain_guid; - struct GUID *domain_guid; - uint32 ptr_site_guid; - struct GUID *site_guid; - uint32 flags; -} NET_Q_DSR_GETDCNAME; - -/* NET_R_DSR_GETDCNAME */ -typedef struct net_r_dsr_getdcname { - uint32 ptr_dc_unc; - UNISTR2 uni_dc_unc; - uint32 ptr_dc_address; - UNISTR2 uni_dc_address; - int32 dc_address_type; - struct GUID domain_guid; - uint32 ptr_domain_name; - UNISTR2 uni_domain_name; - uint32 ptr_forest_name; - UNISTR2 uni_forest_name; - uint32 dc_flags; - uint32 ptr_dc_site_name; - UNISTR2 uni_dc_site_name; - uint32 ptr_client_site_name; - UNISTR2 uni_client_site_name; - WERROR result; -} NET_R_DSR_GETDCNAME; - #endif /* _RPC_NETLOGON_H */ diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 5a0c5816e6..a6167bb851 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -379,142 +379,6 @@ NTSTATUS rpccli_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, TALLOC_CTX *me return result; } -static WERROR pull_domain_controller_info_from_getdcname_reply(TALLOC_CTX *mem_ctx, - struct DS_DOMAIN_CONTROLLER_INFO **info_out, - NET_R_DSR_GETDCNAME *r) -{ - struct DS_DOMAIN_CONTROLLER_INFO *info; - - info = TALLOC_ZERO_P(mem_ctx, struct DS_DOMAIN_CONTROLLER_INFO); - if (!info) { - return WERR_NOMEM; - } - - if (&r->uni_dc_unc) { - - char *tmp; - tmp = rpcstr_pull_unistr2_talloc(mem_ctx, &r->uni_dc_unc); - if (tmp == NULL) { - return WERR_GENERAL_FAILURE; - } - if (*tmp == '\\') tmp += 1; - if (*tmp == '\\') tmp += 1; - - info->domain_controller_name = talloc_strdup(mem_ctx, tmp); - if (info->domain_controller_name == NULL) { - return WERR_GENERAL_FAILURE; - } - } - - if (&r->uni_dc_address) { - - char *tmp; - tmp = rpcstr_pull_unistr2_talloc(mem_ctx, &r->uni_dc_address); - if (tmp == NULL) { - return WERR_GENERAL_FAILURE; - } - if (*tmp == '\\') tmp += 1; - if (*tmp == '\\') tmp += 1; - - info->domain_controller_address = talloc_strdup(mem_ctx, tmp); - if (info->domain_controller_address == NULL) { - return WERR_GENERAL_FAILURE; - } - } - - info->domain_controller_address_type = r->dc_address_type; - - info->domain_guid = (struct GUID *)talloc_memdup( - mem_ctx, &r->domain_guid, sizeof(struct GUID)); - if (!info->domain_guid) { - return WERR_GENERAL_FAILURE; - } - - if (&r->uni_domain_name) { - info->domain_name = rpcstr_pull_unistr2_talloc(mem_ctx, &r->uni_domain_name); - if (!info->domain_name) { - return WERR_GENERAL_FAILURE; - } - } - - if (&r->uni_forest_name) { - info->dns_forest_name = rpcstr_pull_unistr2_talloc(mem_ctx, &r->uni_forest_name); - if (!info->dns_forest_name) { - return WERR_GENERAL_FAILURE; - } - } - - info->flags = r->dc_flags; - - if (&r->uni_dc_site_name) { - info->dc_site_name = rpcstr_pull_unistr2_talloc(mem_ctx, &r->uni_dc_site_name); - if (!info->dc_site_name) { - return WERR_GENERAL_FAILURE; - } - } - - if (&r->uni_client_site_name) { - info->client_site_name = rpcstr_pull_unistr2_talloc(mem_ctx, &r->uni_client_site_name); - if (!info->client_site_name) { - return WERR_GENERAL_FAILURE; - } - } - - *info_out = info; - - return WERR_OK; -} - -/* Dsr_GetDCName */ - -WERROR rpccli_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - const char *server_name, - const char *domain_name, - struct GUID *domain_guid, - struct GUID *site_guid, - uint32_t flags, - struct DS_DOMAIN_CONTROLLER_INFO **info_out) -{ - prs_struct qbuf, rbuf; - NET_Q_DSR_GETDCNAME q; - NET_R_DSR_GETDCNAME r; - char *tmp_str; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - /* Initialize input parameters */ - - tmp_str = talloc_asprintf(mem_ctx, "\\\\%s", server_name); - if (tmp_str == NULL) { - return WERR_NOMEM; - } - - init_net_q_dsr_getdcname(&q, tmp_str, domain_name, domain_guid, - site_guid, flags); - - /* Marshall data and send request */ - - CLI_DO_RPC_WERR(cli, mem_ctx, PI_NETLOGON, NET_DSR_GETDCNAME, - q, r, - qbuf, rbuf, - net_io_q_dsr_getdcname, - net_io_r_dsr_getdcname, - WERR_GENERAL_FAILURE); - - if (!W_ERROR_IS_OK(r.result)) { - return r.result; - } - - r.result = pull_domain_controller_info_from_getdcname_reply(mem_ctx, info_out, &r); - if (!W_ERROR_IS_OK(r.result)) { - return r.result; - } - - return WERR_OK; -} - /* Sam synchronisation */ NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index c68d9300b9..55af8211cf 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -3240,239 +3240,3 @@ bool net_io_r_sam_deltas(const char *desc, return True; } - -/******************************************************************* - Inits a NET_Q_DSR_GETDCNAME structure. -********************************************************************/ - -void init_net_q_dsr_getdcname(NET_Q_DSR_GETDCNAME *r_t, const char *server_unc, - const char *domain_name, - struct GUID *domain_guid, - struct GUID *site_guid, - uint32_t flags) -{ - DEBUG(5, ("init_net_q_dsr_getdcname\n")); - - r_t->ptr_server_unc = (server_unc != NULL); - init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE); - - r_t->ptr_domain_name = (domain_name != NULL); - init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE); - - r_t->ptr_domain_guid = (domain_guid != NULL); - r_t->domain_guid = domain_guid; - - r_t->ptr_site_guid = (site_guid != NULL); - r_t->site_guid = site_guid; - - r_t->flags = flags; -} - -/******************************************************************* - Reads or writes an NET_Q_DSR_GETDCNAME structure. -********************************************************************/ - -bool net_io_q_dsr_getdcname(const char *desc, NET_Q_DSR_GETDCNAME *r_t, - prs_struct *ps, int depth) -{ - if (r_t == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_dsr_getdcname"); - depth++; - - if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc)) - return False; - - if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc, - r_t->ptr_server_unc, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name)) - return False; - - if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name, - r_t->ptr_domain_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid)) - return False; - - if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) { - r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1); - if (r_t->domain_guid == NULL) - return False; - } - - if ((r_t->ptr_domain_guid) && - (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth))) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_site_guid", ps, depth, &r_t->ptr_site_guid)) - return False; - - if (UNMARSHALLING(ps) && (r_t->ptr_site_guid)) { - r_t->site_guid = PRS_ALLOC_MEM(ps, struct GUID, 1); - if (r_t->site_guid == NULL) - return False; - } - - if ((r_t->ptr_site_guid) && - (!smb_io_uuid("site_guid", r_t->site_guid, ps, depth))) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("flags", ps, depth, &r_t->flags)) - return False; - - return True; -} - -/******************************************************************* - Inits a NET_R_DSR_GETDCNAME structure. -********************************************************************/ -void init_net_r_dsr_getdcname(NET_R_DSR_GETDCNAME *r_t, const char *dc_unc, - const char *dc_address, int32 dc_address_type, - struct GUID domain_guid, const char *domain_name, - const char *forest_name, uint32 dc_flags, - const char *dc_site_name, - const char *client_site_name) -{ - DEBUG(5, ("init_net_q_dsr_getdcname\n")); - - r_t->ptr_dc_unc = (dc_unc != NULL); - init_unistr2(&r_t->uni_dc_unc, dc_unc, UNI_STR_TERMINATE); - - r_t->ptr_dc_address = (dc_address != NULL); - init_unistr2(&r_t->uni_dc_address, dc_address, UNI_STR_TERMINATE); - - r_t->dc_address_type = dc_address_type; - r_t->domain_guid = domain_guid; - - r_t->ptr_domain_name = (domain_name != NULL); - init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE); - - r_t->ptr_forest_name = (forest_name != NULL); - init_unistr2(&r_t->uni_forest_name, forest_name, UNI_STR_TERMINATE); - - r_t->dc_flags = dc_flags; - - r_t->ptr_dc_site_name = (dc_site_name != NULL); - init_unistr2(&r_t->uni_dc_site_name, dc_site_name, UNI_STR_TERMINATE); - - r_t->ptr_client_site_name = (client_site_name != NULL); - init_unistr2(&r_t->uni_client_site_name, client_site_name, - UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes an NET_R_DSR_GETDCNAME structure. -********************************************************************/ - -bool net_io_r_dsr_getdcname(const char *desc, NET_R_DSR_GETDCNAME *r_t, - prs_struct *ps, int depth) -{ - uint32 info_ptr = 1; - - if (r_t == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_dsr_getdcname"); - depth++; - - /* The reply contains *just* an info struct, this is the ptr to it */ - if (!prs_uint32("info_ptr", ps, depth, &info_ptr)) - return False; - - if (info_ptr == 0) - return False; - - if (!prs_uint32("ptr_dc_unc", ps, depth, &r_t->ptr_dc_unc)) - return False; - - if (!prs_uint32("ptr_dc_address", ps, depth, &r_t->ptr_dc_address)) - return False; - - if (!prs_int32("dc_address_type", ps, depth, &r_t->dc_address_type)) - return False; - - if (!smb_io_uuid("domain_guid", &r_t->domain_guid, ps, depth)) - return False; - - if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name)) - return False; - - if (!prs_uint32("ptr_forest_name", ps, depth, &r_t->ptr_forest_name)) - return False; - - if (!prs_uint32("dc_flags", ps, depth, &r_t->dc_flags)) - return False; - - if (!prs_uint32("ptr_dc_site_name", ps, depth, &r_t->ptr_dc_site_name)) - return False; - - if (!prs_uint32("ptr_client_site_name", ps, depth, - &r_t->ptr_client_site_name)) - return False; - - if (!prs_align(ps)) - return False; - - if (!smb_io_unistr2("dc_unc", &r_t->uni_dc_unc, - r_t->ptr_dc_unc, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!smb_io_unistr2("dc_address", &r_t->uni_dc_address, - r_t->ptr_dc_address, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name, - r_t->ptr_domain_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!smb_io_unistr2("forest_name", &r_t->uni_forest_name, - r_t->ptr_forest_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!smb_io_unistr2("dc_site_name", &r_t->uni_dc_site_name, - r_t->ptr_dc_site_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!smb_io_unistr2("client_site_name", &r_t->uni_client_site_name, - r_t->ptr_client_site_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("result", ps, depth, &r_t->result)) - return False; - - return True; -} -- cgit