mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
r828: Some fixes in the core and regshell concerning hives and
unicode
This commit is contained in:
parent
121dd9ba00
commit
25c27b176c
@ -176,15 +176,15 @@ WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
|
|||||||
return WERR_OK;
|
return WERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_ctx = talloc_init("mem_ctx");
|
|
||||||
|
|
||||||
fullname = talloc_asprintf(mem_ctx, "%s%s%s", parent->path, parent->path[strlen(parent->path)-1] == '\\'?"":"\\", name);
|
|
||||||
|
|
||||||
if(!parent->handle->functions->open_key) {
|
if(!parent->handle->functions->open_key) {
|
||||||
DEBUG(0, ("Registry backend doesn't have get_subkey_by_name nor open_key!\n"));
|
DEBUG(0, ("Registry backend doesn't have get_subkey_by_name nor open_key!\n"));
|
||||||
return WERR_NOT_SUPPORTED;
|
return WERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem_ctx = talloc_init("mem_ctx");
|
||||||
|
|
||||||
|
fullname = talloc_asprintf(mem_ctx, "%s%s%s", reg_key_get_path(parent), strlen(reg_key_get_path(parent))?"\\":"", name);
|
||||||
|
|
||||||
error = parent->handle->functions->open_key(parent->handle, parent->hive, fullname, result);
|
error = parent->handle->functions->open_key(parent->handle, parent->hive, fullname, result);
|
||||||
|
|
||||||
if(!W_ERROR_IS_OK(error)) {
|
if(!W_ERROR_IS_OK(error)) {
|
||||||
@ -193,7 +193,7 @@ WERROR reg_open_key(REG_KEY *parent, const char *name, REG_KEY **result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(*result)->handle = parent->handle;
|
(*result)->handle = parent->handle;
|
||||||
(*result)->path = fullname;
|
(*result)->path = talloc_asprintf((*result)->mem_ctx, "%s\\%s", reg_key_get_path_abs(parent), (*result)->name);
|
||||||
(*result)->hive = parent->hive;
|
(*result)->hive = parent->hive;
|
||||||
talloc_steal(mem_ctx, (*result)->mem_ctx, fullname);
|
talloc_steal(mem_ctx, (*result)->mem_ctx, fullname);
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ WERROR reg_key_get_subkey_by_index(REG_KEY *key, int idx, REG_KEY **subkey)
|
|||||||
return WERR_NOT_SUPPORTED;
|
return WERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s%s%s", key->path, key->path[strlen(key->path)-1] == '\\'?"":"\\", (*subkey)->name);
|
(*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s\\%s", reg_key_get_path_abs(key), (*subkey)->name);
|
||||||
(*subkey)->handle = key->handle;
|
(*subkey)->handle = key->handle;
|
||||||
(*subkey)->hive = key->hive;
|
(*subkey)->hive = key->hive;
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ WERROR reg_key_get_subkey_by_name(REG_KEY *key, const char *name, REG_KEY **subk
|
|||||||
|
|
||||||
if(!W_ERROR_IS_OK(error)) return error;
|
if(!W_ERROR_IS_OK(error)) return error;
|
||||||
|
|
||||||
(*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s%s%s", key->path, key->path[strlen(key->path)-1] == '\\'?"":"\\", (*subkey)->name);
|
(*subkey)->path = talloc_asprintf((*subkey)->mem_ctx, "%s\\%s", reg_key_get_path_abs(key), (*subkey)->name);
|
||||||
(*subkey)->handle = key->handle;
|
(*subkey)->handle = key->handle;
|
||||||
(*subkey)->hive = key->hive;
|
(*subkey)->hive = key->hive;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ char *reg_val_get_path(REG_VAL *v)
|
|||||||
const char *reg_key_get_path(REG_KEY *k)
|
const char *reg_key_get_path(REG_KEY *k)
|
||||||
{
|
{
|
||||||
SMB_REG_ASSERT(k);
|
SMB_REG_ASSERT(k);
|
||||||
return strchr(k->path, '\\')?strchr(k->path, '\\')+1:k->path;
|
return strchr(k->path, '\\')?strchr(k->path, '\\')+1:"";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *reg_key_get_path_abs(REG_KEY *k)
|
const char *reg_key_get_path_abs(REG_KEY *k)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
struct reg_key_s {
|
struct reg_key_s {
|
||||||
char *name; /* Name of the key */
|
char *name; /* Name of the key */
|
||||||
char *path; /* Full path to the key */
|
char *path; /* Full path to the key */
|
||||||
smb_ucs2_t *class_name; /* Name of key class */
|
char *class_name; /* Name of key class */
|
||||||
NTTIME last_mod; /* Time last modified */
|
NTTIME last_mod; /* Time last modified */
|
||||||
SEC_DESC *security;
|
SEC_DESC *security;
|
||||||
REG_HANDLE *handle;
|
REG_HANDLE *handle;
|
||||||
|
@ -1085,12 +1085,15 @@ static WERROR nk_to_key(REG_HANDLE *h, NK_HDR *nk_hdr, int size, REG_KEY *parent
|
|||||||
if (clsname_len) { /* Just print in Ascii for now */
|
if (clsname_len) { /* Just print in Ascii for now */
|
||||||
smb_ucs2_t *clsnamep;
|
smb_ucs2_t *clsnamep;
|
||||||
int clsnam_off;
|
int clsnam_off;
|
||||||
|
char *clsnameu;
|
||||||
|
|
||||||
clsnam_off = IVAL(&nk_hdr->clsnam_off,0);
|
clsnam_off = IVAL(&nk_hdr->clsnam_off,0);
|
||||||
clsnamep = (smb_ucs2_t *)LOCN(regf->base, clsnam_off);
|
clsnamep = (smb_ucs2_t *)LOCN(regf->base, clsnam_off);
|
||||||
DEBUG(2, ("Class Name Offset: %0X\n", clsnam_off));
|
DEBUG(2, ("Class Name Offset: %0X\n", clsnam_off));
|
||||||
|
|
||||||
tmp->class_name = talloc_strdup_w(h->mem_ctx, clsnamep);
|
clsnameu = acnv_u2ux(clsnamep);
|
||||||
|
tmp->class_name = talloc_strdup(tmp->mem_ctx, clsnameu);
|
||||||
|
SAFE_FREE(clsnameu);
|
||||||
|
|
||||||
DEBUGADD(2,(" Class Name: %s\n", cls_name));
|
DEBUGADD(2,(" Class Name: %s\n", cls_name));
|
||||||
|
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
* exit
|
* exit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static REG_KEY *cmd_pwd(REG_KEY *cur, int argc, char **argv)
|
||||||
|
{
|
||||||
|
printf("%s\n", reg_key_get_path_abs(cur));
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
|
||||||
static REG_KEY *cmd_set(REG_KEY *cur, int argc, char **argv)
|
static REG_KEY *cmd_set(REG_KEY *cur, int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
@ -52,7 +58,7 @@ static REG_KEY *cmd_ck(REG_KEY *cur, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Current path is: %s\n", reg_key_get_path(new));
|
printf("Current path is: %s\n", reg_key_get_path_abs(new));
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
@ -68,7 +74,7 @@ static REG_KEY *cmd_ls(REG_KEY *cur, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
|
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
|
||||||
DEBUG(0, ("Error occured while browsing thru keys\n"));
|
DEBUG(0, ("Error occured while browsing thru keys: %s\n", win_errstr(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(cur, i, &value)); i++) {
|
for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(cur, i, &value)); i++) {
|
||||||
@ -90,7 +96,7 @@ static REG_KEY *cmd_mkkey(REG_KEY *cur, int argc, char **argv)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], reg_key_get_path(cur));
|
fprintf(stderr, "Successfully added new subkey '%s' to '%s'\n", argv[1], reg_key_get_path_abs(cur));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -139,6 +145,11 @@ static REG_KEY *cmd_rmval(REG_KEY *cur, int argc, char **argv)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static REG_KEY *cmd_hive(REG_KEY *cur, int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
}
|
||||||
|
|
||||||
static REG_KEY *cmd_exit(REG_KEY *cur, int argc, char **argv)
|
static REG_KEY *cmd_exit(REG_KEY *cur, int argc, char **argv)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -154,10 +165,12 @@ struct {
|
|||||||
REG_KEY *(*handle)(REG_KEY *, int argc, char **argv);
|
REG_KEY *(*handle)(REG_KEY *, int argc, char **argv);
|
||||||
} regshell_cmds[] = {
|
} regshell_cmds[] = {
|
||||||
{"ck", "cd", "Change current key", cmd_ck },
|
{"ck", "cd", "Change current key", cmd_ck },
|
||||||
|
{"ch", "hive", "Change current hive", cmd_hive },
|
||||||
{"list", "ls", "List values/keys in current key", cmd_ls },
|
{"list", "ls", "List values/keys in current key", cmd_ls },
|
||||||
{"mkkey", "mkdir", "Make new key", cmd_mkkey },
|
{"mkkey", "mkdir", "Make new key", cmd_mkkey },
|
||||||
{"rmval", "rm", "Remove value", cmd_rmval },
|
{"rmval", "rm", "Remove value", cmd_rmval },
|
||||||
{"rmkey", "rmdir", "Remove key", cmd_rmkey },
|
{"rmkey", "rmdir", "Remove key", cmd_rmkey },
|
||||||
|
{"pwd", "pwk", "Printing current key", cmd_pwd },
|
||||||
{"set", "update", "Update value", cmd_set },
|
{"set", "update", "Update value", cmd_set },
|
||||||
{"help", "?", "Help", cmd_help },
|
{"help", "?", "Help", cmd_help },
|
||||||
{"exit", "quit", "Exit", cmd_exit },
|
{"exit", "quit", "Exit", cmd_exit },
|
||||||
@ -235,7 +248,7 @@ static REG_KEY *process_cmd(REG_KEY *k, char *line)
|
|||||||
while(True) {
|
while(True) {
|
||||||
char *line, *prompt;
|
char *line, *prompt;
|
||||||
|
|
||||||
asprintf(&prompt, "%s> ", reg_key_get_path(curkey));
|
asprintf(&prompt, "%s> ", reg_key_get_path_abs(curkey));
|
||||||
|
|
||||||
line = smb_readline(prompt, NULL, NULL);
|
line = smb_readline(prompt, NULL, NULL);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < l; i++) putchar(' ');
|
for(i = 0; i < l; i++) putchar(' ');
|
||||||
if(fullpath) printf("%s\n", reg_key_get_path(p));
|
if(fullpath) printf("%s\n", reg_key_get_path_abs(p));
|
||||||
else printf("%s\n", reg_key_name(p));
|
else printf("%s\n", reg_key_name(p));
|
||||||
|
|
||||||
for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(p, i, &subkey)); i++) {
|
for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(p, i, &subkey)); i++) {
|
||||||
@ -38,7 +38,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
|
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
|
||||||
DEBUG(0, ("Error occured while fetching subkeys for '%s': %s\n", reg_key_get_path(p), win_errstr(error)));
|
DEBUG(0, ("Error occured while fetching subkeys for '%s': %s\n", reg_key_get_path_abs(p), win_errstr(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!novals) {
|
if(!novals) {
|
||||||
@ -53,7 +53,7 @@ static void print_tree(int l, REG_KEY *p, int fullpath, int novals)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
|
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
|
||||||
DEBUG(0, ("Error occured while fetching values for '%s': %s\n", reg_key_get_path(p), win_errstr(error)));
|
DEBUG(0, ("Error occured while fetching values for '%s': %s\n", reg_key_get_path_abs(p), win_errstr(error)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user