[SCM] Samba Shared Repository - branch master updated -
89b23974d3efa3d8a1e97cf49c2f949d3fa52ffa
Jelmer Vernooij
jelmer at samba.org
Sun Sep 21 21:32:59 GMT 2008
The branch, master has been updated
via 89b23974d3efa3d8a1e97cf49c2f949d3fa52ffa (commit)
via 08953e44db2d3369c51324bb21474830cd24dd4b (commit)
via 4c7203367fb487de616a137d74ad70c67e8781c9 (commit)
via 5c3e76eddd89d9af18bf2a00e7ee6021ab90b234 (commit)
via 9038f2a0fd87075cf2125b1444e2669125bc72ea (commit)
via 03e582cc866a957af792a7c128716622f1a1dc83 (commit)
via f25f0dd74489bfea39170a9277afbf96deb8f389 (commit)
via 9b70485207735a8d4c1395963944e5a19a791f53 (commit)
via db829f04adc27764a4a53ae94bc24c64e143e024 (commit)
via 04f29b84a4bf2378d326b86a983792095231922e (commit)
via 1e178ffc03456064bfd2ec330b9b6b6217c8561d (commit)
via c1fef1fabf03e9c2f412b03d9f8cd314a5d34760 (commit)
via 92e1574d3ddb0edf3173e18c6e0dfc4974bedcf5 (commit)
via 5bf62260505d1e8dfddcb3acef69ef0217841a3f (commit)
via a2d8ccad734b850a8e368408328c32b4f15e2525 (commit)
via 965a12f5b8bb862bab9eb46fba6e95f3906bae7d (commit)
via faa4ac2a52cee89be66a11604dd65871b3b70a6b (commit)
from 2121c1bb2967f0aa8cc6903c507eb2c22a25b341 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 89b23974d3efa3d8a1e97cf49c2f949d3fa52ffa
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 19 16:03:20 2008 +0200
Torture suite: Revert some changes because they aren't necessary
This reverts some changes made by me because they aren't necessary. The "ZERO_STRUCT"'s remain in.
commit 08953e44db2d3369c51324bb21474830cd24dd4b
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 19 15:53:02 2008 +0200
Registry client: Remove all conversion helper functions
commit 4c7203367fb487de616a137d74ad70c67e8781c9
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 19 14:35:35 2008 +0200
Registry client library: Remove two elementar conversion functions
commit 5c3e76eddd89d9af18bf2a00e7ee6021ab90b234
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 19 12:57:26 2008 +0200
Revert "Registry tool "regtree": Removing an error message"
This reverts commit f37a57fa366e2b0d77f9c1bd232d42a0f2cceb52.
commit 9038f2a0fd87075cf2125b1444e2669125bc72ea
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Mon Sep 15 21:09:32 2008 +0200
Torture suite: Fixes the tests to not segfault again SAMBA 4 registry server
commit 03e582cc866a957af792a7c128716622f1a1dc83
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Mon Sep 15 19:00:07 2008 +0200
Registry client: Fixup the "patchfile" library
Rework and enhance the "patchfile" library (used in "regdiff")
commit f25f0dd74489bfea39170a9277afbf96deb8f389
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Mon Sep 15 18:59:17 2008 +0200
Registry client: Implement the "winreg_QueryValue" call
This is needed for the registry patchfile library
commit 9b70485207735a8d4c1395963944e5a19a791f53
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Mon Sep 15 13:04:40 2008 +0200
Registry client library: Use "talloc_zero" to avoid uninitialized values
commit db829f04adc27764a4a53ae94bc24c64e143e024
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sun Sep 14 03:29:07 2008 +0200
Registry tool "regdiff": Add the event context for remote connections
Adds the event context for remote connections to make the tool working again.
commit 04f29b84a4bf2378d326b86a983792095231922e
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Sep 13 15:02:56 2008 +0200
Registry client library: Fixes the creation of new keys
Giving the right permissions
commit 1e178ffc03456064bfd2ec330b9b6b6217c8561d
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Sep 13 14:26:08 2008 +0200
Registry client library: Fix some buffer problems
This buffer maximum values are used in Windows (2000), so I take them also for SAMBA 4.
commit c1fef1fabf03e9c2f412b03d9f8cd314a5d34760
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Sep 13 12:30:47 2008 +0200
Registry client library: Various fixup's and corrections
I reverted the change with the string conversions because they aren't needed and included
many fixup's and improvements in the code. We should be able now to connect to a Windows WINREG server
without a problem.
commit 92e1574d3ddb0edf3173e18c6e0dfc4974bedcf5
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Sat Sep 13 12:26:03 2008 +0200
Registry tools "regshell" and "regtree": Small fixup's
I fixed up my fault regarding the handling of the default value (if it doesn't exist
it hasn't the index number zero and you get immediately the subvalues). Then I corrected an error in regshell to find the right registry context.
commit 5bf62260505d1e8dfddcb3acef69ef0217841a3f
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 12 20:26:13 2008 +0200
Registry client: Various cleanups and charset conversions
This patch contains various changes to the "rpc.c" file to clean it up and introduces the right string charset conversions (UNIX <-> UTF16).
commit a2d8ccad734b850a8e368408328c32b4f15e2525
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 12 17:02:30 2008 +0200
Registry tool "regshell": Handle the default attribute in the right way
This commit introduces the default attribute in "regshell"
commit 965a12f5b8bb862bab9eb46fba6e95f3906bae7d
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 12 16:57:22 2008 +0200
Registry tool "regtree": Removing an error message
The error message "Error occurred while fetching values" doesn't seem very useful, so remove it.
commit faa4ac2a52cee89be66a11604dd65871b3b70a6b
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date: Fri Sep 12 16:41:49 2008 +0200
Registry tool "regtree": Handle the default attribute in the right way
This commit introduces the default attribute in "regtree"
-----------------------------------------------------------------------
Summary of changes:
source4/lib/registry/patchfile.c | 104 ++++++++-----
source4/lib/registry/rpc.c | 268 ++++++++++++++++++++-------------
source4/lib/registry/tools/regdiff.c | 2 +-
source4/lib/registry/tools/regshell.c | 28 ++--
source4/lib/registry/tools/regtree.c | 23 +--
source4/torture/rpc/winreg.c | 16 ++
6 files changed, 270 insertions(+), 171 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c
index 0ede310..d49d462 100644
--- a/source4/lib/registry/patchfile.c
+++ b/source4/lib/registry/patchfile.c
@@ -4,6 +4,7 @@
Copyright (C) Jelmer Vernooij 2004-2007
Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Matthias Dieter Wallnöfer 2008
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
@@ -58,8 +59,9 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
&old_num_subkeys, &old_num_values,
NULL, NULL, NULL, NULL);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error occured while getting key info: %s\n",
+ DEBUG(0, ("Error occurred while getting key info: %s\n",
win_errstr(error)));
+ talloc_free(mem_ctx);
return error;
}
} else {
@@ -70,11 +72,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Subkeys that were deleted */
for (i = 0; i < old_num_subkeys; i++) {
error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i,
- &keyname1,
- NULL, NULL);
+ &keyname1, NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error occured while getting subkey by index: %s\n",
- win_errstr(error2)));
+ DEBUG(0, ("Error occurred while getting subkey by index: %s\n",
+ win_errstr(error1)));
continue;
}
@@ -98,6 +99,17 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* newkey didn't have such a subkey, add del diff */
tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
callbacks->del_key(callback_data, tmppath);
+
+ /* perform here also the recursive invocation */
+ error1 = reg_open_key(mem_ctx, oldkey, keyname1, &t1);
+ if (!W_ERROR_IS_OK(error1)) {
+ DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ win_errstr(error1)));
+ talloc_free(mem_ctx);
+ return error1;
+ }
+ reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data);
+
talloc_free(tmppath);
}
@@ -106,8 +118,9 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
&new_num_subkeys, &new_num_values,
NULL, NULL, NULL, NULL);
if (!W_ERROR_IS_OK(error)) {
- DEBUG(0, ("Error occured while getting key info: %s\n",
+ DEBUG(0, ("Error occurred while getting key info: %s\n",
win_errstr(error)));
+ talloc_free(mem_ctx);
return error;
}
} else {
@@ -117,11 +130,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Subkeys that were added */
for(i = 0; i < new_num_subkeys; i++) {
- error1 = reg_key_get_subkey_by_index(mem_ctx, newkey,
- i, &keyname1,
- NULL, NULL);
+ error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i,
+ &keyname1, NULL, NULL);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error occured while getting subkey by index: %s\n",
+ DEBUG(0, ("Error occurred while getting subkey by index: %s\n",
win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
@@ -133,12 +145,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
if (W_ERROR_IS_OK(error2))
continue;
} else {
+ error2 = WERR_BADFILE;
t1 = NULL;
- error2 = WERR_BADFILE;
}
if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
- DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ DEBUG(0, ("Error occurred while getting subkey by name: %s\n",
win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
@@ -148,15 +160,20 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
callbacks->add_key(callback_data, tmppath);
- W_ERROR_NOT_OK_RETURN(
- reg_open_key(mem_ctx, newkey, keyname1, &t2));
+ /* perform here also the recursive invocation */
+ error1 = reg_open_key(mem_ctx, newkey, keyname1, &t2);
+ if (!W_ERROR_IS_OK(error1)) {
+ DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+ win_errstr(error1)));
+ talloc_free(mem_ctx);
+ return error1;
+ }
+ reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data);
- reg_generate_diff_key(t1, t2, tmppath,
- callbacks, callback_data);
talloc_free(tmppath);
}
- /* Values that were changed */
+ /* Values that were added or changed */
for(i = 0; i < new_num_values; i++) {
const char *name;
uint32_t type1, type2;
@@ -165,7 +182,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
error1 = reg_key_get_value_by_index(mem_ctx, newkey, i,
&name, &type1, &contents1);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Unable to get key by index: %s\n",
+ DEBUG(0, ("Unable to get value by index: %s\n",
win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
@@ -178,16 +195,17 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
} else
error2 = WERR_BADFILE;
- if(!W_ERROR_IS_OK(error2) &&
- !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
- DEBUG(0, ("Error occured while getting value by name: %s\n",
+ if (!W_ERROR_IS_OK(error2)
+ && !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
+ DEBUG(0, ("Error occurred while getting value by name: %s\n",
win_errstr(error2)));
talloc_free(mem_ctx);
return error2;
}
- if (W_ERROR_IS_OK(error2) &&
- data_blob_cmp(&contents1, &contents2) == 0)
+ if (W_ERROR_IS_OK(error2)
+ && (data_blob_cmp(&contents1, &contents2) == 0)
+ && (type1 == type2))
continue;
callbacks->set_value(callback_data, path, name,
@@ -197,24 +215,31 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
/* Values that were deleted */
for (i = 0; i < old_num_values; i++) {
const char *name;
+ uint32_t type;
+ DATA_BLOB contents;
+
error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name,
- NULL, NULL);
+ &type, &contents);
if (!W_ERROR_IS_OK(error1)) {
- DEBUG(0, ("Error ocurred getting value by index: %s\n",
+ DEBUG(0, ("Unable to get value by index: %s\n",
win_errstr(error1)));
talloc_free(mem_ctx);
return error1;
}
- error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL,
- NULL);
+ if (newkey != NULL)
+ error2 = reg_key_get_value_by_name(mem_ctx, newkey,
+ name, &type, &contents);
+ else
+ error2 = WERR_BADFILE;
if (W_ERROR_IS_OK(error2))
continue;
if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
- DEBUG(0, ("Error occured while getting value by name: %s\n",
+ DEBUG(0, ("Error occurred while getting value by name: %s\n",
win_errstr(error2)));
+ talloc_free(mem_ctx);
return error2;
}
@@ -236,27 +261,30 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
int i;
WERROR error;
- for(i = HKEY_FIRST; i <= HKEY_LAST; i++) {
+ for (i = 0; reg_predefined_keys[i].name; i++) {
struct registry_key *r1 = NULL, *r2 = NULL;
- error = reg_get_predefined_key(ctx1, i, &r1);
+
+ error = reg_get_predefined_key(ctx1,
+ reg_predefined_keys[i].handle, &r1);
if (!W_ERROR_IS_OK(error) &&
!W_ERROR_EQUAL(error, WERR_BADFILE)) {
DEBUG(0, ("Unable to open hive %s for backend 1\n",
- reg_get_predef_name(i)));
+ reg_predefined_keys[i].name));
+ continue;
}
- error = reg_get_predefined_key(ctx2, i, &r2);
+ error = reg_get_predefined_key(ctx2,
+ reg_predefined_keys[i].handle, &r2);
if (!W_ERROR_IS_OK(error) &&
!W_ERROR_EQUAL(error, WERR_BADFILE)) {
DEBUG(0, ("Unable to open hive %s for backend 2\n",
- reg_get_predef_name(i)));
- }
-
- if (r1 == NULL && r2 == NULL)
+ reg_predefined_keys[i].name));
continue;
+ }
- error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i),
- callbacks, callback_data);
+ error = reg_generate_diff_key(r1, r2,
+ reg_predefined_keys[i].name, callbacks,
+ callback_data);
if (!W_ERROR_IS_OK(error)) {
DEBUG(0, ("Unable to determine diff: %s\n",
win_errstr(error)));
diff --git a/source4/lib/registry/rpc.c b/source4/lib/registry/rpc.c
index 18b7607..6429a39 100644
--- a/source4/lib/registry/rpc.c
+++ b/source4/lib/registry/rpc.c
@@ -2,6 +2,7 @@
Samba Unix/Linux SMB implementation
RPC backend for the registry library
Copyright (C) 2003-2007 Jelmer Vernooij, jelmer at samba.org
+ Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer at yahoo.de
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
@@ -20,16 +21,23 @@
#include "registry.h"
#include "librpc/gen_ndr/ndr_winreg_c.h"
+#define MAX_NAMESIZE 512
+#define MAX_VALSIZE 32768
+
struct rpc_key {
struct registry_key key;
struct policy_handle pol;
struct dcerpc_pipe *pipe;
- uint32_t num_values;
+ const char* classname;
uint32_t num_subkeys;
+ uint32_t max_subkeylen;
+ uint32_t max_subkeysize;
+ uint32_t num_values;
uint32_t max_valnamelen;
- uint32_t max_valdatalen;
- uint32_t max_subkeynamelen;
+ uint32_t max_valbufsize;
+ uint32_t secdescsize;
+ NTTIME last_changed_time;
};
struct rpc_registry_context {
@@ -43,26 +51,22 @@ static struct registry_operations reg_backend_rpc;
* This is the RPC backend for the registry library.
*/
-static void init_winreg_String(struct winreg_String *name, const char *s)
-{
- name->name = s;
-}
-
-
#define openhive(u) static WERROR open_ ## u(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *hnd) \
{ \
struct winreg_Open ## u r; \
NTSTATUS status; \
- \
+\
+ ZERO_STRUCT(r); \
r.in.system_name = NULL; \
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; \
r.out.handle = hnd;\
- \
+\
status = dcerpc_winreg_Open ## u(p, mem_ctx, &r); \
- if (NT_STATUS_IS_ERR(status)) {\
- DEBUG(0,("Error executing open\n"));\
- return ntstatus_to_werror(status);\
- }\
+\
+ if (!NT_STATUS_IS_OK(status)) { \
+ DEBUG(1, ("OpenHive failed - %s\n", nt_errstr(status))); \
+ return ntstatus_to_werror(status); \
+ } \
\
return r.out.result;\
}
@@ -90,7 +94,7 @@ static struct {
{ 0, NULL }
};
-static WERROR rpc_query_key(const struct registry_key *k);
+static WERROR rpc_query_key(TALLOC_CTX *mem_ctx, const struct registry_key *k);
static WERROR rpc_get_predefined_key(struct registry_context *ctx,
uint32_t hkey_type,
@@ -127,15 +131,15 @@ static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k)
struct winreg_OpenKey r;
struct rpc_key_data *mykeydata;
- k->backend_data = mykeydata = talloc(mem_ctx, struct rpc_key_data);
+ k->backend_data = mykeydata = talloc_zero(mem_ctx, struct rpc_key_data);
mykeydata->num_values = -1;
mykeydata->num_subkeys = -1;
/* Then, open the handle using the hive */
- memset(&r, 0, sizeof(struct winreg_OpenKey));
+ ZERO_STRUCT(r);
r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol);
- init_winreg_String(&r.in.keyname, k->path);
+ r.in.keyname.name = k->path;
r.in.unknown = 0x00000000;
r.in.access_mask = 0x02000000;
r.out.handle = &mykeydata->pol;
@@ -155,8 +159,7 @@ static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
struct winreg_OpenKey r;
NTSTATUS status;
- mykeydata = talloc(mem_ctx, struct rpc_key);
-
+ mykeydata = talloc_zero(mem_ctx, struct rpc_key);
mykeydata->key.context = parentkeydata->key.context;
mykeydata->pipe = talloc_reference(mykeydata, parentkeydata->pipe);
mykeydata->num_values = -1;
@@ -166,14 +169,15 @@ static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
/* Then, open the handle using the hive */
ZERO_STRUCT(r);
r.in.parent_handle = &parentkeydata->pol;
- init_winreg_String(&r.in.keyname, name);
+ r.in.keyname.name = name;
r.in.unknown = 0x00000000;
r.in.access_mask = 0x02000000;
r.out.handle = &mykeydata->pol;
status = dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r);
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(0,("Error executing openkey: %s\n", nt_errstr(status)));
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("OpenKey failed - %s\n", nt_errstr(status)));
return ntstatus_to_werror(status);
}
@@ -188,47 +192,94 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
DATA_BLOB *data)
{
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
- WERROR error;
struct winreg_EnumValue r;
- uint32_t in_type = 0;
- NTSTATUS status;
struct winreg_StringBuf name;
+ uint8_t value;
+ uint32_t val_size = MAX_VALSIZE;
uint32_t zero = 0;
-
- ZERO_STRUCT(r);
+ WERROR error;
+ NTSTATUS status;
if (mykeydata->num_values == -1) {
- error = rpc_query_key(parent);
+ error = rpc_query_key(mem_ctx, parent);
if(!W_ERROR_IS_OK(error)) return error;
}
- name.length = 0;
- name.size = mykeydata->max_valnamelen * 2;
- name.name = NULL;
+ name.name = "";
+ name.size = MAX_NAMESIZE;
+ ZERO_STRUCT(r);
r.in.handle = &mykeydata->pol;
r.in.enum_index = n;
r.in.name = &name;
- r.in.type = &in_type;
- r.in.value = talloc_zero_array(mem_ctx, uint8_t, 0);
+ r.in.type = type;
+ r.in.value = &value;
+ r.in.size = &val_size;
r.in.length = &zero;
- r.in.size = &mykeydata->max_valdatalen;
r.out.name = &name;
r.out.type = type;
+ r.out.value = &value;
+ r.out.size = &val_size;
+ r.out.length = &zero;
status = dcerpc_winreg_EnumValue(mykeydata->pipe, mem_ctx, &r);
- if(NT_STATUS_IS_ERR(status)) {
- DEBUG(0, ("Error in EnumValue: %s\n", nt_errstr(status)));
- return WERR_GENERAL_FAILURE;
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("EnumValue failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
}
- if(NT_STATUS_IS_OK(status) &&
- W_ERROR_IS_OK(r.out.result) && r.out.length) {
- *value_name = talloc_strdup(mem_ctx, r.out.name->name);
- *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length);
- return WERR_OK;
+ *value_name = talloc_reference(mem_ctx, r.out.name->name);
+ *type = *(r.out.type);
+ *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length);
+
+ return r.out.result;
+}
+
+static WERROR rpc_get_value_by_name(TALLOC_CTX *mem_ctx,
+ const struct registry_key *parent,
+ const char *value_name,
+ uint32_t *type,
+ DATA_BLOB *data)
+{
+ struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
+ struct winreg_QueryValue r;
+ struct winreg_String name;
+ uint8_t value;
+ uint32_t val_size = MAX_VALSIZE;
+ uint32_t zero = 0;
+ WERROR error;
+ NTSTATUS status;
+
+ if (mykeydata->num_values == -1) {
+ error = rpc_query_key(mem_ctx, parent);
+ if(!W_ERROR_IS_OK(error)) return error;
+ }
+
+ name.name = value_name;
+
+ ZERO_STRUCT(r);
+ r.in.handle = &mykeydata->pol;
+ r.in.value_name = name;
+ r.in.type = type;
+ r.in.data = &value;
+ r.in.size = &val_size;
+ r.in.length = &zero;
+ r.out.type = type;
+ r.out.data = &value;
+ r.out.size = &val_size;
+ r.out.length = &zero;
+
+ status = dcerpc_winreg_QueryValue(mykeydata->pipe, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("QueryValue failed - %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
}
+ *type = *(r.out.type);
+ *data = data_blob_talloc(mem_ctx, r.out.data, *r.out.length);
+
return r.out.result;
}
@@ -241,34 +292,39 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
{
struct winreg_EnumKey r;
struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
- NTSTATUS status;
struct winreg_StringBuf namebuf, classbuf;
NTTIME change_time = 0;
+ NTSTATUS status;
- ZERO_STRUCT(r);
-
- namebuf.length = 0;
- namebuf.size = 1024;
- namebuf.name = NULL;
- classbuf.length = 0;
- classbuf.size = 0;
- classbuf.name = NULL;
+ namebuf.name = "";
+ namebuf.size = MAX_NAMESIZE;
+ classbuf.name = NULL;
+ classbuf.size = 0;
--
Samba Shared Repository
More information about the samba-cvs
mailing list