mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
s3-registry: Convert registry key delimiter from slash to backslash.
This is needed to support keynames containing a '/' like TCP/IP. Which is used in serveral standard paths. Signed-off-by: Michael Adam <obnox@samba.org>
This commit is contained in:
parent
f540833632
commit
15bacaf3c5
@ -46,7 +46,7 @@ static bool trim_tree_keypath( char *path, char **base, char **new_path )
|
||||
|
||||
*base = path;
|
||||
|
||||
p = strchr( path, '/' );
|
||||
p = strchr( path, '\\' );
|
||||
|
||||
if ( p ) {
|
||||
*p = '\0';
|
||||
@ -214,7 +214,7 @@ WERROR pathtree_add(struct sorted_tree *tree, const char *path, void *data_p)
|
||||
|
||||
DEBUG(8,("pathtree_add: Enter\n"));
|
||||
|
||||
if ( !path || *path != '/' ) {
|
||||
if ( !path || *path != '\\' ) {
|
||||
DEBUG(0,("pathtree_add: Attempt to add a node with a bad path [%s]\n",
|
||||
path ? path : "NULL" ));
|
||||
return WERR_INVALID_PARAM;
|
||||
@ -225,7 +225,7 @@ WERROR pathtree_add(struct sorted_tree *tree, const char *path, void *data_p)
|
||||
return WERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
/* move past the first '/' */
|
||||
/* move past the first '\\' */
|
||||
|
||||
path++;
|
||||
path2 = SMB_STRDUP( path );
|
||||
@ -248,7 +248,7 @@ WERROR pathtree_add(struct sorted_tree *tree, const char *path, void *data_p)
|
||||
do {
|
||||
/* break off the remaining part of the path */
|
||||
|
||||
str = strchr( str, '/' );
|
||||
str = strchr( str, '\\' );
|
||||
if ( str )
|
||||
*str = '\0';
|
||||
|
||||
@ -269,7 +269,7 @@ WERROR pathtree_add(struct sorted_tree *tree, const char *path, void *data_p)
|
||||
|
||||
base = str;
|
||||
if ( base ) {
|
||||
*base = '/';
|
||||
*base = '\\';
|
||||
base++;
|
||||
str = base;
|
||||
}
|
||||
@ -384,7 +384,7 @@ void* pathtree_find(struct sorted_tree *tree, char *key )
|
||||
|
||||
/* make a copy to play with */
|
||||
|
||||
if ( *key == '/' )
|
||||
if ( *key == '\\' )
|
||||
keystr = SMB_STRDUP( key+1 );
|
||||
else
|
||||
keystr = SMB_STRDUP( key );
|
||||
|
@ -475,16 +475,6 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
|
||||
char *path, *end;
|
||||
WERROR err;
|
||||
|
||||
/*
|
||||
* We must refuse to handle subkey-paths containing
|
||||
* a '/' character because at a lower level, after
|
||||
* normalization, '/' is treated as a key separator
|
||||
* just like '\\'.
|
||||
*/
|
||||
if (strchr(subkeypath, '/') != NULL) {
|
||||
return WERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!(mem_ctx = talloc_new(ctx))) return WERR_NOMEM;
|
||||
|
||||
if (!(path = talloc_strdup(mem_ctx, subkeypath))) {
|
||||
|
@ -641,7 +641,7 @@ static WERROR regdb_delete_key_with_prefix(struct db_context *db,
|
||||
if (prefix == NULL) {
|
||||
path = discard_const_p(char, keyname);
|
||||
} else {
|
||||
path = talloc_asprintf(mem_ctx, "%s/%s", prefix, keyname);
|
||||
path = talloc_asprintf(mem_ctx, "%s\\%s", prefix, keyname);
|
||||
if (path == NULL) {
|
||||
goto done;
|
||||
}
|
||||
@ -686,14 +686,14 @@ static WERROR regdb_delete_key_lists(struct db_context *db, const char *keyname)
|
||||
|
||||
werr = regdb_delete_values(db, keyname);
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
|
||||
DEBUG(1, (__location__ " Deleting %s\\%s failed: %s\n",
|
||||
REG_VALUE_PREFIX, keyname, win_errstr(werr)));
|
||||
goto done;
|
||||
}
|
||||
|
||||
werr = regdb_delete_secdesc(db, keyname);
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
|
||||
DEBUG(1, (__location__ " Deleting %s\\%s failed: %s\n",
|
||||
REG_SECDESC_PREFIX, keyname, win_errstr(werr)));
|
||||
goto done;
|
||||
}
|
||||
@ -806,7 +806,7 @@ static WERROR regdb_store_keys_internal2(struct db_context *db,
|
||||
* Delete a sorted subkey cache for regdb_key_exists, will be
|
||||
* recreated automatically
|
||||
*/
|
||||
keyname = talloc_asprintf(ctx, "%s/%s", REG_SORTED_SUBKEYS_PREFIX,
|
||||
keyname = talloc_asprintf(ctx, "%s\\%s", REG_SORTED_SUBKEYS_PREFIX,
|
||||
keyname);
|
||||
if (keyname == NULL) {
|
||||
werr = WERR_NOMEM;
|
||||
@ -897,7 +897,7 @@ static NTSTATUS regdb_store_keys_action(struct db_context *db,
|
||||
continue;
|
||||
}
|
||||
|
||||
path = talloc_asprintf(mem_ctx, "%s/%s", store_ctx->key,
|
||||
path = talloc_asprintf(mem_ctx, "%s\\%s", store_ctx->key,
|
||||
oldkeyname);
|
||||
if (!path) {
|
||||
werr = WERR_NOMEM;
|
||||
@ -941,7 +941,7 @@ static NTSTATUS regdb_store_keys_action(struct db_context *db,
|
||||
}
|
||||
|
||||
for (i=0; i<num_subkeys; i++) {
|
||||
path = talloc_asprintf(mem_ctx, "%s/%s", store_ctx->key,
|
||||
path = talloc_asprintf(mem_ctx, "%s\\%s", store_ctx->key,
|
||||
regsubkey_ctr_specific_key(store_ctx->ctr, i));
|
||||
if (!path) {
|
||||
werr = WERR_NOMEM;
|
||||
@ -1184,7 +1184,7 @@ static WERROR regdb_delete_subkey(const char *key, const char *subkey)
|
||||
goto done;
|
||||
}
|
||||
|
||||
path = talloc_asprintf(mem_ctx, "%s/%s", key, subkey);
|
||||
path = talloc_asprintf(mem_ctx, "%s\\%s", key, subkey);
|
||||
if (path == NULL) {
|
||||
werr = WERR_NOMEM;
|
||||
goto done;
|
||||
@ -1228,7 +1228,7 @@ static TDB_DATA regdb_fetch_key_internal(struct db_context *db,
|
||||
|
||||
/**
|
||||
* check whether a given key name represents a base key,
|
||||
* i.e one without a subkey separator ('/' or '\').
|
||||
* i.e one without a subkey separator ('\').
|
||||
*/
|
||||
static bool regdb_key_is_base_key(const char *key)
|
||||
{
|
||||
@ -1250,7 +1250,7 @@ static bool regdb_key_is_base_key(const char *key)
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = (strrchr(path, '/') == NULL);
|
||||
ret = (strrchr(path, '\\') == NULL);
|
||||
|
||||
done:
|
||||
TALLOC_FREE(mem_ctx);
|
||||
@ -1453,7 +1453,7 @@ static bool scan_parent_subkeys(struct db_context *db, const char *parent,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
key = talloc_asprintf(talloc_tos(), "%s/%s",
|
||||
key = talloc_asprintf(talloc_tos(), "%s\\%s",
|
||||
REG_SORTED_SUBKEYS_PREFIX, path);
|
||||
if (key == NULL) {
|
||||
goto fail;
|
||||
@ -1533,7 +1533,7 @@ static bool regdb_key_exists(struct db_context *db, const char *key)
|
||||
goto done;
|
||||
}
|
||||
|
||||
p = strrchr(path, '/');
|
||||
p = strrchr(path, '\\');
|
||||
if (p == NULL) {
|
||||
/* this is a base key */
|
||||
value = regdb_fetch_key_internal(db, mem_ctx, path);
|
||||
@ -1727,7 +1727,7 @@ static int regdb_fetch_values_internal(struct db_context *db, const char* key,
|
||||
goto done;
|
||||
}
|
||||
|
||||
keystr = talloc_asprintf(ctx, "%s/%s", REG_VALUE_PREFIX, key);
|
||||
keystr = talloc_asprintf(ctx, "%s\\%s", REG_VALUE_PREFIX, key);
|
||||
if (!keystr) {
|
||||
goto done;
|
||||
}
|
||||
@ -1786,7 +1786,7 @@ static bool regdb_store_values_internal(struct db_context *db, const char *key,
|
||||
|
||||
SMB_ASSERT( len == data.dsize );
|
||||
|
||||
keystr = talloc_asprintf(ctx, "%s/%s", REG_VALUE_PREFIX, key );
|
||||
keystr = talloc_asprintf(ctx, "%s\\%s", REG_VALUE_PREFIX, key );
|
||||
if (!keystr) {
|
||||
goto done;
|
||||
}
|
||||
@ -1835,7 +1835,7 @@ static WERROR regdb_get_secdesc(TALLOC_CTX *mem_ctx, const char *key,
|
||||
goto done;
|
||||
}
|
||||
|
||||
tdbkey = talloc_asprintf(tmp_ctx, "%s/%s", REG_SECDESC_PREFIX, key);
|
||||
tdbkey = talloc_asprintf(tmp_ctx, "%s\\%s", REG_SECDESC_PREFIX, key);
|
||||
if (tdbkey == NULL) {
|
||||
err = WERR_NOMEM;
|
||||
goto done;
|
||||
@ -1880,7 +1880,7 @@ static WERROR regdb_set_secdesc(const char *key,
|
||||
goto done;
|
||||
}
|
||||
|
||||
tdbkey = talloc_asprintf(mem_ctx, "%s/%s", REG_SECDESC_PREFIX, key);
|
||||
tdbkey = talloc_asprintf(mem_ctx, "%s\\%s", REG_SECDESC_PREFIX, key);
|
||||
if (tdbkey == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -46,12 +46,6 @@ static WERROR keyname_to_path(TALLOC_CTX *mem_ctx, const char *keyname,
|
||||
return WERR_NOMEM;
|
||||
}
|
||||
|
||||
tmp_path = talloc_string_sub(mem_ctx, tmp_path, "\\", "/");
|
||||
if (tmp_path == NULL) {
|
||||
DEBUG(0, ("talloc_string_sub_failed!\n"));
|
||||
return WERR_NOMEM;
|
||||
}
|
||||
|
||||
*path = tmp_path;
|
||||
|
||||
return WERR_OK;
|
||||
|
@ -86,9 +86,8 @@ bool reg_split_key(char *path, char **base, char **key)
|
||||
}
|
||||
|
||||
/**
|
||||
* The full path to the registry key is used as database key
|
||||
* after the \'s are converted to /'s.
|
||||
* Leading and trailing '/' and '\' characters are stripped.
|
||||
* The full path to the registry key is used as database key.
|
||||
* Leading and trailing '\' characters are stripped.
|
||||
* Key string is also normalized to UPPER case.
|
||||
*/
|
||||
|
||||
@ -97,22 +96,22 @@ char *normalize_reg_path(TALLOC_CTX *ctx, const char *keyname )
|
||||
char *p;
|
||||
char *nkeyname;
|
||||
|
||||
/* skip leading '/' and '\' chars */
|
||||
/* skip leading '\' chars */
|
||||
p = (char *)keyname;
|
||||
while ((*p == '/') || (*p == '\\')) {
|
||||
while (*p == '\\') {
|
||||
p++;
|
||||
}
|
||||
|
||||
nkeyname = talloc_string_sub(ctx, p, "\\", "/");
|
||||
nkeyname = talloc_strdup(ctx, p);
|
||||
if (nkeyname == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* strip trailing '/' chars */
|
||||
p = strrchr(nkeyname, '/');
|
||||
/* strip trailing '\' chars */
|
||||
p = strrchr(nkeyname, '\\');
|
||||
while ((p != NULL) && (p[1] == '\0')) {
|
||||
*p = '\0';
|
||||
p = strrchr(nkeyname, '/');
|
||||
p = strrchr(nkeyname, '\\');
|
||||
}
|
||||
|
||||
strupper_m(nkeyname);
|
||||
@ -139,11 +138,7 @@ char *reg_remaining_path(TALLOC_CTX *ctx, const char *key)
|
||||
}
|
||||
/* normalize_reg_path( new_path ); */
|
||||
if (!(p = strchr(new_path, '\\')) ) {
|
||||
if (!(p = strchr( new_path, '/'))) {
|
||||
p = new_path;
|
||||
} else {
|
||||
p++;
|
||||
}
|
||||
p = new_path;
|
||||
} else {
|
||||
p++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user