diff options
author | Gerald Carter <jerry@samba.org> | 2006-09-26 15:15:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:14:46 -0500 |
commit | bbaa0b178d834f4962ab440dff0e1837029369df (patch) | |
tree | 99d6b5c007301ffe8ce55deb3be43a0582a724c4 /source3 | |
parent | cda3a18f2343d4c2f5ff8b08be6015eec37647c3 (diff) | |
download | samba-bbaa0b178d834f4962ab440dff0e1837029369df.tar.gz samba-bbaa0b178d834f4962ab440dff0e1837029369df.tar.bz2 samba-bbaa0b178d834f4962ab440dff0e1837029369df.zip |
r18919: * Get the new rpccli_winreg_XXXX() functions into the tree
There some broken functionality here that I'm still working on.
* remove unneeded parsing routines
(This used to be commit cbfe1a4b498593a48fc34f584754ed4a9ef72cc5)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 18 | ||||
-rw-r--r-- | source3/libmsrpc/cac_winreg.c | 165 | ||||
-rw-r--r-- | source3/rpc_client/cli_reg.c | 632 | ||||
-rw-r--r-- | source3/rpc_client/cli_shutdown.c | 119 | ||||
-rw-r--r-- | source3/rpc_parse/parse_reg.c | 1737 | ||||
-rw-r--r-- | source3/rpc_parse/parse_shutdown.c | 268 | ||||
-rw-r--r-- | source3/utils/net_rpc.c | 53 | ||||
-rw-r--r-- | source3/utils/net_rpc_registry.c | 72 |
8 files changed, 206 insertions, 2858 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 2630338854..3611638b2e 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -211,7 +211,7 @@ PASSCHANGE_OBJ = libsmb/passchange.o LIBNDR_OBJ = librpc/ndr/ndr_basic.o librpc/ndr/ndr.o librpc/ndr/ndr_misc.o \ librpc/ndr/ndr_sec_helper.o librpc/ndr/ndr_string.o librpc/ndr/sid.o \ - rpc_client/ndr.o + rpc_client/ndr.o LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_unixinfo.o librpc/gen_ndr/ndr_lsa.o \ librpc/gen_ndr/ndr_dfs.o librpc/gen_ndr/ndr_echo.o \ @@ -299,15 +299,13 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \ libsmb/gpo.o LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \ - rpc_client/cli_netlogon.o \ - rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \ + rpc_client/cli_netlogon.o rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \ rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o \ - rpc_client/cli_ds.o \ - rpc_client/cli_shutdown.o rpc_client/cli_svcctl.o + rpc_client/cli_ds.o rpc_client/cli_svcctl.o LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_unixinfo.o librpc/gen_ndr/cli_lsa.o \ librpc/gen_ndr/cli_dfs.o librpc/gen_ndr/cli_echo.o \ - librpc/gen_ndr/cli_srvsvc.o \ + librpc/gen_ndr/cli_srvsvc.o \ librpc/gen_ndr/cli_winreg.o librpc/gen_ndr/cli_initshutdown.o \ librpc/gen_ndr/cli_eventlog.o \ $(LIBNDR_GEN_OBJ) $(LIBNDR_OBJ) @@ -362,12 +360,10 @@ RPC_SERVER_OBJ = @RPC_STATIC@ $(RPC_PIPE_OBJ) RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_net.o \ - rpc_parse/parse_reg.o rpc_parse/parse_rpc.o \ - rpc_parse/parse_samr.o \ + rpc_parse/parse_rpc.o rpc_parse/parse_samr.o \ rpc_parse/parse_ds.o rpc_parse/parse_spoolss.o \ - rpc_parse/parse_shutdown.o rpc_parse/parse_svcctl.o \ - rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o \ - rpc_parse/parse_ntsvcs.o $(REGOBJS_OBJ) + rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o \ + rpc_parse/parse_ntsvcs.o rpc_parse/parse_svcctl.o $(REGOBJS_OBJ) RPC_CLIENT_OBJ = rpc_client/cli_pipe.o diff --git a/source3/libmsrpc/cac_winreg.c b/source3/libmsrpc/cac_winreg.c index ea17efb811..448197627e 100644 --- a/source3/libmsrpc/cac_winreg.c +++ b/source3/libmsrpc/cac_winreg.c @@ -26,7 +26,6 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect SMBCSRV *srv = NULL; struct rpc_pipe_client *pipe_hnd = NULL; POLICY_HND *key = NULL; - WERROR err; if(!hnd) return CAC_FAILURE; @@ -68,8 +67,7 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect return CAC_FAILURE; } - err = rpccli_reg_connect( pipe_hnd, mem_ctx, op->in.root, op->in.access, key); - hnd->status = werror_to_ntstatus(err); + hnd->status = rpccli_winreg_connect( pipe_hnd, mem_ctx, op->in.root, op->in.access, key); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -82,7 +80,6 @@ int cac_RegConnect(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegConnect int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; if(!hnd) return CAC_FAILURE; @@ -103,8 +100,7 @@ int cac_RegClose(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *key) { return CAC_FAILURE; } - err = rpccli_reg_close(pipe_hnd, mem_ctx, key); - hnd->status = werror_to_ntstatus(err); + hnd->status = rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, key); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -115,7 +111,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) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; + struct winreg_String key_string; POLICY_HND *key_out; POLICY_HND *parent_key; @@ -181,8 +177,8 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey return CAC_FAILURE; } - err = rpccli_reg_open_entry( pipe_hnd, mem_ctx, parent_key, key_name, op->in.access, key_out); - hnd->status = werror_to_ntstatus(err); + key_string.name = key_name; + hnd->status = rpccli_winreg_OpenKey( pipe_hnd, mem_ctx, parent_key, key_string, 0, op->in.access, key_out); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -190,8 +186,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 = rpccli_reg_close( pipe_hnd, mem_ctx, parent_key); - hnd->status = werror_to_ntstatus(err); + hnd->status = rpccli_winreg_CloseKey( pipe_hnd, mem_ctx, parent_key); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -205,7 +200,6 @@ int cac_RegOpenKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegOpenKey int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKeys *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; /*buffers for rpccli_reg_enum_key call*/ fstring key_name_in; @@ -267,8 +261,7 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey resume_idx = op->out.resume_idx; do { - 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 = rpccli_winreg_enum_key( pipe_hnd, mem_ctx, op->in.key, resume_idx, key_name_in, class_name_in, &mod_times_out[num_keys_out]); if(!NT_STATUS_IS_OK(hnd->status)) { /*don't increment any values*/ @@ -304,11 +297,10 @@ int cac_RegEnumKeys(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumKey int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreateKey *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; - POLICY_HND *key_out; - struct RegOpenKey rok; + struct winreg_String key_string, class_string; + enum winreg_CreateAction action = 0; if(!hnd) return CAC_FAILURE; @@ -349,8 +341,10 @@ int cac_RegCreateKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegCreate return CAC_FAILURE; } - 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); + key_string.name = op->in.key_name; + class_string.name = op->in.class_name; + hnd->status = rpccli_winreg_CreateKey( pipe_hnd, mem_ctx, op->in.parent_key, + key_string, class_string, 0, op->in.access, NULL, key_out, &action); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -376,15 +370,19 @@ WERROR cac_delete_subkeys_recursive(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX int cur_key = 0; while(W_ERROR_IS_OK(err)) { - err = rpccli_reg_enum_key( pipe_hnd, mem_ctx, key, cur_key, subkey_name, class_buf, &mod_time_buf); + struct winreg_String key_string; + NTSTATUS status; + + status = rpccli_winreg_enum_key( pipe_hnd, mem_ctx, key, cur_key, subkey_name, class_buf, &mod_time_buf); - if(!W_ERROR_IS_OK(err)) + if ( !NT_STATUS_IS_OK(status) ) break; /*try to open the key with full access*/ - err = rpccli_reg_open_entry(pipe_hnd, mem_ctx, key, subkey_name, REG_KEY_ALL, &subkey); + key_string.name = subkey_name; + status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, key, key_string, 0, REG_KEY_ALL, &subkey); - if(!W_ERROR_IS_OK(err)) + if ( !NT_STATUS_IS_OK(status) ) break; err = cac_delete_subkeys_recursive(pipe_hnd, mem_ctx, &subkey); @@ -396,10 +394,12 @@ WERROR cac_delete_subkeys_recursive(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX rpccli_winreg_FlushKey(pipe_hnd, mem_ctx, key); /*close the key that we opened*/ - rpccli_reg_close(pipe_hnd, mem_ctx, &subkey); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &subkey); /*now we delete the subkey*/ - err = rpccli_reg_delete_key(pipe_hnd, mem_ctx, key, subkey_name); + key_string.name = subkey_name; + status = rpccli_winreg_DeleteKey(pipe_hnd, mem_ctx, key, key_string); + err = ntstatus_to_werror(status); cur_key++; @@ -414,6 +414,7 @@ WERROR cac_delete_subkeys_recursive(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteKey *op) { struct rpc_pipe_client *pipe_hnd = NULL; WERROR err; + struct winreg_String key_string; if(!hnd) return CAC_FAILURE; @@ -459,8 +460,8 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete /*now go on to actually delete the key*/ } - err = rpccli_reg_delete_key( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name); - hnd->status = werror_to_ntstatus(err); + key_string.name = op->in.name; + hnd->status = rpccli_winreg_DeleteKey( pipe_hnd, mem_ctx, op->in.parent_key, key_string ); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -471,7 +472,7 @@ int cac_RegDeleteKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDelete int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDeleteValue *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; + struct winreg_String value_string; if(!hnd) return CAC_FAILURE; @@ -492,8 +493,8 @@ int cac_RegDeleteValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegDele return CAC_FAILURE; } - err = rpccli_reg_delete_val( pipe_hnd, mem_ctx, op->in.parent_key, op->in.name); - hnd->status = werror_to_ntstatus(err); + value_string.name = op->in.name; + hnd->status = rpccli_winreg_DeleteValue( pipe_hnd, mem_ctx, op->in.parent_key, value_string ); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -593,11 +594,13 @@ int cac_RegQueryKeyInfo(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQue int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQueryValue *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; - - uint32 val_type; + struct winreg_String value_string; REGVAL_BUFFER buffer; REG_VALUE_DATA *data_out = NULL; + enum winreg_Type val_type; + uint8 *buf; + uint32 buf_size = 4096; + uint32 length = 0; if(!hnd) return CAC_FAILURE; @@ -618,12 +621,21 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery return CAC_FAILURE; } - 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); + value_string.name = op->in.val_name; + + if ( (buf = TALLOC_ARRAY( mem_ctx, uint8, buf_size )) == NULL ) { + hnd->status = NT_STATUS_NO_MEMORY; + return CAC_FAILURE; + } + + hnd->status = rpccli_winreg_QueryValue(pipe_hnd, mem_ctx, op->in.key, + value_string, &val_type, buf, &buf_size, &length ); if(!NT_STATUS_IS_OK(hnd->status)) return CAC_FAILURE; + init_regval_buffer( &buffer, buf, length ); + data_out = cac_MakeRegValueData(mem_ctx, val_type, buffer); if(!data_out) { if(errno == ENOMEM) @@ -643,7 +655,6 @@ int cac_RegQueryValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegQuery int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumValues *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; /*buffers for rpccli_reg_enum_key call*/ fstring val_name_buf; @@ -705,8 +716,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV do { ZERO_STRUCT(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 = rpccli_winreg_enum_val(pipe_hnd, mem_ctx, op->in.key, resume_idx, val_name_buf, &types_out[num_values_out], &val_buf); if(!NT_STATUS_IS_OK(hnd->status)) break; @@ -737,7 +747,7 @@ int cac_RegEnumValues(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegEnumV int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValue *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; + struct winreg_String value_string; RPC_DATA_BLOB *buffer; @@ -771,8 +781,8 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu return CAC_FAILURE; } - 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); + value_string.name = op->in.val_name; + hnd->status = rpccli_winreg_SetValue(pipe_hnd, mem_ctx, op->in.key, value_string, op->in.type, buffer->buffer, buffer->buf_len); if(!NT_STATUS_IS_OK(hnd->status)) return CAC_FAILURE; @@ -790,8 +800,6 @@ int cac_RegSetValue(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetValu int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVersion *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; - uint32 version_out; if(!hnd) @@ -813,8 +821,7 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe return CAC_FAILURE; } - err = rpccli_reg_getversion( pipe_hnd, mem_ctx, op->in.key, &version_out); - hnd->status = werror_to_ntstatus(err); + hnd->status = rpccli_winreg_GetVersion( pipe_hnd, mem_ctx, op->in.key, &version_out); if(!NT_STATUS_IS_OK(hnd->status)) return CAC_FAILURE; @@ -826,12 +833,9 @@ int cac_RegGetVersion(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetVe int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegGetKeySecurity *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; + struct KeySecurityData keysec; - uint32 buf_size; - SEC_DESC_BUF buf; - - ZERO_STRUCT(buf); + ZERO_STRUCT(keysec); if(!hnd) return CAC_FAILURE; @@ -852,16 +856,16 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG return CAC_FAILURE; } - 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); - + hnd->status = rpccli_winreg_GetKeySecurity(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, &keysec); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; } +#if 0 /* FIX ME!!!! unmarshall the security descriptor */ op->out.size = buf.sd_size; op->out.descriptor = dup_sec_desc(mem_ctx, buf.sd); +#endif if (op->out.descriptor == NULL) { return CAC_FAILURE; @@ -872,41 +876,9 @@ int cac_RegGetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegG int cac_RegSetKeySecurity(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSetKeySecurity *op) { struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; - - if(!hnd) - return CAC_FAILURE; - - if(!hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG]) { - hnd->status = NT_STATUS_INVALID_HANDLE; - return CAC_FAILURE; - } + struct KeySecurityData keysec; - if(!op || !op->in.key || op->in.info_type == 0 || op->in.size == 0 || !op->in.descriptor || !mem_ctx) { - hnd->status = NT_STATUS_INVALID_PARAMETER; - return CAC_FAILURE; - } - - pipe_hnd = cac_GetPipe(hnd, PI_WINREG); - if(!pipe_hnd) { - hnd->status = NT_STATUS_INVALID_HANDLE; - return CAC_FAILURE; - } - - 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); - - - if(!NT_STATUS_IS_OK(hnd->status)) { - return CAC_FAILURE; - } - - return CAC_SUCCESS; -} - -int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey *op) { - struct rpc_pipe_client *pipe_hnd = NULL; - WERROR err; + ZERO_STRUCT( keysec ); if(!hnd) return CAC_FAILURE; @@ -916,7 +888,7 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey return CAC_FAILURE; } - if(!op || !op->in.key || !op->in.filename || !mem_ctx) { + if(!op || !op->in.key || op->in.info_type == 0 || op->in.size == 0 || !op->in.descriptor || !mem_ctx) { hnd->status = NT_STATUS_INVALID_PARAMETER; return CAC_FAILURE; } @@ -927,9 +899,8 @@ int cac_RegSaveKey(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct RegSaveKey return CAC_FAILURE; } - err = rpccli_reg_save_key( pipe_hnd, mem_ctx, op->in.key, op->in.filename); - hnd->status = werror_to_ntstatus(err); - + /* FIXME!!! Marshall in the input sec_desc to struct KeySecurityData */ + hnd->status = rpccli_winreg_SetKeySecurity(pipe_hnd, mem_ctx, op->in.key, op->in.info_type, &keysec ); if(!NT_STATUS_IS_OK(hnd->status)) { return CAC_FAILURE; @@ -941,6 +912,8 @@ 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; + struct initshutdown_String msg_string; + struct initshutdown_String_sub s; char *msg; @@ -979,15 +952,19 @@ int cac_Shutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct Shutdown *op) } msg = (op->in.message != NULL) ? op->in.message : talloc_strdup(mem_ctx, ""); + msg_string.name = &s; + msg_string.name->name = msg; hnd->status = NT_STATUS_OK; if(hnd->_internal.srv_level > SRV_WIN_NT4) { - hnd->status = rpccli_shutdown_init_ex( pipe_hnd, mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force, op->in.reason); + hnd->status = rpccli_initshutdown_InitEx( pipe_hnd, mem_ctx, NULL, &msg_string, + 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 = rpccli_shutdown_init( pipe_hnd, mem_ctx, msg, op->in.timeout, op->in.reboot, op->in.force); + hnd->status = rpccli_initshutdown_Init( pipe_hnd, mem_ctx, NULL, &msg_string, + op->in.timeout, op->in.reboot, op->in.force); hnd->_internal.srv_level = SRV_WIN_NT4; } @@ -1016,7 +993,7 @@ int cac_AbortShutdown(CacServerHandle *hnd, TALLOC_CTX *mem_ctx) { return CAC_FAILURE; } - hnd->status = rpccli_shutdown_abort(pipe_hnd, mem_ctx); + hnd->status = rpccli_initshutdown_Abort(pipe_hnd, mem_ctx, NULL); if(!NT_STATUS_IS_OK(hnd->status)) return CAC_FAILURE; diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c index 0f0c642d21..9b0420a4ec 100644 --- a/source3/rpc_client/cli_reg.c +++ b/source3/rpc_client/cli_reg.c @@ -2,11 +2,7 @@ Unix SMB/CIFS implementation. RPC Pipe client - Copyright (C) Andrew Tridgell 1992-2000, - Copyright (C) Jeremy Allison 1999 - 2005 - Copyright (C) Simo Sorce 2001 - Copyright (C) Jeremy Cooper 2004 - Copyright (C) Gerald (Jerry) Carter 2005 + Copyright (C) Gerald (Jerry) Carter 2005-2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,619 +22,101 @@ #include "includes.h" #include "rpc_client.h" -/* Shutdown a server */ - -/******************************************************************* - internal connect to a registry hive root (open a registry policy) -*******************************************************************/ - -static WERROR rpccli_reg_open_hive_int(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, uint16 op_code, - const char *op_name, - uint32 access_mask, POLICY_HND *hnd) -{ - REG_Q_OPEN_HIVE in; - REG_R_OPEN_HIVE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - init_reg_q_open_hive(&in, access_mask); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, op_code, - in, out, - qbuf, rbuf, - reg_io_q_open_hive, - reg_io_r_open_hive, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( hnd, &out.pol, sizeof(POLICY_HND) ); - - return out.status; -} - /******************************************************************* connect to a registry hive root (open a registry policy) *******************************************************************/ -WERROR rpccli_reg_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, +NTSTATUS rpccli_winreg_connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 reg_type, uint32 access_mask, POLICY_HND *reg_hnd) -{ uint16 op_code; - const char *op_name; - +{ ZERO_STRUCTP(reg_hnd); switch (reg_type) { case HKEY_CLASSES_ROOT: - op_code = REG_OPEN_HKCR; - op_name = "REG_OPEN_HKCR"; - break; + return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL, + access_mask, reg_hnd ); + case HKEY_LOCAL_MACHINE: - op_code = REG_OPEN_HKLM; - op_name = "REG_OPEN_HKLM"; - break; + return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL, + access_mask, reg_hnd ); + case HKEY_USERS: - op_code = REG_OPEN_HKU; - op_name = "REG_OPEN_HKU"; - break; + return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL, + access_mask, reg_hnd ); + case HKEY_PERFORMANCE_DATA: - op_code = REG_OPEN_HKPD; - op_name = "REG_OPEN_HKPD"; - break; + return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL, + access_mask, reg_hnd ); + default: - return WERR_INVALID_PARAM; + /* fall through to end of function */ + break; } - return rpccli_reg_open_hive_int(cli, mem_ctx, op_code, op_name, - access_mask, reg_hnd); -} - - -/******************************************************************* -*******************************************************************/ - -WERROR rpccli_reg_shutdown(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - const char *msg, uint32 timeout, BOOL do_reboot, - BOOL force) -{ - REG_Q_SHUTDOWN in; - REG_R_SHUTDOWN out; - prs_struct qbuf, rbuf; - - if (msg == NULL) - return WERR_INVALID_PARAM; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - /* Marshall data and send request */ - - init_reg_q_shutdown(&in, msg, timeout, do_reboot, force); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SHUTDOWN, - in, out, - qbuf, rbuf, - reg_io_q_shutdown, - reg_io_r_shutdown, - WERR_GENERAL_FAILURE ); - - return out.status; + return NT_STATUS_INVALID_PARAMETER; } /**************************************************************************** -do a REG Query Key ****************************************************************************/ -WERROR rpccli_reg_query_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, +NTSTATUS rpccli_winreg_query_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hnd, char *key_class, uint32 *class_len, uint32 *num_subkeys, uint32 *max_subkeylen, - uint32 *max_classlen, uint32 *num_values, + uint32 *max_subkeysize, uint32 *num_values, uint32 *max_valnamelen, uint32 *max_valbufsize, - uint32 *sec_desc, NTTIME *mod_time) -{ - REG_Q_QUERY_KEY in; - REG_R_QUERY_KEY out; - prs_struct qbuf, rbuf; - uint32 saved_class_len = *class_len; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_query_key( &in, hnd, key_class ); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY, - in, out, - qbuf, rbuf, - reg_io_q_query_key, - reg_io_r_query_key, - WERR_GENERAL_FAILURE ); - - if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) { - ZERO_STRUCT (in); - - *class_len = out.key_class.string->uni_max_len; - if ( *class_len > saved_class_len ) - return out.status; - - /* set a string of spaces and NULL terminate */ - - memset( key_class, (int)' ', *class_len ); - key_class[*class_len] = '\0'; - - init_reg_q_query_key( &in, hnd, key_class ); - - ZERO_STRUCT (out); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_KEY, - in, out, - qbuf, rbuf, - reg_io_q_query_key, - reg_io_r_query_key, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - *class_len = out.key_class.string->uni_max_len; - unistr2_to_ascii(key_class, out.key_class.string, saved_class_len-1); - *num_subkeys = out.num_subkeys ; - *max_subkeylen = out.max_subkeylen ; - *num_values = out.num_values ; - *max_valnamelen = out.max_valnamelen; - *max_valbufsize = out.max_valbufsize; - *sec_desc = out.sec_desc ; - *mod_time = out.mod_time ; - /* Maybe: *max_classlen = out.reserved; */ - - return out.status; -} - -/**************************************************************************** -****************************************************************************/ - -WERROR rpccli_reg_getversion(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, uint32 *version) -{ - REG_Q_GETVERSION in; - REG_R_GETVERSION out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_getversion(&in, hnd); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GETVERSION, - in, out, - qbuf, rbuf, - reg_io_q_getversion, - reg_io_r_getversion, - WERR_GENERAL_FAILURE ); - - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - *version = out.win_version; - - return out.status; -} - -/**************************************************************************** -do a REG Query Info -****************************************************************************/ - -WERROR rpccli_reg_query_value(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, const char *val_name, - uint32 *type, REGVAL_BUFFER *buffer) -{ - REG_Q_QUERY_VALUE in; - REG_R_QUERY_VALUE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_query_value(&in, hnd, val_name, buffer); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_QUERY_VALUE, - in, out, - qbuf, rbuf, - reg_io_q_query_value, - reg_io_r_query_value, - WERR_GENERAL_FAILURE ); - - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - *type = *out.type; - *buffer = *out.value; - - return out.status; -} - -/**************************************************************************** -do a REG Set Key Security -****************************************************************************/ - -WERROR rpccli_reg_set_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, uint32 sec_info, - size_t secdesc_size, SEC_DESC *sec_desc) + uint32 *secdescsize, NTTIME *mod_time) { - REG_Q_SET_KEY_SEC in; - REG_R_SET_KEY_SEC out; - prs_struct qbuf, rbuf; - SEC_DESC_BUF *sec_desc_buf; + NTSTATUS status; + struct winreg_String classname_in, classname_out; - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - /* Flatten the security descriptor */ - - if ( !(sec_desc_buf = make_sec_desc_buf(mem_ctx, secdesc_size, sec_desc)) ) - return WERR_GENERAL_FAILURE; - - init_reg_q_set_key_sec(&in, hnd, sec_info, sec_desc_buf); + classname_in.name = key_class; + status = rpccli_winreg_QueryInfoKey( cli, mem_ctx, hnd, + classname_in, &classname_out, num_subkeys, + max_subkeylen, max_subkeysize, num_values, + max_valnamelen, max_valbufsize, secdescsize, + mod_time ); - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_KEY_SEC, - in, out, - qbuf, rbuf, - reg_io_q_set_key_sec, - reg_io_r_set_key_sec, - WERR_GENERAL_FAILURE ); - + /* The old code would check for INSUFFICIENT_BUFFER. + Will have to work this out. */ - return out.status; + return status; } /**************************************************************************** -do a REG Query Key Security ****************************************************************************/ -WERROR rpccli_reg_get_key_sec(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, uint32 sec_info, - uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf) +NTSTATUS rpccli_winreg_enum_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *hnd, int idx, + fstring val_name, uint32 *type, REGVAL_BUFFER *value) { - REG_Q_GET_KEY_SEC in; - REG_R_GET_KEY_SEC out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_get_key_sec(&in, hnd, sec_info, *sec_buf_size, sec_buf); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_GET_KEY_SEC, - in, out, - qbuf, rbuf, - reg_io_q_get_key_sec, - reg_io_r_get_key_sec, - WERR_GENERAL_FAILURE ); - - - /* this might be able to return WERR_MORE_DATA, I'm not sure */ + NTSTATUS status = NT_STATUS_INVALID_PARAMETER; - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; + /* do rpc */ - sec_buf = out.data; - *sec_buf_size = out.data->sd_size; - return out.status; -} - -/**************************************************************************** -do a REG Delete Value -****************************************************************************/ - -WERROR rpccli_reg_delete_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, char *val_name) -{ - REG_Q_DELETE_VALUE in; - REG_R_DELETE_VALUE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_delete_val(&in, hnd, val_name); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_VALUE, - in, out, - qbuf, rbuf, - reg_io_q_delete_value, - reg_io_r_delete_value, - WERR_GENERAL_FAILURE ); - - return out.status; -} - -/**************************************************************************** -do a REG Delete Key -****************************************************************************/ - -WERROR rpccli_reg_delete_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, char *key_name) -{ - REG_Q_DELETE_KEY in; - REG_R_DELETE_KEY out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_delete_key(&in, hnd, key_name); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_DELETE_KEY, - in, out, - qbuf, rbuf, - reg_io_q_delete_key, - reg_io_r_delete_key, - WERR_GENERAL_FAILURE ); - - return out.status; -} - -/**************************************************************************** -do a REG Create Key -****************************************************************************/ - -WERROR rpccli_reg_create_key_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, char *key_name, char *key_class, - uint32 access_desired, POLICY_HND *key) -{ - REG_Q_CREATE_KEY_EX in; - REG_R_CREATE_KEY_EX out; - prs_struct qbuf, rbuf; - SEC_DESC *sec; - SEC_DESC_BUF *sec_buf; - size_t sec_len; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - if ( !(sec = make_sec_desc(mem_ctx, 1, SEC_DESC_SELF_RELATIVE, - NULL, NULL, NULL, NULL, &sec_len)) ) { - return WERR_GENERAL_FAILURE; - } - - if ( !(sec_buf = make_sec_desc_buf(mem_ctx, sec_len, sec)) ) - return WERR_GENERAL_FAILURE; - - init_reg_q_create_key_ex(&in, hnd, key_name, key_class, access_desired, sec_buf); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CREATE_KEY_EX, - in, out, - qbuf, rbuf, - reg_io_q_create_key_ex, - reg_io_r_create_key_ex, - WERR_GENERAL_FAILURE ); - - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( key, &out.handle, sizeof(POLICY_HND) ); - - return out.status; + return status; } /**************************************************************************** -do a REG Enum Key ****************************************************************************/ -WERROR rpccli_reg_enum_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, +NTSTATUS rpccli_winreg_enum_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, POLICY_HND *hnd, int key_index, fstring key_name, fstring class_name, time_t *mod_time) { - REG_Q_ENUM_KEY in; - REG_R_ENUM_KEY out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_enum_key(&in, hnd, key_index); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_KEY, - in, out, - qbuf, rbuf, - reg_io_q_enum_key, - reg_io_r_enum_key, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK(out.status) ) - return out.status; - - if ( out.keyname.string ) - rpcstr_pull( key_name, out.keyname.string->buffer, sizeof(fstring), -1, STR_TERMINATE ); - else - fstrcpy( key_name, "(Default)" ); - - if ( out.classname && out.classname->string ) - rpcstr_pull( class_name, out.classname->string->buffer, sizeof(fstring), -1, STR_TERMINATE ); - else - fstrcpy( class_name, "" ); - - *mod_time = nt_time_to_unix(*out.time); - - return out.status; -} - -/**************************************************************************** -do a REG Create Value -****************************************************************************/ - -WERROR rpccli_reg_set_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, char *val_name, uint32 type, - RPC_DATA_BLOB *data) -{ - REG_Q_SET_VALUE in; - REG_R_SET_VALUE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_set_val(&in, hnd, val_name, type, data); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SET_VALUE, - in, out, - qbuf, rbuf, - reg_io_q_set_value, - reg_io_r_set_value, - WERR_GENERAL_FAILURE ); - - return out.status; -} - -/**************************************************************************** -do a REG Enum Value -****************************************************************************/ - -WERROR rpccli_reg_enum_val(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, int idx, - fstring val_name, uint32 *type, REGVAL_BUFFER *value) -{ - REG_Q_ENUM_VALUE in; - REG_R_ENUM_VALUE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_enum_val(&in, hnd, idx, 0x0100, 0x1000); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE, - in, out, - qbuf, rbuf, - reg_io_q_enum_val, - reg_io_r_enum_val, - WERR_GENERAL_FAILURE ); - - if ( W_ERROR_EQUAL(out.status, WERR_MORE_DATA) ) { - - ZERO_STRUCT (in); - - init_reg_q_enum_val(&in, hnd, idx, 0x0100, *out.buffer_len1); - - ZERO_STRUCT (out); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_ENUM_VALUE, - in, out, - qbuf, rbuf, - reg_io_q_enum_val, - reg_io_r_enum_val, - WERR_GENERAL_FAILURE ); - } - - if ( !W_ERROR_IS_OK(out.status) ) - return out.status; - - unistr2_to_ascii(val_name, out.name.string, sizeof(fstring)-1); - *type = *out.type; - *value = *out.value; - - return out.status; -} - -/**************************************************************************** -****************************************************************************/ - -WERROR rpccli_reg_open_entry(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, char *key_name, - uint32 access_desired, POLICY_HND *key_hnd) -{ - REG_Q_OPEN_ENTRY in; - REG_R_OPEN_ENTRY out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_open_entry(&in, hnd, key_name, access_desired); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_OPEN_ENTRY, - in, out, - qbuf, rbuf, - reg_io_q_open_entry, - reg_io_r_open_entry, - WERR_GENERAL_FAILURE ); - - if ( !W_ERROR_IS_OK( out.status ) ) - return out.status; - - memcpy( key_hnd, &out.handle, sizeof(POLICY_HND) ); - - return out.status; -} - -/**************************************************************************** -****************************************************************************/ - -WERROR rpccli_reg_close(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd) -{ - REG_Q_CLOSE in; - REG_R_CLOSE out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_reg_q_close(&in, hnd); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_CLOSE, - in, out, - qbuf, rbuf, - reg_io_q_close, - reg_io_r_close, - WERR_GENERAL_FAILURE ); + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - return out.status; + return status; } -/**************************************************************************** -do a REG Query Info -****************************************************************************/ - -WERROR rpccli_reg_save_key(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *hnd, const char *filename ) -{ - REG_Q_SAVE_KEY in; - REG_R_SAVE_KEY out; - prs_struct qbuf, rbuf; - - ZERO_STRUCT (in); - ZERO_STRUCT (out); - - init_q_reg_save_key( &in, hnd, filename ); - - CLI_DO_RPC_WERR( cli, mem_ctx, PI_WINREG, REG_SAVE_KEY, - in, out, - qbuf, rbuf, - reg_io_q_save_key, - reg_io_r_save_key, - WERR_GENERAL_FAILURE ); - - return out.status; -} - - -/* - ################################################################# - Utility functions - ################################################################# +/* + * + * Utility functions + * */ /***************************************************************** @@ -678,3 +156,23 @@ BOOL reg_split_hive(const char *full_keyname, uint32 *reg_type, pstring key_name return True; } + +/******************************************************************* + Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE + *******************************************************************/ + +uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val ) +{ + uint32 real_size = 0; + + if ( !buf2 || !val ) + return 0; + + real_size = regval_size(val); + init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size ); + + return real_size; +} + + + diff --git a/source3/rpc_client/cli_shutdown.c b/source3/rpc_client/cli_shutdown.c deleted file mode 100644 index afac07325d..0000000000 --- a/source3/rpc_client/cli_shutdown.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - Unix SMB/CIFS implementation. - RPC Pipe client - - Copyright (C) Andrew Tridgell 1992-1998, - Largely rewritten by Jeremy Allison (C) 2005. - Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" - -/* Shutdown a server */ - -NTSTATUS rpccli_shutdown_init(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - const char *msg, uint32 timeout, BOOL do_reboot, - BOOL force) -{ - prs_struct qbuf; - prs_struct rbuf; - SHUTDOWN_Q_INIT q; - SHUTDOWN_R_INIT r; - WERROR result = WERR_GENERAL_FAILURE; - - if (msg == NULL) - return NT_STATUS_INVALID_PARAMETER; - - ZERO_STRUCT (q); - ZERO_STRUCT (r); - - /* Marshall data and send request */ - - init_shutdown_q_init(&q, msg, timeout, do_reboot, force); - - CLI_DO_RPC(cli, mem_ctx, PI_INITSHUTDOWN, SHUTDOWN_INIT, - q, r, - qbuf, rbuf, - shutdown_io_q_init, - shutdown_io_r_init, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - return werror_to_ntstatus(result); -} - -/* Shutdown a server */ - -NTSTATUS rpccli_shutdown_init_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, - const char *msg, uint32 timeout, BOOL do_reboot, - BOOL force, uint32 reason) -{ - prs_struct qbuf; - prs_struct rbuf; - SHUTDOWN_Q_INIT_EX q; - SHUTDOWN_R_INIT_EX r; - WERROR result = WERR_GENERAL_FAILURE; - - if (msg == NULL) - return NT_STATUS_INVALID_PARAMETER; - - ZERO_STRUCT (q); - ZERO_STRUCT (r); - - /* Marshall data and send request */ - - init_shutdown_q_init_ex(&q, msg, timeout, do_reboot, force, reason); - - CLI_DO_RPC(cli, mem_ctx, PI_INITSHUTDOWN, SHUTDOWN_INIT_EX, - q, r, - qbuf, rbuf, - shutdown_io_q_init_ex, - shutdown_io_r_init_ex, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - return werror_to_ntstatus(result); -} - - -/* Abort a server shutdown */ - -NTSTATUS rpccli_shutdown_abort(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx) -{ - prs_struct rbuf; - prs_struct qbuf; - SHUTDOWN_Q_ABORT q; - SHUTDOWN_R_ABORT r; - WERROR result = WERR_GENERAL_FAILURE; - - ZERO_STRUCT (q); - ZERO_STRUCT (r); - - /* Marshall data and send request */ - - init_shutdown_q_abort(&q); - - CLI_DO_RPC(cli, mem_ctx, PI_INITSHUTDOWN, SHUTDOWN_ABORT, - q, r, - qbuf, rbuf, - shutdown_io_q_abort, - shutdown_io_r_abort, - NT_STATUS_UNSUCCESSFUL); - - result = r.status; - return werror_to_ntstatus(result); -} diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c deleted file mode 100644 index f529ad1425..0000000000 --- a/source3/rpc_parse/parse_reg.c +++ /dev/null @@ -1,1737 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. - * Copyright (C) Simo Sorce 2000. - * Copyright (C) Jeremy Cooper 2004 - * Copyright (C) Gerald Carter 2002-2005. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -/******************************************************************* - Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE - *******************************************************************/ - -uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val ) -{ - uint32 real_size = 0; - - if ( !buf2 || !val ) - return 0; - - real_size = regval_size(val); - init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size ); - - return real_size; -} - -/******************************************************************* - Inits a hive connect request structure -********************************************************************/ - -void init_reg_q_open_hive( REG_Q_OPEN_HIVE *q_o, uint32 access_desired ) -{ - - q_o->server = TALLOC_P( get_talloc_ctx(), uint16); - if (!q_o->server) { - smb_panic("init_reg_q_open_hive: talloc fail.\n"); - return; - } - *q_o->server = 0x1; - - q_o->access = access_desired; -} - -/******************************************************************* -Marshalls a hive connect request -********************************************************************/ - -BOOL reg_io_q_open_hive(const char *desc, REG_Q_OPEN_HIVE *q_u, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "reg_io_q_open_hive"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_pointer("server", ps, depth, (void*)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("access", ps, depth, &q_u->access)) - return False; - - return True; -} - - -/******************************************************************* -Unmarshalls a hive connect response -********************************************************************/ - -BOOL reg_io_r_open_hive(const char *desc, REG_R_OPEN_HIVE *r_u, - prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_hive"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_u->pol, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes SEC_DESC_BUF and SEC_DATA structures. -********************************************************************/ - -static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, - SEC_DESC_BUF *data, prs_struct *ps, int depth) -{ - if (ptr != 0) { - uint32 hdr_offset; - uint32 old_offset; - if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, - &hdr_offset)) - return False; - - old_offset = prs_offset(ps); - - if (ptr3 != NULL) { - if(!prs_uint32("ptr3", ps, depth, ptr3)) - return False; - } - - if (ptr3 == NULL || *ptr3 != 0) { - /* JRA - this next line is probably wrong... */ - if(!sec_io_desc_buf("data ", &data, ps, depth)) - return False; - } - - if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, - hdr_offset, data->sd_size, data->sd_size)) - return False; - if(!prs_set_offset(ps, old_offset + data->sd_size + - sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3))) - return False; - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a registry key create request -********************************************************************/ - -void init_reg_q_create_key_ex(REG_Q_CREATE_KEY_EX *q_c, POLICY_HND *hnd, - char *name, char *key_class, uint32 access_desired, - SEC_DESC_BUF *sec_buf) -{ - ZERO_STRUCTP(q_c); - - memcpy(&q_c->handle, hnd, sizeof(q_c->handle)); - - - init_unistr4( &q_c->name, name, UNI_STR_TERMINATE ); - init_unistr4( &q_c->key_class, key_class, UNI_STR_TERMINATE ); - - q_c->access = access_desired; - - q_c->sec_info = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!q_c->sec_info) { - smb_panic("init_reg_q_create_key_ex: talloc fail\n"); - return; - } - *q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION; - - q_c->data = sec_buf; - q_c->ptr2 = 1; - init_buf_hdr(&q_c->hdr_sec, sec_buf->sd_size, sec_buf->sd_size); - q_c->ptr3 = 1; - q_c->disposition = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!q_c->disposition) { - smb_panic("init_reg_q_create_key_ex: talloc fail\n"); - return; - } -} - -/******************************************************************* -Marshalls a registry key create request -********************************************************************/ - -BOOL reg_io_q_create_key_ex(const char *desc, REG_Q_CREATE_KEY_EX *q_u, - prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_create_key_ex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->handle, ps, depth)) - return False; - - if(!prs_unistr4 ("name", ps, depth, &q_u->name)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_unistr4 ("key_class", ps, depth, &q_u->key_class)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("options", ps, depth, &q_u->options)) - return False; - if(!prs_uint32("access", ps, depth, &q_u->access)) - return False; - - if(!prs_pointer("sec_info", ps, depth, (void*)&q_u->sec_info, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - if ( q_u->sec_info ) { - if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2)) - return False; - if(!reg_io_hdrbuf_sec(q_u->ptr2, &q_u->ptr3, &q_u->hdr_sec, q_u->data, ps, depth)) - return False; - } - - if(!prs_pointer("disposition", ps, depth, (void*)&q_u->disposition, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - return True; -} - -/******************************************************************* -Unmarshalls a registry key create response -********************************************************************/ - -BOOL reg_io_r_create_key_ex(const char *desc, REG_R_CREATE_KEY_EX *r_u, - prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_create_key_ex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_u->handle, ps, depth)) - return False; - if(!prs_uint32("disposition", ps, depth, &r_u->disposition)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd, - char *name) -{ - ZERO_STRUCTP(q_c); - - memcpy(&q_c->handle, hnd, sizeof(q_c->handle)); - init_unistr4(&q_c->name, name, UNI_STR_TERMINATE); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_delete_value(const char *desc, REG_Q_DELETE_VALUE *q_u, - prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_delete_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->handle, ps, depth)) - return False; - - if(!prs_unistr4("name", ps, depth, &q_u->name)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_delete_value(const char *desc, REG_R_DELETE_VALUE *r_u, - prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_delete_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd, - char *name) -{ - ZERO_STRUCTP(q_c); - - memcpy(&q_c->handle, hnd, sizeof(q_c->handle)); - - init_unistr4(&q_c->name, name, UNI_STR_TERMINATE); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *q_u, - prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_delete_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->handle, ps, depth)) - return False; - - if(!prs_unistr4("", ps, depth, &q_u->name)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_delete_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, const char *key_class) -{ - ZERO_STRUCTP(q_o); - - memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); - init_unistr4(&q_o->key_class, key_class, UNI_STR_TERMINATE); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_query_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - if(!prs_unistr4("key_class", ps, depth, &q_u->key_class)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_query_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_unistr4("key_class", ps, depth, &r_u->key_class)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_subkeys ", ps, depth, &r_u->num_subkeys)) - return False; - if(!prs_uint32("max_subkeylen ", ps, depth, &r_u->max_subkeylen)) - return False; - if(!prs_uint32("reserved ", ps, depth, &r_u->reserved)) - return False; - if(!prs_uint32("num_values ", ps, depth, &r_u->num_values)) - return False; - if(!prs_uint32("max_valnamelen", ps, depth, &r_u->max_valnamelen)) - return False; - if(!prs_uint32("max_valbufsize", ps, depth, &r_u->max_valbufsize)) - return False; - if(!prs_uint32("sec_desc ", ps, depth, &r_u->sec_desc)) - return False; - if(!smb_io_time("mod_time ", &r_u->mod_time, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_getversion(REG_Q_GETVERSION *q_o, POLICY_HND *hnd) -{ - memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_getversion(const char *desc, REG_Q_GETVERSION *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_getversion"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_getversion(const char *desc, REG_R_GETVERSION *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_getversion"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("win_version", ps, depth, &r_u->win_version)) - return False; - if(!prs_werror("status" , ps, depth, &r_u->status)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_restore_key(const char *desc, REG_Q_RESTORE_KEY *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_restore_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - - if(!prs_unistr4("filename", ps, depth, &q_u->filename)) - return False; - - if(!prs_uint32("flags", ps, depth, &q_u->flags)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_restore_key(const char *desc, REG_R_RESTORE_KEY *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_restore_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status" , ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -void init_q_reg_save_key( REG_Q_SAVE_KEY *q_u, POLICY_HND *handle, const char *fname ) -{ - memcpy(&q_u->pol, handle, sizeof(q_u->pol)); - init_unistr4( &q_u->filename, fname, UNI_STR_TERMINATE ); - q_u->sec_attr = NULL; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_save_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - - if(!prs_unistr4("filename", ps, depth, &q_u->filename)) - return False; - -#if 0 /* reg_io_sec_attr() */ - if(!prs_uint32("unknown", ps, depth, &q_u->unknown)) - return False; -#endif - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_save_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status" , ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an REG_Q_CLOSE structure. -********************************************************************/ - -void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd) -{ - DEBUG(5,("init_reg_q_close\n")); - - memcpy(&q_c->pol, hnd, sizeof(q_c->pol)); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_close(const char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_u->pol, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_u, POLICY_HND *pol, - uint32 sec_info, SEC_DESC_BUF *sec_desc_buf) -{ - memcpy(&q_u->handle, pol, sizeof(q_u->handle)); - - q_u->sec_info = sec_info; - - q_u->ptr = 1; - init_buf_hdr(&q_u->hdr_sec, sec_desc_buf->sd_size, sec_desc_buf->sd_size); - q_u->data = sec_desc_buf; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_set_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->handle, ps, depth)) - return False; - - if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) - return False; - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - - if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_set_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &q_u->status)) - return False; - - return True; -} - - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_u, POLICY_HND *pol, - uint32 sec_info, uint32 sec_buf_size, - SEC_DESC_BUF *psdb) -{ - memcpy(&q_u->handle, pol, sizeof(q_u->handle)); - - q_u->sec_info = sec_info; - - q_u->ptr = psdb != NULL ? 1 : 0; - q_u->data = psdb; - - init_buf_hdr(&q_u->hdr_sec, sec_buf_size, 0); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_get_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->handle, ps, depth)) - return False; - - if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) - return False; - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - - if(!reg_io_hdrbuf_sec(q_u->ptr, NULL, &q_u->hdr_sec, q_u->data, ps, depth)) - return False; - - return True; -} - -#if 0 -/******************************************************************* -makes a structure. -********************************************************************/ - void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, - uint32 buf_len, uint8 *buf, - NTSTATUS status) -{ - r_i->ptr = 1; - init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len); - init_sec_desc_buf(r_i->data, buf_len, 1); - - r_i->status = status; /* 0x0000 0000 or 0x0000 007a */ -} -#endif - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_get_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - - if (q_u->ptr != 0) { - if(!smb_io_hdrbuf("", &q_u->hdr_sec, ps, depth)) - return False; - if(!sec_io_desc_buf("", &q_u->data, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - - if(!prs_werror("status", ps, depth, &q_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -BOOL init_reg_q_query_value(REG_Q_QUERY_VALUE *q_u, POLICY_HND *pol, const char *val_name, - REGVAL_BUFFER *value_output) -{ - if (q_u == NULL) - return False; - - q_u->pol = *pol; - - init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE); - - q_u->ptr_reserved = 1; - q_u->ptr_buf = 1; - - q_u->ptr_bufsize = 1; - q_u->bufsize = value_output->buf_max_len; - q_u->buf_unk = 0; - - q_u->unk1 = 0; - q_u->ptr_buflen = 1; - q_u->buflen = value_output->buf_max_len; - - q_u->ptr_buflen2 = 1; - q_u->buflen2 = 0; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_query_value(const char *desc, REG_Q_QUERY_VALUE *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_query_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - if(!prs_unistr4("name", ps, depth, &q_u->name)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_reserved", ps, depth, &(q_u->ptr_reserved))) - return False; - - if(!prs_uint32("ptr_buf", ps, depth, &(q_u->ptr_buf))) - return False; - - if(q_u->ptr_buf) { - if(!prs_uint32("ptr_bufsize", ps, depth, &(q_u->ptr_bufsize))) - return False; - if(!prs_uint32("bufsize", ps, depth, &(q_u->bufsize))) - return False; - if(!prs_uint32("buf_unk", ps, depth, &(q_u->buf_unk))) - return False; - } - - if(!prs_uint32("unk1", ps, depth, &(q_u->unk1))) - return False; - - if(!prs_uint32("ptr_buflen", ps, depth, &(q_u->ptr_buflen))) - return False; - - if (q_u->ptr_buflen) { - if(!prs_uint32("buflen", ps, depth, &(q_u->buflen))) - return False; - if(!prs_uint32("ptr_buflen2", ps, depth, &(q_u->ptr_buflen2))) - return False; - if(!prs_uint32("buflen2", ps, depth, &(q_u->buflen2))) - return False; - } - - return True; -} - -/******************************************************************* - Inits a structure. - New version to replace older init_reg_r_query_value() -********************************************************************/ - -BOOL init_reg_r_query_value(uint32 include_keyval, REG_R_QUERY_VALUE *r_u, - REGISTRY_VALUE *val, WERROR status) -{ - uint32 buf_len = 0; - REGVAL_BUFFER buf2; - - if( !r_u || !val ) - return False; - - r_u->type = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!r_u->type) { - return False; - } - *r_u->type = val->type; - - buf_len = reg_init_regval_buffer( &buf2, val ); - - r_u->buf_max_len = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!r_u->buf_max_len) { - return False; - } - *r_u->buf_max_len = buf_len; - - r_u->buf_len = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!r_u->buf_len) { - return False; - } - *r_u->buf_len = buf_len; - - /* if include_keyval is not set, don't send the key value, just - the buflen data. probably used by NT5 to allocate buffer space - SK */ - - if ( include_keyval ) { - r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER ); - if (!r_u->value) { - return False; - } - /* steal the memory */ - *r_u->value = buf2; - } - - r_u->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_query_value(const char *desc, REG_R_QUERY_VALUE *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_query_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_pointer("type", ps, depth, (void*)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - if ( !prs_pointer("value", ps, depth, (void*)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer)) - return False; - if(!prs_align(ps)) - return False; - - if ( !prs_pointer("buf_max_len", ps, depth, (void*)&r_u->buf_max_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - if ( !prs_pointer("buf_len", ps, depth, (void*)&r_u->buf_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_u, POLICY_HND *pol, - uint32 val_idx, - uint32 max_name_len, uint32 max_buf_len) -{ - ZERO_STRUCTP(q_u); - - memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - - q_u->val_index = val_idx; - - q_u->name.size = max_name_len*2; - q_u->name.string = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR2 ); - if (!q_u->name.string) { - smb_panic("init_reg_q_enum_val: talloc fail\n"); - return; - } - q_u->name.string->uni_max_len = max_name_len; - - q_u->type = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!q_u->type) { - smb_panic("init_reg_q_enum_val: talloc fail\n"); - return; - } - *q_u->type = 0x0; - - q_u->value = TALLOC_ZERO_P( get_talloc_ctx(), REGVAL_BUFFER ); - if (!q_u->value) { - smb_panic("init_reg_q_enum_val: talloc fail\n"); - return; - } - - q_u->value->buf_max_len = max_buf_len; - - q_u->buffer_len = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!q_u->buffer_len) { - smb_panic("init_reg_q_enum_val: talloc fail\n"); - return; - } - *q_u->buffer_len = max_buf_len; - - q_u->name_len = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!q_u->name_len) { - smb_panic("init_reg_q_enum_val: talloc fail\n"); - return; - } - *q_u->name_len = 0x0; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val ) -{ - uint32 real_size; - - ZERO_STRUCTP(r_u); - - /* value name */ - - DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename)); - - init_unistr4( &r_u->name, val->valuename, UNI_STR_TERMINATE); - - /* type */ - - r_u->type = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!r_u->type) { - smb_panic("init_reg_r_enum_val: talloc fail\n"); - return; - } - *r_u->type = val->type; - - /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */ - - r_u->value = TALLOC_P( get_talloc_ctx(), REGVAL_BUFFER ); - if (!r_u->value) { - smb_panic("init_reg_r_enum_val: talloc fail\n"); - return; - } - real_size = reg_init_regval_buffer( r_u->value, val ); - - /* lengths */ - - r_u->buffer_len1 = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!r_u->buffer_len1) { - smb_panic("init_reg_r_enum_val: talloc fail\n"); - return; - } - *r_u->buffer_len1 = real_size; - r_u->buffer_len2 = TALLOC_P( get_talloc_ctx(), uint32 ); - if (!r_u->buffer_len2) { - smb_panic("init_reg_r_enum_val: talloc fail\n"); - return; - } - *r_u->buffer_len2 = real_size; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_enum_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint32("val_index", ps, depth, &q_u->val_index)) - return False; - - if(!prs_unistr4("name", ps, depth, &q_u->name )) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("type", ps, depth, (void*)&q_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - if ( !prs_pointer("value", ps, depth, (void*)&q_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("buffer_len", ps, depth, (void*)&q_u->buffer_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - if(!prs_pointer("name_len", ps, depth, (void*)&q_u->name_len, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_enum_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_unistr4("name", ps, depth, &r_u->name )) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("type", ps, depth, (void*)&r_u->type, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - if ( !prs_pointer("value", ps, depth, (void*)&r_u->value, sizeof(REGVAL_BUFFER), (PRS_POINTER_CAST)smb_io_regval_buffer)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_pointer("buffer_len1", ps, depth, (void*)&r_u->buffer_len1, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - if(!prs_pointer("buffer_len2", ps, depth, (void*)&r_u->buffer_len2, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_set_val(REG_Q_SET_VALUE *q_u, POLICY_HND *pol, - char *val_name, uint32 type, - RPC_DATA_BLOB *val) -{ - ZERO_STRUCTP(q_u); - - memcpy(&q_u->handle, pol, sizeof(q_u->handle)); - - init_unistr4(&q_u->name, val_name, UNI_STR_TERMINATE); - - q_u->type = type; - q_u->value = *val; - q_u->size = val->buf_len; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_set_value(const char *desc, REG_Q_SET_VALUE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_set_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->handle, ps, depth)) - return False; - - if(!prs_unistr4("name", ps, depth, &q_u->name )) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("type", ps, depth, &q_u->type)) - return False; - - if(!smb_io_rpc_blob("value", &q_u->value, ps, depth )) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("size", ps, depth, &q_u->size)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_set_value(const char *desc, REG_R_SET_VALUE *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_set_value"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &q_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_u, POLICY_HND *pol, uint32 key_idx) -{ - memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - - q_u->key_index = key_idx; - q_u->key_name_len = 0; - q_u->unknown_1 = 0x0414; - - q_u->ptr1 = 1; - q_u->unknown_2 = 0x0000020A; - memset(q_u->pad1, 0, sizeof(q_u->pad1)); - - q_u->ptr2 = 1; - memset(q_u->pad2, 0, sizeof(q_u->pad2)); - - q_u->ptr3 = 1; - unix_to_nt_time(&q_u->time, 0); /* current time? */ -} - -/******************************************************************* -makes a reply structure. -********************************************************************/ - -void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey ) -{ - if ( !r_u ) - return; - - init_unistr4( &r_u->keyname, subkey, UNI_STR_TERMINATE ); - r_u->classname = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 ); - if (!r_u->classname) { - smb_panic("init_reg_r_enum_key: talloc fail\n"); - return; - } - r_u->time = TALLOC_ZERO_P( get_talloc_ctx(), NTTIME ); - if (!r_u->time) { - smb_panic("init_reg_r_enum_key: talloc fail\n"); - return; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_enum_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint32("key_index", ps, depth, &q_u->key_index)) - return False; - if(!prs_uint16("key_name_len", ps, depth, &q_u->key_name_len)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1)) - return False; - - if(!prs_uint32("ptr1", ps, depth, &q_u->ptr1)) - return False; - - if (q_u->ptr1 != 0) { - if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2)) - return False; - if(!prs_uint8s(False, "pad1", ps, depth, q_u->pad1, sizeof(q_u->pad1))) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2)) - return False; - - if (q_u->ptr2 != 0) { - if(!prs_uint8s(False, "pad2", ps, depth, q_u->pad2, sizeof(q_u->pad2))) - return False; - } - - if(!prs_uint32("ptr3", ps, depth, &q_u->ptr3)) - return False; - - if (q_u->ptr3 != 0) { - if(!smb_io_time("", &q_u->time, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_enum_key"); - depth++; - - if(!prs_align(ps)) - return False; - if ( !prs_unistr4( "keyname", ps, depth, &q_u->keyname ) ) - return False; - - if(!prs_align(ps)) - return False; - if (!prs_pointer("class", ps, depth, (void*)&q_u->classname, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) - return False; - - if(!prs_align(ps)) - return False; - if (!prs_pointer("time", ps, depth, (void*)&q_u->time, sizeof(NTTIME), (PRS_POINTER_CAST)smb_io_nttime)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &q_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *q_u, POLICY_HND *pol, - char *key_name, uint32 access_desired) -{ - memcpy(&q_u->pol, pol, sizeof(q_u->pol)); - - init_unistr4(&q_u->name, key_name, UNI_STR_TERMINATE); - - q_u->unknown_0 = 0x00000000; - q_u->access = access_desired; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *q_u, prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_open_entry"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - if(!prs_unistr4("name", ps, depth, &q_u->name)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("unknown_0 ", ps, depth, &q_u->unknown_0)) - return False; - if(!prs_uint32("access", ps, depth, &q_u->access)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_u, prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_entry"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("handle", &r_u->handle, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -Inits a structure. -********************************************************************/ - -void init_reg_q_shutdown(REG_Q_SHUTDOWN *q_u, const char *msg, - uint32 timeout, BOOL do_reboot, BOOL force) -{ - q_u->server = TALLOC_P( get_talloc_ctx(), uint16 ); - if (!q_u->server) { - smb_panic("init_reg_q_shutdown: talloc fail\n"); - return; - } - *q_u->server = 0x1; - - q_u->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 ); - if (!q_u->message) { - smb_panic("init_reg_q_shutdown: talloc fail\n"); - return; - } - - if ( msg && *msg ) { - init_unistr4( q_u->message, msg, UNI_FLAGS_NONE ); - - /* Win2000 is apparently very sensitive to these lengths */ - /* do a special case here */ - - q_u->message->string->uni_max_len++; - q_u->message->size += 2; - - } - - q_u->timeout = timeout; - - q_u->reboot = do_reboot ? 1 : 0; - q_u->force = force ? 1 : 0; -} - -/******************************************************************* -Inits a REG_Q_SHUTDOWN_EX structure. -********************************************************************/ - -void init_reg_q_shutdown_ex(REG_Q_SHUTDOWN_EX * q_u_ex, const char *msg, - uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason) -{ - REG_Q_SHUTDOWN q_u; - - ZERO_STRUCT( q_u ); - - init_reg_q_shutdown( &q_u, msg, timeout, do_reboot, force ); - - /* steal memory */ - - q_u_ex->server = q_u.server; - q_u_ex->message = q_u.message; - - q_u_ex->reboot = q_u.reboot; - q_u_ex->force = q_u.force; - - q_u_ex->reason = reason; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN *q_u, prs_struct *ps, - int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_shutdown"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_pointer("server", ps, depth, (void*)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - if (!prs_align(ps)) - return False; - - if (!prs_pointer("message", ps, depth, (void*)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("timeout", ps, depth, &(q_u->timeout))) - return False; - - if (!prs_uint8("force ", ps, depth, &(q_u->force))) - return False; - if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot))) - return False; - - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN *r_u, prs_struct *ps, - int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_shutdown"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a REG_Q_SHUTDOWN_EX structure. -********************************************************************/ - -BOOL reg_io_q_shutdown_ex(const char *desc, REG_Q_SHUTDOWN_EX *q_u, prs_struct *ps, - int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_shutdown_ex"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_pointer("server", ps, depth, (void*)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - if (!prs_align(ps)) - return False; - - if (!prs_pointer("message", ps, depth, (void*)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("timeout", ps, depth, &(q_u->timeout))) - return False; - - if (!prs_uint8("force ", ps, depth, &(q_u->force))) - return False; - if (!prs_uint8("reboot ", ps, depth, &(q_u->reboot))) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("reason", ps, depth, &(q_u->reason))) - return False; - - - return True; -} - -/******************************************************************* -reads or writes a REG_R_SHUTDOWN_EX structure. -********************************************************************/ -BOOL reg_io_r_shutdown_ex(const char *desc, REG_R_SHUTDOWN_EX *r_u, prs_struct *ps, - int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_shutdown_ex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -Inits a structure. -********************************************************************/ - -void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN *q_u) -{ - q_u->server = TALLOC_P( get_talloc_ctx(), uint16 ); - if (!q_u->server) { - smb_panic("init_reg_q_abort_shutdown: talloc fail\n"); - return; - } - *q_u->server = 0x1; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN *q_u, - prs_struct *ps, int depth) -{ - if ( !q_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_pointer("server", ps, depth, (void*)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - if (!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN *r_u, - prs_struct *ps, int depth) -{ - if ( !r_u ) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} diff --git a/source3/rpc_parse/parse_shutdown.c b/source3/rpc_parse/parse_shutdown.c deleted file mode 100644 index 8c417c05dc..0000000000 --- a/source3/rpc_parse/parse_shutdown.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. - * Copyright (C) Gerald (Jerry) Carter 2002-2005. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -/******************************************************************* -Inits a structure. -********************************************************************/ - -void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg, - uint32 timeout, BOOL do_reboot, BOOL force) -{ - q_s->server = TALLOC_P( get_talloc_ctx(), uint16 ); - if (!q_s->server) { - smb_panic("init_shutdown_q_init: talloc fail.\n"); - return; - } - - *q_s->server = 0x1; - - q_s->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 ); - if (!q_s->message) { - smb_panic("init_shutdown_q_init: talloc fail.\n"); - return; - } - - if ( msg && *msg ) { - init_unistr4( q_s->message, msg, UNI_FLAGS_NONE ); - - /* Win2000 is apparently very sensitive to these lengths */ - /* do a special case here */ - - q_s->message->string->uni_max_len++; - q_s->message->size += 2; - } - - q_s->timeout = timeout; - - q_s->reboot = do_reboot ? 1 : 0; - q_s->force = force ? 1 : 0; -} - -/******************************************************************* -********************************************************************/ - -void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg, - uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason) -{ - SHUTDOWN_Q_INIT q_u; - - ZERO_STRUCT( q_u ); - - init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force ); - - /* steal memory */ - - q_u_ex->server = q_u.server; - q_u_ex->message = q_u.message; - - q_u_ex->reboot = q_u.reboot; - q_u_ex->force = q_u.force; - - q_u_ex->reason = reason; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps, - int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "shutdown_io_q_init"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_pointer("server", ps, depth, (void*)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - if (!prs_align(ps)) - return False; - - if (!prs_pointer("message", ps, depth, (void*)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) - return False; - - if (!prs_uint8("force ", ps, depth, &(q_s->force))) - return False; - if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps, - int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "shutdown_io_r_init"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_s->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a REG_Q_SHUTDOWN_EX structure. -********************************************************************/ - -BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struct *ps, - int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "shutdown_io_q_init_ex"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_pointer("server", ps, depth, (void*)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - if (!prs_align(ps)) - return False; - - if (!prs_pointer("message", ps, depth, (void*)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) - return False; - - if (!prs_uint8("force ", ps, depth, &(q_s->force))) - return False; - if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("reason", ps, depth, &(q_s->reason))) - return False; - - - return True; -} - -/******************************************************************* -reads or writes a REG_R_SHUTDOWN_EX structure. -********************************************************************/ -BOOL shutdown_io_r_init_ex(const char *desc, SHUTDOWN_R_INIT_EX * r_s, prs_struct *ps, - int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "shutdown_io_r_init_ex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_s->status)) - return False; - - return True; -} - - -/******************************************************************* -Inits a structure. -********************************************************************/ -void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s) -{ - q_s->server = TALLOC_P( get_talloc_ctx(), uint16 ); - if (!q_s->server) { - smb_panic("init_shutdown_q_abort: talloc fail.\n"); - return; - } - - *q_s->server = 0x1; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s, - prs_struct *ps, int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "shutdown_io_q_abort"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_pointer("server", ps, depth, (void*)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) - return False; - if (!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s, - prs_struct *ps, int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "shutdown_io_r_abort"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("status", ps, depth, &r_s->status)) - return False; - - return True; -} diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index a09ed3cb3c..c22ffb9878 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -4937,7 +4937,7 @@ static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid, { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - result = rpccli_shutdown_abort(pipe_hnd, mem_ctx); + result = rpccli_initshutdown_Abort(pipe_hnd, mem_ctx, NULL); if (NT_STATUS_IS_OK(result)) { d_printf("\nShutdown successfully aborted\n"); @@ -5038,6 +5038,8 @@ static NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; const char *msg = "This machine will be shutdown shortly"; uint32 timeout = 20; + struct initshutdown_String msg_string; + struct initshutdown_String_sub s; if (opt_comment) { msg = opt_comment; @@ -5046,9 +5048,12 @@ static NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid, timeout = opt_timeout; } + s.name = msg; + msg_string.name = &s; + /* create an entry */ - result = rpccli_shutdown_init(pipe_hnd, mem_ctx, msg, timeout, opt_reboot, - opt_force); + result = rpccli_initshutdown_Init(pipe_hnd, mem_ctx, NULL, + &msg_string, timeout, opt_force, opt_reboot); if (NT_STATUS_IS_OK(result)) { d_printf("\nShutdown of remote machine succeeded\n"); @@ -5083,55 +5088,37 @@ static NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid, int argc, const char **argv) { - WERROR result; const char *msg = "This machine will be shutdown shortly"; uint32 timeout = 20; -#if 0 - poptContext pc; - int rc; - - struct poptOption long_options[] = { - {"message", 'm', POPT_ARG_STRING, &msg}, - {"timeout", 't', POPT_ARG_INT, &timeout}, - {"reboot", 'r', POPT_ARG_NONE, &reboot}, - {"force", 'f', POPT_ARG_NONE, &force}, - { 0, 0, 0, 0} - }; - - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, - POPT_CONTEXT_KEEP_FIRST); + struct initshutdown_String msg_string; + struct initshutdown_String_sub s; + NTSTATUS result; - rc = poptGetNextOpt(pc); - - if (rc < -1) { - /* an error occurred during option processing */ - DEBUG(0, ("%s: %s\n", - poptBadOption(pc, POPT_BADOPTION_NOALIAS), - poptStrerror(rc))); - return NT_STATUS_INVALID_PARAMETER; - } -#endif if (opt_comment) { msg = opt_comment; } + s.name = msg; + msg_string.name = &s; + if (opt_timeout) { timeout = opt_timeout; } /* create an entry */ - result = rpccli_reg_shutdown(pipe_hnd, mem_ctx, msg, timeout, opt_reboot, opt_force); + result = rpccli_winreg_InitiateSystemShutdown(pipe_hnd, mem_ctx, NULL, + &msg_string, timeout, opt_force, opt_reboot); - if (W_ERROR_IS_OK(result)) { + if (NT_STATUS_IS_OK(result)) { d_printf("\nShutdown of remote machine succeeded\n"); } else { d_fprintf(stderr, "\nShutdown of remote machine failed\n"); - if (W_ERROR_EQUAL(result,WERR_MACHINE_LOCKED)) + if ( W_ERROR_EQUAL(ntstatus_to_werror(result),WERR_MACHINE_LOCKED) ) d_fprintf(stderr, "\nMachine locked, use -f switch to force\n"); else - d_fprintf(stderr, "\nresult was: %s\n", dos_errstr(result)); + d_fprintf(stderr, "\nresult was: %s\n", nt_errstr(result)); } - return werror_to_ntstatus(result); + return result; } /** diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 3eaff90155..36a925ae13 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -85,6 +85,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, pstring subpath; POLICY_HND pol_hive, pol_key; uint32 idx; + NTSTATUS status; + struct winreg_String subkeyname; if (argc != 1 ) { d_printf("Usage: net rpc enumerate <path> [recurse]\n"); @@ -99,16 +101,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, /* open the top level hive and then the registry key */ - result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); - if ( !W_ERROR_IS_OK(result) ) { + status = rpccli_winreg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr, "Unable to connect to remote registry: " "%s\n", dos_errstr(result)); - return werror_to_ntstatus(result); + return status; } - result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, - MAXIMUM_ALLOWED_ACCESS, &pol_key ); - if ( !W_ERROR_IS_OK(result) ) { + subkeyname.name = subpath; + status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, &pol_hive, subkeyname, + 0, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr, "Unable to open [%s]: %s\n", argv[0], dos_errstr(result)); return werror_to_ntstatus(result); @@ -116,17 +119,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, /* get the subkeys */ - result = WERR_OK; + status = NT_STATUS_OK; idx = 0; - while ( W_ERROR_IS_OK(result) ) { + while ( NT_STATUS_IS_OK(status) ) { time_t modtime; fstring keyname, classname; - result = rpccli_reg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx, + status = rpccli_winreg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx, keyname, classname, &modtime ); - if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { - result = WERR_OK; + if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { + status = NT_STATUS_OK; break; } @@ -138,14 +141,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, idx++; } - if ( !W_ERROR_IS_OK(result) ) + if ( !NT_STATUS_IS_OK(status) ) goto out; /* get the values */ - result = WERR_OK; + status = NT_STATUS_OK; idx = 0; - while ( W_ERROR_IS_OK(result) ) { + while ( NT_STATUS_IS_OK(status) ) { uint32 type; fstring name; REGVAL_BUFFER value; @@ -153,11 +156,11 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, fstrcpy( name, "" ); ZERO_STRUCT( value ); - result = rpccli_reg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx, + status = rpccli_winreg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx, name, &type, &value ); - if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) { - result = WERR_OK; + if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) { + status = NT_STATUS_OK; break; } @@ -175,10 +178,10 @@ out: /* cleanup */ if ( strlen( subpath ) != 0 ) - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); - return werror_to_ntstatus(result); + return status; } /******************************************************************** @@ -205,6 +208,8 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, uint32 hive; pstring subpath; POLICY_HND pol_hive, pol_key; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + struct winreg_String subkeyname; if (argc != 2 ) { d_printf("Usage: net rpc backup <path> <file> \n"); @@ -218,30 +223,39 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, /* open the top level hive and then the registry key */ - result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); - if ( !W_ERROR_IS_OK(result) ) { + status = rpccli_winreg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); + if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr, "Unable to connect to remote registry\n"); - return werror_to_ntstatus(result); + return status; } - result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); - if ( !W_ERROR_IS_OK(result) ) { + subkeyname.name = subpath; + status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, &pol_hive, subkeyname, + 0, MAXIMUM_ALLOWED_ACCESS, &pol_key ); + if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr, "Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); } - result = rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); +#if 0 /* IDL not implemented */ + /* original call was: rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); */ + + status = rpccli_winreg_SaveKey( cli, mem_ctx ); if ( !W_ERROR_IS_OK(result) ) { d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } +#else + d_printf("Call not implemented.\n"); + status = NT_STATUS_NOT_IMPLEMENTED; +#endif /* cleanup */ - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key ); - rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key ); + rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive ); - return werror_to_ntstatus(result); + return status; } /******************************************************************** |