diff options
author | Michael Adam <obnox@samba.org> | 2008-03-17 18:01:33 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-03-17 18:03:02 +0100 |
commit | 6274929b1e1ddf89f4c5e93414121eaf06b6ab14 (patch) | |
tree | b1a3cec7bb2cbd5d2ddcfd9423fee3b90a583cb7 | |
parent | 670418c1165f0a149bfdd4bcdc5bde575df43ef2 (diff) | |
download | samba-6274929b1e1ddf89f4c5e93414121eaf06b6ab14.tar.gz samba-6274929b1e1ddf89f4c5e93414121eaf06b6ab14.tar.bz2 samba-6274929b1e1ddf89f4c5e93414121eaf06b6ab14.zip |
libsmbconf: rename all occurrences of libnet_conf_ to smbconf_ .
Michael
(This used to be commit 097af0309d7c3e9342058ba5266667293b23c80d)
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 11 | ||||
-rw-r--r-- | source3/lib/smbconf/smbconf.c | 295 | ||||
-rw-r--r-- | source3/lib/smbconf/smbconf.h | 80 | ||||
-rw-r--r-- | source3/libnet/libnet_join.c | 34 | ||||
-rw-r--r-- | source3/param/loadparm.c | 16 | ||||
-rw-r--r-- | source3/utils/net_conf.c | 94 |
6 files changed, 257 insertions, 273 deletions
diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index d30e7d97f7..a29a840da0 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -169,7 +169,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, uint32_t *parm_error) { WERROR werr; - struct libnet_conf_ctx *conf_ctx; + struct smbconf_ctx *conf_ctx; struct srvsvc_NetSrvInfo1005 *info1005; if (!buffer) { @@ -191,17 +191,16 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx, return WERR_NOT_SUPPORTED; } - werr = libnet_conf_open(ctx, &conf_ctx); + werr = smbconf_open(ctx, &conf_ctx); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = libnet_conf_set_global_parameter(conf_ctx, - "server string", - info1005->comment); + werr = smbconf_set_global_parameter(conf_ctx, "server string", + info1005->comment); done: - libnet_conf_close(conf_ctx); + smbconf_close(conf_ctx); return werr; } diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c index 688097bc5e..4ccba09ef7 100644 --- a/source3/lib/smbconf/smbconf.c +++ b/source3/lib/smbconf/smbconf.c @@ -19,7 +19,6 @@ */ #include "includes.h" -#include "libnet/libnet.h" /********************************************************************** * @@ -31,10 +30,10 @@ /** * add a string to a talloced array of strings. */ -static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, - char ***array, - uint32_t count, - const char *string) +static WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, + char ***array, + uint32_t count, + const char *string) { char **new_array = NULL; @@ -58,7 +57,7 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx, return WERR_OK; } -static WERROR libnet_conf_reg_initialize(struct libnet_conf_ctx *ctx) +static WERROR smbconf_reg_initialize(struct smbconf_ctx *ctx) { WERROR werr = WERR_OK; @@ -81,11 +80,11 @@ 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) +static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + const char *path, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; @@ -96,8 +95,8 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx, } if (ctx->token == NULL) { - DEBUG(1, ("Error: token missing from libnet_conf_ctx. " - "was libnet_conf_open() called?\n")); + DEBUG(1, ("Error: token missing from smbconf_ctx. " + "was smbconf_open() called?\n")); werr = WERR_INVALID_PARAM; goto done; } @@ -122,11 +121,11 @@ done: /** * Open a subkey of KEY_SMBCONF (i.e a service) */ -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) +static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + const char *servicename, + uint32 desired_access, + struct registry_key **key) { WERROR werr = WERR_OK; char *path = NULL; @@ -143,8 +142,7 @@ static WERROR libnet_conf_reg_open_service_key(TALLOC_CTX *mem_ctx, goto done; } - werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, desired_access, - key); + werr = smbconf_reg_open_path(mem_ctx, ctx, path, desired_access, key); done: TALLOC_FREE(path); @@ -154,20 +152,19 @@ done: /** * open the base key KEY_SMBCONF */ -static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *mem_ctx, - struct libnet_conf_ctx *ctx, - uint32 desired_access, - struct registry_key **key) +static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + uint32 desired_access, + struct registry_key **key) { - return libnet_conf_reg_open_path(mem_ctx, ctx, KEY_SMBCONF, - desired_access, key); + return smbconf_reg_open_path(mem_ctx, 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) +static bool smbconf_value_exists(struct registry_key *key, const char *param) { bool ret = false; WERROR werr = WERR_OK; @@ -186,10 +183,10 @@ 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 *mem_ctx, - struct libnet_conf_ctx *ctx, - const char * subkeyname, - struct registry_key **newkey) +static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + const char * subkeyname, + struct registry_key **newkey) { WERROR werr = WERR_OK; struct registry_key *create_parent = NULL; @@ -204,8 +201,8 @@ static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *mem_ctx, goto done; } - werr = libnet_conf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE, - &create_parent); + werr = smbconf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE, + &create_parent); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -229,9 +226,9 @@ done: /** * add a value to a key. */ -static WERROR libnet_conf_reg_set_value(struct registry_key *key, - const char *valname, - const char *valstr) +static WERROR smbconf_reg_set_value(struct registry_key *key, + const char *valname, + const char *valstr) { struct registry_value val; WERROR werr = WERR_OK; @@ -303,8 +300,8 @@ done: * which are ar stored as REG_SZ values, so the incomplete * handling should be ok. */ -static char *libnet_conf_format_registry_value(TALLOC_CTX *mem_ctx, - struct registry_value *value) +static char *smbconf_format_registry_value(TALLOC_CTX *mem_ctx, + struct registry_value *value) { char *result = NULL; @@ -348,11 +345,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_conf_reg_get_values(TALLOC_CTX *mem_ctx, - struct registry_key *key, - uint32_t *num_values, - char ***value_names, - char ***value_strings) +static WERROR 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 = NULL; WERROR werr = WERR_OK; @@ -382,19 +379,16 @@ static WERROR libnet_conf_reg_get_values(TALLOC_CTX *mem_ctx, { char *valstring; - werr = libnet_conf_add_string_to_array(tmp_ctx, - &tmp_valnames, - count, valname); + werr = smbconf_add_string_to_array(tmp_ctx, + &tmp_valnames, + count, valname); if (!W_ERROR_IS_OK(werr)) { goto done; } - valstring = libnet_conf_format_registry_value(tmp_ctx, - valvalue); - werr = libnet_conf_add_string_to_array(tmp_ctx, - &tmp_valstrings, - count, - valstring); + valstring = smbconf_format_registry_value(tmp_ctx, valvalue); + werr = smbconf_add_string_to_array(tmp_ctx, &tmp_valstrings, + count, valstring); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -419,7 +413,7 @@ done: return werr; } -static int libnet_conf_destroy_ctx(struct libnet_conf_ctx *ctx) +static int smbconf_destroy_ctx(struct smbconf_ctx *ctx) { return regdb_close(); } @@ -433,36 +427,36 @@ static int libnet_conf_destroy_ctx(struct libnet_conf_ctx *ctx) /** * Open the configuration. * - * This should be the first function in a sequence of calls to libnet_conf + * This should be the first function in a sequence of calls to smbconf * functions: * * Upon success, this creates and returns the conf context * that should be passed around in subsequent calls to the other - * libnet_conf functions. + * smbconf functions. * - * After the work with the configuration is completed, libnet_conf_close() + * After the work with the configuration is completed, smbconf_close() * should be called. */ -WERROR libnet_conf_open(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx **conf_ctx) +WERROR smbconf_open(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx) { WERROR werr = WERR_OK; - struct libnet_conf_ctx *ctx; + struct smbconf_ctx *ctx; if (conf_ctx == NULL) { return WERR_INVALID_PARAM; } - ctx = TALLOC_ZERO_P(mem_ctx, struct libnet_conf_ctx); + ctx = TALLOC_ZERO_P(mem_ctx, struct smbconf_ctx); if (ctx == NULL) { return WERR_NOMEM; } - werr = libnet_conf_reg_initialize(ctx); + werr = smbconf_reg_initialize(ctx); if (!W_ERROR_IS_OK(werr)) { goto fail; } - talloc_set_destructor(ctx, libnet_conf_destroy_ctx); + talloc_set_destructor(ctx, smbconf_destroy_ctx); *conf_ctx = ctx; return werr; @@ -475,7 +469,7 @@ fail: /** * Close the configuration. */ -void libnet_conf_close(struct libnet_conf_ctx *ctx) +void smbconf_close(struct smbconf_ctx *ctx) { /* this also closes the registry (by destructor): */ TALLOC_FREE(ctx); @@ -488,8 +482,8 @@ void libnet_conf_close(struct libnet_conf_ctx *ctx) * of the service and parameter, it returns the registry-sequence * number. */ -uint64_t libnet_conf_get_seqnum(struct libnet_conf_ctx *ctx, - const char *service, const char *param) +uint64_t smbconf_get_seqnum(struct smbconf_ctx *ctx, + const char *service, const char *param) { return (uint64_t)regdb_get_seqnum(); } @@ -497,7 +491,7 @@ uint64_t libnet_conf_get_seqnum(struct libnet_conf_ctx *ctx, /** * Drop the whole configuration (restarting empty). */ -WERROR libnet_conf_drop(struct libnet_conf_ctx *ctx) +WERROR smbconf_drop(struct smbconf_ctx *ctx) { char *path, *p; WERROR werr = WERR_OK; @@ -513,8 +507,8 @@ WERROR libnet_conf_drop(struct libnet_conf_ctx *ctx) } p = strrchr(path, '\\'); *p = '\0'; - werr = libnet_conf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE, - &parent_key); + werr = smbconf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE, + &parent_key); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -543,8 +537,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, - struct libnet_conf_ctx *ctx, uint32_t *num_shares, +WERROR smbconf_get_config(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, uint32_t *num_shares, char ***share_names, uint32_t **num_params, char ****param_names, char ****param_values) { @@ -571,8 +565,8 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, goto done; } - werr = libnet_conf_get_share_names(tmp_ctx, ctx, &tmp_num_shares, - &tmp_share_names); + werr = smbconf_get_share_names(tmp_ctx, ctx, &tmp_num_shares, + &tmp_share_names); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -589,11 +583,11 @@ WERROR libnet_conf_get_config(TALLOC_CTX *mem_ctx, } for (count = 0; count < tmp_num_shares; 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]); + werr = smbconf_get_share(mem_ctx, 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; } @@ -622,10 +616,10 @@ done: /** * get the list of share names defined in the configuration. */ -WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, - struct libnet_conf_ctx *ctx, - uint32_t *num_shares, - char ***share_names) +WERROR smbconf_get_share_names(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + uint32_t *num_shares, + char ***share_names) { uint32_t count; uint32_t added_count = 0; @@ -647,18 +641,17 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, } /* make sure "global" is always listed first */ - if (libnet_conf_share_exists(ctx, GLOBAL_NAME)) { - werr = libnet_conf_add_string_to_array(tmp_ctx, - &tmp_share_names, - 0, GLOBAL_NAME); + if (smbconf_share_exists(ctx, GLOBAL_NAME)) { + werr = 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_conf_reg_open_base_key(tmp_ctx, ctx, - SEC_RIGHTS_ENUM_SUBKEYS, &key); + werr = smbconf_reg_open_base_key(tmp_ctx, ctx, + SEC_RIGHTS_ENUM_SUBKEYS, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -672,10 +665,10 @@ WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, continue; } - werr = libnet_conf_add_string_to_array(tmp_ctx, - &tmp_share_names, - added_count, - subkey_name); + werr = smbconf_add_string_to_array(tmp_ctx, + &tmp_share_names, + added_count, + subkey_name); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -701,16 +694,16 @@ done: /** * check if a share/service of a given name exists */ -bool libnet_conf_share_exists(struct libnet_conf_ctx *ctx, - const char *servicename) +bool smbconf_share_exists(struct smbconf_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, ctx, servicename, - REG_KEY_READ, &key); + werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename, + REG_KEY_READ, &key); if (W_ERROR_IS_OK(werr)) { ret = true; } @@ -722,20 +715,19 @@ bool libnet_conf_share_exists(struct libnet_conf_ctx *ctx, /** * Add a service if it does not already exist. */ -WERROR libnet_conf_create_share(struct libnet_conf_ctx *ctx, - const char *servicename) +WERROR smbconf_create_share(struct smbconf_ctx *ctx, + const char *servicename) { WERROR werr; TALLOC_CTX *mem_ctx = talloc_stackframe(); struct registry_key *key = NULL; - if (libnet_conf_share_exists(ctx, servicename)) { + if (smbconf_share_exists(ctx, servicename)) { werr = WERR_ALREADY_EXISTS; goto done; } - werr = libnet_conf_reg_create_service_key(mem_ctx, ctx, servicename, - &key); + werr = smbconf_reg_create_service_key(mem_ctx, ctx, servicename, &key); done: TALLOC_FREE(mem_ctx); @@ -745,21 +737,21 @@ done: /** * get a definition of a share (service) from configuration. */ -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 smbconf_get_share(TALLOC_CTX *mem_ctx, struct smbconf_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, ctx, servicename, - REG_KEY_READ, &key); + werr = smbconf_reg_open_service_key(mem_ctx, ctx, servicename, + REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = libnet_conf_reg_get_values(mem_ctx, key, num_params, - param_names, param_values); + werr = smbconf_reg_get_values(mem_ctx, key, num_params, + param_names, param_values); done: TALLOC_FREE(key); @@ -769,14 +761,13 @@ done: /** * delete a service from configuration */ -WERROR libnet_conf_delete_share(struct libnet_conf_ctx *ctx, - const char *servicename) +WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename) { WERROR werr = WERR_OK; struct registry_key *key = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); - werr = libnet_conf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key); + werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -791,27 +782,27 @@ done: /** * set a configuration parameter to the value provided. */ -WERROR libnet_conf_set_parameter(struct libnet_conf_ctx *ctx, - const char *service, - const char *param, - const char *valstr) +WERROR smbconf_set_parameter(struct smbconf_ctx *ctx, + const char *service, + const char *param, + const char *valstr) { WERROR werr; struct registry_key *key = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!libnet_conf_share_exists(ctx, service)) { + if (!smbconf_share_exists(ctx, service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } - werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, - REG_KEY_WRITE, &key); + werr = smbconf_reg_open_service_key(mem_ctx, ctx, service, + REG_KEY_WRITE, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } - werr = libnet_conf_reg_set_value(key, param, valstr); + werr = smbconf_reg_set_value(key, param, valstr); done: TALLOC_FREE(mem_ctx); @@ -824,18 +815,18 @@ done: * * 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 smbconf_set_global_parameter(struct smbconf_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 (!smbconf_share_exists(ctx, GLOBAL_NAME)) { + werr = smbconf_create_share(ctx, GLOBAL_NAME); if (!W_ERROR_IS_OK(werr)) { goto done; } } - werr = libnet_conf_set_parameter(ctx, GLOBAL_NAME, param, val); + werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val); done: return werr; @@ -844,11 +835,11 @@ 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) +WERROR smbconf_get_parameter(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + const char *service, + const char *param, + char **valstr) { WERROR werr = WERR_OK; struct registry_key *key = NULL; @@ -859,18 +850,18 @@ WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx, goto done; } - if (!libnet_conf_share_exists(ctx, service)) { + if (!smbconf_share_exists(ctx, service)) { werr = WERR_NO_SUCH_SERVICE; goto done; } - werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, - REG_KEY_READ, &key); + werr = smbconf_reg_open_service_key(mem_ctx, ctx, service, + REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } - if (!libnet_conf_value_exists(key, param)) { + if (!smbconf_value_exists(key, param)) { werr = WERR_INVALID_PARAM; goto done; } @@ -880,7 +871,7 @@ WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx, goto done; } - *valstr = libnet_conf_format_registry_value(mem_ctx, value); + *valstr = smbconf_format_registry_value(mem_ctx, value); if (*valstr == NULL) { werr = WERR_NOMEM; @@ -897,21 +888,20 @@ done: * * 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 smbconf_get_global_parameter(TALLOC_CTX *mem_ctx, + struct smbconf_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 (!smbconf_share_exists(ctx, GLOBAL_NAME)) { + werr = smbconf_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); + werr = smbconf_get_parameter(mem_ctx, ctx, GLOBAL_NAME, param, valstr); done: return werr; @@ -920,25 +910,24 @@ done: /** * delete a parameter from configuration */ -WERROR libnet_conf_delete_parameter(struct libnet_conf_ctx *ctx, - const char *service, const char *param) +WERROR smbconf_delete_parameter(struct smbconf_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(ctx, service)) { + if (!smbconf_share_exists(ctx, service)) { return WERR_NO_SUCH_SERVICE; } - werr = libnet_conf_reg_open_service_key(mem_ctx, ctx, service, - REG_KEY_ALL, - &key); + werr = smbconf_reg_open_service_key(mem_ctx, ctx, service, + REG_KEY_ALL, &key); if (!W_ERROR_IS_OK(werr)) { goto done; } - if (!libnet_conf_value_exists(key, param)) { + if (!smbconf_value_exists(key, param)) { werr = WERR_INVALID_PARAM; goto done; } @@ -955,18 +944,18 @@ done: * * Create [global] if it does not exist. */ -WERROR libnet_conf_delete_global_parameter(struct libnet_conf_ctx *ctx, - const char *param) +WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, + const char *param) { WERROR werr; - if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) { - werr = libnet_conf_create_share(ctx, GLOBAL_NAME); + if (!smbconf_share_exists(ctx, GLOBAL_NAME)) { + werr = smbconf_create_share(ctx, GLOBAL_NAME); if (!W_ERROR_IS_OK(werr)) { goto done; } } - werr = libnet_conf_delete_parameter(ctx, GLOBAL_NAME, param); + werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); done: return werr; diff --git a/source3/lib/smbconf/smbconf.h b/source3/lib/smbconf/smbconf.h index 0b04bdd4ec..d2e05045f7 100644 --- a/source3/lib/smbconf/smbconf.h +++ b/source3/lib/smbconf/smbconf.h @@ -20,7 +20,7 @@ #ifndef __LIBSMBCONF_H__ #define __LIBSMBCONF_H__ -struct libnet_conf_ctx { +struct smbconf_ctx { NT_USER_TOKEN *token; }; @@ -30,46 +30,44 @@ struct libnet_conf_ctx { * (Backends and possibly remote support being added ...) */ -WERROR libnet_conf_open(TALLOC_CTX *mem_ctx, struct libnet_conf_ctx **conf_ctx); -void libnet_conf_close(struct libnet_conf_ctx *ctx); -uint64_t libnet_conf_get_seqnum(struct libnet_conf_ctx *ctx, +WERROR smbconf_open(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx); +void smbconf_close(struct smbconf_ctx *ctx); +uint64_t smbconf_get_seqnum(struct smbconf_ctx *ctx, + const char *service, const char *param); +WERROR smbconf_drop(struct smbconf_ctx *ctx); +WERROR smbconf_get_config(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, uint32_t *num_shares, + char ***share_names, uint32_t **num_params, + char ****param_names, char ****param_values); +WERROR smbconf_get_share_names(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + uint32_t *num_shares, + char ***share_names); +bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename); +WERROR smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename); +WERROR smbconf_get_share(TALLOC_CTX *mem_ctx, struct smbconf_ctx *ctx, + const char *servicename, uint32_t *num_params, + char ***param_names, char ***param_values); +WERROR smbconf_delete_share(struct smbconf_ctx *ctx, + const char *servicename); +WERROR smbconf_set_parameter(struct smbconf_ctx *ctx, + const char *service, + const char *param, + const char *valstr); +WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx, + const char *param, const char *val); +WERROR smbconf_get_parameter(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + const char *service, + const char *param, + char **valstr); +WERROR smbconf_get_global_parameter(TALLOC_CTX *mem_ctx, + struct smbconf_ctx *ctx, + const char *param, + char **valstr); +WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, const char *service, const char *param); -WERROR libnet_conf_drop(struct libnet_conf_ctx *ctx); -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); -WERROR libnet_conf_get_share_names(TALLOC_CTX *mem_ctx, - struct libnet_conf_ctx *ctx, - uint32_t *num_shares, - char ***share_names); -bool libnet_conf_share_exists(struct libnet_conf_ctx *ctx, - const char *servicename); -WERROR libnet_conf_create_share(struct libnet_conf_ctx *ctx, - const char *servicename); -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 libnet_conf_delete_share(struct libnet_conf_ctx *ctx, - const char *servicename); -WERROR libnet_conf_set_parameter(struct libnet_conf_ctx *ctx, - const char *service, - const char *param, - const char *valstr); -WERROR libnet_conf_set_global_parameter(struct libnet_conf_ctx *ctx, - const char *param, const char *val); -WERROR libnet_conf_get_parameter(TALLOC_CTX *mem_ctx, - struct libnet_conf_ctx *ctx, - const char *service, - const char *param, - char **valstr); -WERROR libnet_conf_get_global_parameter(TALLOC_CTX *mem_ctx, - struct libnet_conf_ctx *ctx, - const char *param, - char **valstr); -WERROR libnet_conf_delete_parameter(struct libnet_conf_ctx *ctx, - const char *service, const char *param); -WERROR libnet_conf_delete_global_parameter(struct libnet_conf_ctx *ctx, - const char *param); +WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, + const char *param); #endif /* _LIBSMBCONF_H_ */ diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 9bed346b5e..2e634a16f1 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1199,41 +1199,41 @@ done: static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r) { WERROR werr; - struct libnet_conf_ctx *ctx; + struct smbconf_ctx *ctx; - werr = libnet_conf_open(r, &ctx); + werr = smbconf_open(r, &ctx); if (!W_ERROR_IS_OK(werr)) { goto done; } if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) { - werr = libnet_conf_set_global_parameter(ctx, "security", "user"); + werr = smbconf_set_global_parameter(ctx, "security", "user"); W_ERROR_NOT_OK_GOTO_DONE(werr); - werr = libnet_conf_set_global_parameter(ctx, "workgroup", - r->in.domain_name); + werr = smbconf_set_global_parameter(ctx, "workgroup", + r->in.domain_name); goto done; } - werr = libnet_conf_set_global_parameter(ctx, "security", "domain"); + werr = smbconf_set_global_parameter(ctx, "security", "domain"); W_ERROR_NOT_OK_GOTO_DONE(werr); - werr = libnet_conf_set_global_parameter(ctx, "workgroup", - r->out.netbios_domain_name); + werr = smbconf_set_global_parameter(ctx, "workgroup", + r->out.netbios_domain_name); W_ERROR_NOT_OK_GOTO_DONE(werr); if (r->out.domain_is_ad) { - werr = libnet_conf_set_global_parameter(ctx, "security", "ads"); + werr = smbconf_set_global_parameter(ctx, "security", "ads"); W_ERROR_NOT_OK_GOTO_DONE(werr); - werr = libnet_conf_set_global_parameter(ctx, "realm", - r->out.dns_domain_name); + werr = smbconf_set_global_parameter(ctx, "realm", + r->out.dns_domain_name); W_ERROR_NOT_OK_GOTO_DONE(werr); } done: - libnet_conf_close(ctx); + smbconf_close(ctx); return werr; } @@ -1243,22 +1243,22 @@ static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r) static WERROR do_unjoin_modify_vals_config(struct libnet_UnjoinCtx *r) { WERROR werr = WERR_OK; - struct libnet_conf_ctx *ctx; + struct smbconf_ctx *ctx; - werr = libnet_conf_open(r, &ctx); + werr = smbconf_open(r, &ctx); if (!W_ERROR_IS_OK(werr)) { goto done; } if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) { - werr = libnet_conf_set_global_parameter(ctx, "security", "user"); + werr = smbconf_set_global_parameter(ctx, "security", "user"); W_ERROR_NOT_OK_GOTO_DONE(werr); - libnet_conf_delete_global_parameter(ctx, "realm"); + smbconf_delete_global_parameter(ctx, "realm"); } done: - libnet_conf_close(ctx); + smbconf_close(ctx); return werr; } diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index e144c03b61..900790498e 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -73,7 +73,7 @@ extern userdom_struct current_user_info; static bool in_client = False; /* Not in the client by default */ static uint64_t conf_last_seqnum = 0; -static struct libnet_conf_ctx *conf_ctx = NULL; +static struct smbconf_ctx *conf_ctx = NULL; #define CONFIG_BACKEND_FILE 0 #define CONFIG_BACKEND_REGISTRY 1 @@ -6498,21 +6498,21 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *)) if (conf_ctx == NULL) { /* first time */ - werr = libnet_conf_open(NULL, &conf_ctx); + werr = smbconf_open(NULL, &conf_ctx); if (!W_ERROR_IS_OK(werr)) { goto done; } } - if (!libnet_conf_share_exists(conf_ctx, GLOBAL_NAME)) { + if (!smbconf_share_exists(conf_ctx, GLOBAL_NAME)) { /* nothing to read from the registry yet but make sure lp_load * doesn't return false */ ret = true; goto done; } - werr = libnet_conf_get_share(mem_ctx, conf_ctx, GLOBAL_NAME, - &num_params, ¶m_names, ¶m_values); + werr = smbconf_get_share(mem_ctx, conf_ctx, GLOBAL_NAME, + &num_params, ¶m_names, ¶m_values); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -6525,7 +6525,7 @@ static bool process_registry_globals(bool (*pfunc)(const char *, const char *)) } ret = pfunc("registry shares", "yes"); - conf_last_seqnum = libnet_conf_get_seqnum(conf_ctx, NULL, NULL); + conf_last_seqnum = smbconf_get_seqnum(conf_ctx, NULL, NULL); done: TALLOC_FREE(mem_ctx); @@ -6608,14 +6608,14 @@ bool lp_file_list_changed(void) uint64_t conf_cur_seqnum; if (conf_ctx == NULL) { WERROR werr; - werr = libnet_conf_open(NULL, &conf_ctx); + werr = smbconf_open(NULL, &conf_ctx); if (!W_ERROR_IS_OK(werr)) { DEBUG(0, ("error opening configuration: %s\n", dos_errstr(werr))); return false; } } - conf_cur_seqnum = libnet_conf_get_seqnum(conf_ctx, NULL, NULL); + conf_cur_seqnum = smbconf_get_seqnum(conf_ctx, NULL, NULL); if (conf_last_seqnum != conf_cur_seqnum) { DEBUGADD(6, ("regdb seqnum changed: old = %llu, " "new = %llu\n", diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index 26ed41b2a0..21a3b2f7d2 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -20,7 +20,7 @@ /* * This is an interface to Samba's configuration as made available - * by the libnet_conf interface (source/libnet/libnet_conf.c). + * by the libsmbconf interface (source/lib/smbconf/smbconf.c). * * This currently supports local interaction with the configuration * stored in the registry. But other backends and remote access via @@ -29,7 +29,6 @@ #include "includes.h" #include "utils/net.h" -#include "libnet/libnet.h" /********************************************************************** * @@ -200,7 +199,7 @@ static char *parm_valstr(TALLOC_CTX *ctx, struct parm_struct *parm, * been loaded with lp_load() to registry. */ static int import_process_service(TALLOC_CTX *ctx, - struct libnet_conf_ctx *conf_ctx, + struct smbconf_ctx *conf_ctx, struct share_params *share) { int ret = -1; @@ -223,13 +222,13 @@ static int import_process_service(TALLOC_CTX *ctx, if (opt_testmode) { d_printf("[%s]\n", servicename); } else { - if (libnet_conf_share_exists(conf_ctx, servicename)) { - werr = libnet_conf_delete_share(conf_ctx, servicename); + if (smbconf_share_exists(conf_ctx, servicename)) { + werr = smbconf_delete_share(conf_ctx, servicename); if (!W_ERROR_IS_OK(werr)) { goto done; } } - werr = libnet_conf_create_share(conf_ctx, servicename); + werr = smbconf_create_share(conf_ctx, servicename); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -249,10 +248,10 @@ static int import_process_service(TALLOC_CTX *ctx, if (opt_testmode) { d_printf("\t%s = %s\n", parm->label, valstr); } else { - werr = libnet_conf_set_parameter(conf_ctx, - servicename, - parm->label, - valstr); + werr = smbconf_set_parameter(conf_ctx, + servicename, + parm->label, + valstr); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error setting parameter '%s'" @@ -299,7 +298,7 @@ static bool globals_exist(void) * **********************************************************************/ -static int net_conf_list(struct libnet_conf_ctx *conf_ctx, +static int net_conf_list(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { WERROR werr = WERR_OK; @@ -319,8 +318,8 @@ static int net_conf_list(struct libnet_conf_ctx *conf_ctx, goto done; } - werr = libnet_conf_get_config(ctx, conf_ctx, &num_shares, &share_names, - &num_params, ¶m_names, ¶m_values); + werr = smbconf_get_config(ctx, conf_ctx, &num_shares, &share_names, + &num_params, ¶m_names, ¶m_values); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error getting config: %s\n", dos_errstr(werr)); @@ -346,7 +345,7 @@ done: return ret; } -static int net_conf_import(struct libnet_conf_ctx *conf_ctx, +static int net_conf_import(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -433,7 +432,7 @@ done: return ret; } -static int net_conf_listshares(struct libnet_conf_ctx *conf_ctx, +static int net_conf_listshares(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { WERROR werr = WERR_OK; @@ -449,8 +448,8 @@ static int net_conf_listshares(struct libnet_conf_ctx *conf_ctx, goto done; } - werr = libnet_conf_get_share_names(ctx, conf_ctx, &num_shares, - &share_names); + werr = smbconf_get_share_names(ctx, conf_ctx, &num_shares, + &share_names); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -467,7 +466,7 @@ done: return ret; } -static int net_conf_drop(struct libnet_conf_ctx *conf_ctx, +static int net_conf_drop(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -478,7 +477,7 @@ static int net_conf_drop(struct libnet_conf_ctx *conf_ctx, goto done; } - werr = libnet_conf_drop(conf_ctx); + werr = smbconf_drop(conf_ctx); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error deleting configuration: %s\n", dos_errstr(werr)); @@ -491,7 +490,7 @@ done: return ret; } -static int net_conf_showshare(struct libnet_conf_ctx *conf_ctx, +static int net_conf_showshare(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -512,8 +511,8 @@ static int net_conf_showshare(struct libnet_conf_ctx *conf_ctx, sharename = argv[0]; - werr = libnet_conf_get_share(ctx, conf_ctx, sharename, &num_params, - ¶m_names, ¶m_values); + werr = smbconf_get_share(ctx, conf_ctx, sharename, &num_params, + ¶m_names, ¶m_values); if (!W_ERROR_IS_OK(werr)) { d_printf("error getting share parameters: %s\n", dos_errstr(werr)); @@ -538,9 +537,9 @@ done: * Add a share, with a couple of standard parameters, partly optional. * * This is a high level utility function of the net conf utility, - * not a direct frontend to the libnet_conf API. + * not a direct frontend to the smbconf API. */ -static int net_conf_addshare(struct libnet_conf_ctx *conf_ctx, +static int net_conf_addshare(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -629,7 +628,7 @@ static int net_conf_addshare(struct libnet_conf_ctx *conf_ctx, goto done; } - if (libnet_conf_share_exists(conf_ctx, sharename)) { + if (smbconf_share_exists(conf_ctx, sharename)) { d_fprintf(stderr, "ERROR: share %s already exists.\n", sharename); goto done; @@ -664,7 +663,7 @@ static int net_conf_addshare(struct libnet_conf_ctx *conf_ctx, * create the share */ - werr = libnet_conf_create_share(conf_ctx, sharename); + werr = smbconf_create_share(conf_ctx, sharename); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error creating share %s: %s\n", sharename, dos_errstr(werr)); @@ -675,7 +674,7 @@ static int net_conf_addshare(struct libnet_conf_ctx *conf_ctx, * fill the share with parameters */ - werr = libnet_conf_set_parameter(conf_ctx, sharename, "path", path); + werr = smbconf_set_parameter(conf_ctx, sharename, "path", path); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error setting parameter %s: %s\n", "path", dos_errstr(werr)); @@ -683,8 +682,8 @@ static int net_conf_addshare(struct libnet_conf_ctx *conf_ctx, } if (comment != NULL) { - werr = libnet_conf_set_parameter(conf_ctx, sharename, "comment", - comment); + werr = smbconf_set_parameter(conf_ctx, sharename, "comment", + comment); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error setting parameter %s: %s\n", "comment", dos_errstr(werr)); @@ -692,16 +691,15 @@ static int net_conf_addshare(struct libnet_conf_ctx *conf_ctx, } } - werr = libnet_conf_set_parameter(conf_ctx, sharename, "guest ok", - guest_ok); + werr = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error setting parameter %s: %s\n", "'guest ok'", dos_errstr(werr)); goto done; } - werr = libnet_conf_set_parameter(conf_ctx, sharename, "writeable", - writeable); + werr = smbconf_set_parameter(conf_ctx, sharename, "writeable", + writeable); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error setting parameter %s: %s\n", "writeable", dos_errstr(werr)); @@ -715,7 +713,7 @@ done: return ret; } -static int net_conf_delshare(struct libnet_conf_ctx *conf_ctx, +static int net_conf_delshare(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -728,7 +726,7 @@ static int net_conf_delshare(struct libnet_conf_ctx *conf_ctx, } sharename = argv[0]; - werr = libnet_conf_delete_share(conf_ctx, sharename); + werr = smbconf_delete_share(conf_ctx, sharename); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error deleting share %s: %s\n", sharename, dos_errstr(werr)); @@ -740,7 +738,7 @@ done: return ret; } -static int net_conf_setparm(struct libnet_conf_ctx *conf_ctx, +static int net_conf_setparm(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -757,8 +755,8 @@ static int net_conf_setparm(struct libnet_conf_ctx *conf_ctx, param = strdup_lower(argv[1]); value_str = argv[2]; - if (!libnet_conf_share_exists(conf_ctx, service)) { - werr = libnet_conf_create_share(conf_ctx, service); + if (!smbconf_share_exists(conf_ctx, service)) { + werr = smbconf_create_share(conf_ctx, service); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error creating share '%s': %s\n", service, dos_errstr(werr)); @@ -766,7 +764,7 @@ static int net_conf_setparm(struct libnet_conf_ctx *conf_ctx, } } - werr = libnet_conf_set_parameter(conf_ctx, service, param, value_str); + werr = smbconf_set_parameter(conf_ctx, service, param, value_str); if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "Error setting value '%s': %s\n", @@ -782,7 +780,7 @@ done: return ret; } -static int net_conf_getparm(struct libnet_conf_ctx *conf_ctx, +static int net_conf_getparm(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -801,7 +799,7 @@ static int net_conf_getparm(struct libnet_conf_ctx *conf_ctx, service = strdup_lower(argv[0]); param = strdup_lower(argv[1]); - werr = libnet_conf_get_parameter(ctx, conf_ctx, service, param, &valstr); + werr = smbconf_get_parameter(ctx, conf_ctx, service, param, &valstr); if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) { d_fprintf(stderr, @@ -829,7 +827,7 @@ done: return ret; } -static int net_conf_delparm(struct libnet_conf_ctx *conf_ctx, +static int net_conf_delparm(struct smbconf_ctx *conf_ctx, int argc, const char **argv) { int ret = -1; @@ -844,7 +842,7 @@ static int net_conf_delparm(struct libnet_conf_ctx *conf_ctx, service = strdup_lower(argv[0]); param = strdup_lower(argv[1]); - werr = libnet_conf_delete_parameter(conf_ctx, service, param); + werr = smbconf_delete_parameter(conf_ctx, service, param); if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) { d_fprintf(stderr, @@ -882,16 +880,16 @@ done: * The wrapper calls handles opening and closing of the * configuration. */ -static int net_conf_wrap_function(int (*fn)(struct libnet_conf_ctx *, +static int net_conf_wrap_function(int (*fn)(struct smbconf_ctx *, int, const char **), int argc, const char **argv) { WERROR werr; TALLOC_CTX *mem_ctx = talloc_stackframe(); - struct libnet_conf_ctx *conf_ctx; + struct smbconf_ctx *conf_ctx; int ret = -1; - werr = libnet_conf_open(mem_ctx, &conf_ctx); + werr = smbconf_open(mem_ctx, &conf_ctx); if (!W_ERROR_IS_OK(werr)) { return -1; @@ -899,7 +897,7 @@ static int net_conf_wrap_function(int (*fn)(struct libnet_conf_ctx *, ret = fn(conf_ctx, argc, argv); - libnet_conf_close(conf_ctx); + smbconf_close(conf_ctx); return ret; } @@ -911,7 +909,7 @@ static int net_conf_wrap_function(int (*fn)(struct libnet_conf_ctx *, */ struct conf_functable { const char *funcname; - int (*fn)(struct libnet_conf_ctx *ctx, int argc, const char **argv); + int (*fn)(struct smbconf_ctx *ctx, int argc, const char **argv); const char *helptext; }; |