summaryrefslogtreecommitdiff
path: root/source4/lib/registry/common
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-12-15 00:16:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:07:27 -0500
commitd8c3428b3bb10075cec3b37adbca54db634d3b00 (patch)
tree3d75a8bab1f735e29c1e8dfae06dd2be9c970a8e /source4/lib/registry/common
parent707d1808982fa3788156999016904475eef26ffe (diff)
downloadsamba-d8c3428b3bb10075cec3b37adbca54db634d3b00.tar.gz
samba-d8c3428b3bb10075cec3b37adbca54db634d3b00.tar.bz2
samba-d8c3428b3bb10075cec3b37adbca54db634d3b00.zip
r4209: Fix several smaller bugs
Add "predef" and "set" commands in regshell Some of the remote calls from a Windows box work now. (This used to be commit f3e05782804fe4b4942fa966f1b9650c64bc234d)
Diffstat (limited to 'source4/lib/registry/common')
-rw-r--r--source4/lib/registry/common/reg_interface.c9
-rw-r--r--source4/lib/registry/common/reg_util.c67
2 files changed, 65 insertions, 11 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index c729945a26..f5c3598721 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -348,9 +348,12 @@ WERROR reg_key_get_subkey_by_name(TALLOC_CTX *mem_ctx, struct registry_key *key,
for(i = 0; W_ERROR_IS_OK(error); i++) {
error = reg_key_get_subkey_by_index(mem_ctx, key, i, subkey);
if(W_ERROR_IS_OK(error) && !strcmp((*subkey)->name, name)) {
- return error;
+ break;
}
}
+
+ if (W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
+ error = WERR_DEST_NOT_FOUND;
} else {
return WERR_NOT_SUPPORTED;
}
@@ -375,7 +378,7 @@ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx, struct registry_key *key,
} else {
for(i = 0; W_ERROR_IS_OK(error); i++) {
error = reg_key_get_value_by_index(mem_ctx, key, i, val);
- if(W_ERROR_IS_OK(error) && StrCaseCmp((*val)->name, name)) {
+ if(W_ERROR_IS_OK(error) && !strcmp((*val)->name, name)) {
break;
}
}
@@ -402,7 +405,7 @@ WERROR reg_key_del(struct registry_key *parent, const char *name)
return WERR_OK;
}
-WERROR reg_key_add_name(TALLOC_CTX *mem_ctx, struct registry_key *parent, const char *name, uint32_t access_mask, SEC_DESC *desc, struct registry_key **newkey)
+WERROR reg_key_add_name(TALLOC_CTX *mem_ctx, struct registry_key *parent, const char *name, uint32_t access_mask, struct security_descriptor *desc, struct registry_key **newkey)
{
WERROR error;
diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c
index 1d1f770324..68144fc56f 100644
--- a/source4/lib/registry/common/reg_util.c
+++ b/source4/lib/registry/common/reg_util.c
@@ -24,14 +24,27 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
+static const struct {
+ uint32 id;
+ const char *name;
+} reg_value_types[] = {
+ { REG_SZ, "REG_SZ" },
+ { REG_DWORD, "REG_DWORD" },
+ { REG_BINARY, "REG_BINARY" },
+ { REG_EXPAND_SZ, "REG_EXPAND_SZ" },
+ { REG_NONE, "REG_NONE" },
+ { 0, NULL }
+};
+
/* Return string description of registry value type */
const char *str_regtype(int type)
{
- switch(type) {
- case REG_SZ: return "STRING";
- case REG_DWORD: return "DWORD";
- case REG_BINARY: return "BINARY";
+ int i;
+ for (i = 0; reg_value_types[i].name; i++) {
+ if (reg_value_types[i].id == type)
+ return reg_value_types[i].name;
}
+
return "Unknown";
}
@@ -84,10 +97,48 @@ char *reg_val_description(TALLOC_CTX *mem_ctx, struct registry_value *val)
return talloc_asprintf(mem_ctx, "%s = %s : %s", val->name?val->name:"<No Name>", str_regtype(val->data_type), reg_val_data_string(mem_ctx, val));
}
-BOOL reg_val_set_string(struct registry_value *val, char *str)
+BOOL reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, struct registry_value **value)
{
- /* FIXME */
- return False;
+ int i;
+ *value = talloc_p(mem_ctx, struct registry_value);
+ (*value)->data_type = -1;
+
+ /* Find the correct type */
+ for (i = 0; reg_value_types[i].name; i++) {
+ if (!strcmp(reg_value_types[i].name, type_str)) {
+ (*value)->data_type = reg_value_types[i].id;
+ break;
+ }
+ }
+
+ if ((*value)->data_type == -1)
+ return False;
+
+ /* Convert data appropriately */
+
+ switch ((*value)->data_type)
+ {
+ case REG_SZ:
+ case REG_EXPAND_SZ:
+ (*value)->data_blk = talloc_strdup(mem_ctx, data_str);
+ (*value)->data_len = strlen(data_str);
+ break;
+ case REG_DWORD:
+ (*value)->data_len = sizeof(uint32);
+ (*value)->data_blk = talloc_p(mem_ctx, uint32);
+ *((uint32 *)(*value)->data_blk) = atol(data_str);
+ break;
+
+ case REG_NONE:
+ (*value)->data_len = 0;
+ (*value)->data_blk = NULL;
+ break;
+
+ default:
+ case REG_BINARY: /* FIXME */
+ return False;
+ }
+ return True;
}
WERROR reg_key_get_subkey_val(TALLOC_CTX *mem_ctx, struct registry_key *key, const char *subname, const char *valname, struct registry_value **val)
@@ -220,7 +271,7 @@ WERROR reg_key_del_abs(struct registry_context *ctx, const char *path)
return error;
}
-WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx, const char *path, uint32 access_mask, SEC_DESC *sec_desc, struct registry_key **result)
+WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx, const char *path, uint32 access_mask, struct security_descriptor *sec_desc, struct registry_key **result)
{
struct registry_key *parent;
const char *n;