mirror of
https://github.com/samba-team/samba.git
synced 2025-12-03 04:23:50 +03:00
r11124: Commit Chris' fixes for libmsrpc after the rpc_client
rewrite. His comments:
I've gotten the libmsrpc code to work with TRUNK.
I've put the patch at:
www.uoguelph.ca/~cnicholl/libmsrpc_trunk_v1.patch.gz
It is from revision 11093.
I also fixed a minor bug in the svcctl code, the timeout
parameter for all the control functions was working
in milliseconds instead of seconds.
Also fixed bug in Makefile when building libmsrpc.a
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
24e7663086
commit
d3a52900ec
@@ -141,7 +141,7 @@ BIN_PROGS = $(BIN_PROGS1) $(BIN_PROGS2) $(BIN_PROGS3) @EXTRA_BIN_PROGS@
|
|||||||
EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ bin/talloctort@EXEEXT@ \
|
EVERYTHING_PROGS = bin/debug2html@EXEEXT@ bin/smbfilter@EXEEXT@ bin/talloctort@EXEEXT@ \
|
||||||
bin/log2pcap@EXEEXT@
|
bin/log2pcap@EXEEXT@
|
||||||
|
|
||||||
SHLIBS = @SHLIB_PROGS@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@
|
SHLIBS = @SHLIB_PROGS@ @LIBSMBCLIENT@ @LIBSMBSHAREMODES@ cac
|
||||||
|
|
||||||
SCRIPTS = $(srcdir)/script/smbtar $(builddir)/script/findsmb
|
SCRIPTS = $(srcdir)/script/smbtar $(builddir)/script/findsmb
|
||||||
|
|
||||||
@@ -524,6 +524,11 @@ LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \
|
|||||||
$(LIBMSRPC_OBJ) $(RPC_PARSE_OBJ) \
|
$(LIBMSRPC_OBJ) $(RPC_PARSE_OBJ) \
|
||||||
$(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_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
|
LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o tdb/tdb.o tdb/spinlock.o
|
||||||
|
|
||||||
# This shared library is intended for linking with unit test programs
|
# This shared library is intended for linking with unit test programs
|
||||||
@@ -663,6 +668,9 @@ PICOBJS = $(SMBWRAPPER_OBJ:.o=.@PICSUFFIX@)
|
|||||||
LIBSMBCLIENT_PICOBJS = $(LIBSMBCLIENT_OBJ:.o=.@PICSUFFIX@)
|
LIBSMBCLIENT_PICOBJS = $(LIBSMBCLIENT_OBJ:.o=.@PICSUFFIX@)
|
||||||
LIBSMBSHAREMODES_PICOBJS = $(LIBSMBSHAREMODES_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_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \
|
||||||
pam_smbpass/pam_smb_acct.o pam_smbpass/support.o \
|
pam_smbpass/pam_smb_acct.o pam_smbpass/support.o \
|
||||||
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
|
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
|
||||||
@@ -768,6 +776,8 @@ wins : SHOWFLAGS @WINBIND_WINS_NSS@
|
|||||||
|
|
||||||
modules: SHOWFLAGS proto_exists $(MODULES)
|
modules: SHOWFLAGS proto_exists $(MODULES)
|
||||||
|
|
||||||
|
cac: SHOWFLAGS bin/libmsrpc.@SHLIBEXT@ bin/libmsrpc.a
|
||||||
|
|
||||||
everything: all libsmbclient debug2html smbfilter talloctort modules torture eventlogadm \
|
everything: all libsmbclient debug2html smbfilter talloctort modules torture eventlogadm \
|
||||||
$(EVERYTHING_PROGS)
|
$(EVERYTHING_PROGS)
|
||||||
|
|
||||||
@@ -1055,6 +1065,15 @@ bin/libsmbsharemodes.a: $(LIBSMBSHAREMODES_PICOBJS)
|
|||||||
@echo Linking libsmbsharemodes non-shared library $@
|
@echo Linking libsmbsharemodes non-shared library $@
|
||||||
@-$(AR) -rc $@ $(LIBSMBSHAREMODES_PICOBJS)
|
@-$(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.
|
# This is probably wrong for anything other than the GNU linker.
|
||||||
bin/libbigballofmud.@SHLIBEXT@: $(LIBBIGBALLOFMUD_PICOBJS)
|
bin/libbigballofmud.@SHLIBEXT@: $(LIBBIGBALLOFMUD_PICOBJS)
|
||||||
@echo Linking bigballofmud shared library $@
|
@echo Linking bigballofmud shared library $@
|
||||||
@@ -1333,9 +1352,6 @@ bin/pam_smbpass.@SHLIBEXT@: $(PAM_SMBPASS_PICOOBJ)
|
|||||||
@echo "Linking shared library $@"
|
@echo "Linking shared library $@"
|
||||||
@$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_SMBPASS_PICOOBJ) -lpam $(DYNEXP) $(LIBS) -lc $(LDAP_LIBS) $(KRB5LIBS)
|
@$(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
|
bin/tdbbackup@EXEEXT@: $(TDBBACKUP_OBJ) bin/.dummy
|
||||||
@echo Linking $@
|
@echo Linking $@
|
||||||
@$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBBACKUP_OBJ) @SOCKWRAP@
|
@$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(LDFLAGS) $(DYNEXP) $(LIBS) $(TDBBACKUP_OBJ) @SOCKWRAP@
|
||||||
|
|||||||
@@ -3043,6 +3043,8 @@ int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sv
|
|||||||
|
|
||||||
/**@}*/ /*SCM_Functions*/
|
/**@}*/ /*SCM_Functions*/
|
||||||
|
|
||||||
|
struct rpc_pipe_client *cac_GetPipe(CacServerHandle *hnd, int pi_idx);
|
||||||
|
|
||||||
#endif /* LIBMSRPC_H */
|
#endif /* LIBMSRPC_H */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ struct CacServerHandleInternal {
|
|||||||
BOOL user_supplied_ctx;
|
BOOL user_supplied_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/
|
||||||
|
|
||||||
/*nessecary prototypes*/
|
/*nessecary prototypes*/
|
||||||
BOOL rid_in_list(uint32 rid, uint32 *list, uint32 list_len);
|
BOOL rid_in_list(uint32 rid, uint32 *list, uint32 list_len);
|
||||||
|
|
||||||
@@ -59,6 +61,9 @@ CacDomainInfo *cac_MakeDomainInfo(TALLOC_CTX *mem_ctx, SAM_UNK_INFO_1 *info1, SA
|
|||||||
CacService *cac_MakeServiceArray(TALLOC_CTX *mem_ctx, ENUM_SERVICES_STATUS *svc, uint32 num_services);
|
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);
|
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,
|
SMBCSRV *smbc_attr_server(SMBCCTX *context,
|
||||||
const char *server, const char *share,
|
const char *server, const char *share,
|
||||||
fstring workgroup,
|
fstring workgroup,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op) {
|
int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenPolicy *op) {
|
||||||
SMBCSRV *srv = NULL;
|
SMBCSRV *srv = NULL;
|
||||||
POLICY_HND *policy = NULL;
|
POLICY_HND *policy = NULL;
|
||||||
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
return CAC_FAILURE;
|
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*/
|
/*see if there is already an active session on this pipe, if not then open one*/
|
||||||
if(!hnd->_internal.pipes[PI_LSARPC]) {
|
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;
|
hnd->status = NT_STATUS_UNSUCCESSFUL;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -56,9 +59,6 @@ int cac_LsaOpenPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpenP
|
|||||||
hnd->_internal.pipes[PI_LSARPC] = True;
|
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);
|
policy = SMB_MALLOC_P(POLICY_HND);
|
||||||
if(!policy) {
|
if(!policy) {
|
||||||
errno = ENOMEM;
|
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*/
|
/*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*/
|
/*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)) {
|
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)) {
|
if(hnd->_internal.srv_level > SRV_WIN_NT4 && NT_STATUS_IS_OK(hnd->status)) {
|
||||||
/*change the server level to 1*/
|
/*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) {
|
int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *pol) {
|
||||||
|
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -113,16 +113,14 @@ int cac_LsaClosePolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *po
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
int result = -1;
|
||||||
|
|
||||||
@@ -168,17 +166,16 @@ int cac_LsaGetNamesFromSids(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
|
|||||||
|
|
||||||
num_sids = op->in.num_sids;
|
num_sids = op->in.num_sids;
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*make sure we're on the right pipe*/
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
/*now actually lookup the names*/
|
/*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);
|
op->in.sids, &domains, &names, &types);
|
||||||
|
|
||||||
if(NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
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 result = -1;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -292,17 +289,15 @@ int cac_LsaGetSidsFromNames(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
|
|||||||
|
|
||||||
num_names = op->in.num_names;
|
num_names = op->in.num_names;
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*make sure we're on the right pipe*/
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
/*now actually lookup the names*/
|
/*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);
|
(const char **)op->in.names, &sids, &types);
|
||||||
|
|
||||||
if(NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
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;
|
int result = -1;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -399,15 +394,12 @@ int cac_LsaFetchSid(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaFetchSi
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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.local_sid = NULL;
|
||||||
op->out.domain_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;
|
DOM_SID *local_sid = NULL;
|
||||||
char *dom_name = 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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
result = CAC_FAILURE;
|
result = CAC_FAILURE;
|
||||||
@@ -441,7 +433,7 @@ domain:
|
|||||||
DOM_SID *domain_sid;
|
DOM_SID *domain_sid;
|
||||||
char *dom_name;
|
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(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
/*if we succeeded above, report partial success*/
|
/*if we succeeded above, report partial success*/
|
||||||
result = (result == CAC_SUCCESS) ? CAC_PARTIAL_SUCCESS : CAC_FAILURE;
|
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) {
|
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 *domain_name = NULL;
|
||||||
char *dns_name = NULL;
|
char *dns_name = NULL;
|
||||||
@@ -490,17 +482,14 @@ int cac_LsaQueryInfoPolicy(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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*/
|
/*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);
|
&domain_name, &dns_name, &forest_name, &domain_guid, &domain_sid);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
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;
|
uint32 num_sids;
|
||||||
DOM_SID *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;
|
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
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);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
uint32 count = 0;
|
||||||
char **privs = NULL;
|
char **privs = NULL;
|
||||||
@@ -579,21 +566,18 @@ int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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) {
|
if(op->in.name && !op->in.sid) {
|
||||||
DOM_SID *user_sid = NULL;
|
DOM_SID *user_sid = NULL;
|
||||||
uint32 *type;
|
uint32 *type;
|
||||||
|
|
||||||
/*lookup the 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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -601,7 +585,7 @@ int cac_LsaEnumAccountRights(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
|
|||||||
op->in.sid = user_sid;
|
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);
|
&count, &privs);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaEnumTrustedDomains *op) {
|
||||||
SMBCSRV *srv;
|
struct rpc_pipe_client *pipe_hnd;
|
||||||
|
|
||||||
uint32 num_domains;
|
uint32 num_domains;
|
||||||
char **domain_names;
|
char **domain_names;
|
||||||
@@ -634,15 +618,13 @@ int cac_LsaEnumTrustedDomains(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
hnd->status = rpccli_lsa_enum_trust_dom( pipe_hnd, mem_ctx, op->in.pol, &(op->out.resume_idx), &num_domains, &domain_names, &domain_sids);
|
||||||
|
|
||||||
hnd->status = cli_lsa_enum_trust_dom( &(srv->cli), mem_ctx, op->in.pol, &(op->out.resume_idx), &num_domains, &domain_names, &domain_sids);
|
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
POLICY_HND *dom_pol = NULL;
|
||||||
|
|
||||||
@@ -673,14 +655,12 @@ int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
dom_pol = talloc(mem_ctx, POLICY_HND);
|
dom_pol = talloc(mem_ctx, POLICY_HND);
|
||||||
if(!dom_pol) {
|
if(!dom_pol) {
|
||||||
hnd->status = NT_STATUS_NO_MEMORY;
|
hnd->status = NT_STATUS_NO_MEMORY;
|
||||||
@@ -688,7 +668,7 @@ int cac_LsaOpenTrustedDomain(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
|
|||||||
return CAC_FAILURE;
|
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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
LSA_TRUSTED_DOMAIN_INFO *dom_info;
|
||||||
|
|
||||||
@@ -722,19 +702,17 @@ int cac_LsaQueryTrustedDomainInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, str
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
if(op->in.domain_sid) {
|
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) {
|
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)) {
|
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) {
|
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;
|
int num_privs;
|
||||||
char **priv_names;
|
char **priv_names;
|
||||||
@@ -769,15 +747,13 @@ int cac_LsaEnumPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaE
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
hnd->status = rpccli_lsa_enum_privilege(pipe_hnd, mem_ctx, op->in.pol, &(op->out.resume_idx), op->in.pref_max_privs,
|
||||||
|
|
||||||
hnd->status = cli_lsa_enum_privilege(&(srv->cli), mem_ctx, op->in.pol, &(op->out.resume_idx), op->in.pref_max_privs,
|
|
||||||
&num_privs, &priv_names, &high_bits, &low_bits);
|
&num_privs, &priv_names, &high_bits, &low_bits);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
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;
|
POLICY_HND *user_pol = NULL;
|
||||||
|
|
||||||
@@ -816,12 +792,6 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
|
|||||||
return CAC_FAILURE;
|
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*/
|
/*look up the user's SID if we have to*/
|
||||||
if(op->in.name && !op->in.sid) {
|
if(op->in.name && !op->in.sid) {
|
||||||
@@ -829,7 +799,7 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
|
|||||||
uint32 *type;
|
uint32 *type;
|
||||||
|
|
||||||
/*lookup the 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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -843,7 +813,7 @@ int cac_LsaOpenAccount(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaOpen
|
|||||||
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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
talloc_free(user_pol);
|
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) {
|
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;
|
DOM_SID *user_sid = NULL;
|
||||||
uint32 *type = NULL;
|
uint32 *type = NULL;
|
||||||
@@ -881,17 +851,15 @@ int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
if(op->in.name && !op->in.sid) {
|
if(op->in.name && !op->in.sid) {
|
||||||
/*lookup the 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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -899,7 +867,7 @@ int cac_LsaAddPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
|
|||||||
op->in.sid = user_sid;
|
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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
DOM_SID *user_sid = NULL;
|
||||||
uint32 *type = NULL;
|
uint32 *type = NULL;
|
||||||
@@ -933,17 +901,15 @@ int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
if(op->in.name && !op->in.sid) {
|
if(op->in.name && !op->in.sid) {
|
||||||
/*lookup the 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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -951,7 +917,7 @@ int cac_LsaRemovePrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Ls
|
|||||||
op->in.sid = user_sid;
|
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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
DOM_SID *user_sid = NULL;
|
||||||
uint32 *type = NULL;
|
uint32 *type = NULL;
|
||||||
@@ -985,17 +951,15 @@ int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
if(op->in.name && !op->in.sid) {
|
if(op->in.name && !op->in.sid) {
|
||||||
/*lookup the 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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -1003,7 +967,7 @@ int cac_LsaClearPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Lsa
|
|||||||
op->in.sid = user_sid;
|
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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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;
|
DOM_SID *user_sid = NULL;
|
||||||
uint32 *type = NULL;
|
uint32 *type = NULL;
|
||||||
@@ -1037,16 +1001,14 @@ int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
|
||||||
|
|
||||||
if(op->in.name && !op->in.sid) {
|
if(op->in.name && !op->in.sid) {
|
||||||
/*lookup the 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))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -1055,13 +1017,13 @@ int cac_LsaSetPrivileges(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct LsaAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*first remove all privileges*/
|
/*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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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)) {
|
if(!NT_STATUS_IS_OK(hnd->status)) {
|
||||||
return CAC_FAILURE;
|
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) {
|
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*/
|
/*this is taken from rpcclient/cmd_lsarpc.c*/
|
||||||
uint16 info_level = 4;
|
uint16 info_level = 4;
|
||||||
@@ -1092,15 +1054,13 @@ int cac_LsaGetSecurityObject(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct L
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_LSARPC);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_LSARPC;
|
hnd->status = rpccli_lsa_query_secobj( pipe_hnd, mem_ctx, op->in.pol, info_level, &sec_out);
|
||||||
|
|
||||||
hnd->status = cli_lsa_query_secobj( &(srv->cli), mem_ctx, op->in.pol, info_level, &sec_out);
|
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -21,10 +21,11 @@
|
|||||||
#include "libmsrpc.h"
|
#include "libmsrpc.h"
|
||||||
#include "libsmb_internal.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) {
|
int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm *op) {
|
||||||
SMBCSRV *srv = NULL;
|
SMBCSRV *srv = NULL;
|
||||||
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
POLICY_HND *scm_out = NULL;
|
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;
|
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
srv = cac_GetServer(hnd);
|
||||||
if(!srv) {
|
if(!srv) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
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*/
|
/*initialize for samr pipe if we have to*/
|
||||||
if(!hnd->_internal.pipes[PI_SVCCTL]) {
|
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;
|
hnd->status = NT_STATUS_UNSUCCESSFUL;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -58,15 +59,13 @@ int cac_SvcOpenScm(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenScm
|
|||||||
hnd->_internal.pipes[PI_SVCCTL] = True;
|
hnd->_internal.pipes[PI_SVCCTL] = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
|
||||||
|
|
||||||
scm_out = talloc(mem_ctx, POLICY_HND);
|
scm_out = talloc(mem_ctx, POLICY_HND);
|
||||||
if(!scm_out) {
|
if(!scm_out) {
|
||||||
hnd->status = NT_STATUS_NO_MEMORY;
|
hnd->status = NT_STATUS_NO_MEMORY;
|
||||||
return CAC_FAILURE;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
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;
|
WERROR err;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -94,15 +93,13 @@ int cac_SvcClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *scm_hnd)
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_close_service( pipe_hnd, mem_ctx, scm_hnd);
|
||||||
|
|
||||||
err = cli_svcctl_close_service( &(srv->cli), mem_ctx, scm_hnd);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnumServices *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
uint32 type_buf = 0;
|
uint32 type_buf = 0;
|
||||||
@@ -135,18 +132,16 @@ int cac_SvcEnumServices(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcEnu
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
|
||||||
|
|
||||||
type_buf = (op->in.type != 0) ? op->in.type : (SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32);
|
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;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpenService *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
POLICY_HND *svc_hnd_out = NULL;
|
POLICY_HND *svc_hnd_out = NULL;
|
||||||
@@ -185,21 +180,19 @@ int cac_SvcOpenService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcOpen
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
|
||||||
|
|
||||||
svc_hnd_out = talloc(mem_ctx, POLICY_HND);
|
svc_hnd_out = talloc(mem_ctx, POLICY_HND);
|
||||||
if(!svc_hnd_out) {
|
if(!svc_hnd_out) {
|
||||||
hnd->status = NT_STATUS_NO_MEMORY;
|
hnd->status = NT_STATUS_NO_MEMORY;
|
||||||
return CAC_FAILURE;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcControlService *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_STATUS status_out;
|
SERVICE_STATUS status_out;
|
||||||
@@ -234,15 +227,13 @@ int cac_SvcControlService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcC
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, op->in.control, &status_out);
|
||||||
|
|
||||||
err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, op->in.control, &status_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetStatus *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_STATUS status_out;
|
SERVICE_STATUS status_out;
|
||||||
@@ -270,15 +261,13 @@ int cac_SvcGetStatus(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetSta
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, op->in.svc_hnd, &status_out);
|
||||||
|
|
||||||
err = cli_svcctl_query_status( &(srv->cli), mem_ctx, op->in.svc_hnd, &status_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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
|
* 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) {
|
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*/
|
/*number of milliseconds we have spent*/
|
||||||
uint32 time_spent = 0;
|
uint32 time_spent = 0;
|
||||||
WERROR err;
|
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)
|
if(!hnd || !mem_ctx || !svc_hnd || !status)
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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*/
|
/*if this is the first call, then we _just_ got the status.. sleep now*/
|
||||||
usleep(WAIT_SLEEP_TIME);
|
usleep(WAIT_SLEEP_TIME);
|
||||||
time_spent += 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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status->state == state)
|
if(status->state == state)
|
||||||
return CAC_SUCCESS;
|
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) {
|
int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStartService *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_STATUS status_buf;
|
SERVICE_STATUS status_buf;
|
||||||
@@ -353,15 +342,13 @@ int cac_SvcStartService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcSta
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, op->in.svc_hnd, (const char **)op->in.parms, op->in.num_parms);
|
||||||
|
|
||||||
err = cli_svcctl_start_service(&(srv->cli), mem_ctx, op->in.svc_hnd, (const char **)op->in.parms, op->in.num_parms);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStopService *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_STATUS status_out;
|
SERVICE_STATUS status_out;
|
||||||
@@ -392,15 +379,13 @@ int cac_SvcStopService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcStop
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_STOP, &status_out);
|
||||||
|
|
||||||
err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_STOP, &status_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPauseService *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_STATUS status_out;
|
SERVICE_STATUS status_out;
|
||||||
@@ -433,15 +418,13 @@ int cac_SvcPauseService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcPau
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_PAUSE, &status_out);
|
||||||
|
|
||||||
err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_PAUSE, &status_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcContinueService *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_STATUS status_out;
|
SERVICE_STATUS status_out;
|
||||||
@@ -474,15 +457,13 @@ int cac_SvcContinueService(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Svc
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_CONTINUE, &status_out);
|
||||||
|
|
||||||
err = cli_svcctl_control_service( &(srv->cli), mem_ctx, op->in.svc_hnd, SVCCTL_CONTROL_CONTINUE, &status_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetDisplayName *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
fstring disp_name_out;
|
fstring disp_name_out;
|
||||||
@@ -515,15 +496,13 @@ int cac_SvcGetDisplayName(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcG
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_get_dispname( pipe_hnd, mem_ctx, op->in.svc_hnd, disp_name_out);
|
||||||
|
|
||||||
err = cli_svcctl_get_dispname( &(srv->cli), mem_ctx, op->in.svc_hnd, disp_name_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SvcGetServiceConfig *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
SERVICE_CONFIG config_out;
|
SERVICE_CONFIG config_out;
|
||||||
@@ -559,15 +538,13 @@ int cac_SvcGetServiceConfig(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Sv
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SVCCTL);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SVCCTL;
|
err = rpccli_svcctl_query_config( pipe_hnd, mem_ctx, op->in.svc_hnd, &config_out);
|
||||||
|
|
||||||
err = cli_svcctl_query_config( &(srv->cli), mem_ctx, op->in.svc_hnd, &config_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op) {
|
int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op) {
|
||||||
SMBCSRV *srv = NULL;
|
SMBCSRV *srv = NULL;
|
||||||
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
POLICY_HND *key = NULL;
|
POLICY_HND *key = NULL;
|
||||||
WERROR err;
|
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*/
|
/*initialize for winreg pipe if we have to*/
|
||||||
if(!hnd->_internal.pipes[PI_WINREG]) {
|
if(!hnd->_internal.pipes[PI_WINREG]) {
|
||||||
if(!cli_nt_session_open(&srv->cli, PI_WINREG)) {
|
if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_WINREG, &(hnd->status)))) {
|
||||||
hnd->status = NT_STATUS_UNSUCCESSFUL;
|
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
|
|||||||
hnd->status = NT_STATUS_NO_MEMORY;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -90,13 +90,13 @@ int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
POLICY_HND *key_out;
|
POLICY_HND *key_out;
|
||||||
@@ -131,12 +131,6 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
|
|||||||
return CAC_FAILURE;
|
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);
|
key_out = talloc(mem_ctx, POLICY_HND);
|
||||||
if(!key_out) {
|
if(!key_out) {
|
||||||
@@ -174,9 +168,13 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
|
|||||||
key_name = op->in.name;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
if(!op->in.parent_key) {
|
||||||
/*then close the one that we opened above*/
|
/*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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
/*buffers for cli_reg_enum_key call*/
|
/*buffers for rpccli_reg_enum_key call*/
|
||||||
fstring key_name_in;
|
fstring key_name_in;
|
||||||
fstring class_name_in;
|
fstring class_name_in;
|
||||||
|
|
||||||
@@ -230,14 +228,12 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
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*/
|
/**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);
|
key_names_out = TALLOC_ARRAY(mem_ctx, char *, op->in.max_keys);
|
||||||
if(!key_names_out) {
|
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;
|
resume_idx = op->out.resume_idx;
|
||||||
|
|
||||||
do {
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
POLICY_HND *key_out;
|
POLICY_HND *key_out;
|
||||||
@@ -320,12 +316,6 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
|
|||||||
return CAC_FAILURE;
|
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*/
|
/*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);
|
ZERO_STRUCT(rok);
|
||||||
|
|
||||||
@@ -340,7 +330,11 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*just be ultra-safe*/
|
/*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);
|
key_out = talloc(mem_ctx, POLICY_HND);
|
||||||
if(!key_out) {
|
if(!key_out) {
|
||||||
@@ -348,7 +342,7 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
|
|||||||
return CAC_FAILURE;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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
|
/*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*/
|
* 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;
|
int cur_key = 0;
|
||||||
|
|
||||||
while(W_ERROR_IS_OK(err)) {
|
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))
|
if(!W_ERROR_IS_OK(err))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*try to open the key with full access*/
|
/*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))
|
if(!W_ERROR_IS_OK(err))
|
||||||
break;
|
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))
|
if(!W_ERROR_EQUAL(err,WERR_NO_MORE_ITEMS) && !W_ERROR_IS_OK(err))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*flush the key just to be safe*/
|
/*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*/
|
/*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*/
|
/*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++;
|
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) {
|
int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -427,14 +421,12 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
|
||||||
|
|
||||||
if(op->in.recursive) {
|
if(op->in.recursive) {
|
||||||
/*first open the key, and then delete all of it's subkeys recursively*/
|
/*first open the key, and then delete all of it's subkeys recursively*/
|
||||||
struct RegOpenKey rok;
|
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))
|
if(!cac_RegOpenKey(hnd, mem_ctx, &rok))
|
||||||
return CAC_FAILURE;
|
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*/
|
/*close the key that we opened*/
|
||||||
cac_RegClose(hnd, mem_ctx, rok.out.key);
|
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*/
|
/*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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -487,15 +479,13 @@ int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDele
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_delete_val( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name);
|
||||||
|
|
||||||
err = cli_reg_delete_val( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status)) {
|
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) {
|
int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryKeyInfo *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
char *class_name_out = NULL;
|
char *class_name_out = NULL;
|
||||||
@@ -533,15 +523,13 @@ int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQue
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_query_key( pipe_hnd, mem_ctx, op->in.key,
|
||||||
|
|
||||||
err = cli_reg_query_key( &(srv->cli), mem_ctx, op->in.key,
|
|
||||||
class_name_out,
|
class_name_out,
|
||||||
&class_len,
|
&class_len,
|
||||||
&num_subkeys_out,
|
&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) {
|
int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
uint32 val_type;
|
uint32 val_type;
|
||||||
@@ -611,15 +599,13 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_query_value(pipe_hnd, mem_ctx, op->in.key, op->in.val_name, &val_type, &buffer);
|
||||||
|
|
||||||
err = cli_reg_query_value(&srv->cli, mem_ctx, op->in.key, op->in.val_name, &val_type, &buffer);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
/*buffers for cli_reg_enum_key call*/
|
/*buffers for rpccli_reg_enum_key call*/
|
||||||
fstring val_name_buf;
|
fstring val_name_buf;
|
||||||
REGVAL_BUFFER val_buf;
|
REGVAL_BUFFER val_buf;
|
||||||
|
|
||||||
@@ -674,14 +660,12 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
|
||||||
|
|
||||||
/*we need to assume that the max number of values will be enumerated*/
|
/*we need to assume that the max number of values will be enumerated*/
|
||||||
types_out = talloc_array(mem_ctx, int, op->in.max_values);
|
types_out = talloc_array(mem_ctx, int, op->in.max_values);
|
||||||
if(!types_out) {
|
if(!types_out) {
|
||||||
@@ -708,7 +692,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
|
|||||||
do {
|
do {
|
||||||
ZERO_STRUCT(val_buf);
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
RPC_DATA_BLOB *buffer;
|
RPC_DATA_BLOB *buffer;
|
||||||
@@ -757,14 +741,12 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
|
||||||
|
|
||||||
buffer = cac_MakeRpcDataBlob(mem_ctx, op->in.type, op->in.value);
|
buffer = cac_MakeRpcDataBlob(mem_ctx, op->in.type, op->in.value);
|
||||||
|
|
||||||
if(!buffer) {
|
if(!buffer) {
|
||||||
@@ -776,14 +758,14 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
|
|||||||
return CAC_FAILURE;
|
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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
|
|
||||||
/*flush*/
|
/*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);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
uint32 version_out;
|
uint32 version_out;
|
||||||
@@ -813,15 +795,13 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_getversion( pipe_hnd, mem_ctx, op->in.key, &version_out);
|
||||||
|
|
||||||
err = cli_reg_getversion( &(srv->cli), mem_ctx, op->in.key, &version_out);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
hnd->status = werror_to_ntstatus(err);
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
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) {
|
int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
uint32 buf_size;
|
uint32 buf_size;
|
||||||
@@ -852,15 +832,13 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_get_key_sec(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, &buf_size, buf);
|
||||||
|
|
||||||
err = cli_reg_get_key_sec(&(srv->cli), mem_ctx, op->in.key, op->in.info_type, &buf_size, buf);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
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) {
|
int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -891,15 +869,13 @@ int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegS
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_set_key_sec(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, op->in.size, op->in.descriptor);
|
||||||
|
|
||||||
err = cli_reg_set_key_sec(&(srv->cli), mem_ctx, op->in.key, op->in.info_type, op->in.size, op->in.descriptor);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
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) {
|
int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
WERROR err;
|
WERROR err;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
@@ -927,15 +903,13 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_WINREG;
|
err = rpccli_reg_save_key( pipe_hnd, mem_ctx, op->in.key, op->in.filename);
|
||||||
|
|
||||||
err = cli_reg_save_key( &(srv->cli), mem_ctx, op->in.key, op->in.filename);
|
|
||||||
hnd->status = werror_to_ntstatus(err);
|
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) {
|
int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op) {
|
||||||
SMBCSRV *srv = NULL;
|
SMBCSRV *srv = NULL;
|
||||||
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
|
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
@@ -964,35 +939,31 @@ int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op)
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
srv = cac_GetServer(hnd);
|
||||||
if(!srv) {
|
if(!srv) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*initialize for winreg pipe if we have to*/
|
/*initialize for winreg pipe if we have to*/
|
||||||
if(!hnd->_internal.pipes[PI_SHUTDOWN]) {
|
if(!hnd->_internal.pipes[PI_SHUTDOWN]) {
|
||||||
if(!cli_nt_session_open(&srv->cli, PI_SHUTDOWN)) {
|
if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_SHUTDOWN, &(hnd->status)))) {
|
||||||
hnd->status = NT_STATUS_UNSUCCESSFUL;
|
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hnd->_internal.pipes[PI_SHUTDOWN] = True;
|
hnd->_internal.pipes[PI_SHUTDOWN] = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SHUTDOWN;
|
|
||||||
|
|
||||||
msg = (op->in.message != NULL) ? op->in.message : talloc_strdup(mem_ctx, "");
|
msg = (op->in.message != NULL) ? op->in.message : talloc_strdup(mem_ctx, "");
|
||||||
|
|
||||||
hnd->status = NT_STATUS_OK;
|
hnd->status = NT_STATUS_OK;
|
||||||
|
|
||||||
if(hnd->_internal.srv_level > SRV_WIN_NT4) {
|
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)) {
|
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;
|
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) {
|
int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
|
||||||
SMBCSRV *srv = NULL;
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
@@ -1015,15 +986,13 @@ int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
|
|||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv = cac_GetServer(hnd);
|
pipe_hnd = cac_GetPipe(hnd, PI_SHUTDOWN);
|
||||||
if(!srv) {
|
if(!pipe_hnd) {
|
||||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
srv->cli.pipe_idx = PI_SHUTDOWN;
|
hnd->status = rpccli_shutdown_abort(pipe_hnd, mem_ctx);
|
||||||
|
|
||||||
hnd->status = cli_shutdown_abort(&(srv->cli), mem_ctx);
|
|
||||||
|
|
||||||
if(!NT_STATUS_IS_OK(hnd->status))
|
if(!NT_STATUS_IS_OK(hnd->status))
|
||||||
return CAC_FAILURE;
|
return CAC_FAILURE;
|
||||||
|
|||||||
@@ -214,22 +214,18 @@ int cac_Connect(CacServerHandle *hnd, const char *srv) {
|
|||||||
void cac_FreeHandle(CacServerHandle * hnd) {
|
void cac_FreeHandle(CacServerHandle * hnd) {
|
||||||
SMBCSRV *srv = NULL;
|
SMBCSRV *srv = NULL;
|
||||||
uint32 i = 0;
|
uint32 i = 0;
|
||||||
|
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||||
|
|
||||||
if(!hnd)
|
if(!hnd)
|
||||||
return;
|
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)
|
if(srv) {
|
||||||
cli_nt_session_close(&(srv->cli));
|
/*close all pipe sessions*/
|
||||||
|
cli_nt_pipes_close(&(srv->cli));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*only free the context if we created it*/
|
/*only free the context if we created it*/
|
||||||
if(!hnd->_internal.user_supplied_ctx) {
|
if(!hnd->_internal.user_supplied_ctx) {
|
||||||
smbc_free_context(hnd->_internal.ctx, True);
|
smbc_free_context(hnd->_internal.ctx, True);
|
||||||
|
|||||||
@@ -22,6 +22,33 @@
|
|||||||
#include "libmsrpc.h"
|
#include "libmsrpc.h"
|
||||||
#include "libmsrpc_internal.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)*/
|
/*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) {
|
int cac_ParseRegPath(char *path, uint32 *reg_type, char **key_name) {
|
||||||
|
|
||||||
|
|||||||
@@ -853,27 +853,29 @@ SMBCSRV *smbc_attr_server(SMBCCTX *context,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pol) {
|
||||||
pipe_hnd = cli_rpc_pipe_open_noauth(ipc_cli, PI_LSARPC, &nt_status);
|
pipe_hnd = cli_rpc_pipe_open_noauth(ipc_cli, PI_LSARPC, &nt_status);
|
||||||
if (!pipe_hnd) {
|
if (!pipe_hnd) {
|
||||||
DEBUG(1, ("cli_nt_session_open fail!\n"));
|
DEBUG(1, ("cli_nt_session_open fail!\n"));
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
cli_shutdown(ipc_cli);
|
cli_shutdown(ipc_cli);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED,
|
/* Some systems don't support SEC_RIGHTS_MAXIMUM_ALLOWED,
|
||||||
but NT sends 0x2000000 so we might as well do it too. */
|
but NT sends 0x2000000 so we might as well do it too. */
|
||||||
|
|
||||||
nt_status = rpccli_lsa_open_policy(pipe_hnd,
|
nt_status = rpccli_lsa_open_policy(pipe_hnd,
|
||||||
ipc_cli->mem_ctx,
|
ipc_cli->mem_ctx,
|
||||||
True,
|
True,
|
||||||
GENERIC_EXECUTE_ACCESS,
|
GENERIC_EXECUTE_ACCESS,
|
||||||
pol);
|
pol);
|
||||||
|
|
||||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||||
errno = smbc_errno(context, ipc_cli);
|
errno = smbc_errno(context, ipc_cli);
|
||||||
cli_shutdown(ipc_cli);
|
cli_shutdown(ipc_cli);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc_srv = SMB_MALLOC_P(SMBCSRV);
|
ipc_srv = SMB_MALLOC_P(SMBCSRV);
|
||||||
|
|||||||
Reference in New Issue
Block a user