mirror of
https://github.com/samba-team/samba.git
synced 2025-02-14 01:57:53 +03:00
Abstract opening of registry path out of libnet_smbconf_reg_open_service_key().
Creates new function libnet_smbconf_reg_open_path(). Use libnet_smbconf_reg_open_path() directly in libnet_smbconf_reg_open_basekey(). Return error in libnet_smbconf_reg_open_service_key() when NULL servicename is given. Michael (This used to be commit 1e46b479638c54e8bd7ba939bc7aba18a27b5155)
This commit is contained in:
parent
f9bb8a345e
commit
3bf57a4d82
@ -54,6 +54,42 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
|
|||||||
return WERR_OK;
|
return WERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a subkey of KEY_SMBCONF (i.e a service)
|
||||||
|
*/
|
||||||
|
static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
|
||||||
|
const char *path,
|
||||||
|
uint32 desired_access,
|
||||||
|
struct registry_key **key)
|
||||||
|
{
|
||||||
|
WERROR werr = WERR_OK;
|
||||||
|
NT_USER_TOKEN *token;
|
||||||
|
|
||||||
|
if (path == NULL) {
|
||||||
|
DEBUG(1, ("Error: NULL path string given\n"));
|
||||||
|
werr = WERR_INVALID_PARAM;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
token = registry_create_admin_token(mem_ctx);
|
||||||
|
if (token == NULL) {
|
||||||
|
DEBUG(1, ("Error creating admin token\n"));
|
||||||
|
/* what is the appropriate error code here? */
|
||||||
|
werr = WERR_CAN_NOT_COMPLETE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
werr = reg_open_path(mem_ctx, path, desired_access, token, key);
|
||||||
|
|
||||||
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
|
DEBUG(1, ("Error opening registry path '%s': %s\n",
|
||||||
|
path, dos_errstr(werr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
return werr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a subkey of KEY_SMBCONF (i.e a service)
|
* Open a subkey of KEY_SMBCONF (i.e a service)
|
||||||
*/
|
*/
|
||||||
@ -66,26 +102,15 @@ static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx,
|
|||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
NT_USER_TOKEN *token;
|
NT_USER_TOKEN *token;
|
||||||
|
|
||||||
if (!(token = registry_create_admin_token(ctx))) {
|
if (servicename == NULL) {
|
||||||
DEBUG(1, ("Error creating admin token\n"));
|
DEBUG(3, ("Error: NULL servicename given.\n"));
|
||||||
/* what is the appropriate error code here? */
|
werr = WERR_INVALID_PARAM;
|
||||||
werr = WERR_CAN_NOT_COMPLETE;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servicename == NULL) {
|
path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename);
|
||||||
path = talloc_strdup(ctx, KEY_SMBCONF);
|
|
||||||
} else {
|
|
||||||
path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename);
|
|
||||||
}
|
|
||||||
|
|
||||||
werr = reg_open_path(ctx, path, desired_access,
|
werr = libnet_smbconf_reg_open_path(ctx, path, desired_access, key);
|
||||||
token, key);
|
|
||||||
|
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
|
||||||
DEBUG(1, ("Error opening registry path '%s': %s\n",
|
|
||||||
path, dos_errstr(werr)));
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TALLOC_FREE(path);
|
TALLOC_FREE(path);
|
||||||
@ -99,8 +124,8 @@ static WERROR libnet_smbconf_reg_open_basekey(TALLOC_CTX *ctx,
|
|||||||
uint32 desired_access,
|
uint32 desired_access,
|
||||||
struct registry_key **key)
|
struct registry_key **key)
|
||||||
{
|
{
|
||||||
return libnet_smbconf_reg_open_service_key(ctx, NULL, desired_access,
|
return libnet_smbconf_reg_open_path(ctx, KEY_SMBCONF, desired_access,
|
||||||
key);
|
key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool libnet_smbconf_value_exists(struct registry_key *key,
|
static bool libnet_smbconf_value_exists(struct registry_key *key,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user