diff options
author | Michael Adam <obnox@samba.org> | 2008-04-04 16:46:01 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-04-04 17:05:00 +0200 |
commit | 65088387c061aebd8a847857a5fc87ca7a9257f3 (patch) | |
tree | 6d515d4a3a511a53702a75a2ec680fc8dc0577a6 /source3/utils | |
parent | 0bd2ac713068341a3b4e9461e4d422d4571c6474 (diff) | |
download | samba-65088387c061aebd8a847857a5fc87ca7a9257f3.tar.gz samba-65088387c061aebd8a847857a5fc87ca7a9257f3.tar.bz2 samba-65088387c061aebd8a847857a5fc87ca7a9257f3.zip |
net_rpc_registry: use split_hive_key to normalize hive befor open.
THis allows to specify keys in the form "HKLM/Software/samba",
i.e. "/" instead of "\\".
Michael
(This used to be commit 61d09caef340d2fee303e429f6f25d011cb3023c)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_rpc_registry.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 89cb265550..0d1f068862 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -23,45 +23,56 @@ #include "regfio.h" #include "reg_objects.h" -static bool reg_hive_key(const char *fullname, uint32 *reg_type, - const char **key_name) +static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname, + uint32 *reg_type, const char **key_name) { - const char *sep; - ptrdiff_t len; + WERROR werr; + char *hivename = NULL; + const char *tmp_keyname = NULL; + bool ret = false; + TALLOC_CTX *tmp_ctx = talloc_stackframe(); - sep = strchr_m(fullname, '\\'); - - if (sep != NULL) { - len = sep - fullname; - *key_name = sep+1; + werr = split_hive_key(tmp_ctx, fullname, &hivename, &tmp_keyname); + if (!W_ERROR_IS_OK(werr)) { + goto done; } - else { - len = strlen(fullname); - *key_name = ""; + + *key_name = talloc_strdup(ctx, tmp_keyname); + if (*key_name == NULL) { + goto done; } - if (strnequal(fullname, "HKLM", len) || - strnequal(fullname, "HKEY_LOCAL_MACHINE", len)) + if (strequal(hivename, "HKLM") || + strequal(hivename, "HKEY_LOCAL_MACHINE")) + { (*reg_type) = HKEY_LOCAL_MACHINE; - else if (strnequal(fullname, "HKCR", len) || - strnequal(fullname, "HKEY_CLASSES_ROOT", len)) + } else if (strequal(hivename, "HKCR") || + strequal(hivename, "HKEY_CLASSES_ROOT")) + { (*reg_type) = HKEY_CLASSES_ROOT; - else if (strnequal(fullname, "HKU", len) || - strnequal(fullname, "HKEY_USERS", len)) + } else if (strequal(hivename, "HKU") || + strequal(hivename, "HKEY_USERS")) + { (*reg_type) = HKEY_USERS; - else if (strnequal(fullname, "HKCU", len) || - strnequal(fullname, "HKEY_CURRENT_USER", len)) + } else if (strequal(hivename, "HKCU") || + strequal(hivename, "HKEY_CURRENT_USER")) + { (*reg_type) = HKEY_CURRENT_USER; - else if (strnequal(fullname, "HKPD", len) || - strnequal(fullname, "HKEY_PERFORMANCE_DATA", len)) + } else if (strequal(hivename, "HKPD") || + strequal(hivename, "HKEY_PERFORMANCE_DATA")) + { (*reg_type) = HKEY_PERFORMANCE_DATA; - else { + } else { DEBUG(10,("reg_hive_key: unrecognised hive key %s\n", fullname)); - return False; + goto done; } - return True; + ret = true; + +done: + TALLOC_FREE(tmp_ctx); + return ret; } static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, @@ -76,7 +87,7 @@ static NTSTATUS registry_openkey(TALLOC_CTX *mem_ctx, ZERO_STRUCT(key); - if (!reg_hive_key(name, &hive, &key.name)) { + if (!reg_hive_key(mem_ctx, name, &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } @@ -494,7 +505,7 @@ static NTSTATUS rpc_registry_createkey_internal(const DOM_SID *domain_sid, ZERO_STRUCT(key); ZERO_STRUCT(keyclass); - if (!reg_hive_key(argv[0], &hive, &key.name)) { + if (!reg_hive_key(mem_ctx, argv[0], &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } @@ -562,7 +573,7 @@ static NTSTATUS rpc_registry_deletekey_internal(const DOM_SID *domain_sid, ZERO_STRUCT(key); - if (!reg_hive_key(argv[0], &hive, &key.name)) { + if (!reg_hive_key(mem_ctx, argv[0], &hive, &key.name)) { return NT_STATUS_INVALID_PARAMETER; } |