summaryrefslogtreecommitdiff
path: root/source3/libmsrpc/cac_winreg.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libmsrpc/cac_winreg.c')
-rw-r--r--source3/libmsrpc/cac_winreg.c229
1 files changed, 99 insertions, 130 deletions
diff --git a/source3/libmsrpc/cac_winreg.c b/source3/libmsrpc/cac_winreg.c
index 3a90aa871e..66fa8806fd 100644
--- a/source3/libmsrpc/cac_winreg.c
+++ b/source3/libmsrpc/cac_winreg.c
@@ -24,6 +24,7 @@
int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND *key = NULL;
WERROR err;
@@ -48,8 +49,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
/*initialize for winreg pipe if we have to*/
if(!hnd->_internal.pipes[PI_WINREG]) {
- if(!cli_nt_session_open(&srv->cli, PI_WINREG)) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_WINREG, &(hnd->status)))) {
return CAC_FAILURE;
}
@@ -61,7 +61,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
hnd->status = NT_STATUS_NO_MEMORY;
}
- err = cli_reg_connect( &(srv->cli), mem_ctx, op->in.root, op->in.access, key);
+ err = rpccli_reg_connect( pipe_hnd, mem_ctx, op->in.root, op->in.access, key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -74,7 +74,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect
}
int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -90,13 +90,13 @@ int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- err = cli_reg_close(&srv->cli, mem_ctx, key);
+ err = rpccli_reg_close(pipe_hnd, mem_ctx, key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -107,7 +107,7 @@ int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
}
int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
POLICY_HND *key_out;
@@ -131,12 +131,6 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
key_out = talloc(mem_ctx, POLICY_HND);
if(!key_out) {
@@ -174,9 +168,13 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
key_name = op->in.name;
}
- srv->cli.pipe_idx = PI_WINREG;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
- err = cli_reg_open_entry( &(srv->cli), mem_ctx, parent_key, key_name, op->in.access, key_out);
+ err = rpccli_reg_open_entry( pipe_hnd, mem_ctx, parent_key, key_name, op->in.access, key_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -185,7 +183,7 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
if(!op->in.parent_key) {
/*then close the one that we opened above*/
- err = cli_reg_close( &(srv->cli), mem_ctx, parent_key);
+ err = rpccli_reg_close( pipe_hnd, mem_ctx, parent_key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -199,10 +197,10 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey
}
int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
- /*buffers for cli_reg_enum_key call*/
+ /*buffers for rpccli_reg_enum_key call*/
fstring key_name_in;
fstring class_name_in;
@@ -230,14 +228,12 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
/**the only way to know how many keys to expect is to assume max_keys keys will be found*/
key_names_out = TALLOC_ARRAY(mem_ctx, char *, op->in.max_keys);
if(!key_names_out) {
@@ -264,7 +260,7 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
resume_idx = op->out.resume_idx;
do {
- err = cli_reg_enum_key( &(srv->cli), mem_ctx, op->in.key, resume_idx, key_name_in, class_name_in, &mod_times_out[num_keys_out]);
+ err = rpccli_reg_enum_key( pipe_hnd, mem_ctx, op->in.key, resume_idx, key_name_in, class_name_in, &mod_times_out[num_keys_out]);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -300,7 +296,7 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey
}
int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
POLICY_HND *key_out;
@@ -320,12 +316,6 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
- return CAC_FAILURE;
- }
-
/*first try to open the key - we use cac_RegOpenKey(). this doubles as a way to ensure the winreg pipe is initialized*/
ZERO_STRUCT(rok);
@@ -340,7 +330,11 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
}
/*just be ultra-safe*/
- srv->cli.pipe_idx = PI_WINREG;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
+ return CAC_FAILURE;
+ }
key_out = talloc(mem_ctx, POLICY_HND);
if(!key_out) {
@@ -348,7 +342,7 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
return CAC_FAILURE;
}
- err = cli_reg_create_key_ex( &(srv->cli), mem_ctx, op->in.parent_key, op->in.key_name, op->in.class_name, op->in.access, key_out);
+ err = rpccli_reg_create_key_ex( pipe_hnd, mem_ctx, op->in.parent_key, op->in.key_name, op->in.class_name, op->in.access, key_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -361,7 +355,7 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate
}
-WERROR cac_delete_subkeys_recursive(struct cli_state *cli, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
+WERROR cac_delete_subkeys_recursive(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) {
/*NOTE: using cac functions might result in a big(ger) memory bloat, and would probably be far less efficient
* so we use the cli_reg functions directly*/
@@ -375,30 +369,30 @@ WERROR cac_delete_subkeys_recursive(struct cli_state *cli, TALLOC_CTX *mem_ctx,
int cur_key = 0;
while(W_ERROR_IS_OK(err)) {
- err = cli_reg_enum_key( cli, mem_ctx, key, cur_key, subkey_name, class_buf, &mod_time_buf);
+ err = rpccli_reg_enum_key( pipe_hnd, mem_ctx, key, cur_key, subkey_name, class_buf, &mod_time_buf);
if(!W_ERROR_IS_OK(err))
break;
/*try to open the key with full access*/
- err = cli_reg_open_entry(cli, mem_ctx, key, subkey_name, REG_KEY_ALL, &subkey);
+ err = rpccli_reg_open_entry(pipe_hnd, mem_ctx, key, subkey_name, REG_KEY_ALL, &subkey);
if(!W_ERROR_IS_OK(err))
break;
- err = cac_delete_subkeys_recursive(cli, mem_ctx, &subkey);
+ err = cac_delete_subkeys_recursive(pipe_hnd, mem_ctx, &subkey);
if(!W_ERROR_EQUAL(err,WERR_NO_MORE_ITEMS) && !W_ERROR_IS_OK(err))
break;
/*flush the key just to be safe*/
- cli_reg_flush_key(cli, mem_ctx, key);
+ rpccli_reg_flush_key(pipe_hnd, mem_ctx, key);
/*close the key that we opened*/
- cli_reg_close(cli, mem_ctx, &subkey);
+ rpccli_reg_close(pipe_hnd, mem_ctx, &subkey);
/*now we delete the subkey*/
- err = cli_reg_delete_key(cli, mem_ctx, key, subkey_name);
+ err = rpccli_reg_delete_key(pipe_hnd, mem_ctx, key, subkey_name);
cur_key++;
@@ -411,7 +405,7 @@ WERROR cac_delete_subkeys_recursive(struct cli_state *cli, TALLOC_CTX *mem_ctx,
int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -427,14 +421,12 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
if(op->in.recursive) {
/*first open the key, and then delete all of it's subkeys recursively*/
struct RegOpenKey rok;
@@ -447,7 +439,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
if(!cac_RegOpenKey(hnd, mem_ctx, &rok))
return CAC_FAILURE;
- err = cac_delete_subkeys_recursive(&(srv->cli), mem_ctx, rok.out.key);
+ err = cac_delete_subkeys_recursive(pipe_hnd, mem_ctx, rok.out.key);
/*close the key that we opened*/
cac_RegClose(hnd, mem_ctx, rok.out.key);
@@ -460,7 +452,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
/*now go on to actually delete the key*/
}
- err = cli_reg_delete_key( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
+ err = rpccli_reg_delete_key( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -471,7 +463,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete
}
int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -487,15 +479,13 @@ int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDele
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_delete_val( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
+ err = rpccli_reg_delete_val( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -506,7 +496,7 @@ int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDele
}
int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryKeyInfo *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
char *class_name_out = NULL;
@@ -533,15 +523,13 @@ int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQue
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_query_key( &(srv->cli), mem_ctx, op->in.key,
+ err = rpccli_reg_query_key( pipe_hnd, mem_ctx, op->in.key,
class_name_out,
&class_len,
&num_subkeys_out,
@@ -591,7 +579,7 @@ int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQue
}
int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 val_type;
@@ -611,15 +599,13 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_query_value(&srv->cli, mem_ctx, op->in.key, op->in.val_name, &val_type, &buffer);
+ err = rpccli_reg_query_value(pipe_hnd, mem_ctx, op->in.key, op->in.val_name, &val_type, &buffer);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -643,10 +629,10 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery
int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
- /*buffers for cli_reg_enum_key call*/
+ /*buffers for rpccli_reg_enum_key call*/
fstring val_name_buf;
REGVAL_BUFFER val_buf;
@@ -674,14 +660,12 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
/*we need to assume that the max number of values will be enumerated*/
types_out = talloc_array(mem_ctx, int, op->in.max_values);
if(!types_out) {
@@ -708,7 +692,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
do {
ZERO_STRUCT(val_buf);
- err = cli_reg_enum_val(&srv->cli, mem_ctx, op->in.key, resume_idx, val_name_buf, &types_out[num_values_out], &val_buf);
+ err = rpccli_reg_enum_val(pipe_hnd, mem_ctx, op->in.key, resume_idx, val_name_buf, &types_out[num_values_out], &val_buf);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -739,7 +723,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV
}
int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
RPC_DATA_BLOB *buffer;
@@ -757,14 +741,12 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
buffer = cac_MakeRpcDataBlob(mem_ctx, op->in.type, op->in.value);
if(!buffer) {
@@ -776,14 +758,14 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
return CAC_FAILURE;
}
- err = cli_reg_set_val(&srv->cli, mem_ctx, op->in.key, op->in.val_name, op->in.type, buffer);
+ err = rpccli_reg_set_val(pipe_hnd, mem_ctx, op->in.key, op->in.val_name, op->in.type, buffer);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;
/*flush*/
- err = cli_reg_flush_key(&(srv->cli), mem_ctx, op->in.key);
+ err = rpccli_reg_flush_key(pipe_hnd, mem_ctx, op->in.key);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -795,7 +777,7 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu
int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 version_out;
@@ -813,15 +795,13 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_getversion( &(srv->cli), mem_ctx, op->in.key, &version_out);
+ err = rpccli_reg_getversion( pipe_hnd, mem_ctx, op->in.key, &version_out);
hnd->status = werror_to_ntstatus(err);
if(!NT_STATUS_IS_OK(hnd->status))
@@ -833,7 +813,7 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe
}
int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
uint32 buf_size;
@@ -852,15 +832,13 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_get_key_sec(&(srv->cli), mem_ctx, op->in.key, op->in.info_type, &buf_size, buf);
+ err = rpccli_reg_get_key_sec(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, &buf_size, buf);
hnd->status = werror_to_ntstatus(err);
@@ -875,7 +853,7 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG
}
int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -891,15 +869,13 @@ int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegS
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_set_key_sec(&(srv->cli), mem_ctx, op->in.key, op->in.info_type, op->in.size, op->in.descriptor);
+ err = rpccli_reg_set_key_sec(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, op->in.size, op->in.descriptor);
hnd->status = werror_to_ntstatus(err);
@@ -911,7 +887,7 @@ int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegS
}
int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
WERROR err;
if(!hnd)
@@ -927,15 +903,13 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_WINREG);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_WINREG;
-
- err = cli_reg_save_key( &(srv->cli), mem_ctx, op->in.key, op->in.filename);
+ err = rpccli_reg_save_key( pipe_hnd, mem_ctx, op->in.key, op->in.filename);
hnd->status = werror_to_ntstatus(err);
@@ -948,6 +922,7 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey
int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op) {
SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
char *msg;
@@ -964,35 +939,31 @@ int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op)
return CAC_FAILURE;
}
-
srv = cac_GetServer(hnd);
if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
/*initialize for winreg pipe if we have to*/
if(!hnd->_internal.pipes[PI_SHUTDOWN]) {
- if(!cli_nt_session_open(&srv->cli, PI_SHUTDOWN)) {
- hnd->status = NT_STATUS_UNSUCCESSFUL;
+ if(!(pipe_hnd = cli_rpc_pipe_open_noauth(&srv->cli, PI_SHUTDOWN, &(hnd->status)))) {
return CAC_FAILURE;
}
hnd->_internal.pipes[PI_SHUTDOWN] = True;
}
- srv->cli.pipe_idx = PI_SHUTDOWN;
-
msg = (op->in.message != NULL) ? op->in.message : talloc_strdup(mem_ctx, "");
hnd->status = NT_STATUS_OK;
if(hnd->_internal.srv_level > SRV_WIN_NT4) {
- hnd->status = cli_shutdown_init_ex( &(srv->cli), mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force, op->in.reason);
+ hnd->status = rpccli_shutdown_init_ex( pipe_hnd, mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force, op->in.reason);
}
if(hnd->_internal.srv_level < SRV_WIN_2K || !NT_STATUS_IS_OK(hnd->status)) {
- hnd->status = cli_shutdown_init( &(srv->cli), mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force);
+ hnd->status = rpccli_shutdown_init( pipe_hnd, mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force);
hnd->_internal.srv_level = SRV_WIN_NT4;
}
@@ -1005,7 +976,7 @@ int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op)
}
int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
- SMBCSRV *srv = NULL;
+ struct rpc_pipe_client *pipe_hnd = NULL;
if(!hnd)
return CAC_FAILURE;
@@ -1015,15 +986,13 @@ int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) {
return CAC_FAILURE;
}
- srv = cac_GetServer(hnd);
- if(!srv) {
- hnd->status = NT_STATUS_INVALID_CONNECTION;
+ pipe_hnd = cac_GetPipe(hnd, PI_SHUTDOWN);
+ if(!pipe_hnd) {
+ hnd->status = NT_STATUS_INVALID_HANDLE;
return CAC_FAILURE;
}
- srv->cli.pipe_idx = PI_SHUTDOWN;
-
- hnd->status = cli_shutdown_abort(&(srv->cli), mem_ctx);
+ hnd->status = rpccli_shutdown_abort(pipe_hnd, mem_ctx);
if(!NT_STATUS_IS_OK(hnd->status))
return CAC_FAILURE;