From 1b5c1ae7424ba2fad857adf3701a5809ba3b27fe Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 11 Dec 2007 21:21:17 +0100 Subject: Very quick conversion of net_conf functions into the libnet_conf layer. Certainly needs cleanup later. Guenther (This used to be commit 2b41ac926de76804a50681bd246b3a20e112853b) --- source3/libnet/libnet_conf.c | 149 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 source3/libnet/libnet_conf.c (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c new file mode 100644 index 0000000000..f394e02e20 --- /dev/null +++ b/source3/libnet/libnet_conf.c @@ -0,0 +1,149 @@ +/* + * Unix SMB/CIFS implementation. + * libnet smbconf registry Support + * Copyright (C) Michael Adam 2007 + * Copyright (C) Guenther Deschner 2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "includes.h" + +/* + * Open a subkey of KEY_SMBCONF (i.e a service) + * - variant without error output (q = quiet)- + */ +WERROR libnet_smbconf_open_path_q(TALLOC_CTX *ctx, const char *subkeyname, + 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))) { + DEBUG(1, ("Error creating admin token\n")); + goto done; + } + + if (subkeyname == NULL) { + path = talloc_strdup(ctx, KEY_SMBCONF); + } else { + path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, subkeyname); + } + + werr = reg_open_path(ctx, path, desired_access, + token, key); + +done: + TALLOC_FREE(path); + return werr; +} + +/* + * check if a subkey of KEY_SMBCONF of a given name exists + */ +bool libnet_smbconf_key_exists(TALLOC_CTX *ctx, const char *subkeyname) +{ + bool ret = False; + WERROR werr = WERR_OK; + TALLOC_CTX *mem_ctx; + struct registry_key *key; + + if (!(mem_ctx = talloc_new(ctx))) { + d_fprintf(stderr, "ERROR: Out of memory...!\n"); + goto done; + } + + werr = libnet_smbconf_open_path_q(mem_ctx, subkeyname, REG_KEY_READ, &key); + if (W_ERROR_IS_OK(werr)) { + ret = True; + } + +done: + TALLOC_FREE(mem_ctx); + return ret; +} + +/* + * Open a subkey of KEY_SMBCONF (i.e a service) + * - variant with error output - + */ +WERROR libnet_smbconf_open_path(TALLOC_CTX *ctx, const char *subkeyname, + uint32 desired_access, + struct registry_key **key) +{ + WERROR werr = WERR_OK; + + werr = libnet_smbconf_open_path_q(ctx, subkeyname, desired_access, key); + if (!W_ERROR_IS_OK(werr)) { + d_fprintf(stderr, "Error opening registry path '%s\\%s': %s\n", + KEY_SMBCONF, + (subkeyname == NULL) ? "" : subkeyname, + dos_errstr(werr)); + } + + return werr; +} + +/* + * open the base key KEY_SMBCONF + */ +WERROR libnet_smbconf_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, + struct registry_key **key) +{ + return libnet_smbconf_open_path(ctx, NULL, desired_access, key); +} + +/* + * create a subkey of KEY_SMBCONF + */ +WERROR libnet_reg_createkey_internal(TALLOC_CTX *ctx, + const char * subkeyname, + struct registry_key **newkey) +{ + WERROR werr = WERR_OK; + struct registry_key *create_parent = NULL; + TALLOC_CTX *create_ctx; + enum winreg_CreateAction action = REG_ACTION_NONE; + + /* create a new talloc ctx for creation. it will hold + * the intermediate parent key (SMBCONF) for creation + * and will be destroyed when leaving this function... */ + if (!(create_ctx = talloc_new(ctx))) { + werr = WERR_NOMEM; + goto done; + } + + werr = libnet_smbconf_open_basepath(create_ctx, REG_KEY_WRITE, &create_parent); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = reg_createkey(ctx, create_parent, subkeyname, + REG_KEY_WRITE, newkey, &action); + if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) { + d_fprintf(stderr, "Key '%s' already exists.\n", subkeyname); + werr = WERR_ALREADY_EXISTS; + } + if (!W_ERROR_IS_OK(werr)) { + d_fprintf(stderr, "Error creating key %s: %s\n", + subkeyname, dos_errstr(werr)); + } + +done: + TALLOC_FREE(create_ctx); + return werr; +} + -- cgit From 991112eda710c97dff607dd615c777023395da65 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 19 Dec 2007 16:07:40 +0100 Subject: Implement NetServerSetInfo level 1005 in local mode with smbconf registry. Guenther (This used to be commit 15c2bc15f20a677c3c94895150e396275de6ac9b) --- source3/libnet/libnet_conf.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index f394e02e20..8bc5161268 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -147,3 +147,49 @@ done: return werr; } +static WERROR do_modify_val_config(struct registry_key *key, + const char *val_name, + const char *val_data) +{ + struct registry_value val; + + ZERO_STRUCT(val); + + val.type = REG_SZ; + val.v.sz.str = CONST_DISCARD(char *, val_data); + val.v.sz.len = strlen(val_data) + 1; + + return reg_setvalue(key, val_name, &val); +} + +WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, + const char *param, + const char *val) +{ + WERROR werr; + struct registry_key *key = NULL; + + if (!lp_include_registry_globals()) { + return WERR_NOT_SUPPORTED; + } + + if (!registry_init_regdb()) { + return WERR_REG_IO_FAILURE; + } + + if (!libnet_smbconf_key_exists(mem_ctx, GLOBAL_NAME)) { + werr = libnet_reg_createkey_internal(mem_ctx, + GLOBAL_NAME, &key); + } else { + werr = libnet_smbconf_open_path(mem_ctx, + GLOBAL_NAME, + REG_KEY_WRITE, &key); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + return do_modify_val_config(key, param, val); +} + -- cgit From aeea4bfadd98f23df71c5754bef7defc42d2f67f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 01:43:13 +0100 Subject: Make libnet_smbconf_open_path_q() static. Michael (This used to be commit 8cf8ed9de8c3f41588fa93bd102f61f5b8b493c4) --- source3/libnet/libnet_conf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 8bc5161268..dcaa7689b3 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -24,9 +24,10 @@ * Open a subkey of KEY_SMBCONF (i.e a service) * - variant without error output (q = quiet)- */ -WERROR libnet_smbconf_open_path_q(TALLOC_CTX *ctx, const char *subkeyname, - uint32 desired_access, - struct registry_key **key) +static WERROR libnet_smbconf_open_path_q(TALLOC_CTX *ctx, + const char *subkeyname, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; -- cgit From ec3e8587ecdef8e4a52d4c37ac379d9e414b861b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 02:44:29 +0100 Subject: Move smbconf_value_exists() to libnet/net_conf.c renaming it to libnet_smbconf_value_exists(). Michael (This used to be commit ba71c6844588f0342589163f514385911e7331e7) --- source3/libnet/libnet_conf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index dcaa7689b3..9f64e7fc0d 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -194,3 +194,20 @@ WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, return do_modify_val_config(key, param, val); } +bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, + struct registry_key *key, + const char *param) +{ + bool ret = False; + WERROR werr = WERR_OK; + struct registry_value *value = NULL; + + werr = reg_queryvalue(ctx, key, param, &value); + if (W_ERROR_IS_OK(werr)) { + ret = True; + } + + TALLOC_FREE(value); + return ret; +} + -- cgit From b04708866f146ada8a7cc353347244df54821fbf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 02:55:25 +0100 Subject: Move logic of net_smbconf_delparm() to libnet/libnet_conf.c Logic in new function libnet_smbconf_delparm(). Michael (This used to be commit 0cff79e3552e91ba0b6bc054802d28afcf4e8da4) --- source3/libnet/libnet_conf.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 9f64e7fc0d..960ee80dbc 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -194,7 +194,7 @@ WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, return do_modify_val_config(key, param, val); } -bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, +static bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, struct registry_key *key, const char *param) { @@ -211,3 +211,26 @@ bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, return ret; } +WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, + const char *service, + const char *param) +{ + struct registry_key *key = NULL; + WERROR werr = WERR_OK; + + if (!libnet_smbconf_key_exists(mem_ctx, service)) { + return WERR_NO_SUCH_SERVICE; + } + + werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key); + W_ERROR_NOT_OK_RETURN(werr); + + if (!libnet_smbconf_value_exists(mem_ctx, key, param)) { + return WERR_INVALID_PARAM; + } + + werr = reg_deletevalue(key, param); + W_ERROR_NOT_OK_RETURN(werr); + + return WERR_OK; +} -- cgit From 31d436e54c2ec56ae59527feb9a31d13eca44f6d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 03:34:36 +0100 Subject: Move reg_setvalue_internal() to libnet_conf.c renaming it to libnet_smbconf_setvalue_internal() Michael (This used to be commit 7cb51a1d6d95704225d9ab22e88cc76fa910d38c) --- source3/libnet/libnet_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 960ee80dbc..d42e5ad227 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -148,6 +148,78 @@ done: return werr; } + +/* + * add a value to a key. + */ +WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, + const char *valname, + const char *valstr) +{ + struct registry_value val; + WERROR werr = WERR_OK; + char *subkeyname; + const char *canon_valname; + const char *canon_valstr; + + if (!lp_canonicalize_parameter_with_value(valname, valstr, + &canon_valname, + &canon_valstr)) + { + if (canon_valname == NULL) { + d_fprintf(stderr, "invalid parameter '%s' given\n", + valname); + } else { + d_fprintf(stderr, "invalid value '%s' given for " + "parameter '%s'\n", valstr, valname); + } + werr = WERR_INVALID_PARAM; + goto done; + } + + ZERO_STRUCT(val); + + val.type = REG_SZ; + val.v.sz.str = CONST_DISCARD(char *, canon_valstr); + val.v.sz.len = strlen(canon_valstr) + 1; + + if (registry_smbconf_valname_forbidden(canon_valname)) { + d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n", + canon_valname); + werr = WERR_INVALID_PARAM; + goto done; + } + + subkeyname = strrchr_m(key->key->name, '\\'); + if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) { + d_fprintf(stderr, "Invalid registry key '%s' given as " + "smbconf section.\n", key->key->name); + werr = WERR_INVALID_PARAM; + goto done; + } + subkeyname++; + if (!strequal(subkeyname, GLOBAL_NAME) && + lp_parameter_is_global(valname)) + { + d_fprintf(stderr, "Global paramter '%s' not allowed in " + "service definition ('%s').\n", canon_valname, + subkeyname); + werr = WERR_INVALID_PARAM; + goto done; + } + + werr = reg_setvalue(key, canon_valname, &val); + if (!W_ERROR_IS_OK(werr)) { + d_fprintf(stderr, + "Error adding value '%s' to " + "key '%s': %s\n", + canon_valname, key->key->name, dos_errstr(werr)); + } + +done: + return werr; +} + static WERROR do_modify_val_config(struct registry_key *key, const char *val_name, const char *val_data) -- cgit From 62f08d3dd9b1f1d53a8e9ecf352fbbfb4c12c484 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 03:41:55 +0100 Subject: Move net_conf_setparm() to libnet_conf.c renaming it to libnet_smbconf_setparm() Michael (This used to be commit 60f49b22b5aa125ff6cb358a258a1be99c378d7a) --- source3/libnet/libnet_conf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index d42e5ad227..00dc1d473d 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -235,6 +235,27 @@ static WERROR do_modify_val_config(struct registry_key *key, return reg_setvalue(key, val_name, &val); } +WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, + const char *service, + const char *param, + const char *valstr) +{ + WERROR werr; + struct registry_key *key = NULL; + + if (!libnet_smbconf_key_exists(mem_ctx, service)) { + werr = libnet_reg_createkey_internal(mem_ctx, service, &key); + } else { + werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_WRITE, + &key); + } + W_ERROR_NOT_OK_RETURN(werr); + + werr = libnet_smbconf_reg_setvalue_internal(key, param, valstr); + + return werr; +} + WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, const char *param, const char *val) -- cgit From b6527f3d29dccc4b86252e7d6722371e61870e80 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 03:47:16 +0100 Subject: Reorder libnet_conf.c some, adding "section" comments. Michael (This used to be commit b9f22adfd3e67046b7d786b5b338e078b4cdc6df) --- source3/libnet/libnet_conf.c | 48 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 00dc1d473d..f364e4fb64 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -20,6 +20,13 @@ #include "includes.h" +/********************************************************************** + * + * Helper functions (mostly registry related) + * TODO: These should be eventually static. + + **********************************************************************/ + /* * Open a subkey of KEY_SMBCONF (i.e a service) * - variant without error output (q = quiet)- @@ -77,6 +84,23 @@ done: return ret; } +static bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, + struct registry_key *key, + const char *param) +{ + bool ret = False; + WERROR werr = WERR_OK; + struct registry_value *value = NULL; + + werr = reg_queryvalue(ctx, key, param, &value); + if (W_ERROR_IS_OK(werr)) { + ret = True; + } + + TALLOC_FREE(value); + return ret; +} + /* * Open a subkey of KEY_SMBCONF (i.e a service) * - variant with error output - @@ -148,7 +172,6 @@ done: return werr; } - /* * add a value to a key. */ @@ -235,6 +258,12 @@ static WERROR do_modify_val_config(struct registry_key *key, return reg_setvalue(key, val_name, &val); } +/********************************************************************** + * + * The actual net conf api functions, that are exported. + * + **********************************************************************/ + WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, const char *service, const char *param, @@ -287,23 +316,6 @@ WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, return do_modify_val_config(key, param, val); } -static bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, - struct registry_key *key, - const char *param) -{ - bool ret = False; - WERROR werr = WERR_OK; - struct registry_value *value = NULL; - - werr = reg_queryvalue(ctx, key, param, &value); - if (W_ERROR_IS_OK(werr)) { - ret = True; - } - - TALLOC_FREE(value); - return ret; -} - WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, const char *service, const char *param) -- cgit From a48f3c8a964fe6b320a052a6251354351f8d98e0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 03:52:00 +0100 Subject: Make libnet_smbconf_set_global_param() call libnet_smbconf_setparm(). This not only removes duplicate logic, but also the use of libnet_smbconf_reg_setvalue_internal() instead of do_modify_val_config() which is removed, does add important tests and canonicalizations. Michael (This used to be commit fa844866493ee270f31faa3eca77cdff16b26301) --- source3/libnet/libnet_conf.c | 61 +++++++++++--------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index f364e4fb64..9d06f8287b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,21 +243,6 @@ done: return werr; } -static WERROR do_modify_val_config(struct registry_key *key, - const char *val_name, - const char *val_data) -{ - struct registry_value val; - - ZERO_STRUCT(val); - - val.type = REG_SZ; - val.v.sz.str = CONST_DISCARD(char *, val_data); - val.v.sz.len = strlen(val_data) + 1; - - return reg_setvalue(key, val_name, &val); -} - /********************************************************************** * * The actual net conf api functions, that are exported. @@ -285,37 +270,6 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, return werr; } -WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, - const char *param, - const char *val) -{ - WERROR werr; - struct registry_key *key = NULL; - - if (!lp_include_registry_globals()) { - return WERR_NOT_SUPPORTED; - } - - if (!registry_init_regdb()) { - return WERR_REG_IO_FAILURE; - } - - if (!libnet_smbconf_key_exists(mem_ctx, GLOBAL_NAME)) { - werr = libnet_reg_createkey_internal(mem_ctx, - GLOBAL_NAME, &key); - } else { - werr = libnet_smbconf_open_path(mem_ctx, - GLOBAL_NAME, - REG_KEY_WRITE, &key); - } - - if (!W_ERROR_IS_OK(werr)) { - return werr; - } - - return do_modify_val_config(key, param, val); -} - WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, const char *service, const char *param) @@ -339,3 +293,18 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, return WERR_OK; } + + +/********************************************************************** + * + * Convenience functions, that are also exportet. + * + **********************************************************************/ + +WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, + const char *param, + const char *val) +{ + return libnet_smbconf_setparm(mem_ctx, GLOBAL_NAME, param, val); +} + -- cgit From d1c2280cd44e40a4398115c7d862ac0c296c98bc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 04:10:15 +0100 Subject: Rename libnet_reg_createkey_internal() to libnet_smbconf_reg_createkey_internal(). Michael (This used to be commit 0e7f215f54c68b2d40f65f90ed11c41e1a7ef5ed) --- source3/libnet/libnet_conf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 9d06f8287b..69a105f8f5 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -134,9 +134,9 @@ WERROR libnet_smbconf_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, /* * create a subkey of KEY_SMBCONF */ -WERROR libnet_reg_createkey_internal(TALLOC_CTX *ctx, - const char * subkeyname, - struct registry_key **newkey) +WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, + const char * subkeyname, + struct registry_key **newkey) { WERROR werr = WERR_OK; struct registry_key *create_parent = NULL; @@ -258,7 +258,8 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, struct registry_key *key = NULL; if (!libnet_smbconf_key_exists(mem_ctx, service)) { - werr = libnet_reg_createkey_internal(mem_ctx, service, &key); + werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, + &key); } else { werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_WRITE, &key); -- cgit From 8f163d5c5ae48a3ff1974e936b9316781eceff8a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 15:07:20 +0100 Subject: Move logic of net_conf_getparm() to libnet_conf.c. Michael (This used to be commit d3a20c4d5a8109334cd3ed665ba60cfcc4425059) --- source3/libnet/libnet_conf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 69a105f8f5..121ec35468 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -271,6 +271,30 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, return werr; } +WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, + const char *service, + const char *param, + struct registry_value **value) +{ + WERROR werr; + struct registry_key *key = NULL; + + if (!libnet_smbconf_key_exists(mem_ctx, service)) { + return WERR_NO_SUCH_SERVICE; + } + + werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key); + W_ERROR_NOT_OK_RETURN(werr); + + if (!libnet_smbconf_value_exists(mem_ctx, key, param)) { + return WERR_INVALID_PARAM; + } + + werr = reg_queryvalue(mem_ctx, key, param, value); + + return werr; +} + WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, const char *service, const char *param) -- cgit From 6306005f4c12275df2f0cd2c2a95493bea36824d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 23:02:47 +0100 Subject: Remove redundant check of return value. Michael (This used to be commit 29f46c2d45e7ad7f8a9a525f9ac82c050a510967) --- source3/libnet/libnet_conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 121ec35468..9eb5c16adc 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -314,9 +314,8 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, } werr = reg_deletevalue(key, param); - W_ERROR_NOT_OK_RETURN(werr); - return WERR_OK; + return werr; } -- cgit From 44860bce54d448316d2ac0bb9b0a2d0677d6c4eb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 23 Dec 2007 23:58:58 +0100 Subject: Fix rights error in libnet_smbconf_delparm(). Introduced by additional test for existence of given parameter. Michael (This used to be commit 0fe095e85ca981e5660a67f3fb7d7965ae62c667) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 9eb5c16adc..3a64c3d844 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -306,7 +306,7 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, return WERR_NO_SUCH_SERVICE; } - werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key); + werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_ALL, &key); W_ERROR_NOT_OK_RETURN(werr); if (!libnet_smbconf_value_exists(mem_ctx, key, param)) { -- cgit From 225dbe6c02e45b30541acb21f60cc20ddcfbf362 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 24 Dec 2007 00:47:43 +0100 Subject: Don't leak memory in libnet_smbconf_getparm(). Michael (This used to be commit 09e62c765401102480d39a483bfffaf5a054babc) --- source3/libnet/libnet_conf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3a64c3d844..d9a9e7de9b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -280,18 +280,24 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, struct registry_key *key = NULL; if (!libnet_smbconf_key_exists(mem_ctx, service)) { - return WERR_NO_SUCH_SERVICE; + werr = WERR_NO_SUCH_SERVICE; + goto done; } werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key); - W_ERROR_NOT_OK_RETURN(werr); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } if (!libnet_smbconf_value_exists(mem_ctx, key, param)) { - return WERR_INVALID_PARAM; + werr = WERR_INVALID_PARAM; + goto done; } werr = reg_queryvalue(mem_ctx, key, param, value); +done: + TALLOC_FREE(key); return werr; } -- cgit From c74579f49149171e731ae9b5a8e77c579d120cbb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 24 Dec 2007 00:53:22 +0100 Subject: Make libnet_smbconf_key_exists() use talloc_stackframe(). And not pass a talloc context. Michael (This used to be commit 7e8451f2f03b246801783aaf4b3d54465292f8f7) --- source3/libnet/libnet_conf.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index d9a9e7de9b..26e17f2ea3 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -62,24 +62,18 @@ done: /* * check if a subkey of KEY_SMBCONF of a given name exists */ -bool libnet_smbconf_key_exists(TALLOC_CTX *ctx, const char *subkeyname) +bool libnet_smbconf_key_exists(const char *subkeyname) { bool ret = False; WERROR werr = WERR_OK; - TALLOC_CTX *mem_ctx; - struct registry_key *key; - - if (!(mem_ctx = talloc_new(ctx))) { - d_fprintf(stderr, "ERROR: Out of memory...!\n"); - goto done; - } + TALLOC_CTX *mem_ctx = talloc_stackframe(); + struct registry_key *key = NULL; werr = libnet_smbconf_open_path_q(mem_ctx, subkeyname, REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = True; } -done: TALLOC_FREE(mem_ctx); return ret; } @@ -257,7 +251,7 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, WERROR werr; struct registry_key *key = NULL; - if (!libnet_smbconf_key_exists(mem_ctx, service)) { + if (!libnet_smbconf_key_exists(service)) { werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, &key); } else { @@ -279,7 +273,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, WERROR werr; struct registry_key *key = NULL; - if (!libnet_smbconf_key_exists(mem_ctx, service)) { + if (!libnet_smbconf_key_exists(service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } @@ -308,7 +302,7 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, struct registry_key *key = NULL; WERROR werr = WERR_OK; - if (!libnet_smbconf_key_exists(mem_ctx, service)) { + if (!libnet_smbconf_key_exists(service)) { return WERR_NO_SUCH_SERVICE; } -- cgit From 434f0bcb02fe9df247527e1fa0372c94359f2f07 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 24 Dec 2007 00:56:24 +0100 Subject: Make libnet_smbconf_value_exists() use talloc_stackframe(). And not pass a talloc context. Michael (This used to be commit 2983aba9d092e6ede43f6eb521c17fe3f304d041) --- source3/libnet/libnet_conf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 26e17f2ea3..35eb740588 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -78,12 +78,12 @@ bool libnet_smbconf_key_exists(const char *subkeyname) return ret; } -static bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, - struct registry_key *key, +static bool libnet_smbconf_value_exists(struct registry_key *key, const char *param) { bool ret = False; WERROR werr = WERR_OK; + TALLOC_CTX *ctx = talloc_stackframe(); struct registry_value *value = NULL; werr = reg_queryvalue(ctx, key, param, &value); @@ -91,7 +91,7 @@ static bool libnet_smbconf_value_exists(TALLOC_CTX *ctx, ret = True; } - TALLOC_FREE(value); + TALLOC_FREE(ctx); return ret; } @@ -283,7 +283,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - if (!libnet_smbconf_value_exists(mem_ctx, key, param)) { + if (!libnet_smbconf_value_exists(key, param)) { werr = WERR_INVALID_PARAM; goto done; } @@ -309,7 +309,7 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_ALL, &key); W_ERROR_NOT_OK_RETURN(werr); - if (!libnet_smbconf_value_exists(mem_ctx, key, param)) { + if (!libnet_smbconf_value_exists(key, param)) { return WERR_INVALID_PARAM; } -- cgit From 92b1ef15df560c9cc0429bc5ecb4084efe05610f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 24 Dec 2007 00:57:04 +0100 Subject: Use the appropriate boolean constants. Michael (This used to be commit 45e3e2451adc1490b62d39d486c169ad53e1d3f3) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 35eb740588..ebf2d6654f 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -64,14 +64,14 @@ done: */ bool libnet_smbconf_key_exists(const char *subkeyname) { - bool ret = False; + bool ret = false; WERROR werr = WERR_OK; TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; werr = libnet_smbconf_open_path_q(mem_ctx, subkeyname, REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { - ret = True; + ret = true; } TALLOC_FREE(mem_ctx); @@ -81,14 +81,14 @@ bool libnet_smbconf_key_exists(const char *subkeyname) static bool libnet_smbconf_value_exists(struct registry_key *key, const char *param) { - bool ret = False; + bool ret = false; WERROR werr = WERR_OK; TALLOC_CTX *ctx = talloc_stackframe(); struct registry_value *value = NULL; werr = reg_queryvalue(ctx, key, param, &value); if (W_ERROR_IS_OK(werr)) { - ret = True; + ret = true; } TALLOC_FREE(ctx); -- cgit From 713221e1c52db2df787ec8ec66c14f17b168cc78 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 24 Dec 2007 01:00:46 +0100 Subject: Do not leak memory in libnet_smbconf_setparm(). Michael (This used to be commit a657b1c9f17d3cebc86b596f1f2d244750d70a6d) --- source3/libnet/libnet_conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ebf2d6654f..4945413bb1 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -258,10 +258,14 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_WRITE, &key); } - W_ERROR_NOT_OK_RETURN(werr); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } werr = libnet_smbconf_reg_setvalue_internal(key, param, valstr); +done: + TALLOC_FREE(key); return werr; } -- cgit From 3177cece659b12114e37033a22becc595649d07a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 24 Dec 2007 01:03:14 +0100 Subject: Do not leak memory in libnet_smbconf_delparm(). Michael (This used to be commit 49cfe2b9ebe03d5985187890445b775047f8a2f4) --- source3/libnet/libnet_conf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 4945413bb1..a371915a36 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -311,14 +311,19 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, } werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_ALL, &key); - W_ERROR_NOT_OK_RETURN(werr); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } if (!libnet_smbconf_value_exists(key, param)) { - return WERR_INVALID_PARAM; + werr = WERR_INVALID_PARAM; + goto done; } werr = reg_deletevalue(key, param); +done: + TALLOC_FREE(key); return werr; } -- cgit From c9f65929b733353baec531c4735749a754f051c5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 02:21:30 +0100 Subject: Move reg_delkey_internal() to libnet/libnet_conf.c Michael (This used to be commit c1b863fd0520ce64a1bad5e2fa3f69afcc2c78d5) --- source3/libnet/libnet_conf.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index a371915a36..30342e1e43 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,6 +243,30 @@ done: * **********************************************************************/ +/* + * delete a subkey of KEY_SMBCONF + */ +WERROR reg_delkey_internal(TALLOC_CTX *ctx, const char *keyname) +{ + WERROR werr = WERR_OK; + struct registry_key *key = NULL; + + werr = libnet_smbconf_open_basepath(ctx, REG_KEY_WRITE, &key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = reg_deletekey_recursive(key, key, keyname); + if (!W_ERROR_IS_OK(werr)) { + d_fprintf(stderr, "Error deleting registry key %s\\%s: %s\n", + KEY_SMBCONF, keyname, dos_errstr(werr)); + } + +done: + TALLOC_FREE(key); + return werr; +} + WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, const char *service, const char *param, -- cgit From 9c20b9a731d581ae8bbf4f9ef66c3b7ded7e4122 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 02:24:39 +0100 Subject: Rename reg_delkey_internal() to libnet_smbconf_delshare(). Michael (This used to be commit 7d501f0d78ec57509d0bc5ef0dc16fcd24ee27e7) --- source3/libnet/libnet_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 30342e1e43..ad02930ce4 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,10 +243,10 @@ done: * **********************************************************************/ -/* - * delete a subkey of KEY_SMBCONF +/** + * delete a service from configuration */ -WERROR reg_delkey_internal(TALLOC_CTX *ctx, const char *keyname) +WERROR libnet_smbconf_delshare(TALLOC_CTX *ctx, const char *keyname) { WERROR werr = WERR_OK; struct registry_key *key = NULL; -- cgit From 86486fcc9826663f7bf03fe4ceb354818415d089 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 02:31:41 +0100 Subject: Simplify libnet_smbconf_delshare(). Remove talloc context parameter. Remove d_printf error message. Michael (This used to be commit 870d35c04889603843bae989fb9c01396b4c6ed1) --- source3/libnet/libnet_conf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ad02930ce4..4c5a0829d6 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -246,24 +246,21 @@ done: /** * delete a service from configuration */ -WERROR libnet_smbconf_delshare(TALLOC_CTX *ctx, const char *keyname) +WERROR libnet_smbconf_delshare(const char *servicename) { WERROR werr = WERR_OK; struct registry_key *key = NULL; + TALLOC_CTX *ctx = talloc_stackframe(); werr = libnet_smbconf_open_basepath(ctx, REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = reg_deletekey_recursive(key, key, keyname); - if (!W_ERROR_IS_OK(werr)) { - d_fprintf(stderr, "Error deleting registry key %s\\%s: %s\n", - KEY_SMBCONF, keyname, dos_errstr(werr)); - } + werr = reg_deletekey_recursive(key, key, servicename); done: - TALLOC_FREE(key); + TALLOC_FREE(ctx); return werr; } -- cgit From 8e53343a74ab6c8947523ca9bd9a8c1583a8691e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 02:55:07 +0100 Subject: Move drop_smbconf_internal() to libnet_conf.c Michael (This used to be commit 4c2a3396bb687703f6b74655fda2014d1f75200b) --- source3/libnet/libnet_conf.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 4c5a0829d6..e81b8b4111 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,6 +243,56 @@ done: * **********************************************************************/ +WERROR drop_smbconf_internal(TALLOC_CTX *ctx) +{ + char *path, *p; + WERROR werr = WERR_OK; + NT_USER_TOKEN *token; + struct registry_key *parent_key = NULL; + struct registry_key *new_key = NULL; + TALLOC_CTX* tmp_ctx = NULL; + enum winreg_CreateAction action; + + tmp_ctx = talloc_new(ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + if (!(token = registry_create_admin_token(tmp_ctx))) { + /* what is the appropriate error code here? */ + werr = WERR_CAN_NOT_COMPLETE; + goto done; + } + + path = talloc_strdup(tmp_ctx, KEY_SMBCONF); + if (path == NULL) { + d_fprintf(stderr, "ERROR: out of memory!\n"); + werr = WERR_NOMEM; + goto done; + } + p = strrchr(path, '\\'); + *p = '\0'; + werr = reg_open_path(tmp_ctx, path, REG_KEY_WRITE, token, &parent_key); + + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = reg_deletekey_recursive(tmp_ctx, parent_key, p+1); + + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = reg_createkey(tmp_ctx, parent_key, p+1, REG_KEY_WRITE, + &new_key, &action); + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} + /** * delete a service from configuration */ -- cgit From 2764f5a0a6404b1ade9b996783e0a131b7b2d231 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:01:59 +0100 Subject: Rename drop_smbconf_internal() to libnet_smbconf_drop(). Michael (This used to be commit 5873e6a1f8242e07b1699366a536350a7199c28c) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index e81b8b4111..bc8dc9e4d0 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,7 +243,7 @@ done: * **********************************************************************/ -WERROR drop_smbconf_internal(TALLOC_CTX *ctx) +WERROR libnet_smbconf_drop(TALLOC_CTX *ctx) { char *path, *p; WERROR werr = WERR_OK; -- cgit From e5a87c2543dea12488250eb8e15dcfe02b34dfe1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:05:06 +0100 Subject: Remove talloc context parameter from libnet_smbconf_drop(). Make use of talloc_stackframe. Michael (This used to be commit aaceab1153f6c2a2adde83681913c771a16ca81f) --- source3/libnet/libnet_conf.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index bc8dc9e4d0..c85579b8e0 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,29 +243,23 @@ done: * **********************************************************************/ -WERROR libnet_smbconf_drop(TALLOC_CTX *ctx) +WERROR libnet_smbconf_drop(void) { char *path, *p; WERROR werr = WERR_OK; NT_USER_TOKEN *token; struct registry_key *parent_key = NULL; struct registry_key *new_key = NULL; - TALLOC_CTX* tmp_ctx = NULL; + TALLOC_CTX* mem_ctx = talloc_stackframe(); enum winreg_CreateAction action; - tmp_ctx = talloc_new(ctx); - if (tmp_ctx == NULL) { - werr = WERR_NOMEM; - goto done; - } - - if (!(token = registry_create_admin_token(tmp_ctx))) { + if (!(token = registry_create_admin_token(mem_ctx))) { /* what is the appropriate error code here? */ werr = WERR_CAN_NOT_COMPLETE; goto done; } - path = talloc_strdup(tmp_ctx, KEY_SMBCONF); + path = talloc_strdup(mem_ctx, KEY_SMBCONF); if (path == NULL) { d_fprintf(stderr, "ERROR: out of memory!\n"); werr = WERR_NOMEM; @@ -273,23 +267,23 @@ WERROR libnet_smbconf_drop(TALLOC_CTX *ctx) } p = strrchr(path, '\\'); *p = '\0'; - werr = reg_open_path(tmp_ctx, path, REG_KEY_WRITE, token, &parent_key); + werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token, &parent_key); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = reg_deletekey_recursive(tmp_ctx, parent_key, p+1); + werr = reg_deletekey_recursive(mem_ctx, parent_key, p+1); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = reg_createkey(tmp_ctx, parent_key, p+1, REG_KEY_WRITE, + werr = reg_createkey(mem_ctx, parent_key, p+1, REG_KEY_WRITE, &new_key, &action); done: - TALLOC_FREE(tmp_ctx); + TALLOC_FREE(mem_ctx); return werr; } -- cgit From efd218fb070f4f819d313455660e74970fee7689 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:06:48 +0100 Subject: Remove a d_fprintf() from libnet_smbconf_drop(). Michael (This used to be commit 078e5e98b3589cec78893d44146a653dad9a7460) --- source3/libnet/libnet_conf.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index c85579b8e0..5b3dea58ef 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -261,7 +261,6 @@ WERROR libnet_smbconf_drop(void) path = talloc_strdup(mem_ctx, KEY_SMBCONF); if (path == NULL) { - d_fprintf(stderr, "ERROR: out of memory!\n"); werr = WERR_NOMEM; goto done; } -- cgit From dff8e6b62c8f2a517e867a9137c8e1a777b129ad Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:08:00 +0100 Subject: Add comment header to function libnet_smbconf_drop(). Michael (This used to be commit e94edb6bdbc9379b48679d7c72618acfe862fe52) --- source3/libnet/libnet_conf.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 5b3dea58ef..c9b4f20de3 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -243,6 +243,9 @@ done: * **********************************************************************/ +/** + * Drop the whole configuration (restarting empty). + */ WERROR libnet_smbconf_drop(void) { char *path, *p; -- cgit From a66a5fd94bfb8a41bdb46aedf7eba28b55fbdaaf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:16:25 +0100 Subject: Typofix in comment. Michael (This used to be commit 5039a70246a475176fa8212ad78b430f2211951f) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index c9b4f20de3..be9edad4e9 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -397,7 +397,7 @@ done: /********************************************************************** * - * Convenience functions, that are also exportet. + * Convenience functions that are also exported. * **********************************************************************/ -- cgit From f3b0469b4a623c3ef17e2453bf40eb52778b5c42 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:29:05 +0100 Subject: Remove talloc context parameter from libnet_smbconf_setparm(). Make use of talloc stackframe internally. This removes talloc contxt from net_conf_setparm. Michael (This used to be commit efaffefc438f8375a083b194ac7a09e563000d3c) --- source3/libnet/libnet_conf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index be9edad4e9..6ea97a82eb 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -310,13 +310,13 @@ done: return werr; } -WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, - const char *service, +WERROR libnet_smbconf_setparm(const char *service, const char *param, const char *valstr) { WERROR werr; struct registry_key *key = NULL; + TALLOC_CTX *mem_ctx = talloc_stackframe(); if (!libnet_smbconf_key_exists(service)) { werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, @@ -332,7 +332,7 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx, werr = libnet_smbconf_reg_setvalue_internal(key, param, valstr); done: - TALLOC_FREE(key); + TALLOC_FREE(mem_ctx); return werr; } @@ -401,10 +401,9 @@ done: * **********************************************************************/ -WERROR libnet_smbconf_set_global_param(TALLOC_CTX *mem_ctx, - const char *param, +WERROR libnet_smbconf_set_global_param(const char *param, const char *val) { - return libnet_smbconf_setparm(mem_ctx, GLOBAL_NAME, param, val); + return libnet_smbconf_setparm(GLOBAL_NAME, param, val); } -- cgit From 44631bfd4d418cbf1ca4309057e6161cdce50bd4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Dec 2007 03:34:04 +0100 Subject: Remove talloc context parameter from libnet_smbconf_delparm(). Make use of talloc stackframe internally. This removes talloc contxt from net_conf_delparm. Michael (This used to be commit 16f137393881edc78c9322f038ba38e53e3ee07d) --- source3/libnet/libnet_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 6ea97a82eb..bb0e637b33 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -366,12 +366,12 @@ done: return werr; } -WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, - const char *service, +WERROR libnet_smbconf_delparm(const char *service, const char *param) { struct registry_key *key = NULL; WERROR werr = WERR_OK; + TALLOC_CTX *mem_ctx = talloc_stackframe(); if (!libnet_smbconf_key_exists(service)) { return WERR_NO_SUCH_SERVICE; @@ -390,7 +390,7 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx, werr = reg_deletevalue(key, param); done: - TALLOC_FREE(key); + TALLOC_FREE(mem_ctx); return werr; } -- cgit From e8cfbb0f4c58b45eb2585a8f130af017fd83adc8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 26 Dec 2007 00:53:19 +0100 Subject: Rename libnet_smbconf_open_path_q() to libnet_smbconf_open_path() removing previouse libnet_smbconf_open_path() and adding DEBUG output (instead of d_fprintf error output) to new libnet_smbconf_open_path(). Michael (This used to be commit e63cc54fab8a0b03573f76305eab366a3ee4eda1) --- source3/libnet/libnet_conf.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index bb0e637b33..3598f6c23c 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -29,12 +29,11 @@ /* * Open a subkey of KEY_SMBCONF (i.e a service) - * - variant without error output (q = quiet)- */ -static WERROR libnet_smbconf_open_path_q(TALLOC_CTX *ctx, - const char *subkeyname, - uint32 desired_access, - struct registry_key **key) +WERROR libnet_smbconf_open_path(TALLOC_CTX *ctx, + const char *subkeyname, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; @@ -54,6 +53,11 @@ static WERROR libnet_smbconf_open_path_q(TALLOC_CTX *ctx, werr = reg_open_path(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: TALLOC_FREE(path); return werr; @@ -69,7 +73,7 @@ bool libnet_smbconf_key_exists(const char *subkeyname) TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - werr = libnet_smbconf_open_path_q(mem_ctx, subkeyname, REG_KEY_READ, &key); + werr = libnet_smbconf_open_path(mem_ctx, subkeyname, REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = true; } @@ -95,27 +99,6 @@ static bool libnet_smbconf_value_exists(struct registry_key *key, return ret; } -/* - * Open a subkey of KEY_SMBCONF (i.e a service) - * - variant with error output - - */ -WERROR libnet_smbconf_open_path(TALLOC_CTX *ctx, const char *subkeyname, - uint32 desired_access, - struct registry_key **key) -{ - WERROR werr = WERR_OK; - - werr = libnet_smbconf_open_path_q(ctx, subkeyname, desired_access, key); - if (!W_ERROR_IS_OK(werr)) { - d_fprintf(stderr, "Error opening registry path '%s\\%s': %s\n", - KEY_SMBCONF, - (subkeyname == NULL) ? "" : subkeyname, - dos_errstr(werr)); - } - - return werr; -} - /* * open the base key KEY_SMBCONF */ -- cgit From 18ea20e19b59d3151ca59f0576211f855931f839 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 26 Dec 2007 00:58:11 +0100 Subject: Rename libnet_smbconf_open_path() to libnet_smbconf_reg_open_path(). Michael (This used to be commit 4b0e636965bd37e7c0deecb7b5eff0cc4487408b) --- source3/libnet/libnet_conf.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3598f6c23c..59989eccd5 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -30,10 +30,10 @@ /* * Open a subkey of KEY_SMBCONF (i.e a service) */ -WERROR libnet_smbconf_open_path(TALLOC_CTX *ctx, - const char *subkeyname, - uint32 desired_access, - struct registry_key **key) +WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *ctx, + const char *subkeyname, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; @@ -73,7 +73,8 @@ bool libnet_smbconf_key_exists(const char *subkeyname) TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - werr = libnet_smbconf_open_path(mem_ctx, subkeyname, REG_KEY_READ, &key); + werr = libnet_smbconf_reg_open_path(mem_ctx, subkeyname, REG_KEY_READ, + &key); if (W_ERROR_IS_OK(werr)) { ret = true; } @@ -105,7 +106,7 @@ static bool libnet_smbconf_value_exists(struct registry_key *key, WERROR libnet_smbconf_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, struct registry_key **key) { - return libnet_smbconf_open_path(ctx, NULL, desired_access, key); + return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); } /* @@ -305,8 +306,8 @@ WERROR libnet_smbconf_setparm(const char *service, werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, &key); } else { - werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_WRITE, - &key); + werr = libnet_smbconf_reg_open_path(mem_ctx, service, + REG_KEY_WRITE, &key); } if (!W_ERROR_IS_OK(werr)) { goto done; @@ -332,7 +333,8 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_READ, &key); + werr = libnet_smbconf_reg_open_path(mem_ctx, service, REG_KEY_READ, + &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -360,7 +362,7 @@ WERROR libnet_smbconf_delparm(const char *service, return WERR_NO_SUCH_SERVICE; } - werr = libnet_smbconf_open_path(mem_ctx, service, REG_KEY_ALL, &key); + werr = libnet_smbconf_reg_open_path(mem_ctx, service, REG_KEY_ALL, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From afca308742795a34e58f7a049c9a8d86cdff80c1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 26 Dec 2007 01:01:14 +0100 Subject: Rename libnet_smbconf_open_basepath() to libnet_smbconf_reg_open_basepath(). Michael (This used to be commit 4c0e7270c42788e7f77c402032ae74cf0f8a7106) --- source3/libnet/libnet_conf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 59989eccd5..3c765769fe 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -103,8 +103,8 @@ static bool libnet_smbconf_value_exists(struct registry_key *key, /* * open the base key KEY_SMBCONF */ -WERROR libnet_smbconf_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, - struct registry_key **key) +WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, + struct registry_key **key) { return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); } @@ -129,7 +129,8 @@ WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, goto done; } - werr = libnet_smbconf_open_basepath(create_ctx, REG_KEY_WRITE, &create_parent); + werr = libnet_smbconf_reg_open_basepath(create_ctx, REG_KEY_WRITE, + &create_parent); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -282,7 +283,7 @@ WERROR libnet_smbconf_delshare(const char *servicename) struct registry_key *key = NULL; TALLOC_CTX *ctx = talloc_stackframe(); - werr = libnet_smbconf_open_basepath(ctx, REG_KEY_WRITE, &key); + werr = libnet_smbconf_reg_open_basepath(ctx, REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From f99af84e6a48c8e3e3e4af9f06d31669a6fb2d90 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 26 Dec 2007 01:03:28 +0100 Subject: Move libnet_smbconf_reg_open_basepath() in source file to group helper functions more logically. Michael (This used to be commit 3fa3891f8721e9f02594cd1be2dc6b9b88692416) --- source3/libnet/libnet_conf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3c765769fe..93e13009a4 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -63,6 +63,15 @@ done: return werr; } +/* + * open the base key KEY_SMBCONF + */ +WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, + struct registry_key **key) +{ + return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); +} + /* * check if a subkey of KEY_SMBCONF of a given name exists */ @@ -100,15 +109,6 @@ static bool libnet_smbconf_value_exists(struct registry_key *key, return ret; } -/* - * open the base key KEY_SMBCONF - */ -WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, - struct registry_key **key) -{ - return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); -} - /* * create a subkey of KEY_SMBCONF */ -- cgit From dfa8d9356cea0dd6a1b013a72c3d68c026deb511 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 00:05:23 +0100 Subject: Move format_value() to libnet_conf.c. Michael (This used to be commit 3422a5048ad4b7f789ec233356885d78dbdacf9a) --- source3/libnet/libnet_conf.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 93e13009a4..5389d856b3 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -222,6 +222,40 @@ done: return werr; } +char *format_value(TALLOC_CTX *mem_ctx, struct registry_value *value) +{ + char *result = NULL; + + /* what if mem_ctx = NULL? */ + + switch (value->type) { + case REG_DWORD: + result = talloc_asprintf(mem_ctx, "%d", value->v.dword); + break; + case REG_SZ: + case REG_EXPAND_SZ: + result = talloc_asprintf(mem_ctx, "%s", value->v.sz.str); + break; + case REG_MULTI_SZ: { + uint32 j; + for (j = 0; j < value->v.multi_sz.num_strings; j++) { + result = talloc_asprintf(mem_ctx, "\"%s\" ", + value->v.multi_sz.strings[j]); + } + break; + } + case REG_BINARY: + result = talloc_asprintf(mem_ctx, "binary (%d bytes)", + (int)value->v.binary.length); + break; + default: + result = talloc_asprintf(mem_ctx, ""); + break; + } + return result; +} + + /********************************************************************** * * The actual net conf api functions, that are exported. -- cgit From 4b75bc63bb82f2322acdb013f1cfa9eb36419856 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 01:17:39 +0100 Subject: Rename format_value() to libnet_smbconf_format_registry_value(). Michael (This used to be commit 95d5dd9bb0546181cd499e6deabff562166412e3) --- source3/libnet/libnet_conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 5389d856b3..dfea724497 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -222,7 +222,8 @@ done: return werr; } -char *format_value(TALLOC_CTX *mem_ctx, struct registry_value *value) +char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, + struct registry_value *value) { char *result = NULL; @@ -362,6 +363,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, { WERROR werr; struct registry_key *key = NULL; + struct registry_value *value = NULL; if (!libnet_smbconf_key_exists(service)) { werr = WERR_NO_SUCH_SERVICE; -- cgit From eb356fbafc4b6e0d94b1ba75c6c466262e3221e5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 02:12:33 +0100 Subject: Hide the registry backend from libnet_smbconf_getparm(). Return a formatted string of the value instead. Michael (This used to be commit 7d0ec5bae155cda6620db04dcb7bd43db59241aa) --- source3/libnet/libnet_conf.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index dfea724497..1e9e033205 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -359,12 +359,17 @@ done: WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, const char *service, const char *param, - struct registry_value **value) + char **valstr) { - WERROR werr; + WERROR werr = WERR_OK; struct registry_key *key = NULL; struct registry_value *value = NULL; + if (valstr == NULL) { + werr = WERR_INVALID_PARAM; + goto done; + } + if (!libnet_smbconf_key_exists(service)) { werr = WERR_NO_SUCH_SERVICE; goto done; @@ -381,10 +386,20 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - werr = reg_queryvalue(mem_ctx, key, param, value); + werr = reg_queryvalue(mem_ctx, key, param, &value); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + *valstr = libnet_smbconf_format_registry_value(mem_ctx, value); + + if (*valstr == NULL) { + werr = WERR_NOMEM; + } done: TALLOC_FREE(key); + TALLOC_FREE(value); return werr; } -- cgit From 618b0efbbcc42beff60da4fe57ad6a6162b5e3f0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 02:16:38 +0100 Subject: Handle NULL talloc context in libnet_smbconf_format_registry_value(). Maybe we should generate a new context instead of returning NULL? Michael (This used to be commit d7aaec713e17f93eed5177f0c3468deb625402a8) --- source3/libnet/libnet_conf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 1e9e033205..3335c37299 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -227,7 +227,10 @@ char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, { char *result = NULL; - /* what if mem_ctx = NULL? */ + /* alternatively, create a new talloc context? */ + if (mem_ctx == NULL) { + return result; + } switch (value->type) { case REG_DWORD: -- cgit From b5b51b530fedf2190f675adbc1ba6e333a86ac0d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 02:18:44 +0100 Subject: Add a comment header for libnet_smbconf_format_registry_value(). Michael (This used to be commit 80e73407ea326cc68cd8728845c7a1c0907e2201) --- source3/libnet/libnet_conf.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3335c37299..6603de0199 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -222,6 +222,13 @@ done: return werr; } +/** + * format a registry_value into a string. + * + * This is intended to be used for smbconf registry values, + * which are ar stored as REG_SZ values, so the incomplete + * handling should be ok. + */ char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, struct registry_value *value) { -- cgit From 27f0130434d978cf98bab4db38718cd1d3856535 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 02:26:33 +0100 Subject: Add a couple of comment headers to the main libnet_conf functions. Michael (This used to be commit e9694ae20e1da1d8c1cbb252e630815b561647dd) --- source3/libnet/libnet_conf.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 6603de0199..a8a8e01538 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -340,6 +340,9 @@ done: return werr; } +/** + * set a configuration parameter to the value provided. + */ WERROR libnet_smbconf_setparm(const char *service, const char *param, const char *valstr) @@ -366,6 +369,9 @@ done: return werr; } +/** + * get the value of a configuration parameter as a string + */ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, const char *service, const char *param, @@ -413,6 +419,9 @@ done: return werr; } +/** + * delete a parameter from configuration + */ WERROR libnet_smbconf_delparm(const char *service, const char *param) { -- cgit From f8c39cbb7b3e4df3c07735575bc5f31717b22f66 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 03:38:13 +0100 Subject: Move functionality of net_conf_showshare() to libnet_conf.c The functionality is moved to a new function libnet_smbconf_getshare(). This returns the parameters of the given share as two lists: the list of parameter names and the list of matching (formatted) parameter values. The retrieval and formatting is done in a new internal helper function libnet_smbconf_reg_get_values() that is to become the replacement for list_values() from net_conf.c once functionality of net_conf_list() has been moved to libnet_conf, too. Michael (This used to be commit 198232bd525cfac933b4885e6b330ebf4ac2c8ae) --- source3/libnet/libnet_conf.c | 89 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index a8a8e01538..ca25a5cc50 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -266,6 +266,71 @@ char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, return result; } +/** + * Get the values of a key as a list of value names + * and a list of value strings (ordered) + */ +static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, + struct registry_key *key, + uint32_t *num_values, + char ***value_names, + char ***value_strings) +{ + TALLOC_CTX *tmp_ctx; + WERROR werr = WERR_OK; + uint32_t count; + struct registry_value *valvalue = NULL; + char *valname = NULL; + char **tmp_valnames = NULL; + char **tmp_valstrings = NULL; + + if ((num_values == NULL) || (value_names == NULL) || + (value_strings == NULL)) + { + werr = WERR_INVALID_PARAM; + goto done; + } + + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + for (count = 0; + W_ERROR_IS_OK(werr = reg_enumvalue(tmp_ctx, key, count, &valname, + &valvalue)); + count++) + { + tmp_valnames = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valnames, + char *, count + 1); + tmp_valstrings = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valstrings, + char *, count + 1); + if ((tmp_valstrings == NULL) || (tmp_valnames == NULL)) { + werr = WERR_NOMEM; + goto done; + } + tmp_valnames[count] = talloc_strdup(tmp_valnames, valname); + tmp_valstrings[count] = + libnet_smbconf_format_registry_value(tmp_valstrings, + valvalue); + } + if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { + goto done; + } + + werr = WERR_OK; + + *num_values = count - 1; + if (count > 0) { + *value_names = talloc_move(mem_ctx, &tmp_valnames); + *value_strings = talloc_move(mem_ctx, &tmp_valstrings); + } + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} /********************************************************************** * @@ -319,6 +384,30 @@ done: return werr; } +/** + * get a definition of a share (service) from configuration. + */ +WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename, + uint32_t *num_params, char ***param_names, + char ***param_values) +{ + WERROR werr = WERR_OK; + struct registry_key *key = NULL; + + werr = libnet_smbconf_reg_open_path(mem_ctx, servicename, REG_KEY_READ, + &key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + werr = libnet_smbconf_reg_get_values(mem_ctx, key, num_params, + param_names, param_values); + +done: + TALLOC_FREE(key); + return werr; +} + /** * delete a service from configuration */ -- cgit From 2a642a6e2b42c2b111870f95fe6dd38e875766f1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 12:52:09 +0100 Subject: Move functionality of net_conf_listshares() to libnet_conf.c into new function libnet_smbconf_getshares(). Michael (This used to be commit 306c7e4d9cecac4c2c0ea1172bd585c3c17d4541) --- source3/libnet/libnet_conf.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ca25a5cc50..a67a361f6e 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -384,6 +384,59 @@ done: return werr; } +WERROR libnet_smbconf_getshares(TALLOC_CTX *mem_ctx, uint32_t *num_shares, + char ***share_names) +{ + uint32_t count; + TALLOC_CTX *tmp_ctx; + WERROR werr = WERR_OK; + struct registry_key *key = NULL; + char *subkey_name = NULL; + char **tmp_share_names = NULL; + + if ((num_shares == NULL) || (share_names == NULL)) { + werr = WERR_INVALID_PARAM; + goto done; + } + + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + werr = libnet_smbconf_reg_open_basepath(tmp_ctx, + SEC_RIGHTS_ENUM_SUBKEYS, + &key); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + for (count = 0; + W_ERROR_IS_OK(werr = reg_enumkey(tmp_ctx, key, count, + &subkey_name, NULL)); + count++) + { + tmp_share_names = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_share_names, + char *, count + 1); + tmp_share_names[count] = talloc_strdup(tmp_ctx, subkey_name); + } + if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { + goto done; + } + + werr = WERR_OK; + + *num_shares = count - 1; + if (count > 0) { + *share_names = talloc_move(mem_ctx, &tmp_share_names); + } + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} + /** * get a definition of a share (service) from configuration. */ -- cgit From cf90b67d59340e55d2941c63db5cef98d0d71613 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 12:53:19 +0100 Subject: Add a comment header for libnet_smbconf_getshares(). Michael (This used to be commit 7b51535f2f76b5c3c18620ffd9ac64505357e6db) --- source3/libnet/libnet_conf.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index a67a361f6e..5d15c88252 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -384,6 +384,9 @@ done: return werr; } +/** + * get the list of share names defined in the configuration. + */ WERROR libnet_smbconf_getshares(TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names) { -- cgit From 1c03f6b6081a54f6b6e684d9a76be039fd468444 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 12:55:42 +0100 Subject: Rename libnet_smbconf_getshares() to libnet_smbconf_get_share_names(). Michael (This used to be commit 9b3b9aa7e1044719a5112b9e5446e6fbdd7cecf9) --- source3/libnet/libnet_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 5d15c88252..99fde86adc 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -387,8 +387,8 @@ done: /** * get the list of share names defined in the configuration. */ -WERROR libnet_smbconf_getshares(TALLOC_CTX *mem_ctx, uint32_t *num_shares, - char ***share_names) +WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, + char ***share_names) { uint32_t count; TALLOC_CTX *tmp_ctx; -- cgit From d38aa8d0371dd48a0bed3a38069b9125d3dfb440 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 29 Dec 2007 16:35:51 +0100 Subject: Fix uninitalized variables (This used to be commit 2322fe718728178990fdc3696b84f5de7ae7701b) --- source3/libnet/libnet_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 99fde86adc..23b9131bae 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -276,7 +276,7 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, char ***value_names, char ***value_strings) { - TALLOC_CTX *tmp_ctx; + TALLOC_CTX *tmp_ctx = NULL; WERROR werr = WERR_OK; uint32_t count; struct registry_value *valvalue = NULL; @@ -391,7 +391,7 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names) { uint32_t count; - TALLOC_CTX *tmp_ctx; + TALLOC_CTX *tmp_ctx = NULL; WERROR werr = WERR_OK; struct registry_key *key = NULL; char *subkey_name = NULL; -- cgit From 0e8ca78720ed0fff3853b8dbd407d41044aa4275 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 14:32:13 +0100 Subject: Move talloc-appending a string to an array to its own helper function libnet_smbconf_add_string_to_array(). Michael (This used to be commit f4a4c1b26a03cd0f334e00912d32f15c73474ff1) --- source3/libnet/libnet_conf.c | 62 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 23b9131bae..ad8deda04c 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -27,6 +27,33 @@ **********************************************************************/ +/** + * add a string to a talloced array of strings. + */ +static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, + char ***array, + uint32_t count, + const char *string) +{ + WERROR werr = WERR_OK; + char **new_array = NULL; + + if ((array == NULL) || (string == NULL)) { + return WERR_INVALID_PARAM; + } + + new_array = TALLOC_REALLOC_ARRAY(mem_ctx, *array, char *, count + 1); + if (new_array == NULL) { + return WERR_NOMEM; + } + + new_array[count] = talloc_strdup(new_array, string); + + *array = new_array; + + return WERR_OK; +} + /* * Open a subkey of KEY_SMBCONF (i.e a service) */ @@ -302,18 +329,24 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, &valvalue)); count++) { - tmp_valnames = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valnames, - char *, count + 1); - tmp_valstrings = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_valstrings, - char *, count + 1); - if ((tmp_valstrings == NULL) || (tmp_valnames == NULL)) { - werr = WERR_NOMEM; + char *valstring; + + werr = libnet_smbconf_add_string_to_array(tmp_ctx, + &tmp_valnames, + count, valname); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + valstring = libnet_smbconf_format_registry_value(tmp_ctx, + valvalue); + werr = libnet_smbconf_add_string_to_array(tmp_ctx, + &tmp_valstrings, + count, + valstring); + if (!W_ERROR_IS_OK(werr)) { goto done; } - tmp_valnames[count] = talloc_strdup(tmp_valnames, valname); - tmp_valstrings[count] = - libnet_smbconf_format_registry_value(tmp_valstrings, - valvalue); } if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { goto done; @@ -420,9 +453,12 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, &subkey_name, NULL)); count++) { - tmp_share_names = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_share_names, - char *, count + 1); - tmp_share_names[count] = talloc_strdup(tmp_ctx, subkey_name); + werr = libnet_smbconf_add_string_to_array(tmp_ctx, + &tmp_share_names, + count, subkey_name); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } } if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { goto done; -- cgit From e8cb7cecf2dde62f271a37376cefa5179eb7b7bc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 14:38:42 +0100 Subject: Make sure libnet_smbconf_get_share_names() always lists "global" first. And don't return count-1 but count. Michael (This used to be commit b7cb9b78231512dc4a88c307048d7fb5334fa319) --- source3/libnet/libnet_conf.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ad8deda04c..636e966a37 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -424,6 +424,7 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, char ***share_names) { uint32_t count; + uint32_t added_count = 0; TALLOC_CTX *tmp_ctx = NULL; WERROR werr = WERR_OK; struct registry_key *key = NULL; @@ -441,6 +442,17 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, goto done; } + /* make sure "global" is always listed first */ + if (libnet_smbconf_key_exists(GLOBAL_NAME)) { + werr = libnet_smbconf_add_string_to_array(tmp_ctx, + &tmp_share_names, + 0, GLOBAL_NAME); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + added_count++; + } + werr = libnet_smbconf_reg_open_basepath(tmp_ctx, SEC_RIGHTS_ENUM_SUBKEYS, &key); @@ -453,21 +465,26 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, &subkey_name, NULL)); count++) { + if (strequal(subkey_name, GLOBAL_NAME)) { + continue; + } + werr = libnet_smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, - count, subkey_name); + added_count, + subkey_name); if (!W_ERROR_IS_OK(werr)) { goto done; } + added_count++; } if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { goto done; } - werr = WERR_OK; - *num_shares = count - 1; - if (count > 0) { + *num_shares = added_count; + if (added_count > 0) { *share_names = talloc_move(mem_ctx, &tmp_share_names); } -- cgit From a6d6fbb73d56d3b96ccf55c1d028c5af00d83386 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 17:02:27 +0100 Subject: Dont return count - 1 but count from libnet_smbconf_reg_get_values(). Michael (This used to be commit ded60dec7d75db7df485a159fb6bf628d8e24805) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 636e966a37..300ea916cd 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -354,7 +354,7 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, werr = WERR_OK; - *num_values = count - 1; + *num_values = count; if (count > 0) { *value_names = talloc_move(mem_ctx, &tmp_valnames); *value_strings = talloc_move(mem_ctx, &tmp_valstrings); -- cgit From 397b4d5397e87fa60e35ac1f36facf2411ebc126 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 17:06:49 +0100 Subject: Return NULL (instead of unchanged) for no shares/parameters defined. Michael (This used to be commit bfe3d1462f52d2849611fc58ad70fa08b4917077) --- source3/libnet/libnet_conf.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 300ea916cd..3f5265a452 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -358,6 +358,9 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, if (count > 0) { *value_names = talloc_move(mem_ctx, &tmp_valnames); *value_strings = talloc_move(mem_ctx, &tmp_valstrings); + } else { + *value_names = NULL; + *value_strings = NULL; } done: @@ -486,6 +489,8 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, *num_shares = added_count; if (added_count > 0) { *share_names = talloc_move(mem_ctx, &tmp_share_names); + } else { + *share_names = NULL; } done: -- cgit From df93c1aa57c33f188548fc3de6719170c472b5eb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 21:59:28 +0100 Subject: Include libnet/libnet.h in libnet_conf.c to have prototypes available. Michael (This used to be commit 4842438c396b93007fc4f4dded437567e562a2dc) --- source3/libnet/libnet_conf.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3f5265a452..6d0e65e932 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "libnet/libnet.h" /********************************************************************** * -- cgit From fe47e2e85585c1f7f9455747f1ef5d4c20501960 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 22:08:11 +0100 Subject: Add a function libnet_smbconf_get_config() to libnet_conf.c This gets the whole config as a set of lists (of share names and corresponding lists of parameter names and values). The function is an aggregate of libnet_smbconf_get_share_names() and libnet_smbconf_getshare(). Michael (This used to be commit 94e97a72548a7f76a5273346d472e3ba5b24795a) --- source3/libnet/libnet_conf.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 6d0e65e932..642b6880ec 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -421,6 +421,90 @@ done: return werr; } +/** + * Get the whole configuration as lists of strings with counts: + * + * num_shares : number of shares + * share_names : list of length num_shares of share names + * num_params : list of length num_shares of parameter counts for each share + * param_names : list of lists of parameter names for each share + * param_values : list of lists of parameter values for each share + */ +WERROR libnet_smbconf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, + char ***share_names, uint32_t **num_params, + char ****param_names, char ****param_values) +{ + WERROR werr = WERR_OK; + TALLOC_CTX *tmp_ctx = NULL; + uint32_t tmp_num_shares; + char **tmp_share_names; + uint32_t *tmp_num_params; + char ***tmp_param_names; + char ***tmp_param_values; + uint32_t count; + + if ((num_shares == NULL) || (share_names == NULL) || + (num_params == NULL) || (param_names == NULL) || + (param_values == NULL)) + { + werr = WERR_INVALID_PARAM; + goto done; + } + + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + werr = libnet_smbconf_get_share_names(tmp_ctx, &tmp_num_shares, + &tmp_share_names); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + tmp_num_params = TALLOC_ARRAY(tmp_ctx, uint32_t, tmp_num_shares); + tmp_param_names = TALLOC_ARRAY(tmp_ctx, char **, tmp_num_shares); + tmp_param_values = TALLOC_ARRAY(tmp_ctx, char **, tmp_num_shares); + + if ((tmp_num_params == NULL) || (tmp_param_names == NULL) || + (tmp_param_values == NULL)) + { + werr = WERR_NOMEM; + goto done; + } + + for (count = 0; count < tmp_num_shares; count++) { + werr = libnet_smbconf_getshare(mem_ctx, tmp_share_names[count], + &tmp_num_params[count], + &tmp_param_names[count], + &tmp_param_values[count]); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + } + + werr = WERR_OK; + + *num_shares = tmp_num_shares; + if (tmp_num_shares > 0) { + *share_names = talloc_move(mem_ctx, &tmp_share_names); + *num_params = talloc_move(mem_ctx, &tmp_num_params); + *param_names = talloc_move(mem_ctx, &tmp_param_names); + *param_values = talloc_move(mem_ctx, &tmp_param_values); + } else { + *share_names = NULL; + *num_params = NULL; + *param_names = NULL; + *param_values = NULL; + } + +done: + TALLOC_FREE(tmp_ctx); + return werr; +} + + /** * get the list of share names defined in the configuration. */ -- cgit From 59128c783761c6f823971e7aa9513834a7be4b7d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 22:11:09 +0100 Subject: Remove list_values() from net_conf.c - it is not needed any more. Also make libnet.c:libnet_smbconf_format_registry_value() static. (There are nor more external callers.) Michael (This used to be commit ac7baa17e89d2363b5b3db85de9c842b596dea25) --- source3/libnet/libnet_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 642b6880ec..3c04c1333f 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -257,8 +257,8 @@ done: * which are ar stored as REG_SZ values, so the incomplete * handling should be ok. */ -char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, - struct registry_value *value) +static char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, + struct registry_value *value) { char *result = NULL; -- cgit From 1f992517ec67be36b03decefcac03ba71eec8705 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 22:29:00 +0100 Subject: Make libnet_smbconf_reg_open_basepath() static. Michael (This used to be commit 8e87dd79ba4e3aeceb26c7b4e131053172f077cd) --- source3/libnet/libnet_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3c04c1333f..099754cbf4 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -94,8 +94,9 @@ done: /* * open the base key KEY_SMBCONF */ -WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, uint32 desired_access, - struct registry_key **key) +static WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, + uint32 desired_access, + struct registry_key **key) { return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); } -- cgit From d674b95357b34a89b915af68fa12aa6b4169198d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 29 Dec 2007 22:29:33 +0100 Subject: Make libnet_smbconf_reg_open_path() static. Michael (This used to be commit 6447bae71c99407485307dd508603c73d5bb9823) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 099754cbf4..1069abcfbd 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -58,10 +58,10 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, /* * Open a subkey of KEY_SMBCONF (i.e a service) */ -WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *ctx, - const char *subkeyname, - uint32 desired_access, - struct registry_key **key) +static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *ctx, + const char *subkeyname, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; -- cgit From 80957726b694ea59da306c1be2e08b213936dc93 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 30 Dec 2007 22:27:45 +0100 Subject: Remove all d_fprintf-s from libnet_conf.c Replacing them buy DEBUG statements and filling in d_fprintfs in callers in net_conf.c. Michael (This used to be commit 1f0122d8d4ec0f67eaedd5df7383c1b45f37290f) --- source3/libnet/libnet_conf.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 1069abcfbd..a637aedbbc 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -167,12 +167,12 @@ WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, werr = reg_createkey(ctx, create_parent, subkeyname, REG_KEY_WRITE, newkey, &action); if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) { - d_fprintf(stderr, "Key '%s' already exists.\n", subkeyname); + DEBUG(10, ("Key '%s' already exists.\n", subkeyname)); werr = WERR_ALREADY_EXISTS; } if (!W_ERROR_IS_OK(werr)) { - d_fprintf(stderr, "Error creating key %s: %s\n", - subkeyname, dos_errstr(werr)); + DEBUG(5, ("Error creating key %s: %s\n", + subkeyname, dos_errstr(werr))); } done: @@ -198,11 +198,11 @@ WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, &canon_valstr)) { if (canon_valname == NULL) { - d_fprintf(stderr, "invalid parameter '%s' given\n", - valname); + DEBUG(5, ("invalid parameter '%s' given\n", + valname)); } else { - d_fprintf(stderr, "invalid value '%s' given for " - "parameter '%s'\n", valstr, valname); + DEBUG(5, ("invalid value '%s' given for " + "parameter '%s'\n", valstr, valname)); } werr = WERR_INVALID_PARAM; goto done; @@ -215,16 +215,16 @@ WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, val.v.sz.len = strlen(canon_valstr) + 1; if (registry_smbconf_valname_forbidden(canon_valname)) { - d_fprintf(stderr, "Parameter '%s' not allowed in registry.\n", - canon_valname); + DEBUG(5, ("Parameter '%s' not allowed in registry.\n", + canon_valname)); werr = WERR_INVALID_PARAM; goto done; } subkeyname = strrchr_m(key->key->name, '\\'); if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) { - d_fprintf(stderr, "Invalid registry key '%s' given as " - "smbconf section.\n", key->key->name); + DEBUG(5, ("Invalid registry key '%s' given as " + "smbconf section.\n", key->key->name)); werr = WERR_INVALID_PARAM; goto done; } @@ -232,19 +232,18 @@ WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, if (!strequal(subkeyname, GLOBAL_NAME) && lp_parameter_is_global(valname)) { - d_fprintf(stderr, "Global paramter '%s' not allowed in " + DEBUG(5, ("Global paramter '%s' not allowed in " "service definition ('%s').\n", canon_valname, - subkeyname); + subkeyname)); werr = WERR_INVALID_PARAM; goto done; } werr = reg_setvalue(key, canon_valname, &val); if (!W_ERROR_IS_OK(werr)) { - d_fprintf(stderr, - "Error adding value '%s' to " + DEBUG(5, ("Error adding value '%s' to " "key '%s': %s\n", - canon_valname, key->key->name, dos_errstr(werr)); + canon_valname, key->key->name, dos_errstr(werr))); } done: -- cgit From 0f2e7c73817eba0ebf1e98cabc38700560adb600 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 30 Dec 2007 22:29:54 +0100 Subject: Remove an unused variable. Michael (This used to be commit 7bac935b65565099c0dfb34cab0dec73dd5fb479) --- source3/libnet/libnet_conf.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index a637aedbbc..8fe2c76ea3 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -36,7 +36,6 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, uint32_t count, const char *string) { - WERROR werr = WERR_OK; char **new_array = NULL; if ((array == NULL) || (string == NULL)) { -- cgit From e8a680cdf391255fcbdacd1dcebc0f5a947408f1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 31 Dec 2007 01:14:44 +0100 Subject: Rename libnet_smbconf_key_exists() to libnet_smbconf_share_exists() and move it to the api section of libnet_conf.c Michael (This used to be commit 9b5d8f4d95ebfd47831906019e11227aecc83aa1) --- source3/libnet/libnet_conf.c | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 8fe2c76ea3..1b13b5bdc9 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -100,26 +100,6 @@ static WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); } -/* - * check if a subkey of KEY_SMBCONF of a given name exists - */ -bool libnet_smbconf_key_exists(const char *subkeyname) -{ - bool ret = false; - WERROR werr = WERR_OK; - TALLOC_CTX *mem_ctx = talloc_stackframe(); - struct registry_key *key = NULL; - - werr = libnet_smbconf_reg_open_path(mem_ctx, subkeyname, REG_KEY_READ, - &key); - if (W_ERROR_IS_OK(werr)) { - ret = true; - } - - TALLOC_FREE(mem_ctx); - return ret; -} - static bool libnet_smbconf_value_exists(struct registry_key *key, const char *param) { @@ -530,7 +510,7 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, } /* make sure "global" is always listed first */ - if (libnet_smbconf_key_exists(GLOBAL_NAME)) { + if (libnet_smbconf_share_exists(GLOBAL_NAME)) { werr = libnet_smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, 0, GLOBAL_NAME); @@ -582,6 +562,26 @@ done: return werr; } +/** + * check if a share/service of a given name exists + */ +bool libnet_smbconf_share_exists(const char *subkeyname) +{ + bool ret = false; + WERROR werr = WERR_OK; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + struct registry_key *key = NULL; + + werr = libnet_smbconf_reg_open_path(mem_ctx, subkeyname, REG_KEY_READ, + &key); + if (W_ERROR_IS_OK(werr)) { + ret = true; + } + + TALLOC_FREE(mem_ctx); + return ret; +} + /** * get a definition of a share (service) from configuration. */ @@ -638,7 +638,7 @@ WERROR libnet_smbconf_setparm(const char *service, struct registry_key *key = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_smbconf_key_exists(service)) { + if (!libnet_smbconf_share_exists(service)) { werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, &key); } else { @@ -673,7 +673,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - if (!libnet_smbconf_key_exists(service)) { + if (!libnet_smbconf_share_exists(service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } @@ -716,7 +716,7 @@ WERROR libnet_smbconf_delparm(const char *service, WERROR werr = WERR_OK; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_smbconf_key_exists(service)) { + if (!libnet_smbconf_share_exists(service)) { return WERR_NO_SUCH_SERVICE; } -- cgit From 8598bbbcb111103a592f4dcf25199a20b4de258c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 31 Dec 2007 03:57:45 +0100 Subject: Make the last two helper functions in libnet_conf.c static. Now the registry backend is completely hidden from the API. Michael (This used to be commit 5608c398ad9a0d05d651905a81dd92b7a0e120ff) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 1b13b5bdc9..21fe8572ea 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -120,9 +120,9 @@ static bool libnet_smbconf_value_exists(struct registry_key *key, /* * create a subkey of KEY_SMBCONF */ -WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, - const char * subkeyname, - struct registry_key **newkey) +static WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, + const char * subkeyname, + struct registry_key **newkey) { WERROR werr = WERR_OK; struct registry_key *create_parent = NULL; @@ -162,7 +162,7 @@ done: /* * add a value to a key. */ -WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, +static WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, const char *valname, const char *valstr) { -- cgit From 83d74c10a27f2b90682f52fec677bfee67591400 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:35:09 +0100 Subject: Rename libnet_smbconf_reg_open_basepath() to libnet_smbconf_reg_open_basekey(). Michael (This used to be commit 9e953a94e9b3a060769938ef6af25623e446c180) --- source3/libnet/libnet_conf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 21fe8572ea..2de4341e5d 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -93,9 +93,9 @@ done: /* * open the base key KEY_SMBCONF */ -static WERROR libnet_smbconf_reg_open_basepath(TALLOC_CTX *ctx, - uint32 desired_access, - struct registry_key **key) +static WERROR libnet_smbconf_reg_open_basekey(TALLOC_CTX *ctx, + uint32 desired_access, + struct registry_key **key) { return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); } @@ -137,8 +137,8 @@ static WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, goto done; } - werr = libnet_smbconf_reg_open_basepath(create_ctx, REG_KEY_WRITE, - &create_parent); + werr = libnet_smbconf_reg_open_basekey(create_ctx, REG_KEY_WRITE, + &create_parent); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -520,9 +520,9 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, added_count++; } - werr = libnet_smbconf_reg_open_basepath(tmp_ctx, - SEC_RIGHTS_ENUM_SUBKEYS, - &key); + werr = libnet_smbconf_reg_open_basekey(tmp_ctx, + SEC_RIGHTS_ENUM_SUBKEYS, + &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -615,7 +615,7 @@ WERROR libnet_smbconf_delshare(const char *servicename) struct registry_key *key = NULL; TALLOC_CTX *ctx = talloc_stackframe(); - werr = libnet_smbconf_reg_open_basepath(ctx, REG_KEY_WRITE, &key); + werr = libnet_smbconf_reg_open_basekey(ctx, REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From 102fda5c2954b620bb68f0c6e4acf1e6510fd62a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:43:29 +0100 Subject: Choose a more apropriate parameter name. Michael (This used to be commit 39a73b6291fd028d44fc2712afa76abf1fcff9cb) --- source3/libnet/libnet_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 2de4341e5d..469c72e650 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -565,14 +565,14 @@ done: /** * check if a share/service of a given name exists */ -bool libnet_smbconf_share_exists(const char *subkeyname) +bool libnet_smbconf_share_exists(const char *servicename) { bool ret = false; WERROR werr = WERR_OK; TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - werr = libnet_smbconf_reg_open_path(mem_ctx, subkeyname, REG_KEY_READ, + werr = libnet_smbconf_reg_open_path(mem_ctx, servicename, REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = true; -- cgit From d191bb126b778207e1eec7cb03e59554cdc88ada Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:44:47 +0100 Subject: Hey, it is 2008 now. :-) Michael (This used to be commit a1d3f60ea753a158447bb0208441453b76a0f3b9) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 469c72e650..ea8361a873 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. * libnet smbconf registry Support - * Copyright (C) Michael Adam 2007 + * Copyright (C) Michael Adam 2007-2008 * Copyright (C) Guenther Deschner 2007 * * This program is free software; you can redistribute it and/or modify -- cgit From c995a633715fa225637211b88650d9436702778b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:49:53 +0100 Subject: Rename libnet_smbconf_reg_open_path() to libnet_smbconf_reg_open_service_key(). Michael (This used to be commit d95b4935d3a97ca9c4b7990bbcf4e85c81c79516) --- source3/libnet/libnet_conf.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ea8361a873..73949de8a1 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -54,13 +54,13 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, return WERR_OK; } -/* +/** * Open a subkey of KEY_SMBCONF (i.e a service) */ -static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *ctx, - const char *subkeyname, - uint32 desired_access, - struct registry_key **key) +static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx, + const char *subkeyname, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; @@ -97,7 +97,8 @@ static WERROR libnet_smbconf_reg_open_basekey(TALLOC_CTX *ctx, uint32 desired_access, struct registry_key **key) { - return libnet_smbconf_reg_open_path(ctx, NULL, desired_access, key); + return libnet_smbconf_reg_open_service_key(ctx, NULL, desired_access, + key); } static bool libnet_smbconf_value_exists(struct registry_key *key, @@ -572,8 +573,8 @@ bool libnet_smbconf_share_exists(const char *servicename) TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - werr = libnet_smbconf_reg_open_path(mem_ctx, servicename, REG_KEY_READ, - &key); + werr = libnet_smbconf_reg_open_service_key(mem_ctx, servicename, + REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = true; } @@ -592,8 +593,8 @@ WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename, WERROR werr = WERR_OK; struct registry_key *key = NULL; - werr = libnet_smbconf_reg_open_path(mem_ctx, servicename, REG_KEY_READ, - &key); + werr = libnet_smbconf_reg_open_service_key(mem_ctx, servicename, + REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -642,8 +643,8 @@ WERROR libnet_smbconf_setparm(const char *service, werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, &key); } else { - werr = libnet_smbconf_reg_open_path(mem_ctx, service, - REG_KEY_WRITE, &key); + werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, + REG_KEY_WRITE, &key); } if (!W_ERROR_IS_OK(werr)) { goto done; @@ -678,8 +679,8 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - werr = libnet_smbconf_reg_open_path(mem_ctx, service, REG_KEY_READ, - &key); + werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, + REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -720,7 +721,8 @@ WERROR libnet_smbconf_delparm(const char *service, return WERR_NO_SUCH_SERVICE; } - werr = libnet_smbconf_reg_open_path(mem_ctx, service, REG_KEY_ALL, &key); + werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, + REG_KEY_ALL, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From a6fb71e55b583119c28e74e8aa54dd1b5a0fc3af Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:51:36 +0100 Subject: Use a better parameter name. Michael (This used to be commit 3972deb90c4b645fb4d207a7e132cd7e180e78bb) --- source3/libnet/libnet_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 73949de8a1..144026dbb5 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -58,7 +58,7 @@ 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 *subkeyname, + const char *servicename, uint32 desired_access, struct registry_key **key) { @@ -71,10 +71,10 @@ static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx, goto done; } - if (subkeyname == NULL) { + if (servicename == NULL) { path = talloc_strdup(ctx, KEY_SMBCONF); } else { - path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, subkeyname); + path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename); } werr = reg_open_path(ctx, path, desired_access, -- cgit From b344dafa62a6d9e4af1063f612150cc9f9fe3b81 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:52:55 +0100 Subject: Fix setting of error code in error path. Michael (This used to be commit 8a7954a9ae13df527ccedb1004ee4f87d506ce5b) --- source3/libnet/libnet_conf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 144026dbb5..514fd245ad 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -68,6 +68,8 @@ static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx, if (!(token = registry_create_admin_token(ctx))) { DEBUG(1, ("Error creating admin token\n")); + /* what is the appropriate error code here? */ + werr = WERR_CAN_NOT_COMPLETE; goto done; } -- cgit From f9bb8a345ed311f74adc30b164383170048b8dc5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 00:53:34 +0100 Subject: Add debug output in error path. Michael (This used to be commit a58ccbc6d70613f7572bc80621935d81f9e290e3) --- source3/libnet/libnet_conf.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 514fd245ad..7980dbbe4c 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -371,6 +371,7 @@ WERROR libnet_smbconf_drop(void) enum winreg_CreateAction action; if (!(token = registry_create_admin_token(mem_ctx))) { + DEBUG(1, ("Error creating admin token\n")); /* what is the appropriate error code here? */ werr = WERR_CAN_NOT_COMPLETE; goto done; -- cgit From 3bf57a4d824b75dcbfea074e4e10d57f1d907682 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 01:07:30 +0100 Subject: 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) --- source3/libnet/libnet_conf.c | 57 +++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'source3/libnet/libnet_conf.c') 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,36 +57,61 @@ 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", path, dos_errstr(werr))); } +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, -- cgit From 3c9f7c7a64e886ae54beb4242b227a9a223520e1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 01:12:23 +0100 Subject: Use libnet_smbconf_reg_open_path() in libnet_smbconf_drop(). Replaces creation of token and direct use of reg_open_path. Michael (This used to be commit 7e407e18be0761e7004acfbd2376c3a435922c25) --- source3/libnet/libnet_conf.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 0bc7c63471..ca5b0c408f 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -395,13 +395,6 @@ WERROR libnet_smbconf_drop(void) TALLOC_CTX* mem_ctx = talloc_stackframe(); enum winreg_CreateAction action; - if (!(token = registry_create_admin_token(mem_ctx))) { - DEBUG(1, ("Error creating admin token\n")); - /* what is the appropriate error code here? */ - werr = WERR_CAN_NOT_COMPLETE; - goto done; - } - path = talloc_strdup(mem_ctx, KEY_SMBCONF); if (path == NULL) { werr = WERR_NOMEM; @@ -409,7 +402,8 @@ WERROR libnet_smbconf_drop(void) } p = strrchr(path, '\\'); *p = '\0'; - werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token, &parent_key); + werr = libnet_smbconf_reg_open_path(mem_ctx, path, REG_KEY_WRITE, + &parent_key); if (!W_ERROR_IS_OK(werr)) { goto done; -- cgit From ad1cc905b2eef9ebfe727a6061aec62a22574c8b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 01:26:31 +0100 Subject: Don't leak: Use a temporary context for the admin token and free it. Michael (This used to be commit 9d7502115e0f6cdfd27943d52f0de04447582b92) --- source3/libnet/libnet_conf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ca5b0c408f..995fc1b303 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -64,6 +64,7 @@ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx, { WERROR werr = WERR_OK; NT_USER_TOKEN *token; + TALLOC_CTX *tmp_ctx = NULL; if (path == NULL) { DEBUG(1, ("Error: NULL path string given\n")); @@ -71,7 +72,13 @@ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx, goto done; } - token = registry_create_admin_token(mem_ctx); + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + werr = WERR_NOMEM; + goto done; + } + + token = registry_create_admin_token(tmp_ctx); if (token == NULL) { DEBUG(1, ("Error creating admin token\n")); /* what is the appropriate error code here? */ @@ -87,6 +94,7 @@ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx, } done: + TALLOC_FREE(tmp_ctx); return werr; } -- cgit From 40079c4eb47b590a88ac8d568a5d5f039bc02af6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 3 Jan 2008 10:39:19 +0100 Subject: Remove unused vars. Guenther (This used to be commit ff3f0006d167a9bca85919bf6115d73413554909) --- source3/libnet/libnet_conf.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 995fc1b303..ebdfd75744 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -108,7 +108,6 @@ static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx, { WERROR werr = WERR_OK; char *path = NULL; - NT_USER_TOKEN *token; if (servicename == NULL) { DEBUG(3, ("Error: NULL servicename given.\n")); @@ -397,7 +396,6 @@ WERROR libnet_smbconf_drop(void) { char *path, *p; WERROR werr = WERR_OK; - NT_USER_TOKEN *token; struct registry_key *parent_key = NULL; struct registry_key *new_key = NULL; TALLOC_CTX* mem_ctx = talloc_stackframe(); -- cgit From fd597c7e6d1b5d89c75dd24f2b62916ec81a67ae Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 11:30:14 +0100 Subject: Add libnet_conf API function libnet_smbconf_create_share(). And make libnet_smbconf_setparm() return error if the share does not already exist. Adapt net_conf_addshare to this new situation. Michael (This used to be commit de349bd26db3341815f6d8f6c18a5ca1fd664dca) --- source3/libnet/libnet_conf.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ebdfd75744..2c67d4735e 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -611,6 +611,27 @@ bool libnet_smbconf_share_exists(const char *servicename) return ret; } +/** + * Add a service if it does not already exist. + */ +WERROR libnet_smbconf_create_share(const char *servicename) +{ + WERROR werr; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + struct registry_key *key = NULL; + + if (libnet_smbconf_share_exists(servicename)) { + werr = WERR_ALREADY_EXISTS; + goto done; + } + + werr = libnet_smbconf_reg_createkey_internal(mem_ctx, servicename, &key); + +done: + TALLOC_FREE(mem_ctx); + return werr; +} + /** * get a definition of a share (service) from configuration. */ @@ -668,12 +689,12 @@ WERROR libnet_smbconf_setparm(const char *service, TALLOC_CTX *mem_ctx = talloc_stackframe(); if (!libnet_smbconf_share_exists(service)) { - werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service, - &key); - } else { - werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, - REG_KEY_WRITE, &key); + werr = WERR_NO_SUCH_SERVICE; + goto done; } + + werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, + REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From a750e223b3c6e78aa911a52eaa62c85af62f842b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 11:32:00 +0100 Subject: Rename libnet_smbconf_reg_createkey_internal to libnet_smbconf_reg_create_service_key. Michael (This used to be commit 08056a2c8160a44d27744467da467faea9ba0686) --- source3/libnet/libnet_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 2c67d4735e..f435882b3b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -155,7 +155,7 @@ static bool libnet_smbconf_value_exists(struct registry_key *key, /* * create a subkey of KEY_SMBCONF */ -static WERROR libnet_smbconf_reg_createkey_internal(TALLOC_CTX *ctx, +static WERROR libnet_smbconf_reg_create_service_key(TALLOC_CTX *ctx, const char * subkeyname, struct registry_key **newkey) { @@ -625,7 +625,7 @@ WERROR libnet_smbconf_create_share(const char *servicename) goto done; } - werr = libnet_smbconf_reg_createkey_internal(mem_ctx, servicename, &key); + werr = libnet_smbconf_reg_create_service_key(mem_ctx, servicename, &key); done: TALLOC_FREE(mem_ctx); -- cgit From e0ea759807882091fac07e7b200ad82bc78fcc4f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 11:33:17 +0100 Subject: Fix a comment. Michael (This used to be commit 2d0c7fe44f075205db1713ef2d69006f7192c490) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index f435882b3b..304c53c0d0 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -55,7 +55,7 @@ static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, } /** - * Open a subkey of KEY_SMBCONF (i.e a service) + * Open a registry key specified by "path" */ static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx, const char *path, -- cgit From 984aa7a1560a4d052a0c8260d230be4b89303bd7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 11:35:21 +0100 Subject: Rename libnet_smbconf_reg_setvalue_internal() to libnet_smbconf_reg_set_value(). Michael (This used to be commit 3fc3fee88afd9e8b6232afc140a07090b4215c23) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 304c53c0d0..01c4237f20 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -197,9 +197,9 @@ done: /* * add a value to a key. */ -static WERROR libnet_smbconf_reg_setvalue_internal(struct registry_key *key, - const char *valname, - const char *valstr) +static WERROR libnet_smbconf_reg_set_value(struct registry_key *key, + const char *valname, + const char *valstr) { struct registry_value val; WERROR werr = WERR_OK; @@ -699,7 +699,7 @@ WERROR libnet_smbconf_setparm(const char *service, goto done; } - werr = libnet_smbconf_reg_setvalue_internal(key, param, valstr); + werr = libnet_smbconf_reg_set_value(key, param, valstr); done: TALLOC_FREE(mem_ctx); -- cgit From 46123918506112d02db42e19407057dd943b8720 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:31:23 +0100 Subject: Rename libnet_smbconf_add_string_to_array() to libnet_conf_add_string_to_array(). This is the start of making nomenclature more consistent (functions in libnet_conf.c should be called libnet_conf_*, not libnet_smbconf_* ... Michael (This used to be commit 0dd3967bfd88a4d90941e80134c549f5ade63ad0) --- source3/libnet/libnet_conf.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 01c4237f20..68726fa5d9 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -31,10 +31,10 @@ /** * add a string to a talloced array of strings. */ -static WERROR libnet_smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, - char ***array, - uint32_t count, - const char *string) +static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, + char ***array, + uint32_t count, + const char *string) { char **new_array = NULL; @@ -346,19 +346,19 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, { char *valstring; - werr = libnet_smbconf_add_string_to_array(tmp_ctx, - &tmp_valnames, - count, valname); + werr = libnet_conf_add_string_to_array(tmp_ctx, + &tmp_valnames, + count, valname); if (!W_ERROR_IS_OK(werr)) { goto done; } valstring = libnet_smbconf_format_registry_value(tmp_ctx, valvalue); - werr = libnet_smbconf_add_string_to_array(tmp_ctx, - &tmp_valstrings, - count, - valstring); + werr = libnet_conf_add_string_to_array(tmp_ctx, + &tmp_valstrings, + count, + valstring); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -540,9 +540,9 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, /* make sure "global" is always listed first */ if (libnet_smbconf_share_exists(GLOBAL_NAME)) { - werr = libnet_smbconf_add_string_to_array(tmp_ctx, - &tmp_share_names, - 0, GLOBAL_NAME); + werr = libnet_conf_add_string_to_array(tmp_ctx, + &tmp_share_names, + 0, GLOBAL_NAME); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -565,10 +565,10 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, continue; } - werr = libnet_smbconf_add_string_to_array(tmp_ctx, - &tmp_share_names, - added_count, - subkey_name); + werr = libnet_conf_add_string_to_array(tmp_ctx, + &tmp_share_names, + added_count, + subkey_name); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From e598b93d2faf568c6ac03b0ca32dcf22fa0e1352 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:33:10 +0100 Subject: Rename libnet_smbconf_reg_open_path() to libnet_conf_reg_open_path(). Michael (This used to be commit 9868364e2c7827ac7914bee711a65d4456a5e366) --- source3/libnet/libnet_conf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 68726fa5d9..86b2d8b605 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -57,10 +57,10 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, /** * Open a registry key specified by "path" */ -static WERROR libnet_smbconf_reg_open_path(TALLOC_CTX *mem_ctx, - const char *path, - uint32 desired_access, - struct registry_key **key) +static WERROR libnet_conf_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; @@ -117,7 +117,7 @@ static WERROR libnet_smbconf_reg_open_service_key(TALLOC_CTX *ctx, path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename); - werr = libnet_smbconf_reg_open_path(ctx, path, desired_access, key); + werr = libnet_conf_reg_open_path(ctx, path, desired_access, key); done: TALLOC_FREE(path); @@ -131,8 +131,7 @@ static WERROR libnet_smbconf_reg_open_basekey(TALLOC_CTX *ctx, uint32 desired_access, struct registry_key **key) { - return libnet_smbconf_reg_open_path(ctx, KEY_SMBCONF, desired_access, - key); + return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key); } static bool libnet_smbconf_value_exists(struct registry_key *key, @@ -408,8 +407,8 @@ WERROR libnet_smbconf_drop(void) } p = strrchr(path, '\\'); *p = '\0'; - werr = libnet_smbconf_reg_open_path(mem_ctx, path, REG_KEY_WRITE, - &parent_key); + werr = libnet_conf_reg_open_path(mem_ctx, path, REG_KEY_WRITE, + &parent_key); if (!W_ERROR_IS_OK(werr)) { goto done; -- cgit From dde8701b85d88a5536a21d80a161c67c7e8634c9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:36:25 +0100 Subject: Rename libnet_smbconf_reg_open_service_key() to libnet_conf_reg_open_service_key(). Michael (This used to be commit 4d86d2dd6f0a577e446ccb4b362b3cd80f819600) --- source3/libnet/libnet_conf.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 86b2d8b605..735fddcfd2 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -101,10 +101,10 @@ done: /** * 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_conf_reg_open_service_key(TALLOC_CTX *ctx, + const char *servicename, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; @@ -600,8 +600,8 @@ bool libnet_smbconf_share_exists(const char *servicename) TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - werr = libnet_smbconf_reg_open_service_key(mem_ctx, servicename, - REG_KEY_READ, &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, servicename, + REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = true; } @@ -641,8 +641,8 @@ WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename, WERROR werr = WERR_OK; struct registry_key *key = NULL; - werr = libnet_smbconf_reg_open_service_key(mem_ctx, servicename, - REG_KEY_READ, &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, servicename, + REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -692,8 +692,8 @@ WERROR libnet_smbconf_setparm(const char *service, goto done; } - werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, - REG_KEY_WRITE, &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_WRITE, + &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -727,8 +727,8 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, - REG_KEY_READ, &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_READ, + &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -769,8 +769,8 @@ WERROR libnet_smbconf_delparm(const char *service, return WERR_NO_SUCH_SERVICE; } - werr = libnet_smbconf_reg_open_service_key(mem_ctx, service, - REG_KEY_ALL, &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_ALL, + &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From cd84256866d6d2bbd7494b67ae96c3546902e794 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:38:55 +0100 Subject: Rename libnet_smbconf_reg_open_basekey() to libnet_conf_reg_open_base_key(). Michael (This used to be commit c2ba52b2c34abc42b4ff7945715dc36e08a2f112) --- source3/libnet/libnet_conf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 735fddcfd2..53d70bd4f6 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -127,9 +127,9 @@ done: /* * open the base key KEY_SMBCONF */ -static WERROR libnet_smbconf_reg_open_basekey(TALLOC_CTX *ctx, - uint32 desired_access, - struct registry_key **key) +static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx, + uint32 desired_access, + struct registry_key **key) { return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key); } @@ -171,8 +171,8 @@ static WERROR libnet_smbconf_reg_create_service_key(TALLOC_CTX *ctx, goto done; } - werr = libnet_smbconf_reg_open_basekey(create_ctx, REG_KEY_WRITE, - &create_parent); + werr = libnet_conf_reg_open_base_key(create_ctx, REG_KEY_WRITE, + &create_parent); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -548,9 +548,8 @@ WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, added_count++; } - werr = libnet_smbconf_reg_open_basekey(tmp_ctx, - SEC_RIGHTS_ENUM_SUBKEYS, - &key); + werr = libnet_conf_reg_open_base_key(tmp_ctx, SEC_RIGHTS_ENUM_SUBKEYS, + &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -664,7 +663,7 @@ WERROR libnet_smbconf_delshare(const char *servicename) struct registry_key *key = NULL; TALLOC_CTX *ctx = talloc_stackframe(); - werr = libnet_smbconf_reg_open_basekey(ctx, REG_KEY_WRITE, &key); + werr = libnet_conf_reg_open_base_key(ctx, REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } -- cgit From d3e54d913c705337d3caf88ee72d38c7f45f0949 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:40:40 +0100 Subject: Rename libnet_smbconf_value_exists() to libnet_conf_value_exists(). Michael (This used to be commit 49f740797bb7fc5edacbd4c3e8b1eb1aab131ea4) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 53d70bd4f6..0032d549eb 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -134,8 +134,8 @@ static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx, return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key); } -static bool libnet_smbconf_value_exists(struct registry_key *key, - const char *param) +static bool libnet_conf_value_exists(struct registry_key *key, + const char *param) { bool ret = false; WERROR werr = WERR_OK; @@ -732,7 +732,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - if (!libnet_smbconf_value_exists(key, param)) { + if (!libnet_conf_value_exists(key, param)) { werr = WERR_INVALID_PARAM; goto done; } @@ -774,7 +774,7 @@ WERROR libnet_smbconf_delparm(const char *service, goto done; } - if (!libnet_smbconf_value_exists(key, param)) { + if (!libnet_conf_value_exists(key, param)) { werr = WERR_INVALID_PARAM; goto done; } -- cgit From 340cb434db8d3e063a2fb15cb74e550e90c4cf95 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:42:40 +0100 Subject: Rename libnet_smbconf_reg_create_service_key() to libnet_conf_reg_create_service_key(). Michael (This used to be commit cd1846943cbcc02ea9fa3b9237bd02e667a475db) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 0032d549eb..b88242ef8a 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -154,9 +154,9 @@ static bool libnet_conf_value_exists(struct registry_key *key, /* * create a subkey of KEY_SMBCONF */ -static WERROR libnet_smbconf_reg_create_service_key(TALLOC_CTX *ctx, - const char * subkeyname, - struct registry_key **newkey) +static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *ctx, + const char * subkeyname, + struct registry_key **newkey) { WERROR werr = WERR_OK; struct registry_key *create_parent = NULL; @@ -623,7 +623,7 @@ WERROR libnet_smbconf_create_share(const char *servicename) goto done; } - werr = libnet_smbconf_reg_create_service_key(mem_ctx, servicename, &key); + werr = libnet_conf_reg_create_service_key(mem_ctx, servicename, &key); done: TALLOC_FREE(mem_ctx); -- cgit From 547c3583e42e22e42432a10c79803219ee043dc7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:43:34 +0100 Subject: Rename libnet_smbconf_reg_set_value() to libnet_conf_reg_set_value(). Michael (This used to be commit 96b2923bc3c57700352869627c38609529d53cd2) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index b88242ef8a..594e1f7a1d 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -196,9 +196,9 @@ done: /* * add a value to a key. */ -static WERROR libnet_smbconf_reg_set_value(struct registry_key *key, - const char *valname, - const char *valstr) +static WERROR libnet_conf_reg_set_value(struct registry_key *key, + const char *valname, + const char *valstr) { struct registry_value val; WERROR werr = WERR_OK; @@ -697,7 +697,7 @@ WERROR libnet_smbconf_setparm(const char *service, goto done; } - werr = libnet_smbconf_reg_set_value(key, param, valstr); + werr = libnet_conf_reg_set_value(key, param, valstr); done: TALLOC_FREE(mem_ctx); -- cgit From 6ab11e5f981618f58ebd82b89a79846ac048aadf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:45:14 +0100 Subject: Rename libnet_smbconf_format_registry_value() to libnet_conf_format_registry_value(). Michael (This used to be commit 3f9f35335127a673639fa30c88cdea6c79f04b92) --- source3/libnet/libnet_conf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 594e1f7a1d..9a0cd9ff2f 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -270,8 +270,8 @@ done: * which are ar stored as REG_SZ values, so the incomplete * handling should be ok. */ -static char *libnet_smbconf_format_registry_value(TALLOC_CTX *mem_ctx, - struct registry_value *value) +static char *libnet_conf_format_registry_value(TALLOC_CTX *mem_ctx, + struct registry_value *value) { char *result = NULL; @@ -352,8 +352,8 @@ static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, goto done; } - valstring = libnet_smbconf_format_registry_value(tmp_ctx, - valvalue); + valstring = libnet_conf_format_registry_value(tmp_ctx, + valvalue); werr = libnet_conf_add_string_to_array(tmp_ctx, &tmp_valstrings, count, @@ -742,7 +742,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - *valstr = libnet_smbconf_format_registry_value(mem_ctx, value); + *valstr = libnet_conf_format_registry_value(mem_ctx, value); if (*valstr == NULL) { werr = WERR_NOMEM; -- cgit From 12a0cd531060f6a54c7600f3682bbb37fe91bac1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:46:45 +0100 Subject: Rename libnet_smbconf_reg_get_values() to libnet_conf_reg_get_values(). Now all internal helper functions are converted to the consistent naming scheme. Michael (This used to be commit c23e6636a886d93b98c9439ba081def0385f67ac) --- source3/libnet/libnet_conf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 9a0cd9ff2f..191692dc62 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -311,11 +311,11 @@ static char *libnet_conf_format_registry_value(TALLOC_CTX *mem_ctx, * Get the values of a key as a list of value names * and a list of value strings (ordered) */ -static WERROR libnet_smbconf_reg_get_values(TALLOC_CTX *mem_ctx, - struct registry_key *key, - uint32_t *num_values, - char ***value_names, - char ***value_strings) +static WERROR libnet_conf_reg_get_values(TALLOC_CTX *mem_ctx, + struct registry_key *key, + uint32_t *num_values, + char ***value_names, + char ***value_strings) { TALLOC_CTX *tmp_ctx = NULL; WERROR werr = WERR_OK; @@ -646,8 +646,8 @@ WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename, goto done; } - werr = libnet_smbconf_reg_get_values(mem_ctx, key, num_params, - param_names, param_values); + werr = libnet_conf_reg_get_values(mem_ctx, key, num_params, + param_names, param_values); done: TALLOC_FREE(key); -- cgit From 05ff62cf78447dc8caacf4a9d0b4b746f8d8e481 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:48:56 +0100 Subject: Rename libnet_smbconf_drop() to libnet_conf_drop(). Michael (This used to be commit 42ae33a96228e916d7d530d844be6937a80d4fea) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 191692dc62..f9f1759de2 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -391,7 +391,7 @@ done: /** * Drop the whole configuration (restarting empty). */ -WERROR libnet_smbconf_drop(void) +WERROR libnet_conf_drop(void) { char *path, *p; WERROR werr = WERR_OK; -- cgit From 90837d048b18ae72199b6f7ed7e1d17b0cc71102 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:50:55 +0100 Subject: Rename libnet_smbconf_get_config() to libnet_conf_get_config(). Michael (This used to be commit e8f7c07699b5b93acd81b24bca908769f0b5e8d8) --- source3/libnet/libnet_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index f9f1759de2..ec055439d7 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -437,9 +437,9 @@ done: * param_names : list of lists of parameter names for each share * param_values : list of lists of parameter values for each share */ -WERROR libnet_smbconf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, - char ***share_names, uint32_t **num_params, - char ****param_names, char ****param_values) +WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, + char ***share_names, uint32_t **num_params, + char ****param_names, char ****param_values) { WERROR werr = WERR_OK; TALLOC_CTX *tmp_ctx = NULL; -- cgit From daf1a460c821f247c43c22f1e26785d3acdb3ac3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:53:04 +0100 Subject: Rename libnet_smbconf_get_share_names() to libnet_conf_get_share_names(). Michael (This used to be commit 2e4beee66b3672c3259b312aca3d482598731119) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ec055439d7..3cd3933b1f 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -464,8 +464,8 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, goto done; } - werr = libnet_smbconf_get_share_names(tmp_ctx, &tmp_num_shares, - &tmp_share_names); + werr = libnet_conf_get_share_names(tmp_ctx, &tmp_num_shares, + &tmp_share_names); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -515,8 +515,8 @@ done: /** * get the list of share names defined in the configuration. */ -WERROR libnet_smbconf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, - char ***share_names) +WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, + char ***share_names) { uint32_t count; uint32_t added_count = 0; -- cgit From 630de5f555b7fb897e1bb700b2a0a3d8d611e9bd Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:54:31 +0100 Subject: Rename libnet_smbconf_share_exists() to libnet_conf_share_exists(). Michael (This used to be commit 3258758e5c8dfc2c681e1285cb34aaacae697a55) --- source3/libnet/libnet_conf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3cd3933b1f..cf11a42329 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -538,7 +538,7 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, } /* make sure "global" is always listed first */ - if (libnet_smbconf_share_exists(GLOBAL_NAME)) { + if (libnet_conf_share_exists(GLOBAL_NAME)) { werr = libnet_conf_add_string_to_array(tmp_ctx, &tmp_share_names, 0, GLOBAL_NAME); @@ -592,7 +592,7 @@ done: /** * check if a share/service of a given name exists */ -bool libnet_smbconf_share_exists(const char *servicename) +bool libnet_conf_share_exists(const char *servicename) { bool ret = false; WERROR werr = WERR_OK; @@ -618,7 +618,7 @@ WERROR libnet_smbconf_create_share(const char *servicename) TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - if (libnet_smbconf_share_exists(servicename)) { + if (libnet_conf_share_exists(servicename)) { werr = WERR_ALREADY_EXISTS; goto done; } @@ -686,7 +686,7 @@ WERROR libnet_smbconf_setparm(const char *service, struct registry_key *key = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_smbconf_share_exists(service)) { + if (!libnet_conf_share_exists(service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } @@ -721,7 +721,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, goto done; } - if (!libnet_smbconf_share_exists(service)) { + if (!libnet_conf_share_exists(service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } @@ -764,7 +764,7 @@ WERROR libnet_smbconf_delparm(const char *service, WERROR werr = WERR_OK; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_smbconf_share_exists(service)) { + if (!libnet_conf_share_exists(service)) { return WERR_NO_SUCH_SERVICE; } -- cgit From 3f3a29ed509916751e8ead326dba3e2221cab199 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:55:43 +0100 Subject: Rename libnet_smbconf_create_share() to libnet_conf_create_share(). Michael (This used to be commit 6bc4ee210855dbfbee9e86b59e90b08ecb3a9df9) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index cf11a42329..be45e30d50 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -612,7 +612,7 @@ bool libnet_conf_share_exists(const char *servicename) /** * Add a service if it does not already exist. */ -WERROR libnet_smbconf_create_share(const char *servicename) +WERROR libnet_conf_create_share(const char *servicename) { WERROR werr; TALLOC_CTX *mem_ctx = talloc_stackframe(); -- cgit From e1aa474a32a8b6faa952ad4e9e2e91b8727ad56e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 13:59:14 +0100 Subject: Rename libnet_smbconf_getshare() to libnet_conf_get_share(). Michael (This used to be commit 1575612f1936312125e7778a9a4227e444ea36cf) --- source3/libnet/libnet_conf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index be45e30d50..594dea9603 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -482,10 +482,10 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, } for (count = 0; count < tmp_num_shares; count++) { - werr = libnet_smbconf_getshare(mem_ctx, tmp_share_names[count], - &tmp_num_params[count], - &tmp_param_names[count], - &tmp_param_values[count]); + werr = libnet_conf_get_share(mem_ctx, tmp_share_names[count], + &tmp_num_params[count], + &tmp_param_names[count], + &tmp_param_values[count]); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -633,9 +633,9 @@ done: /** * get a definition of a share (service) from configuration. */ -WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename, - uint32_t *num_params, char ***param_names, - char ***param_values) +WERROR libnet_conf_get_share(TALLOC_CTX *mem_ctx, const char *servicename, + uint32_t *num_params, char ***param_names, + char ***param_values) { WERROR werr = WERR_OK; struct registry_key *key = NULL; -- cgit From e89411effda51f9012d1830d18adcb968637baac Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 14:01:50 +0100 Subject: Rename libnet_smbconf_delshare() to libnet_conf_delete_share(). Michael (This used to be commit 2075baf551ca7fc6bcee6b93f63fd7fbf75f9a50) --- source3/libnet/libnet_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 594dea9603..0f11bbbc49 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -657,7 +657,7 @@ done: /** * delete a service from configuration */ -WERROR libnet_smbconf_delshare(const char *servicename) +WERROR libnet_conf_delete_share(const char *servicename) { WERROR werr = WERR_OK; struct registry_key *key = NULL; -- cgit From b9f904b59d867c290675ec1013218ba7333253c5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 14:06:09 +0100 Subject: Rename libnet_smbconf_setparm() to libnet_conf_set_parameter(). Michael (This used to be commit e00cb415d30b3e72ccfb7e5c366c95ec0f9c6247) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 0f11bbbc49..ad9ae4994b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -678,9 +678,9 @@ done: /** * set a configuration parameter to the value provided. */ -WERROR libnet_smbconf_setparm(const char *service, - const char *param, - const char *valstr) +WERROR libnet_conf_set_parameter(const char *service, + const char *param, + const char *valstr) { WERROR werr; struct registry_key *key = NULL; @@ -796,6 +796,6 @@ done: WERROR libnet_smbconf_set_global_param(const char *param, const char *val) { - return libnet_smbconf_setparm(GLOBAL_NAME, param, val); + return libnet_conf_set_parameter(GLOBAL_NAME, param, val); } -- cgit From 55771b356d632ffe7d1d773670a71366e3d7302a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 14:08:45 +0100 Subject: Rename libnet_smbconf_getparm() to libnet_conf_get_parameter(). Michael (This used to be commit d08556dbc7071933feaeec538f01ac8f6a637b1d) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ad9ae4994b..f5504b78d5 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -707,10 +707,10 @@ done: /** * get the value of a configuration parameter as a string */ -WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx, - const char *service, - const char *param, - char **valstr) +WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx, + const char *service, + const char *param, + char **valstr) { WERROR werr = WERR_OK; struct registry_key *key = NULL; -- cgit From 2476254ccdf629d7889b9cff458a6e1097fc71ba Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 14:11:20 +0100 Subject: Rename libnet_smbconf_delparm() to libnet_conf_delete_parameter(). Michael (This used to be commit 073eeca51e46da6a687175aadbfdbb9e029532d6) --- source3/libnet/libnet_conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index f5504b78d5..fbe47b212b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -757,8 +757,7 @@ done: /** * delete a parameter from configuration */ -WERROR libnet_smbconf_delparm(const char *service, - const char *param) +WERROR libnet_conf_delete_parameter(const char *service, const char *param) { struct registry_key *key = NULL; WERROR werr = WERR_OK; -- cgit From 5655ae7a2468e8fc93b1a8d9ac4b2f35abbf3703 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 14:15:05 +0100 Subject: Rename libnet_smbconf_set_global_param() to libnet_conf_set_global_parameter(). Now all functions are converted to the consistent naming scheme. Michael (This used to be commit a559533c0c8a80f3f4078bbc2675de395359485f) --- source3/libnet/libnet_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index fbe47b212b..ea3f708883 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -792,8 +792,8 @@ done: * **********************************************************************/ -WERROR libnet_smbconf_set_global_param(const char *param, - const char *val) +WERROR libnet_conf_set_global_parameter(const char *param, + const char *val) { return libnet_conf_set_parameter(GLOBAL_NAME, param, val); } -- cgit From 6dce6ba0a6551c4db29ccf51e346f20ea1f8430e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 14:34:31 +0100 Subject: Add a comment header and do some slight reformatting. Michael (This used to be commit 5d557e3f95b8d53114c25ba7fa3e564a50be9e05) --- source3/libnet/libnet_conf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ea3f708883..86ef3e5517 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -124,7 +124,7 @@ done: return werr; } -/* +/** * open the base key KEY_SMBCONF */ static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx, @@ -134,6 +134,9 @@ static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx, return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key); } +/** + * check if a value exists in a given registry key + */ static bool libnet_conf_value_exists(struct registry_key *key, const char *param) { @@ -151,7 +154,7 @@ static bool libnet_conf_value_exists(struct registry_key *key, return ret; } -/* +/** * create a subkey of KEY_SMBCONF */ static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *ctx, @@ -193,7 +196,7 @@ done: return werr; } -/* +/** * add a value to a key. */ static WERROR libnet_conf_reg_set_value(struct registry_key *key, @@ -792,8 +795,7 @@ done: * **********************************************************************/ -WERROR libnet_conf_set_global_parameter(const char *param, - const char *val) +WERROR libnet_conf_set_global_parameter(const char *param, const char *val) { return libnet_conf_set_parameter(GLOBAL_NAME, param, val); } -- cgit From 5470f8f638505b8dccc11ca0038632aa472608d8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 3 Jan 2008 15:33:09 +0100 Subject: Make libnet_conf handle opening/initialization of the registry. Open state is currently tracked by a global variable to avoid double initialization. Later, this can possibly be replaced by a conf-context created by an initialization function and passed around to the other api functions. Michael (This used to be commit 77713e776405800ac54c692a77cd4efd153042cb) --- source3/libnet/libnet_conf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 86ef3e5517..665261723b 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -21,6 +21,11 @@ #include "includes.h" #include "libnet/libnet.h" +/* + * yuck - static variable to keep track of the registry initialization. + */ +static bool registry_initialized = false; + /********************************************************************** * * Helper functions (mostly registry related) @@ -54,6 +59,26 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, return WERR_OK; } +static WERROR libnet_conf_reg_initialize(void) +{ + WERROR werr = WERR_OK; + + if (registry_initialized) { + goto done; + } + + if (!registry_init_regdb()) { + /* proper error code? */ + werr = WERR_GENERAL_FAILURE; + goto done; + } + + registry_initialized = true; + +done: + return werr; +} + /** * Open a registry key specified by "path" */ @@ -78,6 +103,13 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, goto done; } + werr = libnet_conf_reg_initialize(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(1, ("Error initializing registry: %s\n", + dos_errstr(werr))); + goto done; + } + token = registry_create_admin_token(tmp_ctx); if (token == NULL) { DEBUG(1, ("Error creating admin token\n")); -- cgit From 192700bd08ba893cad9fb38f80231ad7cf9eb89f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 3 Jan 2008 16:46:26 +0100 Subject: Use different error code for libnet_conf initialization failure. Guenther (This used to be commit 65537eae842065a1dd68d8e532e61502b61e1dbe) --- source3/libnet/libnet_conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 665261723b..c8e55a70b2 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -68,8 +68,7 @@ static WERROR libnet_conf_reg_initialize(void) } if (!registry_init_regdb()) { - /* proper error code? */ - werr = WERR_GENERAL_FAILURE; + werr = WERR_REG_IO_FAILURE; goto done; } -- cgit From 22068a0c167b27cf1d74a32ac516df25dce0f70a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 9 Jan 2008 01:17:13 +0100 Subject: Change registry_create_admin_token() to return NTSTATUS. Michael (This used to be commit 9cd30fb25c42e79946b5140994d0bf2ef4c62f90) --- source3/libnet/libnet_conf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index c8e55a70b2..d0ef6eb0e6 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -87,7 +87,7 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, struct registry_key **key) { WERROR werr = WERR_OK; - NT_USER_TOKEN *token; + NT_USER_TOKEN *token = NULL; TALLOC_CTX *tmp_ctx = NULL; if (path == NULL) { @@ -109,11 +109,9 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, goto done; } - token = registry_create_admin_token(tmp_ctx); - if (token == NULL) { + werr = ntstatus_to_werror(registry_create_admin_token(tmp_ctx, &token)); + if (W_ERROR_IS_OK(werr)) { DEBUG(1, ("Error creating admin token\n")); - /* what is the appropriate error code here? */ - werr = WERR_CAN_NOT_COMPLETE; goto done; } -- cgit From 618f9a60cc60bceb40eed31fbd845db18ccbaee4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 18:55:20 +0100 Subject: Fix panic in "net conf": Fix logic in error condition. Michael (This used to be commit 83aed537c16f632599484f60c5ccebc3ab713801) --- source3/libnet/libnet_conf.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index d0ef6eb0e6..dcb80d96ea 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -110,7 +110,7 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, } werr = ntstatus_to_werror(registry_create_admin_token(tmp_ctx, &token)); - if (W_ERROR_IS_OK(werr)) { + if (!W_ERROR_IS_OK(werr)) { DEBUG(1, ("Error creating admin token\n")); goto done; } @@ -420,6 +420,48 @@ done: * **********************************************************************/ +/** + * Open the configuration. + * + * Upon success, this creates and returns the conf context + * that should be passed around in subsequent calls to the other + * libnet_conf functions. + */ +WERROR libnet_conf_open(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx **conf_ctx) +{ + WERROR werr = WERR_OK; + struct libnet_conf_ctx *ctx; + + if (conf_ctx == NULL) { + return WERR_INVALID_PARAM; + } + + ctx = talloc_zero(mem_ctx, struct libnet_conf_ctx); + if (ctx == NULL) { + return WERR_NOMEM; + } + + talloc_set_destructor(ctx, libnet_conf_destrox_ctx); + + ctx->token = registry_create_admin_token(tmp_ctx); + if (ctx->token == NULL) { + DEBUG(1, ("Error creating admin token\n")); + /* what is the appropriate error code here? */ + werr = WERR_CAN_NOT_COMPLETE; + goto done; + } + + +} + +/** + * Close the configuration. + */ +WERROR libnet_conf_close(struct libnet_conf_ctx *ctx) +{ + regdb_close(); +} + /** * Drop the whole configuration (restarting empty). */ -- cgit From 9cd74303478ac15b4357fb7f76d9576fe9a060a1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Jan 2008 19:02:26 +0100 Subject: Remove code accidentially submittet with last commit 83aed537c16f63. This is ist still in preparation and will follow soon. Soory! Michael (This used to be commit 75acdb54a454ffda9d422fcafb573c8f5581d2e8) --- source3/libnet/libnet_conf.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index dcb80d96ea..0bdf4805d7 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -420,48 +420,6 @@ done: * **********************************************************************/ -/** - * Open the configuration. - * - * Upon success, this creates and returns the conf context - * that should be passed around in subsequent calls to the other - * libnet_conf functions. - */ -WERROR libnet_conf_open(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx **conf_ctx) -{ - WERROR werr = WERR_OK; - struct libnet_conf_ctx *ctx; - - if (conf_ctx == NULL) { - return WERR_INVALID_PARAM; - } - - ctx = talloc_zero(mem_ctx, struct libnet_conf_ctx); - if (ctx == NULL) { - return WERR_NOMEM; - } - - talloc_set_destructor(ctx, libnet_conf_destrox_ctx); - - ctx->token = registry_create_admin_token(tmp_ctx); - if (ctx->token == NULL) { - DEBUG(1, ("Error creating admin token\n")); - /* what is the appropriate error code here? */ - werr = WERR_CAN_NOT_COMPLETE; - goto done; - } - - -} - -/** - * Close the configuration. - */ -WERROR libnet_conf_close(struct libnet_conf_ctx *ctx) -{ - regdb_close(); -} - /** * Drop the whole configuration (restarting empty). */ -- cgit From 8921b2222a9e2db9e185486b247fb5fca448971d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 12 Jan 2008 01:28:20 +0100 Subject: Auto-add missing shares in libnet_conf_set_parameter(). Michael, please have a look. Guenther (This used to be commit 9f4506e5e2828e0f23bc37586770995c3424b208) --- source3/libnet/libnet_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 0bdf4805d7..47b4800d80 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -719,8 +719,10 @@ WERROR libnet_conf_set_parameter(const char *service, TALLOC_CTX *mem_ctx = talloc_stackframe(); if (!libnet_conf_share_exists(service)) { - werr = WERR_NO_SUCH_SERVICE; - goto done; + werr = libnet_conf_create_share(service); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } } werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_WRITE, -- cgit From 1ee6d3e1ee56554d83437a8c79cb169a26732154 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 01:40:05 +0100 Subject: Introduce a libnet_conf context created by libnet_conf_open(). The libnet_conf_ctx stores the information necessary to interoperate with the configuration. It is created by calling libnet_conf_open() and destroyed by calling libnet_conf_close(). The context is passed to all the libnet_conf functions. It currently stores the token to access the registry. Later, it could store more data, e.g. the server to connect to, credentials, and so on. For support of other backends than registry or support of remote configuration, only the open function will have to be changed. In net_conf, the calls to the actual net_conf functions is wrapped into a function that calls libnet_conf_open()/_close(). Thus an individual variant of net_conf_runfunction2() and functable2 is used to cope with functions being called by the wrapper with the additional libnet_conf_ctx argument. Michael (This used to be commit c2a9346faa26e79af5948197a1b322e545f0ed09) --- source3/libnet/libnet_conf.c | 211 ++++++++++++++++++++++++++++--------------- 1 file changed, 136 insertions(+), 75 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 47b4800d80..8e44e4f525 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -21,11 +21,6 @@ #include "includes.h" #include "libnet/libnet.h" -/* - * yuck - static variable to keep track of the registry initialization. - */ -static bool registry_initialized = false; - /********************************************************************** * * Helper functions (mostly registry related) @@ -59,20 +54,21 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, return WERR_OK; } -static WERROR libnet_conf_reg_initialize(void) +static WERROR libnet_conf_reg_initialize(struct libnet_conf_ctx *ctx) { WERROR werr = WERR_OK; - if (registry_initialized) { - goto done; - } - if (!registry_init_regdb()) { werr = WERR_REG_IO_FAILURE; goto done; } - registry_initialized = true; + werr = ntstatus_to_werror(registry_create_admin_token(ctx, + &(ctx->token))); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(1, ("Error creating admin token\n")); + goto done; + } done: return werr; @@ -82,40 +78,33 @@ done: * Open a registry key specified by "path" */ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, const char *path, uint32 desired_access, struct registry_key **key) { WERROR werr = WERR_OK; - NT_USER_TOKEN *token = NULL; - TALLOC_CTX *tmp_ctx = NULL; - if (path == NULL) { - DEBUG(1, ("Error: NULL path string given\n")); + if (ctx == NULL) { + DEBUG(1, ("Error: configuration is not open!\n")); werr = WERR_INVALID_PARAM; goto done; } - tmp_ctx = talloc_new(mem_ctx); - if (tmp_ctx == NULL) { - werr = WERR_NOMEM; - goto done; - } - - werr = libnet_conf_reg_initialize(); - if (!W_ERROR_IS_OK(werr)) { - DEBUG(1, ("Error initializing registry: %s\n", - dos_errstr(werr))); + if (ctx->token == NULL) { + DEBUG(1, ("Error: token missing from libnet_conf_ctx. " + "was libnet_conf_open() called?\n")); + werr = WERR_INVALID_PARAM; goto done; } - werr = ntstatus_to_werror(registry_create_admin_token(tmp_ctx, &token)); - if (!W_ERROR_IS_OK(werr)) { - DEBUG(1, ("Error creating admin token\n")); + if (path == NULL) { + DEBUG(1, ("Error: NULL path string given\n")); + werr = WERR_INVALID_PARAM; goto done; } - werr = reg_open_path(mem_ctx, path, desired_access, token, key); + werr = reg_open_path(mem_ctx, path, desired_access, ctx->token, key); if (!W_ERROR_IS_OK(werr)) { DEBUG(1, ("Error opening registry path '%s': %s\n", @@ -123,14 +112,14 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, } done: - TALLOC_FREE(tmp_ctx); return werr; } /** * Open a subkey of KEY_SMBCONF (i.e a service) */ -static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *ctx, +static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, const char *servicename, uint32 desired_access, struct registry_key **key) @@ -144,9 +133,10 @@ static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *ctx, goto done; } - path = talloc_asprintf(ctx, "%s\\%s", KEY_SMBCONF, servicename); + path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SMBCONF, servicename); - werr = libnet_conf_reg_open_path(ctx, path, desired_access, key); + werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, desired_access, + key); done: TALLOC_FREE(path); @@ -156,11 +146,13 @@ done: /** * open the base key KEY_SMBCONF */ -static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx, +static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, uint32 desired_access, struct registry_key **key) { - return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key); + return libnet_conf_reg_open_path(mem_ctx, ctx, KEY_SMBCONF, + desired_access, key); } /** @@ -186,7 +178,8 @@ static bool libnet_conf_value_exists(struct registry_key *key, /** * create a subkey of KEY_SMBCONF */ -static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *ctx, +static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, const char * subkeyname, struct registry_key **newkey) { @@ -198,18 +191,18 @@ static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *ctx, /* create a new talloc ctx for creation. it will hold * the intermediate parent key (SMBCONF) for creation * and will be destroyed when leaving this function... */ - if (!(create_ctx = talloc_new(ctx))) { + if (!(create_ctx = talloc_new(mem_ctx))) { werr = WERR_NOMEM; goto done; } - werr = libnet_conf_reg_open_base_key(create_ctx, REG_KEY_WRITE, + werr = libnet_conf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE, &create_parent); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = reg_createkey(ctx, create_parent, subkeyname, + werr = reg_createkey(mem_ctx, create_parent, subkeyname, REG_KEY_WRITE, newkey, &action); if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) { DEBUG(10, ("Key '%s' already exists.\n", subkeyname)); @@ -414,16 +407,72 @@ done: return werr; } +static int libnet_conf_destroy_ctx(struct libnet_conf_ctx *ctx) +{ + return regdb_close(); +} + /********************************************************************** * * The actual net conf api functions, that are exported. * **********************************************************************/ +/** + * Open the configuration. + * + * This should be the first function in a sequence of calls to libnet_conf + * functions: + * + * Upon success, this creates and returns the conf context + * that should be passed around in subsequent calls to the other + * libnet_conf functions. + * + * After the work with the configuration is completed, libnet_conf_close() + * should be called. + */ +WERROR libnet_conf_open(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx **conf_ctx) +{ + WERROR werr = WERR_OK; + struct libnet_conf_ctx *ctx; + + if (conf_ctx == NULL) { + return WERR_INVALID_PARAM; + } + + ctx = TALLOC_ZERO_P(mem_ctx, struct libnet_conf_ctx); + if (ctx == NULL) { + return WERR_NOMEM; + } + + werr = libnet_conf_reg_initialize(ctx); + if (!W_ERROR_IS_OK(werr)) { + goto fail; + } + + talloc_set_destructor(ctx, libnet_conf_destroy_ctx); + + *conf_ctx = ctx; + return werr; + +fail: + TALLOC_FREE(ctx); + return werr; +} + +/** + * Close the configuration. + */ +void libnet_conf_close(struct libnet_conf_ctx *ctx) +{ + /* this also closes the registry (by destructor): */ + TALLOC_FREE(ctx); +} + /** * Drop the whole configuration (restarting empty). */ -WERROR libnet_conf_drop(void) +WERROR libnet_conf_drop(struct libnet_conf_ctx *ctx) { char *path, *p; WERROR werr = WERR_OK; @@ -439,7 +488,7 @@ WERROR libnet_conf_drop(void) } p = strrchr(path, '\\'); *p = '\0'; - werr = libnet_conf_reg_open_path(mem_ctx, path, REG_KEY_WRITE, + werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE, &parent_key); if (!W_ERROR_IS_OK(werr)) { @@ -469,7 +518,8 @@ done: * param_names : list of lists of parameter names for each share * param_values : list of lists of parameter values for each share */ -WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, +WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, uint32_t *num_shares, char ***share_names, uint32_t **num_params, char ****param_names, char ****param_values) { @@ -496,7 +546,7 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, goto done; } - werr = libnet_conf_get_share_names(tmp_ctx, &tmp_num_shares, + werr = libnet_conf_get_share_names(tmp_ctx, ctx, &tmp_num_shares, &tmp_share_names); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -514,7 +564,8 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, uint32_t *num_shares, } for (count = 0; count < tmp_num_shares; count++) { - werr = libnet_conf_get_share(mem_ctx, tmp_share_names[count], + werr = libnet_conf_get_share(mem_ctx, ctx, + tmp_share_names[count], &tmp_num_params[count], &tmp_param_names[count], &tmp_param_values[count]); @@ -543,11 +594,12 @@ done: return werr; } - /** * get the list of share names defined in the configuration. */ -WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, +WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, + uint32_t *num_shares, char ***share_names) { uint32_t count; @@ -570,7 +622,7 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, } /* make sure "global" is always listed first */ - if (libnet_conf_share_exists(GLOBAL_NAME)) { + if (libnet_conf_share_exists(ctx, GLOBAL_NAME)) { werr = libnet_conf_add_string_to_array(tmp_ctx, &tmp_share_names, 0, GLOBAL_NAME); @@ -580,8 +632,8 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, uint32_t *num_shares, added_count++; } - werr = libnet_conf_reg_open_base_key(tmp_ctx, SEC_RIGHTS_ENUM_SUBKEYS, - &key); + werr = libnet_conf_reg_open_base_key(tmp_ctx, ctx, + SEC_RIGHTS_ENUM_SUBKEYS, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -624,14 +676,15 @@ done: /** * check if a share/service of a given name exists */ -bool libnet_conf_share_exists(const char *servicename) +bool libnet_conf_share_exists(struct libnet_conf_ctx *ctx, + const char *servicename) { bool ret = false; WERROR werr = WERR_OK; TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - werr = libnet_conf_reg_open_service_key(mem_ctx, servicename, + werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, servicename, REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = true; @@ -644,18 +697,20 @@ bool libnet_conf_share_exists(const char *servicename) /** * Add a service if it does not already exist. */ -WERROR libnet_conf_create_share(const char *servicename) +WERROR libnet_conf_create_share(struct libnet_conf_ctx *ctx, + const char *servicename) { WERROR werr; TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - if (libnet_conf_share_exists(servicename)) { + if (libnet_conf_share_exists(ctx, servicename)) { werr = WERR_ALREADY_EXISTS; goto done; } - werr = libnet_conf_reg_create_service_key(mem_ctx, servicename, &key); + werr = libnet_conf_reg_create_service_key(mem_ctx, ctx, servicename, + &key); done: TALLOC_FREE(mem_ctx); @@ -665,14 +720,14 @@ done: /** * get a definition of a share (service) from configuration. */ -WERROR libnet_conf_get_share(TALLOC_CTX *mem_ctx, const char *servicename, - uint32_t *num_params, char ***param_names, - char ***param_values) +WERROR libnet_conf_get_share(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx *ctx, + const char *servicename, uint32_t *num_params, + char ***param_names, char ***param_values) { WERROR werr = WERR_OK; struct registry_key *key = NULL; - werr = libnet_conf_reg_open_service_key(mem_ctx, servicename, + werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, servicename, REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -689,13 +744,14 @@ done: /** * delete a service from configuration */ -WERROR libnet_conf_delete_share(const char *servicename) +WERROR libnet_conf_delete_share(struct libnet_conf_ctx *ctx, + const char *servicename) { WERROR werr = WERR_OK; struct registry_key *key = NULL; - TALLOC_CTX *ctx = talloc_stackframe(); + TALLOC_CTX *mem_ctx = talloc_stackframe(); - werr = libnet_conf_reg_open_base_key(ctx, REG_KEY_WRITE, &key); + werr = libnet_conf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -703,14 +759,15 @@ WERROR libnet_conf_delete_share(const char *servicename) werr = reg_deletekey_recursive(key, key, servicename); done: - TALLOC_FREE(ctx); + TALLOC_FREE(mem_ctx); return werr; } /** * set a configuration parameter to the value provided. */ -WERROR libnet_conf_set_parameter(const char *service, +WERROR libnet_conf_set_parameter(struct libnet_conf_ctx *ctx, + const char *service, const char *param, const char *valstr) { @@ -718,15 +775,15 @@ WERROR libnet_conf_set_parameter(const char *service, struct registry_key *key = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_conf_share_exists(service)) { - werr = libnet_conf_create_share(service); + if (!libnet_conf_share_exists(ctx, service)) { + werr = libnet_conf_create_share(ctx, service); if (!W_ERROR_IS_OK(werr)) { goto done; } } - werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_WRITE, - &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, + REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -742,6 +799,7 @@ done: * get the value of a configuration parameter as a string */ WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, const char *service, const char *param, char **valstr) @@ -755,13 +813,13 @@ WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx, goto done; } - if (!libnet_conf_share_exists(service)) { + if (!libnet_conf_share_exists(ctx, service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } - werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_READ, - &key); + werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, + REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -791,17 +849,19 @@ done: /** * delete a parameter from configuration */ -WERROR libnet_conf_delete_parameter(const char *service, const char *param) +WERROR libnet_conf_delete_parameter(struct libnet_conf_ctx *ctx, + const char *service, const char *param) { struct registry_key *key = NULL; WERROR werr = WERR_OK; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_conf_share_exists(service)) { + if (!libnet_conf_share_exists(ctx, service)) { return WERR_NO_SUCH_SERVICE; } - werr = libnet_conf_reg_open_service_key(mem_ctx, service, REG_KEY_ALL, + werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, + REG_KEY_ALL, &key); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -826,8 +886,9 @@ done: * **********************************************************************/ -WERROR libnet_conf_set_global_parameter(const char *param, const char *val) +WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx, + const char *param, const char *val) { - return libnet_conf_set_parameter(GLOBAL_NAME, param, val); + return libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val); } -- cgit From 89fb79ada6cf8cdc94ae181cdcfa9a2c0a4ffaeb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 22:49:42 +0100 Subject: Remove auto-generation of missing share from libnet_conf_set_parameter(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Günther, I wanted to have this as atomic as possible. I will add this behaviour to libnet_conf_set_global_parameter() next with the justification that [global] should exist transparently. Michael (This used to be commit e2b34e9c028d712c7c8b22aade2c11d347ae176d) --- source3/libnet/libnet_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 8e44e4f525..11dc1639ad 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -776,10 +776,8 @@ WERROR libnet_conf_set_parameter(struct libnet_conf_ctx *ctx, TALLOC_CTX *mem_ctx = talloc_stackframe(); if (!libnet_conf_share_exists(ctx, service)) { - werr = libnet_conf_create_share(ctx, service); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } + werr = WERR_NO_SUCH_SERVICE; + goto done; } werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, -- cgit From 8fc2db5070aadee5719fd1651e86d92378927cbf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 22:56:11 +0100 Subject: Add auto-adding of [global] to libnet_conf_set_global_parameter(). Michael (This used to be commit ad2497cfac90b2e91be6995931629453fd6ed5fa) --- source3/libnet/libnet_conf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 11dc1639ad..3934f2c476 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -887,6 +887,17 @@ done: WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx, const char *param, const char *val) { - return libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val); + WERROR werr; + + if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) { + werr = libnet_conf_create_share(ctx, GLOBAL_NAME); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + } + werr = libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val); + +done: + return werr; } -- cgit From ecc53ab37147affbc0ee6fdae5a980dabe73b4f4 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 22:56:56 +0100 Subject: Add a comment header to libnet_conf_set_global_parameter(). Michael (This used to be commit c050b148d00c79571ef0e85c6e7c86d551ca6efd) --- source3/libnet/libnet_conf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 3934f2c476..005a35fd0c 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -884,6 +884,12 @@ done: * **********************************************************************/ +/** + * Set a global parameter + * (i.e. a parameter in the [global] service). + * + * This also creates [global] when it does not exist. + */ WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx, const char *param, const char *val) { -- cgit From d042a6409225f17b9d8665477fffb08c311512d9 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 23:00:16 +0100 Subject: Move libnet_conf_set_global_parameter() inside libnet_conf.c Also remove the "convenience function" section comment. The set_global_parameter function now has a right to exist in the api. Michael (This used to be commit fd99c1804ae04b7c2a2b0a605e83ba88fa362edb) --- source3/libnet/libnet_conf.c | 53 +++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 005a35fd0c..858c4a06b4 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -793,6 +793,29 @@ done: return werr; } +/** + * Set a global parameter + * (i.e. a parameter in the [global] service). + * + * This also creates [global] when it does not exist. + */ +WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx, + const char *param, const char *val) +{ + WERROR werr; + + if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) { + werr = libnet_conf_create_share(ctx, GLOBAL_NAME); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + } + werr = libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val); + +done: + return werr; +} + /** * get the value of a configuration parameter as a string */ @@ -877,33 +900,3 @@ done: return werr; } - -/********************************************************************** - * - * Convenience functions that are also exported. - * - **********************************************************************/ - -/** - * Set a global parameter - * (i.e. a parameter in the [global] service). - * - * This also creates [global] when it does not exist. - */ -WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx, - const char *param, const char *val) -{ - WERROR werr; - - if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) { - werr = libnet_conf_create_share(ctx, GLOBAL_NAME); - if (!W_ERROR_IS_OK(werr)) { - goto done; - } - } - werr = libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val); - -done: - return werr; -} - -- cgit From c4899fec9f3957c52d3a856000631d59a3346ac0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 23:12:27 +0100 Subject: Add a function libnet_conf_get_global_parameter() to libnet_conf.c It creates the [global] section if it does not yet exist. Michael (This used to be commit 627a29b690c30f1096a4746186089cd9a1c92407) --- source3/libnet/libnet_conf.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 858c4a06b4..37e05b9fe9 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -867,6 +867,31 @@ done: return werr; } +/** + * Get the value of a global parameter. + * + * Create [global] if it does not exist. + */ +WERROR libnet_conf_get_global_parameter(TALLOC_CTX *mem_ctx, + struct libnet_conf_ctx *ctx, + const char *param, + char **valstr) +{ + WERROR werr; + + if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) { + werr = libnet_conf_create_share(ctx, GLOBAL_NAME); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + } + werr = libnet_conf_get_parameter(mem_ctx, ctx, GLOBAL_NAME, param, + valstr); + +done: + return werr; +} + /** * delete a parameter from configuration */ -- cgit From 864fc10a278869b1474e407c963f9f40464d55c0 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 23:16:01 +0100 Subject: Add a function libnet_conf_delete_global_parameter() to libnet_conf.c Create the [global] section if it does not yet exist. Michael (This used to be commit 90fa2981c949e21f66a44d634ebe9d661819f0a3) --- source3/libnet/libnet_conf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 37e05b9fe9..d20e10b141 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -925,3 +925,24 @@ done: return werr; } +/** + * Delete a global parameter. + * + * Create [global] if it does not exist. + */ +WERROR libnet_conf_delete_global_parameter(struct libnet_conf_ctx *ctx, + const char *param) +{ + WERROR werr; + + if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) { + werr = libnet_conf_create_share(ctx, GLOBAL_NAME); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + } + werr = libnet_conf_delete_parameter(ctx, GLOBAL_NAME, param); + +done: + return werr; +} -- cgit From 188bfbc19230c5451059375cb648d06362ac9395 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:24:23 +0100 Subject: Add a check for talloc failure. - Pointed out by Volker. Michael (This used to be commit bdc49b07cc6de36c9319254a131858c9a7f9dd53) --- source3/libnet/libnet_conf.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index d20e10b141..152148300e 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -48,6 +48,10 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, } new_array[count] = talloc_strdup(new_array, string); + if (new_array[count] == NULL) { + TALLOC_FREE(new_array); + return WERR_NOMEM; + } *array = new_array; -- cgit From 7f2e253efbf5ce9a7195efcd5fee778b219faebb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:28:04 +0100 Subject: Use talloc_stackframe() for temporary contexts throughout libnet_conf.c Michael (This used to be commit 4d734106b70b9b6029b537fe11f8b3c1aebd42cf) --- source3/libnet/libnet_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index 152148300e..ec05fa7c16 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -195,7 +195,7 @@ static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *mem_ctx, /* create a new talloc ctx for creation. it will hold * the intermediate parent key (SMBCONF) for creation * and will be destroyed when leaving this function... */ - if (!(create_ctx = talloc_new(mem_ctx))) { + if (!(create_ctx = talloc_stackframe())) { werr = WERR_NOMEM; goto done; } @@ -361,7 +361,7 @@ static WERROR libnet_conf_reg_get_values(TALLOC_CTX *mem_ctx, goto done; } - tmp_ctx = talloc_new(mem_ctx); + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { werr = WERR_NOMEM; goto done; @@ -544,7 +544,7 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, goto done; } - tmp_ctx = talloc_new(mem_ctx); + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { werr = WERR_NOMEM; goto done; @@ -619,7 +619,7 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, goto done; } - tmp_ctx = talloc_new(mem_ctx); + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { werr = WERR_NOMEM; goto done; -- cgit From c5c38d622754c5b06716cbae41a27af711d22bcf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:31:57 +0100 Subject: Fix formatting of multi_sz registry values. Don't print only the last component. Michael (This used to be commit 654e96208ec847e32797cbd2442ef9e73c014567) --- source3/libnet/libnet_conf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index ec05fa7c16..fc797bbeb9 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -320,8 +320,12 @@ static char *libnet_conf_format_registry_value(TALLOC_CTX *mem_ctx, case REG_MULTI_SZ: { uint32 j; for (j = 0; j < value->v.multi_sz.num_strings; j++) { - result = talloc_asprintf(mem_ctx, "\"%s\" ", + result = talloc_asprintf(mem_ctx, "%s \"%s\" ", + result, value->v.multi_sz.strings[j]); + if (result == NULL) { + break; + } } break; } -- cgit From feb77c978bede01156ae1eb17c73842c7a27cda5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 21 Jan 2008 15:35:09 +0100 Subject: Add another check for talloc failure to libnet_conf Michael (This used to be commit 196e4ce8c5dd5aab518aaa7d170eb1fb5d66bcd1) --- source3/libnet/libnet_conf.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/libnet/libnet_conf.c') diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c index fc797bbeb9..4d998acad8 100644 --- a/source3/libnet/libnet_conf.c +++ b/source3/libnet/libnet_conf.c @@ -138,6 +138,10 @@ static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *mem_ctx, } path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SMBCONF, servicename); + if (path == NULL) { + werr = WERR_NOMEM; + goto done; + } werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, desired_access, key); -- cgit