summaryrefslogtreecommitdiff
path: root/source3/libmsrpc
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libmsrpc')
-rw-r--r--source3/libmsrpc/cac_lsarpc.c234
-rw-r--r--source3/libmsrpc/cac_samr.c581
-rw-r--r--source3/libmsrpc/cac_svcctl.c157
-rw-r--r--source3/libmsrpc/cac_winreg.c229
-rw-r--r--source3/libmsrpc/libmsrpc.c14
-rw-r--r--source3/libmsrpc/libmsrpc_internal.c27
6 files changed, 561 insertions, 681 deletions
diff --git a/source3/libmsrpc/cac_lsarpc.c b/source3/libmsrpc/cac_lsarpc.c
index 911dc906f0..3896c715f5 100644
--- a/source3/libmsrpc/cac_lsarpc.c
+++ b/source3/libmsrpc/cac_lsarpc.c
@@ -24,6 +24,7 @@
int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op) {
SMBCSRV *srv = NULL;
POLICY_HND *policy = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -48,7 +49,9 @@ int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenP
/*see if there is already an active session on this pipe, if not then open one*/
if(!hnd->_internal.pipes[PI_LSARPC]) {
- if(!cli_nt_session_open(&srv->cli, PI_LSARPC)) {
+ pipe_hnd = cli_rpc_pipe_open_noauth(&(srv->cli), PI_LSARPC, &(hnd->status));
+
+ if(!pipe_hnd) {
hnd->status = NT_STATUS_UNSUCCESSFUL;
return CAC_FAILURE;
}
@@ -56,9 +59,6 @@ int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenP
hnd->_internal.pipes[PI_LSARPC] = True;
}
- /**make sure we are working with the right pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
-
policy = SMB_MALLOC_P(POLICY_HND);
if(!policy) {
errno = ENOMEM;
@@ -74,12 +74,12 @@ int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenP
/*try using open_policy2, if this fails try again in next block using open_policy, if that works then adjust hnd->_internal.srv_level*/
/*we shouldn't need to modify the access mask to make it work here*/
- hnd->status = cli_lsa_open_policy2(&(srv->cli), mem_ctx, op->in.security_qos, op->in.access, policy);
+ hnd->status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, op->in.security_qos, op->in.access, policy);
}
if(hnd->_internal.srv_level < SRV_WIN_2K || !NT_STATUS_IS_OK(hnd->status)) {
- hnd->status = cli_lsa_open_policy(&srv->cli, mem_ctx, op->in.security_qos, op->in.access, policy);
+ hnd->status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, op->in.security_qos, op->in.access, policy);
if(hnd->_internal.srv_level > SRV_WIN_NT4 && NT_STATUS_IS_OK(hnd->status)) {
/*change the server level to 1*/
@@ -100,7 +100,7 @@ int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenP
int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *pol) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -113,16 +113,14 @@ int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *po
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- /*make sure we're on the right pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
- hnd->status = cli_lsa_close(&(srv->cli), mem_ctx, pol);
+ hnd->status = rpccli_lsa_close(pipe_hnd, mem_ctx, pol);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -133,7 +131,7 @@ int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *po
}
int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetNamesFromSids *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
int result = -1;
@@ -168,17 +166,16 @@ int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
num_sids = op->in.num_sids;
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- /*make sure we're on the right pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
+
/*now actually lookup the names*/
- hnd->status = cli_lsa_lookup_sids(&(srv->cli), mem_ctx, op->in.pol, op->in.num_sids,
+ hnd->status = rpccli_lsa_lookup_sids(pipe_hnd, mem_ctx, op->in.pol, op->in.num_sids,
op->in.sids, &domains, &names, &types);
if(NT_STATUS_IS_OK(hnd->status)) {
@@ -259,7 +256,7 @@ int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
}
int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSidsFromNames *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
int result = -1;
int i;
@@ -292,17 +289,15 @@ int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
num_names = op->in.num_names;
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- /*make sure we're on the right pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
/*now actually lookup the names*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, num_names,
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, num_names,
(const char **)op->in.names, &sids, &types);
if(NT_STATUS_IS_OK(hnd->status)) {
@@ -383,7 +378,7 @@ int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
}
int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSid *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
int result = -1;
if(!hnd)
@@ -399,15 +394,12 @@ int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSi
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- /*now make sure that it's set up for the LSA pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
-
op->out.local_sid = NULL;
op->out.domain_sid = NULL;
@@ -415,7 +407,7 @@ int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSi
DOM_SID *local_sid = NULL;
char *dom_name = NULL;
- hnd->status = cli_lsa_query_info_policy( &srv->cli, mem_ctx, op->in.pol, CAC_LOCAL_INFO, &dom_name, &local_sid);
+ hnd->status = rpccli_lsa_query_info_policy( pipe_hnd, mem_ctx, op->in.pol, CAC_LOCAL_INFO, &dom_name, &local_sid);
if(!NT_STATUS_IS_OK(hnd->status)) {
result = CAC_FAILURE;
@@ -441,7 +433,7 @@ domain:
DOM_SID *domain_sid;
char *dom_name;
- hnd->status = cli_lsa_query_info_policy( &srv->cli, mem_ctx, op->in.pol, CAC_DOMAIN_INFO, &dom_name, &domain_sid);
+ hnd->status = rpccli_lsa_query_info_policy( pipe_hnd, mem_ctx, op->in.pol, CAC_DOMAIN_INFO, &dom_name, &domain_sid);
if(!NT_STATUS_IS_OK(hnd->status)) {
/*if we succeeded above, report partial success*/
result = (result == CAC_SUCCESS) ? CAC_PARTIAL_SUCCESS : CAC_FAILURE;
@@ -469,7 +461,7 @@ done:
}
int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryInfoPolicy *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
char *domain_name = NULL;
char *dns_name = NULL;
@@ -490,17 +482,14 @@ int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- /*make sure we're on the right pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
-
/*only works if info_class parm is 12*/
- hnd->status = cli_lsa_query_info_policy2(&(srv->cli), mem_ctx, op->in.pol, 12,
+ hnd->status = rpccli_lsa_query_info_policy2(pipe_hnd, mem_ctx, op->in.pol, 12,
&domain_name, &dns_name, &forest_name, &domain_guid, &domain_sid);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -517,7 +506,7 @@ int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
}
int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSids *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 num_sids;
DOM_SID *sids;
@@ -534,15 +523,13 @@ int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSid
hnd->status = NT_STATUS_INVALID_PARAMETER;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
- hnd->status = cli_lsa_enum_sids(&(srv->cli), mem_ctx, op->in.pol, &(op->out.resume_idx), op->in.pref_max_sids, &num_sids, &sids);
+ hnd->status = rpccli_lsa_enum_sids(pipe_hnd, mem_ctx, op->in.pol, &(op->out.resume_idx), op->in.pref_max_sids, &num_sids, &sids);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -556,7 +543,7 @@ int cac_LsaEnumSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumSid
}
int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumAccountRights *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 count = 0;
char **privs = NULL;
@@ -579,21 +566,18 @@ int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- /*make sure we are set up for the lsa pipe*/
- srv->cli.pipe_idx = PI_LSARPC;
-
if(op->in.name && !op->in.sid) {
DOM_SID *user_sid = NULL;
uint32 *type;
/*lookup the SID*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -601,7 +585,7 @@ int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
op->in.sid = user_sid;
}
- hnd->status = cli_lsa_enum_account_rights( &(srv->cli), mem_ctx, op->in.pol, op->in.sid,
+ hnd->status = rpccli_lsa_enum_account_rights( pipe_hnd, mem_ctx, op->in.pol, op->in.sid,
&count, &privs);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -615,7 +599,7 @@ int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
}
int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumTrustedDomains *op) {
- SMBCSRV *srv;
+ struct rpc_pipe_client *pipe_hnd;
uint32 num_domains;
char **domain_names;
@@ -634,15 +618,13 @@ int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
- hnd->status = cli_lsa_enum_trust_dom( &(srv->cli), mem_ctx, op->in.pol, &(op->out.resume_idx), &num_domains, &domain_names, &domain_sids);
+ hnd->status = rpccli_lsa_enum_trust_dom( pipe_hnd, mem_ctx, op->in.pol, &(op->out.resume_idx), &num_domains, &domain_names, &domain_sids);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -656,7 +638,7 @@ int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct
}
int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenTrustedDomain *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *dom_pol = NULL;
@@ -673,14 +655,12 @@ int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
dom_pol = talloc(mem_ctx, POLICY_HND);
if(!dom_pol) {
hnd->status = NT_STATUS_NO_MEMORY;
@@ -688,7 +668,7 @@ int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
return CAC_FAILURE;
}
- hnd->status = cli_lsa_open_trusted_domain( &(srv->cli), mem_ctx, op->in.pol, op->in.domain_sid, op->in.access, dom_pol);
+ hnd->status = rpccli_lsa_open_trusted_domain( pipe_hnd, mem_ctx, op->in.pol, op->in.domain_sid, op->in.access, dom_pol);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -700,7 +680,7 @@ int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
}
int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaQueryTrustedDomainInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
LSA_TRUSTED_DOMAIN_INFO *dom_info;
@@ -722,19 +702,17 @@ int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, str
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
if(op->in.domain_sid) {
- hnd->status = cli_lsa_query_trusted_domain_info_by_sid( &(srv->cli), mem_ctx, op->in.pol, op->in.info_class, op->in.domain_sid, &dom_info);
+ hnd->status = rpccli_lsa_query_trusted_domain_info_by_sid( pipe_hnd, mem_ctx, op->in.pol, op->in.info_class, op->in.domain_sid, &dom_info);
}
else if(op->in.domain_name) {
- hnd->status = cli_lsa_query_trusted_domain_info_by_name( &(srv->cli), mem_ctx, op->in.pol, op->in.info_class, op->in.domain_name, &dom_info);
+ hnd->status = rpccli_lsa_query_trusted_domain_info_by_name( pipe_hnd, mem_ctx, op->in.pol, op->in.info_class, op->in.domain_name, &dom_info);
}
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -748,7 +726,7 @@ int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, str
}
int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumPrivileges *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
int num_privs;
char **priv_names;
@@ -769,15 +747,13 @@ int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaE
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
- hnd->status = cli_lsa_enum_privilege(&(srv->cli), mem_ctx, op->in.pol, &(op->out.resume_idx), op->in.pref_max_privs,
+ hnd->status = rpccli_lsa_enum_privilege(pipe_hnd, mem_ctx, op->in.pol, &(op->out.resume_idx), op->in.pref_max_privs,
&num_privs, &priv_names, &high_bits, &low_bits);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -793,7 +769,7 @@ int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaE
}
int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenAccount *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *user_pol = NULL;
@@ -816,12 +792,6 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
- srv->cli.pipe_idx = PI_LSARPC;
/*look up the user's SID if we have to*/
if(op->in.name && !op->in.sid) {
@@ -829,7 +799,7 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
uint32 *type;
/*lookup the SID*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -843,7 +813,7 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
return CAC_FAILURE;
}
- hnd->status = cli_lsa_open_account(&(srv->cli), mem_ctx, op->in.pol, op->in.sid, op->in.access, user_pol);
+ hnd->status = rpccli_lsa_open_account(pipe_hnd, mem_ctx, op->in.pol, op->in.sid, op->in.access, user_pol);
if(!NT_STATUS_IS_OK(hnd->status)) {
talloc_free(user_pol);
@@ -857,7 +827,7 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_SID *user_sid = NULL;
uint32 *type = NULL;
@@ -881,17 +851,15 @@ int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
if(op->in.name && !op->in.sid) {
/*lookup the SID*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -899,7 +867,7 @@ int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
op->in.sid = user_sid;
}
- hnd->status = cli_lsa_add_account_rights( &(srv->cli), mem_ctx, op->in.pol, *(op->in.sid), op->in.num_privs, (const char **)op->in.priv_names);
+ hnd->status = rpccli_lsa_add_account_rights( pipe_hnd, mem_ctx, op->in.pol, *(op->in.sid), op->in.num_privs, (const char **)op->in.priv_names);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -909,7 +877,7 @@ int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
}
int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaRemovePrivileges *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_SID *user_sid = NULL;
uint32 *type = NULL;
@@ -933,17 +901,15 @@ int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
if(op->in.name && !op->in.sid) {
/*lookup the SID*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -951,7 +917,7 @@ int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
op->in.sid = user_sid;
}
- hnd->status = cli_lsa_remove_account_rights( &(srv->cli), mem_ctx, op->in.pol, *(op->in.sid), False, op->in.num_privs, (const char **)op->in.priv_names);
+ hnd->status = rpccli_lsa_remove_account_rights( pipe_hnd, mem_ctx, op->in.pol, *(op->in.sid), False, op->in.num_privs, (const char **)op->in.priv_names);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -961,7 +927,7 @@ int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
}
int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaClearPrivileges *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_SID *user_sid = NULL;
uint32 *type = NULL;
@@ -985,17 +951,15 @@ int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
if(op->in.name && !op->in.sid) {
/*lookup the SID*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1003,7 +967,7 @@ int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
op->in.sid = user_sid;
}
- hnd->status = cli_lsa_remove_account_rights( &(srv->cli), mem_ctx, op->in.pol, *(op->in.sid), True, 0, NULL);
+ hnd->status = rpccli_lsa_remove_account_rights( pipe_hnd, mem_ctx, op->in.pol, *(op->in.sid), True, 0, NULL);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -1013,7 +977,7 @@ int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
}
int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAddPrivileges *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_SID *user_sid = NULL;
uint32 *type = NULL;
@@ -1037,16 +1001,14 @@ int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
if(op->in.name && !op->in.sid) {
/*lookup the SID*/
- hnd->status = cli_lsa_lookup_names( &(srv->cli), mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
+ hnd->status = rpccli_lsa_lookup_names( pipe_hnd, mem_ctx, op->in.pol, 1, (const char **)&(op->in.name), &user_sid, &type);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1055,13 +1017,13 @@ int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
}
/*first remove all privileges*/
- hnd->status = cli_lsa_remove_account_rights( &(srv->cli), mem_ctx, op->in.pol, *(op->in.sid), True, 0, NULL);
+ hnd->status = rpccli_lsa_remove_account_rights( pipe_hnd, mem_ctx, op->in.pol, *(op->in.sid), True, 0, NULL);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
}
- hnd->status = cli_lsa_add_account_rights( &(srv->cli), mem_ctx, op->in.pol, *(op->in.sid), op->in.num_privs, (const char **)op->in.priv_names);
+ hnd->status = rpccli_lsa_add_account_rights( pipe_hnd, mem_ctx, op->in.pol, *(op->in.sid), op->in.num_privs, (const char **)op->in.priv_names);
if(!NT_STATUS_IS_OK(hnd->status)) {
return CAC_FAILURE;
@@ -1071,7 +1033,7 @@ int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
}
int cac_LsaGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaGetSecurityObject *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
/*this is taken from rpcclient/cmd_lsarpc.c*/
uint16 info_level = 4;
@@ -1092,15 +1054,13 @@ int cac_LsaGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_LSARPC;
-
- hnd->status = cli_lsa_query_secobj( &(srv->cli), mem_ctx, op->in.pol, info_level, &sec_out);
+ hnd->status = rpccli_lsa_query_secobj( pipe_hnd, mem_ctx, op->in.pol, info_level, &sec_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
diff --git a/source3/libmsrpc/cac_samr.c b/source3/libmsrpc/cac_samr.c
index c6efaa2d38..65141ca319 100644
--- a/source3/libmsrpc/cac_samr.c
+++ b/source3/libmsrpc/cac_samr.c
@@ -31,6 +31,7 @@
int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *sam_out = NULL;
if(!hnd)
@@ -54,15 +55,18 @@ int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect
/*initialize for samr pipe if we have to*/
if(!hnd->_internal.pipes[PI_SAMR]) {
- if(!cli_nt_session_open(&srv->cli, PI_SAMR)) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_SAMR, &(hnd->status)))) {
return CAC_FAILURE;
}
hnd->_internal.pipes[PI_SAMR] = True;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
sam_out = talloc(mem_ctx, POLICY_HND);
if(!sam_out) {
@@ -71,13 +75,13 @@ int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect
}
if(hnd->_internal.srv_level >= SRV_WIN_2K_SP3) {
- hnd->status = cli_samr_connect4( &(srv->cli), mem_ctx, op->in.access, sam_out);
+ hnd->status = rpccli_samr_connect4( pipe_hnd, mem_ctx, op->in.access, sam_out);
}
if(hnd->_internal.srv_level < SRV_WIN_2K_SP3 || !NT_STATUS_IS_OK(hnd->status)) {
/*if sam_connect4 failed, the use sam_connect and lower srv_level*/
- hnd->status = cli_samr_connect( &(srv->cli), mem_ctx, op->in.access, sam_out);
+ hnd->status = rpccli_samr_connect( pipe_hnd, mem_ctx, op->in.access, sam_out);
if(NT_STATUS_IS_OK(hnd->status) && hnd->_internal.srv_level > SRV_WIN_2K) {
hnd->_internal.srv_level = SRV_WIN_2K;
@@ -93,7 +97,7 @@ int cac_SamConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamConnect
}
int cac_SamClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sam) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -108,15 +112,13 @@ int cac_SamClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sam) {
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
-
- srv->cli.pipe_idx = PI_SAMR;
- hnd->status = cli_samr_close( &(srv->cli), mem_ctx, sam);
+ hnd->status = rpccli_samr_close( pipe_hnd, mem_ctx, sam);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -165,7 +167,7 @@ DOM_SID *cac_get_domain_sid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, uint32 de
}
int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenDomain *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_SID *sid_buf;
POLICY_HND *sam_out;
@@ -186,13 +188,6 @@ int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenD
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
-
if(!op->in.sam) {
/*use cac_SamConnect() since it does the session setup*/
struct SamConnect sc;
@@ -233,6 +228,11 @@ int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenD
sid_buf = op->in.sid;
}
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
pol_out = talloc(mem_ctx, POLICY_HND);
if(!pol_out) {
@@ -241,7 +241,7 @@ int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenD
}
/*now open the domain*/
- hnd->status = cli_samr_open_domain( &(srv->cli), mem_ctx, sam_out, op->in.access, sid_buf, pol_out);
+ hnd->status = rpccli_samr_open_domain( pipe_hnd, mem_ctx, sam_out, op->in.access, sid_buf, pol_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -253,7 +253,7 @@ int cac_SamOpenDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenD
}
int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUser *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 *rid_buf = NULL;
@@ -280,18 +280,16 @@ int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUse
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
if(op->in.rid == 0 && op->in.name) {
/*lookup the name and then set rid_buf*/
- hnd->status = cli_samr_lookup_names( &(srv->cli), mem_ctx, op->in.dom_hnd, SAMR_LOOKUP_FLAGS, 1, (const char **)&op->in.name,
+ hnd->status = rpccli_samr_lookup_names( pipe_hnd, mem_ctx, op->in.dom_hnd, SAMR_LOOKUP_FLAGS, 1, (const char **)&op->in.name,
&num_rids, &rid_buf, &rid_types);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -315,7 +313,7 @@ int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUse
return CAC_FAILURE;
}
- hnd->status = cli_samr_open_user(&(srv->cli), mem_ctx, op->in.dom_hnd, op->in.access, *rid_buf, user_out);
+ hnd->status = rpccli_samr_open_user(pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.access, *rid_buf, user_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -326,7 +324,7 @@ int cac_SamOpenUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenUse
}
int cac_SamCreateUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateUser *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *user_out = NULL;
uint32 rid_out;
@@ -347,21 +345,19 @@ int cac_SamCreateUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreat
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
user_out = talloc(mem_ctx, POLICY_HND);
if(!user_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_create_dom_user( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.name, op->in.acb_mask, unknown, user_out, &rid_out);
+ hnd->status = rpccli_samr_create_dom_user( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.name, op->in.acb_mask, unknown, user_out, &rid_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -373,7 +369,7 @@ int cac_SamCreateUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreat
}
int cac_SamDeleteUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -388,15 +384,13 @@ int cac_SamDeleteUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *use
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_delete_dom_user( &(srv->cli), mem_ctx, user_hnd);
+ hnd->status = rpccli_samr_delete_dom_user( pipe_hnd, mem_ctx, user_hnd);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -405,7 +399,7 @@ int cac_SamDeleteUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *use
}
int cac_SamEnumUsers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUsers *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 resume_idx_out = 0;
char **names_out = NULL;
@@ -429,17 +423,15 @@ int cac_SamEnumUsers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUs
if(op->out.done == True)
return CAC_FAILURE;
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
resume_idx_out = op->out.resume_idx;
- hnd->status = cli_samr_enum_dom_users( &(srv->cli), mem_ctx, op->in.dom_hnd, &resume_idx_out, op->in.acb_mask, SAMR_ENUM_MAX_SIZE,
+ hnd->status = rpccli_samr_enum_dom_users( pipe_hnd, mem_ctx, op->in.dom_hnd, &resume_idx_out, op->in.acb_mask, SAMR_ENUM_MAX_SIZE,
&names_out, &rids_out, &num_users_out);
@@ -460,7 +452,7 @@ int cac_SamEnumUsers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumUs
}
int cac_SamGetNamesFromRids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetNamesFromRids *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 num_names_out;
char **names_out;
@@ -495,15 +487,13 @@ int cac_SamGetNamesFromRids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
return CAC_SUCCESS;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_lookup_rids( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.num_rids, op->in.rids, &num_names_out, &names_out, &name_types_out);
+ hnd->status = rpccli_samr_lookup_rids( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.num_rids, op->in.rids, &num_names_out, &names_out, &name_types_out);
if(!NT_STATUS_IS_OK(hnd->status) && !NT_STATUS_EQUAL(hnd->status, STATUS_SOME_UNMAPPED))
return CAC_FAILURE;
@@ -541,7 +531,7 @@ int cac_SamGetNamesFromRids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
}
int cac_SamGetRidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetRidsFromNames *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 num_rids_out;
uint32 *rids_out;
@@ -575,15 +565,13 @@ int cac_SamGetRidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
return CAC_SUCCESS;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_lookup_names( &(srv->cli), mem_ctx, op->in.dom_hnd, SAMR_LOOKUP_FLAGS, op->in.num_names, (const char **)op->in.names,
+ hnd->status = rpccli_samr_lookup_names( pipe_hnd, mem_ctx, op->in.dom_hnd, SAMR_LOOKUP_FLAGS, op->in.num_names, (const char **)op->in.names,
&num_rids_out, &rids_out, &rid_types_out);
if(!NT_STATUS_IS_OK(hnd->status) && !NT_STATUS_EQUAL(hnd->status, STATUS_SOME_UNMAPPED))
@@ -625,7 +613,7 @@ int cac_SamGetRidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
int cac_SamGetGroupsForUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupsForUser *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_GID *groups = NULL;
uint32 num_groups_out = 0;
@@ -648,15 +636,13 @@ int cac_SamGetGroupsForUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_usergroups(&(srv->cli), mem_ctx, op->in.user_hnd, &num_groups_out, &groups);
+ hnd->status = rpccli_samr_query_usergroups(pipe_hnd, mem_ctx, op->in.user_hnd, &num_groups_out, &groups);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -690,7 +676,7 @@ int cac_SamGetGroupsForUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
int cac_SamOpenGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGroup *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *group_hnd_out = NULL;
@@ -707,21 +693,19 @@ int cac_SamOpenGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGr
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
group_hnd_out = talloc(mem_ctx, POLICY_HND);
if(!group_hnd_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_open_group( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.access, op->in.rid, group_hnd_out);
+ hnd->status = rpccli_samr_open_group( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.access, op->in.rid, group_hnd_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -732,7 +716,7 @@ int cac_SamOpenGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenGr
}
int cac_SamCreateGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateGroup *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *group_hnd_out = NULL;
@@ -749,21 +733,19 @@ int cac_SamCreateGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCrea
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
group_hnd_out = talloc(mem_ctx, POLICY_HND);
if(!group_hnd_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_create_dom_group( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.name, op->in.access, group_hnd_out);
+ hnd->status = rpccli_samr_create_dom_group( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.name, op->in.access, group_hnd_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -775,7 +757,7 @@ int cac_SamCreateGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCrea
}
int cac_SamDeleteGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -790,15 +772,13 @@ int cac_SamDeleteGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *gr
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_delete_dom_group( &(srv->cli), mem_ctx, group_hnd);
+ hnd->status = rpccli_samr_delete_dom_group( pipe_hnd, mem_ctx, group_hnd);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -808,7 +788,7 @@ int cac_SamDeleteGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *gr
}
int cac_SamGetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupMembers *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 num_mem_out;
uint32 *rids_out;
@@ -827,15 +807,13 @@ int cac_SamGetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_groupmem( &(srv->cli), mem_ctx, op->in.group_hnd, &num_mem_out, &rids_out, &attr_out);
+ hnd->status = rpccli_samr_query_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd, &num_mem_out, &rids_out, &attr_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -849,7 +827,7 @@ int cac_SamGetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
int cac_SamAddGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddGroupMember *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -864,15 +842,13 @@ int cac_SamAddGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamA
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_add_groupmem( &(srv->cli), mem_ctx, op->in.group_hnd, op->in.rid);
+ hnd->status = rpccli_samr_add_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd, op->in.rid);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -881,7 +857,7 @@ int cac_SamAddGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamA
}
int cac_SamRemoveGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveGroupMember *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -896,15 +872,13 @@ int cac_SamRemoveGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct S
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_del_groupmem( &(srv->cli), mem_ctx, op->in.group_hnd, op->in.rid);
+ hnd->status = rpccli_samr_del_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd, op->in.rid);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -913,7 +887,7 @@ int cac_SamRemoveGroupMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct S
}
int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
int result = CAC_SUCCESS;
@@ -938,22 +912,20 @@ int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_H
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_groupmem(&(srv->cli), mem_ctx, group_hnd, &num_mem, &rid, &attr);
+ hnd->status = rpccli_samr_query_groupmem(pipe_hnd, mem_ctx, group_hnd, &num_mem, &rid, &attr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
/*try to delete the users one by one*/
for(i = 0; i < num_mem && NT_STATUS_IS_OK(hnd->status); i++) {
- hnd->status = cli_samr_del_groupmem(&(srv->cli), mem_ctx, group_hnd, rid[i]);
+ hnd->status = rpccli_samr_del_groupmem(pipe_hnd, mem_ctx, group_hnd, rid[i]);
}
/*if not all members could be removed, then try to re-add the members that were already deleted*/
@@ -961,7 +933,7 @@ int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_H
status = NT_STATUS_OK;
for(i -= 1; i >= 0 && NT_STATUS_IS_OK(status); i--) {
- status = cli_samr_add_groupmem( &(srv->cli), mem_ctx, group_hnd, rid[i]);
+ status = rpccli_samr_add_groupmem( pipe_hnd, mem_ctx, group_hnd, rid[i]);
}
/*we return with the NTSTATUS error that we got when trying to delete users*/
@@ -975,7 +947,7 @@ int cac_SamClearGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_H
}
int cac_SamSetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupMembers *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 i = 0;
@@ -992,21 +964,19 @@ int cac_SamSetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
/*use cac_SamClearGroupMembers() to clear them*/
if(!cac_SamClearGroupMembers(hnd, mem_ctx, op->in.group_hnd))
return CAC_FAILURE; /*hnd->status is already set*/
for(i = 0; i < op->in.num_members && NT_STATUS_IS_OK(hnd->status); i++) {
- hnd->status = cli_samr_add_groupmem( &(srv->cli), mem_ctx, op->in.group_hnd, op->in.rids[i]);
+ hnd->status = rpccli_samr_add_groupmem( pipe_hnd, mem_ctx, op->in.group_hnd, op->in.rids[i]);
}
if(!NT_STATUS_IS_OK(hnd->status))
@@ -1017,7 +987,7 @@ int cac_SamSetGroupMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
}
int cac_SamEnumGroups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumGroups *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 i = 0;
@@ -1046,17 +1016,15 @@ int cac_SamEnumGroups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumG
if(op->out.done == True) /*we return failure so the call will break out of a loop*/
return CAC_FAILURE;
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
resume_idx_out = op->out.resume_idx;
- hnd->status = cli_samr_enum_dom_groups( &(srv->cli), mem_ctx, op->in.dom_hnd, &resume_idx_out, SAMR_ENUM_MAX_SIZE,
+ hnd->status = rpccli_samr_enum_dom_groups( pipe_hnd, mem_ctx, op->in.dom_hnd, &resume_idx_out, SAMR_ENUM_MAX_SIZE,
&acct_buf, &num_groups_out);
@@ -1114,7 +1082,7 @@ int cac_SamEnumGroups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumG
}
int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumAliases *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 i = 0;
@@ -1144,17 +1112,15 @@ int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnum
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
resume_idx_out = op->out.resume_idx;
- hnd->status = cli_samr_enum_als_groups( &(srv->cli), mem_ctx, op->in.dom_hnd, &resume_idx_out, SAMR_ENUM_MAX_SIZE,
+ hnd->status = rpccli_samr_enum_als_groups( pipe_hnd, mem_ctx, op->in.dom_hnd, &resume_idx_out, SAMR_ENUM_MAX_SIZE,
&acct_buf, &num_als_out);
@@ -1211,7 +1177,7 @@ int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnum
}
int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *als_hnd_out = NULL;
@@ -1228,21 +1194,19 @@ int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCrea
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
als_hnd_out = talloc(mem_ctx, POLICY_HND);
if(!als_hnd_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_create_dom_alias( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.name, als_hnd_out);
+ hnd->status = rpccli_samr_create_dom_alias( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.name, als_hnd_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1254,7 +1218,7 @@ int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCrea
}
int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *als_hnd_out = NULL;
@@ -1271,21 +1235,19 @@ int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAl
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
als_hnd_out = talloc(mem_ctx, POLICY_HND);
if(!als_hnd_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_open_alias( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.access, op->in.rid, als_hnd_out);
+ hnd->status = rpccli_samr_open_alias( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.access, op->in.rid, als_hnd_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1296,7 +1258,7 @@ int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAl
}
int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1311,15 +1273,13 @@ int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *al
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_delete_dom_alias( &(srv->cli), mem_ctx, alias_hnd);
+ hnd->status = rpccli_samr_delete_dom_alias( pipe_hnd, mem_ctx, alias_hnd);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1329,7 +1289,7 @@ int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *al
}
int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1344,15 +1304,13 @@ int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamA
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_add_aliasmem( &(srv->cli), mem_ctx, op->in.alias_hnd, op->in.sid);
+ hnd->status = rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd, op->in.sid);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1361,7 +1319,7 @@ int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamA
}
int cac_SamRemoveAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRemoveAliasMember *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1376,15 +1334,13 @@ int cac_SamRemoveAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct S
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_del_aliasmem( &(srv->cli), mem_ctx, op->in.alias_hnd, op->in.sid);
+ hnd->status = rpccli_samr_del_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd, op->in.sid);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1393,7 +1349,7 @@ int cac_SamRemoveAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct S
}
int cac_SamGetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasMembers *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 num_mem_out;
DOM_SID *sids_out;
@@ -1411,15 +1367,13 @@ int cac_SamGetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_aliasmem( &(srv->cli), mem_ctx, op->in.alias_hnd, &num_mem_out, &sids_out);
+ hnd->status = rpccli_samr_query_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd, &num_mem_out, &sids_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1431,7 +1385,7 @@ int cac_SamGetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
}
int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
int result = CAC_SUCCESS;
@@ -1455,22 +1409,20 @@ int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_H
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_aliasmem(&(srv->cli), mem_ctx, alias_hnd, &num_mem, &sid);
+ hnd->status = rpccli_samr_query_aliasmem(pipe_hnd, mem_ctx, alias_hnd, &num_mem, &sid);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
/*try to delete the users one by one*/
for(i = 0; i < num_mem && NT_STATUS_IS_OK(hnd->status); i++) {
- hnd->status = cli_samr_del_aliasmem(&(srv->cli), mem_ctx, alias_hnd, &sid[i]);
+ hnd->status = rpccli_samr_del_aliasmem(pipe_hnd, mem_ctx, alias_hnd, &sid[i]);
}
/*if not all members could be removed, then try to re-add the members that were already deleted*/
@@ -1478,7 +1430,7 @@ int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_H
status = NT_STATUS_OK;
for(i -= 1; i >= 0 && NT_STATUS_IS_OK(status); i--) {
- status = cli_samr_add_aliasmem( &(srv->cli), mem_ctx, alias_hnd, &sid[i]);
+ status = rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx, alias_hnd, &sid[i]);
}
/*we return with the NTSTATUS error that we got when trying to delete users*/
@@ -1491,7 +1443,7 @@ int cac_SamClearAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_H
}
int cac_SamSetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasMembers *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
uint32 i = 0;
@@ -1508,21 +1460,19 @@ int cac_SamSetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
/*use cac_SamClearAliasMembers() to clear them*/
if(!cac_SamClearAliasMembers(hnd, mem_ctx, op->in.alias_hnd))
return CAC_FAILURE; /*hnd->status is already set*/
for(i = 0; i < op->in.num_members && NT_STATUS_IS_OK(hnd->status); i++) {
- hnd->status = cli_samr_add_aliasmem( &(srv->cli), mem_ctx, op->in.alias_hnd, &(op->in.sids[i]));
+ hnd->status = rpccli_samr_add_aliasmem( pipe_hnd, mem_ctx, op->in.alias_hnd, &(op->in.sids[i]));
}
if(!NT_STATUS_IS_OK(hnd->status))
@@ -1534,6 +1484,7 @@ int cac_SamSetAliasMembers(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sam
int cac_SamUserChangePasswd(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamUserChangePasswd *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1556,17 +1507,20 @@ int cac_SamUserChangePasswd(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
/*open a session on SAMR if we don't have one*/
if(!hnd->_internal.pipes[PI_SAMR]) {
- if(!cli_nt_session_open(&srv->cli, PI_SAMR)) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_SAMR, &(hnd->status)))) {
return CAC_FAILURE;
}
hnd->_internal.pipes[PI_SAMR] = True;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- hnd->status = cli_samr_chgpasswd_user(&(srv->cli), mem_ctx, op->in.username, op->in.new_password, op->in.password);
+ hnd->status = rpccli_samr_chgpasswd_user(pipe_hnd, mem_ctx, op->in.username, op->in.new_password, op->in.password);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1576,6 +1530,7 @@ int cac_SamUserChangePasswd(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR *ctr;
@@ -1598,10 +1553,14 @@ int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *use
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
/*info_level = 21 is the only level that I have found to work reliably. It would be nice if user_level = 10 worked.*/
- hnd->status = cli_samr_query_userinfo( &(srv->cli), mem_ctx, user_hnd, 0x10, &ctr);
+ hnd->status = rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, user_hnd, 0x10, &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1617,7 +1576,7 @@ int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *use
}
/*now set the userinfo*/
- hnd->status = cli_samr_set_userinfo2( &(srv->cli), mem_ctx, user_hnd, 0x10, &(srv->cli.user_session_key), ctr);
+ hnd->status = rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, user_hnd, 0x10, &(srv->cli.user_session_key), ctr);
/*this will only work properly if we use set_userinfo2 - fail if it is not supported*/
if(!NT_STATUS_IS_OK(hnd->status))
@@ -1628,6 +1587,7 @@ int cac_SamEnableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *use
int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR *ctr;
@@ -1650,9 +1610,13 @@ int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *us
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- hnd->status = cli_samr_query_userinfo( &(srv->cli), mem_ctx, user_hnd, 0x10, &ctr);
+ hnd->status = rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, user_hnd, 0x10, &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1666,7 +1630,7 @@ int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *us
ctr->info.id16->acb_info ^= ACB_DISABLED;
/*this will only work properly if we use set_userinfo2*/
- hnd->status = cli_samr_set_userinfo2( &(srv->cli), mem_ctx, user_hnd, 0x10, &(srv->cli.user_session_key), ctr);
+ hnd->status = rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, user_hnd, 0x10, &(srv->cli.user_session_key), ctr);
/*this will only work properly if we use set_userinfo2 fail if it is not supported*/
if(!NT_STATUS_IS_OK(hnd->status))
@@ -1677,6 +1641,7 @@ int cac_SamDisableUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *us
int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetPassword *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR ctr;
SAM_USER_INFO_24 info24;
@@ -1701,7 +1666,11 @@ int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetP
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
ZERO_STRUCT(ctr);
ZERO_STRUCT(info24);
@@ -1713,7 +1682,7 @@ int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetP
ctr.switch_value = 24;
ctr.info.id24 = &info24;
- hnd->status = cli_samr_set_userinfo( &(srv->cli), mem_ctx, op->in.user_hnd, 24, &(srv->cli.user_session_key), &ctr);
+ hnd->status = rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd, 24, &(srv->cli.user_session_key), &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1722,7 +1691,7 @@ int cac_SamSetPassword(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetP
}
int cac_SamGetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR *ctr;
@@ -1739,15 +1708,13 @@ int cac_SamGetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetU
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_userinfo( &(srv->cli), mem_ctx, op->in.user_hnd, 21, &ctr);
+ hnd->status = rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd, 21, &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1764,6 +1731,7 @@ int cac_SamGetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetU
int cac_SamSetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfo *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR *ctr;
@@ -1792,14 +1760,18 @@ int cac_SamSetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetU
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
if(hnd->_internal.srv_level >= SRV_WIN_NT4) {
- hnd->status = cli_samr_set_userinfo2( &(srv->cli), mem_ctx, op->in.user_hnd, 21, &(srv->cli.user_session_key), ctr);
+ hnd->status = rpccli_samr_set_userinfo2( pipe_hnd, mem_ctx, op->in.user_hnd, 21, &(srv->cli.user_session_key), ctr);
}
if(hnd->_internal.srv_level < SRV_WIN_NT4 || !NT_STATUS_IS_OK(hnd->status)) {
- hnd->status = cli_samr_set_userinfo( &(srv->cli), mem_ctx, op->in.user_hnd, 21, &(srv->cli.user_session_key), ctr);
+ hnd->status = rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd, 21, &(srv->cli.user_session_key), ctr);
if(NT_STATUS_IS_OK(hnd->status) && hnd->_internal.srv_level > SRV_WIN_NT4) {
hnd->_internal.srv_level = SRV_WIN_NT4;
@@ -1815,7 +1787,7 @@ int cac_SamSetUserInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetU
int cac_SamGetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetUserInfoCtr *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR *ctr_out;
@@ -1832,15 +1804,13 @@ int cac_SamGetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamG
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_userinfo( &(srv->cli), mem_ctx, op->in.user_hnd, op->in.info_class, &ctr_out);
+ hnd->status = rpccli_samr_query_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd, op->in.info_class, &ctr_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1852,6 +1822,7 @@ int cac_SamGetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamG
int cac_SamSetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetUserInfoCtr *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1872,10 +1843,14 @@ int cac_SamSetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamS
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- hnd->status = cli_samr_set_userinfo( &(srv->cli), mem_ctx, op->in.user_hnd, op->in.ctr->switch_value, &(srv->cli.user_session_key), op->in.ctr);
+ hnd->status = rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd, op->in.ctr->switch_value, &(srv->cli.user_session_key), op->in.ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1886,6 +1861,7 @@ int cac_SamSetUserInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamS
int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameUser *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_USERINFO_CTR ctr;
SAM_USER_INFO_7 info7;
@@ -1909,7 +1885,11 @@ int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenam
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
ZERO_STRUCT(ctr);
ZERO_STRUCT(info7);
@@ -1919,7 +1899,7 @@ int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenam
ctr.switch_value = 7;
ctr.info.id7 = &info7;
- hnd->status = cli_samr_set_userinfo( &(srv->cli), mem_ctx, op->in.user_hnd, 7, &(srv->cli.user_session_key), &ctr);
+ hnd->status = rpccli_samr_set_userinfo( pipe_hnd, mem_ctx, op->in.user_hnd, 7, &(srv->cli.user_session_key), &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1929,7 +1909,7 @@ int cac_SamRenameUser(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenam
int cac_SamGetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetGroupInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
GROUP_INFO_CTR *ctr;
@@ -1946,16 +1926,15 @@ int cac_SamGetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGet
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
/*get a GROUP_INFO_1 structure*/
- hnd->status = cli_samr_query_groupinfo( &(srv->cli), mem_ctx, op->in.group_hnd, 1, &ctr);
+ hnd->status = rpccli_samr_query_groupinfo( pipe_hnd, mem_ctx, op->in.group_hnd, 1, &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -1970,7 +1949,7 @@ int cac_SamGetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGet
}
int cac_SamSetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetGroupInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
GROUP_INFO_CTR *ctr = NULL;
@@ -1993,15 +1972,13 @@ int cac_SamSetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSet
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_set_groupinfo(&(srv->cli), mem_ctx, op->in.group_hnd, ctr);
+ hnd->status = rpccli_samr_set_groupinfo(pipe_hnd, mem_ctx, op->in.group_hnd, ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2010,7 +1987,7 @@ int cac_SamSetGroupInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSet
}
int cac_SamRenameGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRenameGroup *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
GROUP_INFO_CTR ctr;
@@ -2027,20 +2004,18 @@ int cac_SamRenameGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRena
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
-
- srv->cli.pipe_idx = PI_SAMR;
ZERO_STRUCT(ctr);
init_samr_group_info2(&ctr.group.info2, op->in.new_name);
ctr.switch_value1 = 2;
- hnd->status = cli_samr_set_groupinfo( &(srv->cli), mem_ctx, op->in.group_hnd, &ctr);
+ hnd->status = rpccli_samr_set_groupinfo( pipe_hnd, mem_ctx, op->in.group_hnd, &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2049,7 +2024,7 @@ int cac_SamRenameGroup(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamRena
}
int cac_SamGetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetAliasInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
ALIAS_INFO_CTR ctr;
@@ -2066,16 +2041,14 @@ int cac_SamGetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGet
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
/*get a GROUP_INFO_1 structure*/
- hnd->status = cli_samr_query_alias_info( &(srv->cli), mem_ctx, op->in.alias_hnd, 1, &ctr);
+ hnd->status = rpccli_samr_query_alias_info( pipe_hnd, mem_ctx, op->in.alias_hnd, 1, &ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2091,7 +2064,7 @@ int cac_SamGetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGet
}
int cac_SamSetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSetAliasInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
ALIAS_INFO_CTR *ctr = NULL;
@@ -2114,15 +2087,13 @@ int cac_SamSetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSet
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_set_aliasinfo(&(srv->cli), mem_ctx, op->in.alias_hnd, ctr);
+ hnd->status = rpccli_samr_set_aliasinfo(pipe_hnd, mem_ctx, op->in.alias_hnd, ctr);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2131,7 +2102,7 @@ int cac_SamSetAliasInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamSet
}
int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_UNK_CTR ctr;
SAM_UNK_INFO_1 info1;
@@ -2157,16 +2128,14 @@ int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGe
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
/*first try with info 1*/
- hnd->status = cli_samr_query_dom_info( &(srv->cli), mem_ctx, op->in.dom_hnd, 1, &ctr);
+ hnd->status = rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd, 1, &ctr);
if(NT_STATUS_IS_OK(hnd->status)) {
/*then we buffer the SAM_UNK_INFO_1 structure*/
@@ -2180,7 +2149,7 @@ int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGe
}
/*try again for the next one*/
- hnd->status = cli_samr_query_dom_info( &(srv->cli), mem_ctx, op->in.dom_hnd, 2, &ctr);
+ hnd->status = rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd, 2, &ctr);
if(NT_STATUS_IS_OK(hnd->status)) {
/*store the info*/
@@ -2194,7 +2163,7 @@ int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGe
}
/*once more*/
- hnd->status = cli_samr_query_dom_info( &(srv->cli), mem_ctx, op->in.dom_hnd, 12, &ctr);
+ hnd->status = rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd, 12, &ctr);
if(NT_STATUS_IS_OK(hnd->status)) {
info12 = ctr.info.inf12;
@@ -2225,7 +2194,7 @@ int cac_SamGetDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGe
}
int cac_SamGetDomainInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDomainInfoCtr *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_UNK_CTR *ctr_out;
@@ -2242,21 +2211,19 @@ int cac_SamGetDomainInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
ctr_out = talloc(mem_ctx, SAM_UNK_CTR);
if(!ctr_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_query_dom_info( &(srv->cli), mem_ctx, op->in.dom_hnd, op->in.info_class, ctr_out);
+ hnd->status = rpccli_samr_query_dom_info( pipe_hnd, mem_ctx, op->in.dom_hnd, op->in.info_class, ctr_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2267,7 +2234,7 @@ int cac_SamGetDomainInfoCtr(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sa
}
int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetDisplayInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
SAM_DISPINFO_CTR ctr_out;
@@ -2293,14 +2260,12 @@ int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamG
if(op->out.done == True) /*this is done so we can use the function as a loop condition*/
return CAC_FAILURE;
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
if(op->in.max_entries == 0 || op->in.max_size == 0) {
get_query_dispinfo_params(op->out.loop_count, &max_entries_buf, &max_size_buf);
}
@@ -2311,7 +2276,7 @@ int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamG
resume_idx_out = op->out.resume_idx;
- hnd->status = cli_samr_query_dispinfo( &(srv->cli), mem_ctx, op->in.dom_hnd, &resume_idx_out, op->in.info_class,
+ hnd->status = rpccli_samr_query_dispinfo( pipe_hnd, mem_ctx, op->in.dom_hnd, &resume_idx_out, op->in.info_class,
&num_entries_out, max_entries_buf, max_size_buf, &ctr_out);
if(!NT_STATUS_IS_OK(hnd->status) && !NT_STATUS_EQUAL(hnd->status, STATUS_MORE_ENTRIES)) {
@@ -2335,7 +2300,7 @@ int cac_SamGetDisplayInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamG
}
int cac_SamLookupDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLookupDomain *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
DOM_SID *sid_out = NULL;
@@ -2352,21 +2317,19 @@ int cac_SamLookupDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLoo
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
sid_out = talloc(mem_ctx, DOM_SID);
if(!sid_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- hnd->status = cli_samr_lookup_domain( &(srv->cli), mem_ctx, op->in.sam, op->in.name, sid_out);
+ hnd->status = rpccli_samr_lookup_domain( pipe_hnd, mem_ctx, op->in.sam, op->in.name, sid_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2377,7 +2340,7 @@ int cac_SamLookupDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamLoo
}
int cac_SamGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamGetSecurityObject *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
/*this number taken from rpcclient/cmd_samr.c, I think it is the only supported level*/
uint16 info_level = 4;
@@ -2397,15 +2360,13 @@ int cac_SamGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct S
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SAMR);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SAMR;
-
- hnd->status = cli_samr_query_sec_obj(&(srv->cli), mem_ctx, op->in.pol, info_level, mem_ctx, &sec_out);
+ hnd->status = rpccli_samr_query_sec_obj(pipe_hnd, mem_ctx, op->in.pol, info_level, mem_ctx, &sec_out);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
@@ -2416,8 +2377,6 @@ int cac_SamGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct S
}
int cac_SamFlush(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op) {
- SMBCSRV *srv = NULL;
-
struct SamOpenDomain od;
if(!hnd)
@@ -2433,14 +2392,6 @@ int cac_SamFlush(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op)
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
- srv->cli.pipe_idx = PI_SAMR;
-
if(!cac_SamClose(hnd, mem_ctx, op->in.dom_hnd))
return CAC_FAILURE;
diff --git a/source3/libmsrpc/cac_svcctl.c b/source3/libmsrpc/cac_svcctl.c
index 71c83eba94..2651be64ab 100644
--- a/source3/libmsrpc/cac_svcctl.c
+++ b/source3/libmsrpc/cac_svcctl.c
@@ -21,10 +21,11 @@
#include "libmsrpc.h"
#include "libsmb_internal.h"
-#define WAIT_SLEEP_TIME 300
+#define WAIT_SLEEP_TIME 300000
int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
POLICY_HND *scm_out = NULL;
@@ -41,7 +42,7 @@ int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm
hnd->status = NT_STATUS_INVALID_PARAMETER;
return CAC_FAILURE;
}
-
+
srv = cac_GetServer(hnd);
if(!srv) {
hnd->status = NT_STATUS_INVALID_CONNECTION;
@@ -50,7 +51,7 @@ int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm
/*initialize for samr pipe if we have to*/
if(!hnd->_internal.pipes[PI_SVCCTL]) {
- if(!cli_nt_session_open(&srv->cli, PI_SVCCTL)) {
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_SVCCTL, &(hnd->status)))) {
hnd->status = NT_STATUS_UNSUCCESSFUL;
return CAC_FAILURE;
}
@@ -58,15 +59,13 @@ int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm
hnd->_internal.pipes[PI_SVCCTL] = True;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
scm_out = talloc(mem_ctx, POLICY_HND);
if(!scm_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- err = cli_svcctl_open_scm( &(srv->cli), mem_ctx, scm_out, op->in.access);
+ err = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, scm_out, op->in.access);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -78,7 +77,7 @@ int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm
}
int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -94,15 +93,13 @@ int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd)
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_close_service( &(srv->cli), mem_ctx, scm_hnd);
+ err = rpccli_svcctl_close_service( pipe_hnd, mem_ctx, scm_hnd);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -112,7 +109,7 @@ int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd)
}
int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnumServices *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 type_buf = 0;
@@ -135,18 +132,16 @@ int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnu
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
type_buf = (op->in.type != 0) ? op->in.type : (SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32);
state_buf = (op->in.state != 0) ? op->in.state : SVCCTL_STATE_ALL;
- err = cli_svcctl_enumerate_services( &(srv->cli), mem_ctx, op->in.scm_hnd, type_buf, state_buf, &num_svc_out, &svc_buf);
+ err = rpccli_svcctl_enumerate_services( pipe_hnd, mem_ctx, op->in.scm_hnd, type_buf, state_buf, &num_svc_out, &svc_buf);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -167,7 +162,7 @@ int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnu
}
int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenService *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
POLICY_HND *svc_hnd_out = NULL;
@@ -185,21 +180,19 @@ int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpen
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
svc_hnd_out = talloc(mem_ctx, POLICY_HND);
if(!svc_hnd_out) {
hnd->status = NT_STATUS_NO_MEMORY;
return CAC_FAILURE;
}
- err = cli_svcctl_open_service( &(srv->cli), mem_ctx, op->in.scm_hnd, svc_hnd_out, op->in.name, op->in.access);
+ err = rpccli_svcctl_open_service( pipe_hnd, mem_ctx, op->in.scm_hnd, svc_hnd_out, op->in.name, op->in.access);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -211,7 +204,7 @@ int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpen
}
int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcControlService *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_STATUS status_out;
@@ -234,15 +227,13 @@ int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcC
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, op->in.control, &status_out);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, op->in.control, &status_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -252,7 +243,7 @@ int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcC
}
int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetStatus *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_STATUS status_out;
@@ -270,15 +261,13 @@ int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetSta
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_query_status( &(srv->cli), mem_ctx, op->in.svc_hnd, &status_out);
+ err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, op->in.svc_hnd, &status_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -300,7 +289,7 @@ int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetSta
* or CAC_SUCCESS if the state is reached
*/
int cac_WaitForService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *svc_hnd, uint32 state, uint32 timeout, SERVICE_STATUS *status) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
/*number of milliseconds we have spent*/
uint32 time_spent = 0;
WERROR err;
@@ -308,21 +297,21 @@ int cac_WaitForService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sv
if(!hnd || !mem_ctx || !svc_hnd || !status)
return CAC_FAILURE;
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- while(status->state != state && time_spent < (timeout * 1000) && NT_STATUS_IS_OK(hnd->status)) {
+ while(status->state != state && time_spent < (timeout * 1000000) && NT_STATUS_IS_OK(hnd->status)) {
/*if this is the first call, then we _just_ got the status.. sleep now*/
usleep(WAIT_SLEEP_TIME);
time_spent += WAIT_SLEEP_TIME;
- err = cli_svcctl_query_status(&(srv->cli), mem_ctx, svc_hnd, status);
+ err = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, svc_hnd, status);
hnd->status = werror_to_ntstatus(err);
}
-
+
if(status->state == state)
return CAC_SUCCESS;
@@ -330,7 +319,7 @@ int cac_WaitForService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *sv
}
int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStartService *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_STATUS status_buf;
@@ -353,15 +342,13 @@ int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcSta
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_start_service(&(srv->cli), mem_ctx, op->in.svc_hnd, (const char **)op->in.parms, op->in.num_parms);
+ err = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, op->in.svc_hnd, (const char **)op->in.parms, op->in.num_parms);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -374,7 +361,7 @@ int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcSta
}
int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStopService *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_STATUS status_out;
@@ -392,15 +379,13 @@ int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStop
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_STOP, &status_out);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_STOP, &status_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -415,7 +400,7 @@ int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStop
}
int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPauseService *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_STATUS status_out;
@@ -433,15 +418,13 @@ int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPau
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_PAUSE, &status_out);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_PAUSE, &status_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -456,7 +439,7 @@ int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPau
}
int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcContinueService *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_STATUS status_out;
@@ -474,15 +457,13 @@ int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Svc
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_CONTINUE, &status_out);
+ err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_CONTINUE, &status_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -497,7 +478,7 @@ int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Svc
}
int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetDisplayName *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
fstring disp_name_out;
@@ -515,15 +496,13 @@ int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcG
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_get_dispname( &(srv->cli), mem_ctx, op->in.svc_hnd, disp_name_out);
+ err = rpccli_svcctl_get_dispname( pipe_hnd, mem_ctx, op->in.svc_hnd, disp_name_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -541,7 +520,7 @@ int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcG
int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetServiceConfig *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
SERVICE_CONFIG config_out;
@@ -559,15 +538,13 @@ int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sv
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SVCCTL;
-
- err = cli_svcctl_query_config( &(srv->cli), mem_ctx, op->in.svc_hnd, &config_out);
+ err = rpccli_svcctl_query_config( pipe_hnd, mem_ctx, op->in.svc_hnd, &config_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
diff --git a/source3/libmsrpc/cac_winreg.c b/source3/libmsrpc/cac_winreg.c
index 3a90aa871e..66fa8806fd 100644
--- a/source3/libmsrpc/cac_winreg.c
+++ b/source3/libmsrpc/cac_winreg.c
@@ -24,6 +24,7 @@
int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *key = NULL;
WERROR err;
@@ -48,8 +49,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
/*initialize for winreg pipe if we have to*/
if(!hnd->_internal.pipes[PI_WINREG]) {
- if(!cli_nt_session_open(&srv->cli, PI_WINREG)) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_WINREG, &(hnd->status)))) {
return CAC_FAILURE;
}
@@ -61,7 +61,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
hnd->status = NT_STATUS_NO_MEMORY;
}
- err = cli_reg_connect( &(srv->cli), mem_ctx, op->in.root, op->in.access, key);
+ err = rpccli_reg_connect( pipe_hnd, mem_ctx, op->in.root, op->in.access, key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -74,7 +74,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
}
int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -90,13 +90,13 @@ int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- err = cli_reg_close(&srv->cli, mem_ctx, key);
+ err = rpccli_reg_close(pipe_hnd, mem_ctx, key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -107,7 +107,7 @@ int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
}
int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
POLICY_HND *key_out;
@@ -131,12 +131,6 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
key_out = talloc(mem_ctx, POLICY_HND);
if(!key_out) {
@@ -174,9 +168,13 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
key_name = op->in.name;
}
- srv->cli.pipe_idx = PI_WINREG;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = cli_reg_open_entry( &(srv->cli), mem_ctx, parent_key, key_name, op->in.access, key_out);
+ err = rpccli_reg_open_entry( pipe_hnd, mem_ctx, parent_key, key_name, op->in.access, key_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -185,7 +183,7 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
if(!op->in.parent_key) {
/*then close the one that we opened above*/
- err = cli_reg_close( &(srv->cli), mem_ctx, parent_key);
+ err = rpccli_reg_close( pipe_hnd, mem_ctx, parent_key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -199,10 +197,10 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
}
int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
- /*buffers for cli_reg_enum_key call*/
+ /*buffers for rpccli_reg_enum_key call*/
fstring key_name_in;
fstring class_name_in;
@@ -230,14 +228,12 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
/**the only way to know how many keys to expect is to assume max_keys keys will be found*/
key_names_out = TALLOC_ARRAY(mem_ctx, char *, op->in.max_keys);
if(!key_names_out) {
@@ -264,7 +260,7 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
resume_idx = op->out.resume_idx;
do {
- err = cli_reg_enum_key( &(srv->cli), mem_ctx, op->in.key, resume_idx, key_name_in, class_name_in, &mod_times_out[num_keys_out]);
+ err = rpccli_reg_enum_key( pipe_hnd, mem_ctx, op->in.key, resume_idx, key_name_in, class_name_in, &mod_times_out[num_keys_out]);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -300,7 +296,7 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
}
int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
POLICY_HND *key_out;
@@ -320,12 +316,6 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
/*first try to open the key - we use cac_RegOpenKey(). this doubles as a way to ensure the winreg pipe is initialized*/
ZERO_STRUCT(rok);
@@ -340,7 +330,11 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
}
/*just be ultra-safe*/
- srv->cli.pipe_idx = PI_WINREG;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
key_out = talloc(mem_ctx, POLICY_HND);
if(!key_out) {
@@ -348,7 +342,7 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
return CAC_FAILURE;
}
- err = cli_reg_create_key_ex( &(srv->cli), mem_ctx, op->in.parent_key, op->in.key_name, op->in.class_name, op->in.access, key_out);
+ err = rpccli_reg_create_key_ex( pipe_hnd, mem_ctx, op->in.parent_key, op->in.key_name, op->in.class_name, op->in.access, key_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -361,7 +355,7 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
}
-WERROR cac_delete_subkeys_recursive(struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
+WERROR cac_delete_subkeys_recursive(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
/*NOTE: using cac functions might result in a big(ger) memory bloat, and would probably be far less efficient
* so we use the cli_reg functions directly*/
@@ -375,30 +369,30 @@ WERROR cac_delete_subkeys_recursive(struct cli_state *cli, TALLOC_CTX *mem_ctx,
int cur_key = 0;
while(W_ERROR_IS_OK(err)) {
- err = cli_reg_enum_key( cli, mem_ctx, key, cur_key, subkey_name, class_buf, &mod_time_buf);
+ err = rpccli_reg_enum_key( pipe_hnd, mem_ctx, key, cur_key, subkey_name, class_buf, &mod_time_buf);
if(!W_ERROR_IS_OK(err))
break;
/*try to open the key with full access*/
- err = cli_reg_open_entry(cli, mem_ctx, key, subkey_name, REG_KEY_ALL, &subkey);
+ err = rpccli_reg_open_entry(pipe_hnd, mem_ctx, key, subkey_name, REG_KEY_ALL, &subkey);
if(!W_ERROR_IS_OK(err))
break;
- err = cac_delete_subkeys_recursive(cli, mem_ctx, &subkey);
+ err = cac_delete_subkeys_recursive(pipe_hnd, mem_ctx, &subkey);
if(!W_ERROR_EQUAL(err,WERR_NO_MORE_ITEMS) && !W_ERROR_IS_OK(err))
break;
/*flush the key just to be safe*/
- cli_reg_flush_key(cli, mem_ctx, key);
+ rpccli_reg_flush_key(pipe_hnd, mem_ctx, key);
/*close the key that we opened*/
- cli_reg_close(cli, mem_ctx, &subkey);
+ rpccli_reg_close(pipe_hnd, mem_ctx, &subkey);
/*now we delete the subkey*/
- err = cli_reg_delete_key(cli, mem_ctx, key, subkey_name);
+ err = rpccli_reg_delete_key(pipe_hnd, mem_ctx, key, subkey_name);
cur_key++;
@@ -411,7 +405,7 @@ WERROR cac_delete_subkeys_recursive(struct cli_state *cli, TALLOC_CTX *mem_ctx,
int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -427,14 +421,12 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
if(op->in.recursive) {
/*first open the key, and then delete all of it's subkeys recursively*/
struct RegOpenKey rok;
@@ -447,7 +439,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
if(!cac_RegOpenKey(hnd, mem_ctx, &rok))
return CAC_FAILURE;
- err = cac_delete_subkeys_recursive(&(srv->cli), mem_ctx, rok.out.key);
+ err = cac_delete_subkeys_recursive(pipe_hnd, mem_ctx, rok.out.key);
/*close the key that we opened*/
cac_RegClose(hnd, mem_ctx, rok.out.key);
@@ -460,7 +452,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
/*now go on to actually delete the key*/
}
- err = cli_reg_delete_key( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
+ err = rpccli_reg_delete_key( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -471,7 +463,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
}
int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -487,15 +479,13 @@ int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDele
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_delete_val( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
+ err = rpccli_reg_delete_val( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -506,7 +496,7 @@ int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDele
}
int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryKeyInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
char *class_name_out = NULL;
@@ -533,15 +523,13 @@ int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQue
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_query_key( &(srv->cli), mem_ctx, op->in.key,
+ err = rpccli_reg_query_key( pipe_hnd, mem_ctx, op->in.key,
class_name_out,
&class_len,
&num_subkeys_out,
@@ -591,7 +579,7 @@ int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQue
}
int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 val_type;
@@ -611,15 +599,13 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_query_value(&srv->cli, mem_ctx, op->in.key, op->in.val_name, &val_type, &buffer);
+ err = rpccli_reg_query_value(pipe_hnd, mem_ctx, op->in.key, op->in.val_name, &val_type, &buffer);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -643,10 +629,10 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery
int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
- /*buffers for cli_reg_enum_key call*/
+ /*buffers for rpccli_reg_enum_key call*/
fstring val_name_buf;
REGVAL_BUFFER val_buf;
@@ -674,14 +660,12 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
/*we need to assume that the max number of values will be enumerated*/
types_out = talloc_array(mem_ctx, int, op->in.max_values);
if(!types_out) {
@@ -708,7 +692,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
do {
ZERO_STRUCT(val_buf);
- err = cli_reg_enum_val(&srv->cli, mem_ctx, op->in.key, resume_idx, val_name_buf, &types_out[num_values_out], &val_buf);
+ err = rpccli_reg_enum_val(pipe_hnd, mem_ctx, op->in.key, resume_idx, val_name_buf, &types_out[num_values_out], &val_buf);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -739,7 +723,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
}
int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
RPC_DATA_BLOB *buffer;
@@ -757,14 +741,12 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
buffer = cac_MakeRpcDataBlob(mem_ctx, op->in.type, op->in.value);
if(!buffer) {
@@ -776,14 +758,14 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
return CAC_FAILURE;
}
- err = cli_reg_set_val(&srv->cli, mem_ctx, op->in.key, op->in.val_name, op->in.type, buffer);
+ err = rpccli_reg_set_val(pipe_hnd, mem_ctx, op->in.key, op->in.val_name, op->in.type, buffer);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
/*flush*/
- err = cli_reg_flush_key(&(srv->cli), mem_ctx, op->in.key);
+ err = rpccli_reg_flush_key(pipe_hnd, mem_ctx, op->in.key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -795,7 +777,7 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 version_out;
@@ -813,15 +795,13 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_getversion( &(srv->cli), mem_ctx, op->in.key, &version_out);
+ err = rpccli_reg_getversion( pipe_hnd, mem_ctx, op->in.key, &version_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -833,7 +813,7 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe
}
int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 buf_size;
@@ -852,15 +832,13 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_get_key_sec(&(srv->cli), mem_ctx, op->in.key, op->in.info_type, &buf_size, buf);
+ err = rpccli_reg_get_key_sec(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, &buf_size, buf);
hnd->status = werror_to_ntstatus(err);
@@ -875,7 +853,7 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG
}
int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -891,15 +869,13 @@ int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegS
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_set_key_sec(&(srv->cli), mem_ctx, op->in.key, op->in.info_type, op->in.size, op->in.descriptor);
+ err = rpccli_reg_set_key_sec(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, op->in.size, op->in.descriptor);
hnd->status = werror_to_ntstatus(err);
@@ -911,7 +887,7 @@ int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegS
}
int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -927,15 +903,13 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_save_key( &(srv->cli), mem_ctx, op->in.key, op->in.filename);
+ err = rpccli_reg_save_key( pipe_hnd, mem_ctx, op->in.key, op->in.filename);
hnd->status = werror_to_ntstatus(err);
@@ -948,6 +922,7 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey
int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
char *msg;
@@ -964,35 +939,31 @@ int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op)
return CAC_FAILURE;
}
-
srv = cac_GetServer(hnd);
if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
/*initialize for winreg pipe if we have to*/
if(!hnd->_internal.pipes[PI_SHUTDOWN]) {
- if(!cli_nt_session_open(&srv->cli, PI_SHUTDOWN)) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_SHUTDOWN, &(hnd->status)))) {
return CAC_FAILURE;
}
hnd->_internal.pipes[PI_SHUTDOWN] = True;
}
- srv->cli.pipe_idx = PI_SHUTDOWN;
-
msg = (op->in.message != NULL) ? op->in.message : talloc_strdup(mem_ctx, "");
hnd->status = NT_STATUS_OK;
if(hnd->_internal.srv_level > SRV_WIN_NT4) {
- hnd->status = cli_shutdown_init_ex( &(srv->cli), mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force, op->in.reason);
+ hnd->status = rpccli_shutdown_init_ex( pipe_hnd, mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force, op->in.reason);
}
if(hnd->_internal.srv_level < SRV_WIN_2K || !NT_STATUS_IS_OK(hnd->status)) {
- hnd->status = cli_shutdown_init( &(srv->cli), mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force);
+ hnd->status = rpccli_shutdown_init( pipe_hnd, mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force);
hnd->_internal.srv_level = SRV_WIN_NT4;
}
@@ -1005,7 +976,7 @@ int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op)
}
int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1015,15 +986,13 @@ int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SHUTDOWN);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SHUTDOWN;
-
- hnd->status = cli_shutdown_abort(&(srv->cli), mem_ctx);
+ hnd->status = rpccli_shutdown_abort(pipe_hnd, mem_ctx);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
diff --git a/source3/libmsrpc/libmsrpc.c b/source3/libmsrpc/libmsrpc.c
index 05f2dfe627..252e4ae0be 100644
--- a/source3/libmsrpc/libmsrpc.c
+++ b/source3/libmsrpc/libmsrpc.c
@@ -214,22 +214,18 @@ int cac_Connect(CacServerHandle *hnd, const char *srv) {
void cac_FreeHandle(CacServerHandle * hnd) {
SMBCSRV *srv = NULL;
uint32 i = 0;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return;
-
- /*see if there are any sessions*/
- while(i <= PI_MAX_PIPES && hnd->_internal.pipes[i] == False)
- i++;
- if(i < PI_MAX_PIPES) {
- /*then one or more sessions are open*/
- srv = cac_GetServer(hnd);
- if(srv)
- cli_nt_session_close(&(srv->cli));
+ if(srv) {
+ /*close all pipe sessions*/
+ cli_nt_pipes_close(&(srv->cli));
}
+
/*only free the context if we created it*/
if(!hnd->_internal.user_supplied_ctx) {
smbc_free_context(hnd->_internal.ctx, True);
diff --git a/source3/libmsrpc/libmsrpc_internal.c b/source3/libmsrpc/libmsrpc_internal.c
index 2560fd602b..6a524cdb03 100644
--- a/source3/libmsrpc/libmsrpc_internal.c
+++ b/source3/libmsrpc/libmsrpc_internal.c
@@ -22,6 +22,33 @@
#include "libmsrpc.h"
#include "libmsrpc_internal.h"
+/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/
+struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx) {
+ SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
+
+ if(!hnd)
+ return NULL;
+
+ if(hnd->_internal.pipes[pi_idx] == False) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return NULL;
+ }
+
+ srv = cac_GetServer(hnd);
+ if(!srv) {
+ hnd->status = NT_STATUS_INVALID_CONNECTION;
+ return NULL;
+ }
+
+ pipe_hnd = srv->cli.pipe_list;
+
+ while(pipe_hnd != NULL && pipe_hnd->pipe_idx != pi_idx)
+ pipe_hnd = pipe_hnd->next;
+
+ return pipe_hnd;
+}
+
/*takes a string like HKEY_LOCAL_MACHINE\HARDWARE\ACPI and returns the reg_type code and then a pointer to the start of the path (HARDWARE)*/
int cac_ParseRegPath(char *path, uint32 *reg_type, char **key_name) {