EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ bin/talloctort@EXEEXT@ \
bin/log2pcap@EXEEXT@
-SHLIBS = @SHLIB_PROGS@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@
+SHLIBS = @SHLIB_PROGS@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ cac
SCRIPTS = $(srcdir)/script/smbtar $(builddir)/script/findsmb
$(LIBMSRPC_OBJ) $(RPC_PARSE_OBJ) \
$(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ)
+CAC_OBJ = $(LIBSMBCLIENT_OBJ) \
+ libmsrpc/libmsrpc.o libmsrpc/libmsrpc_internal.o \
+ libmsrpc/cac_lsarpc.o libmsrpc/cac_winreg.o libmsrpc/cac_samr.o \
+ libmsrpc/cac_svcctl.o
+
LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o tdb/tdb.o tdb/spinlock.o
# This shared library is intended for linking with unit test programs
LIBSMBCLIENT_PICOBJS = $(LIBSMBCLIENT_OBJ:.o=.@PICSUFFIX@)
LIBSMBSHAREMODES_PICOBJS = $(LIBSMBSHAREMODES_OBJ:.o=.@PICSUFFIX@)
+CAC_PICOBJS = $(CAC_OBJ:.o=.@PICSUFFIX@)
+
+
PAM_SMBPASS_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \
pam_smbpass/pam_smb_acct.o pam_smbpass/support.o \
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
modules: SHOWFLAGS proto_exists $(MODULES)
+cac: SHOWFLAGS bin/libmsrpc.@SHLIBEXT@ bin/libmsrpc.a
+
everything: all libsmbclient debug2html smbfilter talloctort modules torture eventlogadm \
$(EVERYTHING_PROGS)
@echo Linking libsmbsharemodes non-shared library $@
@-$(AR) -rc $@ $(LIBSMBSHAREMODES_PICOBJS)
+bin/libmsrpc.@SHLIBEXT@: $(CAC_PICOBJS)
+ @echo Linking libmsrpc shared library $@
+ @$(SHLD) $(LDSHFLAGS) -o $@ $(CAC_PICOBJS) $(LDFLAGS) $(LIBS) \
+ @SONAMEFLAG@`basename $@`
+
+bin/libmsrpc.a: $(CAC_PICOBJS)
+ @echo Linking libmsrpc non-shared library $@
+ @-$(AR) -rc $@ $(CAC_PICOBJS)
+
# This is probably wrong for anything other than the GNU linker.
bin/libbigballofmud.@SHLIBEXT@: $(LIBBIGBALLOFMUD_PICOBJS)
@echo Linking bigballofmud shared library $@
@echo "Linking shared library $@"
@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_PICOOBJ) -lpam $(DYNEXP) $(LIBS) -lc $(LDAP_LIBS) $(KRB5LIBS)
-bin/libmsrpc.a: $(LIBMSRPC_PICOBJ)
- @-$(AR) -rc $@ $(LIBMSRPC_PICOBJ)
-
bin/tdbbackup@EXEEXT@: $(TDBBACKUP_OBJ) bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBBACKUP_OBJ) @SOCKWRAP@
/**@}*/ /*SCM_Functions*/
+struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx);
+
#endif /* LIBMSRPC_H */
BOOL user_supplied_ctx;
};
+/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/
+
/*nessecary prototypes*/
BOOL rid_in_list(uint32 rid, uint32 *list, uint32 list_len);
CacService *cac_MakeServiceArray(TALLOC_CTX *mem_ctx, ENUM_SERVICES_STATUS *svc, uint32 num_services);
int cac_InitCacServiceConfig(TALLOC_CTX *mem_ctx, SERVICE_CONFIG *src, CacServiceConfig *dest);
+/*moved to libmsrpc.h*/
+/*struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx);*/
+
SMBCSRV *smbc_attr_server(SMBCCTX *context,
const char *server, const char *share,
fstring workgroup,
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;
/*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;
}
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;
/*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*/
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;
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;
}
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;
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)) {
}
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;
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)) {
}
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)
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;
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;
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;
}
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;
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)) {
}
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;
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;
}
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;
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;
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)) {
}
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;
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;
}
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;
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;
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;
}
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;
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)) {
}
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;
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)) {
}
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;
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) {
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;
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);
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;
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;
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;
}
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;
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;
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;
}
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;
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;
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;
}
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;
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;
}
/*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;
}
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;
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;
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)
/*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) {
}
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;
}
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;
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;
}
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;
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;
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) {
}
/*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;
}
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;
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))
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;
}
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;
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;
}
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;
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;
}
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;
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);
}
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;
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;
}
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;
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))
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;
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;
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
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;
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;
}
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;
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;
}
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;
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*/
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*/
}
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;
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))
}
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;
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);
}
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;
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);
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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*/
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*/
}
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;
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))
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;
/*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;
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;
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;
}
/*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))
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;
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;
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))
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;
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);
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;
}
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);
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;
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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;
}
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;
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*/
}
/*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*/
}
/*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;
}
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;
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;
}
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;
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);
}
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)) {
}
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;
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;
}
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;
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;
}
int cac_SamFlush(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamFlush *op) {
- SMBCSRV *srv = NULL;
-
struct SamOpenDomain od;
if(!hnd)
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;
#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;
hnd->status = NT_STATUS_INVALID_PARAMETER;
return CAC_FAILURE;
}
-
+
srv = cac_GetServer(hnd);
if(!srv) {
hnd->status = NT_STATUS_INVALID_CONNECTION;
/*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;
}
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))
}
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)
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))
}
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;
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))
}
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;
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))
}
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;
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))
}
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;
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))
* 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;
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;
}
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;
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))
}
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;
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))
}
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;
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))
}
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;
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))
}
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;
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))
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;
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))
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;
/*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;
}
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)) {
}
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)
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)) {
}
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;
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) {
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)) {
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)) {
}
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;
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) {
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)) {
}
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;
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);
}
/*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) {
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)) {
}
-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*/
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++;
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)
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;
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);
/*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)) {
}
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)
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)) {
}
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;
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,
}
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;
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))
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;
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) {
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))
}
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;
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) {
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))
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;
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))
}
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;
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);
}
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)
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);
}
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)
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);
int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
char *msg;
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;
}
}
int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
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;
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);
#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) {
return NULL;
}
+ if(pol) {
pipe_hnd = cli_rpc_pipe_open_noauth(ipc_cli, PI_LSARPC, &nt_status);
- if (!pipe_hnd) {
- DEBUG(1, ("cli_nt_session_open fail!\n"));
- errno = ENOTSUP;
- cli_shutdown(ipc_cli);
- return NULL;
- }
+ if (!pipe_hnd) {
+ DEBUG(1, ("cli_nt_session_open fail!\n"));
+ errno = ENOTSUP;
+ cli_shutdown(ipc_cli);
+ return NULL;
+ }
- /* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED,
- but NT sends 0x2000000 so we might as well do it too. */
+ /* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED,
+ but NT sends 0x2000000 so we might as well do it too. */
- nt_status = rpccli_lsa_open_policy(pipe_hnd,
- ipc_cli->mem_ctx,
- True,
- GENERIC_EXECUTE_ACCESS,
- pol);
+ nt_status = rpccli_lsa_open_policy(pipe_hnd,
+ ipc_cli->mem_ctx,
+ True,
+ GENERIC_EXECUTE_ACCESS,
+ pol);
- if (!NT_STATUS_IS_OK(nt_status)) {
- errno = smbc_errno(context, ipc_cli);
- cli_shutdown(ipc_cli);
- return NULL;
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ errno = smbc_errno(context, ipc_cli);
+ cli_shutdown(ipc_cli);
+ return NULL;
+ }
}
ipc_srv = SMB_MALLOC_P(SMBCSRV);