diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 10 | ||||
-rw-r--r-- | source3/configure.in | 5 | ||||
-rw-r--r-- | source3/include/rpc_client.h | 1 | ||||
-rw-r--r-- | source3/include/rpc_reg.h | 4 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_winreg.c | 166 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/winreg.h | 4 | ||||
-rw-r--r-- | source3/librpc/idl/winreg.idl | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_initshutdown_nt.c | 63 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_reg.c | 659 | ||||
-rw-r--r-- | source3/rpc_server/srv_winreg_nt.c (renamed from source3/rpc_server/srv_reg_nt.c) | 444 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 1 |
12 files changed, 486 insertions, 875 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 0044c1d13d..1443cb97dc 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -320,7 +320,8 @@ RPC_SAMR_OBJ = rpc_server/srv_samr.o rpc_server/srv_samr_nt.o \ RPC_UNIXINFO_OBJ = librpc/gen_ndr/srv_unixinfo.o rpc_server/srv_unixinfo_nt.o REGFIO_OBJ = registry/regfio.o -RPC_REG_OBJ = rpc_server/srv_reg.o rpc_server/srv_reg_nt.o $(REGFIO_OBJ) +RPC_REG_OBJ = librpc/gen_ndr/srv_winreg.o rpc_server/srv_winreg_nt.o $(REGFIO_OBJ) +RPC_INITSHUTDOWN_OBJ = librpc/gen_ndr/srv_initshutdown.o rpc_server/srv_initshutdown_nt.o RPC_LSA_DS_OBJ = rpc_server/srv_lsa_ds.o rpc_server/srv_lsa_ds_nt.o @@ -718,7 +719,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \ $(RPC_SVC_OBJ) $(RPC_WKS_OBJ) $(RPC_DFS_OBJ) $(RPC_SPOOLSS_OBJ) \ $(RPC_ECHO_OBJ) $(RPC_SVCCTL_OBJ) $(RPC_EVENTLOG_OBJ) $(SMBLDAP_OBJ) \ $(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) $(RPC_UNIXINFO_OBJ) \ - $(RPC_NTSVCS_OBJ) utils/passwd_util.o + $(RPC_NTSVCS_OBJ) $(RPC_INITSHUTDOWN_OBJ) utils/passwd_util.o WINBIND_WINS_NSS_OBJ = nsswitch/wins.o $(PARAM_OBJ) \ $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) $(NSSWINS_OBJ) $(KRBCLIENT_OBJ) $(SECRETS_OBJ) @@ -1237,6 +1238,11 @@ bin/librpc_winreg.@SHLIBEXT@: $(RPC_REG_OBJ) @$(SHLD) $(LDSHFLAGS) -o $@ $(RPC_REG_OBJ) -lc \ @SONAMEFLAG@`basename $@` +bin/librpc_initshutdown.@SHLIBEXT@: $(RPC_INITSHUTDOWN_OBJ) + @echo "Linking $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(RPC_INITSHUTDOWN_OBJ) -lc \ + @SONAMEFLAG@`basename $@` + bin/librpc_lsa_ds.@SHLIBEXT@: $(RPC_LSA_DS_OBJ) @echo "Linking $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(RPC_LSA_DS_OBJ) -lc \ diff --git a/source3/configure.in b/source3/configure.in index a0e19c1e17..54063d5fac 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -579,7 +579,7 @@ DYNEXP= dnl Add modules that have to be built by default here dnl These have to be built static: -default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default" +default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default" dnl These are preferably build shared, and static if dlopen() is not available default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script" @@ -5616,7 +5616,8 @@ SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o) SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC) -SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC) +SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC) +SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC) SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC) SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC) SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC) diff --git a/source3/include/rpc_client.h b/source3/include/rpc_client.h index 78efc7c2fc..ee66682df1 100644 --- a/source3/include/rpc_client.h +++ b/source3/include/rpc_client.h @@ -28,6 +28,7 @@ #include "librpc/gen_ndr/cli_dfs.h" #include "librpc/gen_ndr/cli_lsa.h" #include "librpc/gen_ndr/cli_winreg.h" +#include "librpc/gen_ndr/cli_initshutdown.h" #include "librpc/gen_ndr/cli_wkssvc.h" /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */ diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h index 883e2a8146..fe29799d27 100644 --- a/source3/include/rpc_reg.h +++ b/source3/include/rpc_reg.h @@ -61,9 +61,13 @@ #define KEY_HKLM "HKLM" #define KEY_HKU "HKU" +#define KEY_HKCC "HKCC" #define KEY_HKCR "HKCR" #define KEY_HKPD "HKPD" #define KEY_HKPT "HKPT" +#define KEY_HKPN "HKPN" +#define KEY_HKCU "HKCU" +#define KEY_HKDD "HKDD" #define KEY_SERVICES "HKLM\\SYSTEM\\CurrentControlSet\\Services" #define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print" #define KEY_PRINTING_2K "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers" diff --git a/source3/librpc/gen_ndr/ndr_winreg.c b/source3/librpc/gen_ndr/ndr_winreg.c index c85aa57f02..5dd8fc49be 100644 --- a/source3/librpc/gen_ndr/ndr_winreg.c +++ b/source3/librpc/gen_ndr/ndr_winreg.c @@ -2281,13 +2281,14 @@ NTSTATUS ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struc if (r->in.type) { NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->in.type)); } - if (r->in.data == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.size)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.length)); - for (cntr_data_1 = 0; cntr_data_1 < *r->in.length; cntr_data_1++) { - if (r->in.data[cntr_data_1] == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_push_ref_ptr(ndr)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.data)); + if (r->in.data) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.size)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.length)); + for (cntr_data_1 = 0; cntr_data_1 < *r->in.length; cntr_data_1++) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.data[cntr_data_1])); + } } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.size)); if (r->in.size) { @@ -2303,13 +2304,14 @@ NTSTATUS ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struc if (r->out.type) { NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->out.type)); } - if (r->out.data == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.size)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); - for (cntr_data_1 = 0; cntr_data_1 < *r->out.length; cntr_data_1++) { - if (r->out.data[cntr_data_1] == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_push_ref_ptr(ndr)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.data)); + if (r->out.data) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.size)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); + for (cntr_data_1 = 0; cntr_data_1 < *r->out.length; cntr_data_1++) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.data[cntr_data_1])); + } } NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.size)); if (r->out.size) { @@ -2333,6 +2335,7 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr uint32_t _ptr_length; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_type_0; + TALLOC_CTX *_mem_save_data_0; TALLOC_CTX *_mem_save_data_1; TALLOC_CTX *_mem_save_data_2; TALLOC_CTX *_mem_save_size_0; @@ -2360,24 +2363,34 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, r->in.type)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_type_0, 0); } - NDR_CHECK(ndr_pull_array_size(ndr, &r->in.data)); - NDR_CHECK(ndr_pull_array_length(ndr, &r->in.data)); - if (ndr_get_array_length(ndr, &r->in.data) > ndr_get_array_size(ndr, &r->in.data)) { - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.data), ndr_get_array_length(ndr, &r->in.data)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->in.data); + } else { + r->in.data = NULL; } - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + if (r->in.data) { + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.data, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.data)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.data)); + if (ndr_get_array_length(ndr, &r->in.data) > ndr_get_array_size(ndr, &r->in.data)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.data), ndr_get_array_length(ndr, &r->in.data)); + } NDR_PULL_ALLOC_N(ndr, r->in.data, ndr_get_array_size(ndr, &r->in.data)); - } - memcpy(r->out.data,r->in.data,ndr_get_array_size(ndr, &r->in.data) * sizeof(*r->in.data)); - _mem_save_data_1 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.data, 0); - for (cntr_data_1 = 0; cntr_data_1 < *r->in.length; cntr_data_1++) { - NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_data)); - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->in.data[cntr_data_1]); + _mem_save_data_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.data, 0); + for (cntr_data_1 = 0; cntr_data_1 < *r->in.length; cntr_data_1++) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->in.data[cntr_data_1]); + } else { + r->in.data[cntr_data_1] = NULL; + } } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_1, 0); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_size)); if (_ptr_size) { NDR_PULL_ALLOC(ndr, r->in.size); @@ -2402,9 +2415,6 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.length)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, 0); } - if (r->in.size == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_PULL_ALLOC_N(ndr, r->out.data, *r->in.size); - memcpy(r->out.data, r->in.data, *r->in.size * sizeof(*r->in.data)); if (r->in.data) { if (r->in.size == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.data, *r->in.size)); @@ -2427,24 +2437,34 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, r->out.type)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_type_0, 0); } - NDR_CHECK(ndr_pull_array_size(ndr, &r->out.data)); - NDR_CHECK(ndr_pull_array_length(ndr, &r->out.data)); - if (ndr_get_array_length(ndr, &r->out.data) > ndr_get_array_size(ndr, &r->out.data)) { - return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->out.data), ndr_get_array_length(ndr, &r->out.data)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->out.data); + } else { + r->out.data = NULL; } - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + if (r->out.data) { + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.data, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->out.data)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->out.data)); + if (ndr_get_array_length(ndr, &r->out.data) > ndr_get_array_size(ndr, &r->out.data)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->out.data), ndr_get_array_length(ndr, &r->out.data)); + } NDR_PULL_ALLOC_N(ndr, r->out.data, ndr_get_array_size(ndr, &r->out.data)); - } - memcpy(r->out.data,r->in.data,ndr_get_array_size(ndr, &r->out.data) * sizeof(*r->in.data)); - _mem_save_data_1 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.data, 0); - for (cntr_data_1 = 0; cntr_data_1 < *r->out.length; cntr_data_1++) { - NDR_CHECK(ndr_pull_ref_ptr(ndr, &_ptr_data)); - if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { - NDR_PULL_ALLOC(ndr, r->out.data[cntr_data_1]); + _mem_save_data_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.data, 0); + for (cntr_data_1 = 0; cntr_data_1 < *r->out.length; cntr_data_1++) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->out.data[cntr_data_1]); + } else { + r->out.data[cntr_data_1] = NULL; + } } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_1, 0); NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_size)); if (_ptr_size) { NDR_PULL_ALLOC(ndr, r->out.size); @@ -2506,21 +2526,25 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr->depth--; ndr_print_ptr(ndr, "data", r->in.data); ndr->depth++; - ndr->print(ndr, "%s: ARRAY(%d)", "data", *r->in.length); - ndr->depth++; - for (cntr_data_1=0;cntr_data_1<*r->in.length;cntr_data_1++) { - char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_data_1); - if (idx_1) { - ndr_print_ptr(ndr, "data", r->in.data[cntr_data_1]); - ndr->depth++; - ndr_print_uint8(ndr, "data", *r->in.data[cntr_data_1]); - ndr->depth--; - free(idx_1); + if (r->in.data) { + ndr->print(ndr, "%s: ARRAY(%d)", "data", *r->in.length); + ndr->depth++; + for (cntr_data_1=0;cntr_data_1<*r->in.length;cntr_data_1++) { + char *idx_1=NULL; + asprintf(&idx_1, "[%d]", cntr_data_1); + if (idx_1) { + ndr_print_ptr(ndr, "data", r->in.data[cntr_data_1]); + ndr->depth++; + if (r->in.data[cntr_data_1]) { + ndr_print_uint8(ndr, "data", *r->in.data[cntr_data_1]); + } + ndr->depth--; + free(idx_1); + } } + ndr->depth--; } ndr->depth--; - ndr->depth--; ndr_print_ptr(ndr, "size", r->in.size); ndr->depth++; if (r->in.size) { @@ -2546,21 +2570,25 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr->depth--; ndr_print_ptr(ndr, "data", r->out.data); ndr->depth++; - ndr->print(ndr, "%s: ARRAY(%d)", "data", *r->out.length); - ndr->depth++; - for (cntr_data_1=0;cntr_data_1<*r->out.length;cntr_data_1++) { - char *idx_1=NULL; - asprintf(&idx_1, "[%d]", cntr_data_1); - if (idx_1) { - ndr_print_ptr(ndr, "data", r->out.data[cntr_data_1]); - ndr->depth++; - ndr_print_uint8(ndr, "data", *r->out.data[cntr_data_1]); - ndr->depth--; - free(idx_1); + if (r->out.data) { + ndr->print(ndr, "%s: ARRAY(%d)", "data", *r->out.length); + ndr->depth++; + for (cntr_data_1=0;cntr_data_1<*r->out.length;cntr_data_1++) { + char *idx_1=NULL; + asprintf(&idx_1, "[%d]", cntr_data_1); + if (idx_1) { + ndr_print_ptr(ndr, "data", r->out.data[cntr_data_1]); + ndr->depth++; + if (r->out.data[cntr_data_1]) { + ndr_print_uint8(ndr, "data", *r->out.data[cntr_data_1]); + } + ndr->depth--; + free(idx_1); + } } + ndr->depth--; } ndr->depth--; - ndr->depth--; ndr_print_ptr(ndr, "size", r->out.size); ndr->depth++; if (r->out.size) { diff --git a/source3/librpc/gen_ndr/winreg.h b/source3/librpc/gen_ndr/winreg.h index a170dcd3c4..ff16c37f9c 100644 --- a/source3/librpc/gen_ndr/winreg.h +++ b/source3/librpc/gen_ndr/winreg.h @@ -334,14 +334,14 @@ struct winreg_QueryValue { struct policy_handle *handle;/* [ref] */ struct winreg_String value_name; enum winreg_Type *type;/* [unique] */ - uint8_t **data;/* [ref,length_is(*length),size_is(*size)] */ + uint8_t **data;/* [unique,length_is(*length),size_is(*size)] */ uint32_t *size;/* [unique] */ uint32_t *length;/* [unique] */ } in; struct { enum winreg_Type *type;/* [unique] */ - uint8_t **data;/* [ref,length_is(*length),size_is(*size)] */ + uint8_t **data;/* [unique,length_is(*length),size_is(*size)] */ uint32_t *size;/* [unique] */ uint32_t *length;/* [unique] */ WERROR result; diff --git a/source3/librpc/idl/winreg.idl b/source3/librpc/idl/winreg.idl index 9c758b7c9d..3ddd71ad47 100644 --- a/source3/librpc/idl/winreg.idl +++ b/source3/librpc/idl/winreg.idl @@ -226,7 +226,7 @@ [in,ref] policy_handle *handle, [in] winreg_String value_name, [in,out] winreg_Type *type, - [in,out,ref,size_is(*size),length_is(*length)] uint8 **data, + [in,out,size_is(*size),length_is(*length)] uint8 **data, [in,out] uint32 *size, [in,out] uint32 *length ); diff --git a/source3/rpc_server/srv_initshutdown_nt.c b/source3/rpc_server/srv_initshutdown_nt.c new file mode 100644 index 0000000000..a73077fe03 --- /dev/null +++ b/source3/rpc_server/srv_initshutdown_nt.c @@ -0,0 +1,63 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Gerald Carter 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 + * 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. + */ + +/* Implementation of registry functions. */ + +#include "includes.h" +#include "regfio.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + + +/******************************************************************* + ********************************************************************/ +WERROR _initshutdown_Init(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot) +{ + uint32_t reason = 0; + + /* thunk down to _winreg_InitiateSystemShutdownEx() + (just returns a status) */ + + return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, + force_apps, reboot, reason ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _initshutdown_InitEx(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot, uint32_t reason) +{ + return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, + force_apps, reboot, reason ); +} + + + + +/******************************************************************* + reg_abort_shutdwon + ********************************************************************/ + +WERROR _initshutdown_Abort(pipes_struct *p, uint16_t *server) +{ + return _winreg_AbortSystemShutdown( p, server ); +} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5abf1c293a..b60ee37f40 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2364,7 +2364,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) wkssvc_get_pipe_fns( &cmds, &n_cmds ); break; case PI_WINREG: - reg_get_pipe_fns( &cmds, &n_cmds ); + winreg_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SPOOLSS: spoolss_get_pipe_fns( &cmds, &n_cmds ); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c deleted file mode 100644 index 1772524038..0000000000 --- a/source3/rpc_server/srv_reg.c +++ /dev/null @@ -1,659 +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 2000, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Gerald Carter 2002, - * 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. - */ - -/* This is the interface for the registry functions. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - api_reg_close - ********************************************************************/ - -static BOOL api_reg_close(pipes_struct *p) -{ - REG_Q_CLOSE q_u; - REG_R_CLOSE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg unknown 1 */ - if(!reg_io_q_close("", &q_u, data, 0)) - return False; - - r_u.status = _reg_close(p, &q_u, &r_u); - - if(!reg_io_r_close("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_khlm - ********************************************************************/ - -static BOOL api_reg_open_hklm(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hklm(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_khu - ********************************************************************/ - -static BOOL api_reg_open_hku(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hku(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_khcr - ********************************************************************/ - -static BOOL api_reg_open_hkcr(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hkcr(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - api_reg_open_entry - ********************************************************************/ - -static BOOL api_reg_open_entry(pipes_struct *p) -{ - REG_Q_OPEN_ENTRY q_u; - REG_R_OPEN_ENTRY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open entry */ - if(!reg_io_q_open_entry("", &q_u, data, 0)) - return False; - - /* construct reply. */ - r_u.status = _reg_open_entry(p, &q_u, &r_u); - - if(!reg_io_r_open_entry("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_query_value - ********************************************************************/ - -static BOOL api_reg_query_value(pipes_struct *p) -{ - REG_Q_QUERY_VALUE q_u; - REG_R_QUERY_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg unknown 0x11*/ - if(!reg_io_q_query_value("", &q_u, data, 0)) - return False; - - r_u.status = _reg_query_value(p, &q_u, &r_u); - - if(!reg_io_r_query_value("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_shutdown - ********************************************************************/ - -static BOOL api_reg_shutdown(pipes_struct *p) -{ - REG_Q_SHUTDOWN q_u; - REG_R_SHUTDOWN r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg shutdown */ - if(!reg_io_q_shutdown("", &q_u, data, 0)) - return False; - - r_u.status = _reg_shutdown(p, &q_u, &r_u); - - if(!reg_io_r_shutdown("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_shutdown_ex - ********************************************************************/ - -static BOOL api_reg_shutdown_ex(pipes_struct *p) -{ - REG_Q_SHUTDOWN_EX q_u; - REG_R_SHUTDOWN_EX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg shutdown ex */ - if(!reg_io_q_shutdown_ex("", &q_u, data, 0)) - return False; - - r_u.status = _reg_shutdown_ex(p, &q_u, &r_u); - - if(!reg_io_r_shutdown_ex("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_abort_shutdown - ********************************************************************/ - -static BOOL api_reg_abort_shutdown(pipes_struct *p) -{ - REG_Q_ABORT_SHUTDOWN q_u; - REG_R_ABORT_SHUTDOWN r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg shutdown */ - if(!reg_io_q_abort_shutdown("", &q_u, data, 0)) - return False; - - r_u.status = _reg_abort_shutdown(p, &q_u, &r_u); - - if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - api_reg_query_key - ********************************************************************/ - -static BOOL api_reg_query_key(pipes_struct *p) -{ - REG_Q_QUERY_KEY q_u; - REG_R_QUERY_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_query_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_query_key(p, &q_u, &r_u); - - if(!reg_io_r_query_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_getversion - ********************************************************************/ - -static BOOL api_reg_getversion(pipes_struct *p) -{ - REG_Q_GETVERSION q_u; - REG_R_GETVERSION r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_getversion("", &q_u, data, 0)) - return False; - - r_u.status = _reg_getversion(p, &q_u, &r_u); - - if(!reg_io_r_getversion("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_enum_key - ********************************************************************/ - -static BOOL api_reg_enum_key(pipes_struct *p) -{ - REG_Q_ENUM_KEY q_u; - REG_R_ENUM_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_enum_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_enum_key(p, &q_u, &r_u); - - if(!reg_io_r_enum_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_enum_value - ********************************************************************/ - -static BOOL api_reg_enum_value(pipes_struct *p) -{ - REG_Q_ENUM_VALUE q_u; - REG_R_ENUM_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_enum_val("", &q_u, data, 0)) - return False; - - r_u.status = _reg_enum_value(p, &q_u, &r_u); - - if(!reg_io_r_enum_val("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_restore_key(pipes_struct *p) -{ - REG_Q_RESTORE_KEY q_u; - REG_R_RESTORE_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_restore_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_restore_key(p, &q_u, &r_u); - - if(!reg_io_r_restore_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ********************************************************************/ - -static BOOL api_reg_save_key(pipes_struct *p) -{ - REG_Q_SAVE_KEY q_u; - REG_R_SAVE_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_save_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_save_key(p, &q_u, &r_u); - - if(!reg_io_r_save_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_hkpd - ********************************************************************/ - -static BOOL api_reg_open_hkpd(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hkpd(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_hkpd - ********************************************************************/ -static BOOL api_reg_open_hkpt(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hkpt(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_create_key_ex(pipes_struct *p) -{ - REG_Q_CREATE_KEY_EX q_u; - REG_R_CREATE_KEY_EX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_create_key_ex("", &q_u, data, 0)) - return False; - - r_u.status = _reg_create_key_ex(p, &q_u, &r_u); - - if(!reg_io_r_create_key_ex("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_set_value(pipes_struct *p) -{ - REG_Q_SET_VALUE q_u; - REG_R_SET_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_set_value("", &q_u, data, 0)) - return False; - - r_u.status = _reg_set_value(p, &q_u, &r_u); - - if(!reg_io_r_set_value("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_delete_key(pipes_struct *p) -{ - REG_Q_DELETE_KEY q_u; - REG_R_DELETE_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_delete_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_delete_key(p, &q_u, &r_u); - - if(!reg_io_r_delete_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_delete_value(pipes_struct *p) -{ - REG_Q_DELETE_VALUE q_u; - REG_R_DELETE_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_delete_value("", &q_u, data, 0)) - return False; - - r_u.status = _reg_delete_value(p, &q_u, &r_u); - - if(!reg_io_r_delete_value("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_get_key_sec(pipes_struct *p) -{ - REG_Q_GET_KEY_SEC q_u; - REG_R_GET_KEY_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_get_key_sec("", &q_u, data, 0)) - return False; - - r_u.status = _reg_get_key_sec(p, &q_u, &r_u); - - if(!reg_io_r_get_key_sec("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_set_key_sec(pipes_struct *p) -{ - REG_Q_SET_KEY_SEC q_u; - REG_R_SET_KEY_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_set_key_sec("", &q_u, data, 0)) - return False; - - r_u.status = _reg_set_key_sec(p, &q_u, &r_u); - - if(!reg_io_r_set_key_sec("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - array of \PIPE\reg operations - ********************************************************************/ - -static struct api_struct api_reg_cmds[] = -{ - { "REG_CLOSE" , REG_CLOSE , api_reg_close }, - { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, - { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, - { "REG_OPEN_HKPD" , REG_OPEN_HKPD , api_reg_open_hkpd }, - { "REG_OPEN_HKPT" , REG_OPEN_HKPT , api_reg_open_hkpt }, - { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, - { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, - { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, - { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, - { "REG_QUERY_VALUE" , REG_QUERY_VALUE , api_reg_query_value }, - { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, - { "REG_SHUTDOWN_EX" , REG_SHUTDOWN_EX , api_reg_shutdown_ex }, - { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, - { "REG_GETVERSION" , REG_GETVERSION , api_reg_getversion }, - { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, - { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key }, - { "REG_CREATE_KEY_EX" , REG_CREATE_KEY_EX , api_reg_create_key_ex }, - { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value }, - { "REG_DELETE_KEY" , REG_DELETE_KEY , api_reg_delete_key }, - { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value }, - { "REG_GET_KEY_SEC" , REG_GET_KEY_SEC , api_reg_get_key_sec }, - { "REG_SET_KEY_SEC" , REG_SET_KEY_SEC , api_reg_set_key_sec } -}; - -void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_reg_cmds; - *n_fns = sizeof(api_reg_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_reg_init(void) -{ - - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_reg_cmds, - sizeof(api_reg_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 3728252c99..aea848fd17 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -2,8 +2,6 @@ * 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) Jeremy Allison 2001. * Copyright (C) Gerald Carter 2002-2005. * @@ -30,9 +28,10 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#if 0 /* temporaily disabled */ static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; - +#endif /****************************************************************** free() function for REGISTRY_KEY @@ -207,11 +206,11 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, reg_close ********************************************************************/ -WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) +WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) { /* close the policy handle */ - if (!close_registry_key(p, &q_u->pol)) + if (!close_registry_key(p, handle)) return WERR_BADFID; return WERR_OK; @@ -220,68 +219,110 @@ WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) /******************************************************************* ********************************************************************/ -WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +WERROR _winreg_OpenHKLM(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { REGISTRY_KEY *keyinfo; - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKLM, q_u->access ); + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKLM, access_mask ); } /******************************************************************* ********************************************************************/ -WERROR _reg_open_hkpd(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { REGISTRY_KEY *keyinfo; - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKPD, q_u->access ); + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPD, access_mask ); } /******************************************************************* ********************************************************************/ -WERROR _reg_open_hkpt(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { REGISTRY_KEY *keyinfo; - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKPT, q_u->access ); + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPT, access_mask ); } /******************************************************************* ********************************************************************/ -WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { REGISTRY_KEY *keyinfo; - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKCR, q_u->access ); + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCR, access_mask ); } /******************************************************************* ********************************************************************/ -WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { REGISTRY_KEY *keyinfo; - - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKU, q_u->access ); + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKU, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCU, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCC, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKDD, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPN, access_mask ); } /******************************************************************* reg_reply_open_entry ********************************************************************/ -WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) +WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, struct winreg_String keyname, uint32_t unknown, uint32_t access_mask, struct policy_handle *handle) { - fstring name; - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->pol); + char *name; + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, parent_handle ); REGISTRY_KEY *newkey = NULL; uint32 check_rights; if ( !parent ) return WERR_BADFID; - rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); + if ( (name = talloc_strdup( p->mem_ctx, keyname.name )) == NULL ) { + return WERR_INVALID_PARAM; + } /* check granted access first; what is the correct mask here? */ @@ -302,29 +343,34 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY * not do this stupidity. --jerry */ - return open_registry_key( p, &r_u->handle, &newkey, parent, name, q_u->access ); + return open_registry_key( p, handle, &newkey, parent, name, access_mask ); } /******************************************************************* reg_reply_info ********************************************************************/ -WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VALUE *r_u) +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t **data, uint32_t *size, uint32_t *length) { WERROR status = WERR_BADFILE; - fstring name; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + char *name; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); REGISTRY_VALUE *val = NULL; REGVAL_CTR *regvals; int i; if ( !regkey ) return WERR_BADFID; + + *size = *length = *type = 0; + value_name.name = NULL; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); - rpcstr_pull(name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0); + if ( (name = talloc_strdup( p->mem_ctx, value_name.name )) == NULL ) { + return WERR_NOMEM; + } DEBUG(5,("_reg_info: looking up value: [%s]\n", name)); @@ -338,8 +384,8 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL { uint32 outbuf_len; prs_struct prs_hkpd; - prs_init(&prs_hkpd, q_u->bufsize, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, q_u->bufsize, &outbuf_len, NULL); + prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, NULL); regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, prs_hkpd.data_p, outbuf_len); val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); @@ -390,8 +436,8 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL /* we probably have a request for a specific object here */ uint32 outbuf_len; prs_struct prs_hkpd; - prs_init(&prs_hkpd, q_u->bufsize, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, q_u->bufsize, &outbuf_len, name); + prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, name); regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, prs_hkpd.data_p, outbuf_len); @@ -420,8 +466,17 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL } } - init_reg_r_query_value(q_u->ptr_buf, r_u, val, status); - + if ( val ) { + *size = regval_size( val ); + *length = regval_size( val ); + + if ( (*data = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { + status = WERR_NOMEM; + } + + *type = val->type; + } + TALLOC_FREE( regvals ); free_registry_value( val ); @@ -431,32 +486,37 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL /***************************************************************************** Implementation of REG_QUERY_KEY ****************************************************************************/ - -WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) + +WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, + struct winreg_String class_in, + struct winreg_String *class_out, uint32_t *num_subkeys, + uint32_t *max_subkeylen, uint32_t *max_subkeysize, + uint32_t *num_values, uint32_t *max_valnamelen, + uint32_t *max_valbufsize, uint32_t *secdescsize, + NTTIME *last_changed_time) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); if ( !regkey ) return WERR_BADFID; - if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) { + if ( !get_subkey_information( regkey, num_subkeys, max_subkeylen) ) { DEBUG(0,("_reg_query_key: get_subkey_information() failed!\n")); return WERR_ACCESS_DENIED; } - if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) { + if ( !get_value_information( regkey, num_values, max_valnamelen, max_valbufsize) ) { DEBUG(0,("_reg_query_key: get_value_information() failed!\n")); return WERR_ACCESS_DENIED; } - - r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ + *secdescsize = 0x00000078; /* size for key's sec_desc */ /* Win9x set this to 0x0 since it does not keep timestamps. Doing the same here for simplicity --jerry */ - ZERO_STRUCT(r_u->mod_time); + *last_changed_time = 0; return status; } @@ -466,17 +526,16 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_ Implementation of REG_GETVERSION ****************************************************************************/ -WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION *r_u) +WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_t *version) { - WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); if ( !regkey ) return WERR_BADFID; - r_u->win_version = 0x00000005; /* Windows 2000 registry API version */ + *version = 0x00000005; /* Windows 2000 registry API version */ - return status; + return WERR_OK; } @@ -484,30 +543,34 @@ WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION Implementation of REG_ENUM_KEY ****************************************************************************/ -WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) +WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); char *subkey = NULL; if ( !regkey ) return WERR_BADFID; + if ( !name || !keyclass || !last_changed_time ) + return WERR_INVALID_PARAM; + DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - if ( !fetch_reg_keys_specific( regkey, &subkey, q_u->key_index ) ) - { + if ( !fetch_reg_keys_specific( regkey, &subkey, enum_index ) ) { status = WERR_NO_MORE_ITEMS; goto done; } DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); - /* subkey has the string name now */ - - init_reg_r_enum_key( r_u, subkey ); - + *last_changed_time = 0; + keyclass->name = NULL; + if ( (name->name = talloc_strdup( p->mem_ctx, subkey )) == NULL ) { + status = WERR_NOMEM; + } + done: SAFE_FREE( subkey ); return status; @@ -516,45 +579,42 @@ done: /***************************************************************************** Implementation of REG_ENUM_VALUE ****************************************************************************/ - -WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u) + +WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, enum winreg_Type *type, uint8_t *value, uint32_t *size, uint32_t *length) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); REGISTRY_VALUE *val; - if ( !regkey ) return WERR_BADFID; + if ( !name || !type || !value || !size || !length ) + return WERR_INVALID_PARAM; + DEBUG(8,("_reg_enum_value: enumerating values for key [%s]\n", regkey->name)); - if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) { + if ( !fetch_reg_values_specific( regkey, &val, enum_index ) ) { status = WERR_NO_MORE_ITEMS; goto done; } -#if 0 /* JERRY TEST CODE */ - if ( val->type == REG_MULTI_SZ ) { - char **str; - int num_strings = regval_convert_multi_sz( (uint16*)regval_data_p(val), regval_size(val), &str ); - uint16 *buffer; - size_t buf_size; - - - if ( num_strings ) - buf_size = regval_build_multi_sz( str, &buffer ); - - TALLOC_FREE( str ); - TALLOC_FREE( buffer ); - } -#endif - DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); /* subkey has the string name now */ - init_reg_r_enum_val( r_u, val ); + if ( (name->name = talloc_strdup( p->mem_ctx, val->valuename )) == NULL ) { + status = WERR_NOMEM; + } + + *size = regval_size( val ); + *length = regval_size( val ); + + if ( (value = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { + status = WERR_NOMEM; + } + + *type = val->type; done: free_registry_value( val ); @@ -567,23 +627,15 @@ done: reg_shutdwon ********************************************************************/ -WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) +WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot) { - REG_Q_SHUTDOWN_EX q_u_ex; - REG_R_SHUTDOWN_EX r_u_ex; - - /* copy fields (including stealing memory) */ - - q_u_ex.server = q_u->server; - q_u_ex.message = q_u->message; - q_u_ex.timeout = q_u->timeout; - q_u_ex.force = q_u->force; - q_u_ex.reboot = q_u->reboot; - q_u_ex.reason = 0x0; /* don't care for now */ - - /* thunk down to _reg_shutdown_ex() (just returns a status) */ + uint32_t reason = 0; + + /* thunk down to _winreg_InitiateSystemShutdownEx() + (just returns a status) */ - return _reg_shutdown_ex( p, &q_u_ex, &r_u_ex ); + return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, + force_apps, reboot, reason ); } /******************************************************************* @@ -594,13 +646,13 @@ WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) #define SHUTDOWN_F_STRING "-f" -WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_EX *r_u) +WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot, uint32_t reason) { pstring shutdown_script; - pstring message; + char *msg = NULL; pstring chkmsg; - fstring timeout; - fstring reason; + fstring str_timeout; + fstring str_reason; fstring r; fstring f; int ret; @@ -614,24 +666,23 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ /* pull the message string and perform necessary sanity checks on it */ - pstrcpy( message, "" ); - if ( q_u->message ) { - UNISTR2 *msg_string = q_u->message->string; - - rpcstr_pull( message, msg_string->buffer, sizeof(message), msg_string->uni_str_len*2, 0 ); - } - alpha_strcpy (chkmsg, message, NULL, sizeof(message)); + if ( message && message->name && message->name->name ) { + if ( (msg = talloc_strdup(p->mem_ctx, message->name->name )) == NULL ) { + return WERR_NOMEM; + } + } + alpha_strcpy (chkmsg, msg?msg:"", NULL, strlen(msg)); - fstr_sprintf(timeout, "%d", q_u->timeout); - fstr_sprintf(r, (q_u->reboot) ? SHUTDOWN_R_STRING : ""); - fstr_sprintf(f, (q_u->force) ? SHUTDOWN_F_STRING : ""); - fstr_sprintf( reason, "%d", q_u->reason ); + fstr_sprintf(str_timeout, "%d", timeout); + fstr_sprintf(r, reboot ? SHUTDOWN_R_STRING : ""); + fstr_sprintf(f, force_apps ? SHUTDOWN_F_STRING : ""); + fstr_sprintf(str_reason, "%d", reason ); all_string_sub( shutdown_script, "%z", chkmsg, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%t", timeout, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%t", str_timeout, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%r", r, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%x", reason, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%x", str_reason, sizeof(shutdown_script) ); can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); @@ -664,7 +715,7 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ reg_abort_shutdwon ********************************************************************/ -WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) +WERROR _winreg_AbortSystemShutdown(pipes_struct *p, uint16_t *server) { pstring abort_shutdown_script; int ret; @@ -696,6 +747,9 @@ WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABO return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } +#if 0 /* This code works but is disabled for now until I + fix the WinReg IDL file -- jerry */ + /******************************************************************* ********************************************************************/ @@ -824,7 +878,7 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) /* open the registry file....fail if the file already exists */ if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { - DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", + DEBUG(0,("restore_registry_key: failed to open \"%s\" (%s)\n", fname, strerror(errno) )); return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); } @@ -846,11 +900,14 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) return result; } +#endif + /******************************************************************* ********************************************************************/ -WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_KEY *r_u) +WERROR _winreg_RestoreKey(pipes_struct *p) { +#if 0 /* temporarily disabled */ REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); pstring filename; int snum; @@ -873,8 +930,14 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_ DEBUG(2,("_reg_restore_key: Restoring [%s] from %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); return restore_registry_key( regkey, filename ); +#endif + + return WERR_NOT_SUPPORTED; } +#if 0 /* this code works but has been disable until I fix + the winreg IDL -- jerry */ + /******************************************************************** ********************************************************************/ @@ -1024,12 +1087,14 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) return result; } +#endif /******************************************************************* ********************************************************************/ -WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) +WERROR _winreg_SaveKey(pipes_struct *p) { +#if 0 REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); pstring filename; int snum; @@ -1047,25 +1112,43 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) DEBUG(2,("_reg_save_key: Saving [%s] to %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); return backup_registry_key( regkey, filename ); +#endif + + /* disabled for now until I fix the IDL --jerry */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_SaveKeyEx(pipes_struct *p) +{ + /* disabled for now until I fix the IDL --jerry */ + return WERR_NOT_SUPPORTED; } /******************************************************************* ********************************************************************/ -WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREATE_KEY_EX *r_u) +WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct winreg_String keyname, + struct winreg_String keyclass, uint32_t options, uint32_t access_mask, + struct winreg_SecBuf *secdesc, struct policy_handle *new_handle, + enum winreg_CreateAction *action_taken ) { - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, handle); REGISTRY_KEY *newparentinfo, *keyinfo; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; - pstring name; + char *name; WERROR result; if ( !parent ) return WERR_BADFID; - - rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); + + if ( (name = talloc_strdup( p->mem_ctx, keyname.name )) == NULL ) { + return WERR_NOMEM; + } /* ok. Here's what we do. */ @@ -1097,7 +1180,7 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT else { /* use the existing open key information */ newparentinfo = parent; - memcpy( &newparent_handle, &q_u->handle, sizeof(POLICY_HND) ); + memcpy( &newparent_handle, handle, sizeof(POLICY_HND) ); } /* (3) check for create subkey rights on the correct parent */ @@ -1129,8 +1212,12 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT /* (5) open the new key and return the handle. Note that it is probably not correct to grant full access on this open handle. */ - result = open_registry_key( p, &r_u->handle, &keyinfo, newparentinfo, name, REG_KEY_READ ); + result = open_registry_key( p, new_handle, &keyinfo, newparentinfo, name, REG_KEY_READ ); keyinfo->access_granted = REG_KEY_ALL; + + /* FIXME: report the truth here */ + + *action_taken = REG_CREATED_NEW_KEY; done: /* close any intermediate key handles */ @@ -1145,12 +1232,12 @@ done: /******************************************************************* ********************************************************************/ -WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r_u) +WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String name, enum winreg_Type type, uint8_t *data, uint32_t size) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); REGVAL_CTR *values; BOOL write_result; - fstring valuename; + char *valuename; if ( !key ) return WERR_BADFID; @@ -1160,12 +1247,11 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) return WERR_ACCESS_DENIED; - rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); - /* verify the name */ - - if ( !*valuename ) + + if ( (valuename = talloc_strdup(p->mem_ctx, name.name)) == NULL ) { return WERR_INVALID_PARAM; + } DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, valuename)); @@ -1176,7 +1262,7 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r fetch_reg_values( key, values ); - regval_ctr_addvalue( values, valuename, q_u->type, (char*)q_u->value.buffer, q_u->value.buf_len ); + regval_ctr_addvalue( values, valuename, type, (const char *)data, size ); /* now write to the registry backend */ @@ -1193,14 +1279,14 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r /******************************************************************* ********************************************************************/ -WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) +WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String key) { - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, handle); REGISTRY_KEY *newparentinfo = NULL; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; - pstring name; + char *name; WERROR result; if ( !parent ) @@ -1215,7 +1301,10 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY goto done; } - rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); + if ( (name = talloc_strdup( p->mem_ctx, key.name )) == NULL ) { + result = WERR_INVALID_PARAM; + goto done; + } /* ok. Here's what we do. */ @@ -1272,12 +1361,12 @@ done: /******************************************************************* ********************************************************************/ -WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE_VALUE *r_u) +WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); REGVAL_CTR *values; BOOL write_result; - fstring valuename; + char *valuename; if ( !key ) return WERR_BADFID; @@ -1287,10 +1376,9 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) return WERR_ACCESS_DENIED; - rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); - - if ( !*valuename ) + if ( (valuename = talloc_strdup( p->mem_ctx, value.name )) == NULL ) { return WERR_INVALID_PARAM; + } DEBUG(8,("_reg_delete_value: Setting value for [%s:%s]\n", key->name, valuename)); @@ -1318,9 +1406,9 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE /******************************************************************* ********************************************************************/ -WERROR _reg_get_key_sec(pipes_struct *p, REG_Q_GET_KEY_SEC *q_u, REG_R_GET_KEY_SEC *r_u) +WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct KeySecurityData *sd) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); if ( !key ) return WERR_BADFID; @@ -1336,9 +1424,9 @@ WERROR _reg_get_key_sec(pipes_struct *p, REG_Q_GET_KEY_SEC *q_u, REG_R_GET_KEY_ /******************************************************************* ********************************************************************/ -WERROR _reg_set_key_sec(pipes_struct *p, REG_Q_SET_KEY_SEC *q_u, REG_R_SET_KEY_SEC *r_u) +WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t access_mask, struct KeySecurityData *sd) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); if ( !key ) return WERR_BADFID; @@ -1350,3 +1438,81 @@ WERROR _reg_set_key_sec(pipes_struct *p, REG_Q_SET_KEY_SEC *q_u, REG_R_SET_KEY_ return WERR_ACCESS_DENIED; } + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_FlushKey(pipes_struct *p, struct policy_handle *handle) +{ + /* I'm just replying OK because there's not a lot + here I see to do i --jerry */ + + return WERR_OK; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_UnLoadKey(pipes_struct *p) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_ReplaceKey(pipes_struct *p) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_LoadKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *keyname, struct winreg_String *filename) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct policy_handle *handle, uint8_t watch_subtree, uint32_t notify_filter, uint32_t unknown, struct winreg_String string1, struct winreg_String string2, uint32_t unknown2) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_QueryMultipleValues(pipes_struct *p, struct policy_handle *key_handle, struct QueryMultipleValue *values, uint32_t num_values, uint8_t *buffer, uint32_t *buffer_size) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_QueryMultipleValues2(pipes_struct *p) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 9cebd21d7d..636dc750ea 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -37,6 +37,7 @@ static const char *known_nt_pipes[] = { "\\lsass", "\\lsarpc", "\\winreg", + "\\initshutdown", "\\spoolss", "\\netdfs", "\\rpcecho", |