summaryrefslogtreecommitdiff
path: root/source3/libnet/libnet_conf.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-01-03 01:07:30 +0100
committerMichael Adam <obnox@samba.org>2008-01-03 01:29:43 +0100
commit3bf57a4d824b75dcbfea074e4e10d57f1d907682 (patch)
tree2082e2dea9113c9df975e8ce4a213e8cae5faee7 /source3/libnet/libnet_conf.c
parentf9bb8a345ed311f74adc30b164383170048b8dc5 (diff)
downloadsamba-3bf57a4d824b75dcbfea074e4e10d57f1d907682.tar.gz
samba-3bf57a4d824b75dcbfea074e4e10d57f1d907682.tar.bz2
samba-3bf57a4d824b75dcbfea074e4e10d57f1d907682.zip
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)
Diffstat (limited to 'source3/libnet/libnet_conf.c')
-rw-r--r--source3/libnet/libnet_conf.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index 7980dbbe4c..0bc7c63471 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -57,30 +57,29 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
/**
* Open a subkey of KEY_SMBCONF (i.e a service)
*/
-static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx,
- const char *servicename,
- uint32 desired_access,
- struct registry_key **key)
+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;
- char *path = NULL;
NT_USER_TOKEN *token;
- if (!(token = registry_create_admin_token(ctx))) {
+ 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;
}
- if (servicename == NULL) {
- path = talloc_strdup(ctx, KEY_SMBCONF);
- } else {
- path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename);
- }
-
- werr = reg_open_path(ctx, path, desired_access,
- token, key);
+ 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",
@@ -88,6 +87,32 @@ static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx,
}
done:
+ return werr;
+}
+
+/**
+ * Open a subkey of KEY_SMBCONF (i.e a service)
+ */
+static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx,
+ const char *servicename,
+ uint32 desired_access,
+ struct registry_key **key)
+{
+ WERROR werr = WERR_OK;
+ char *path = NULL;
+ NT_USER_TOKEN *token;
+
+ if (servicename == NULL) {
+ DEBUG(3, ("Error: NULL servicename given.\n"));
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename);
+
+ werr = libnet_smbconf_reg_open_path(ctx, path, desired_access, key);
+
+done:
TALLOC_FREE(path);
return werr;
}
@@ -99,8 +124,8 @@ static WERROR libnet_smbconf_reg_open_basekey(TALLOC_CTX *ctx,
uint32 desired_access,
struct registry_key **key)
{
- return libnet_smbconf_reg_open_service_key(ctx, NULL, desired_access,
- key);
+ return libnet_smbconf_reg_open_path(ctx, KEY_SMBCONF, desired_access,
+ key);
}
static bool libnet_smbconf_value_exists(struct registry_key *key,