[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-356-g1a5e5bf
Michael Adam
obnox at samba.org
Fri Mar 21 01:52:51 GMT 2008
The branch, v3-2-test has been updated
via 1a5e5bf38f409b10c8b1da6227722c7d3976b175 (commit)
via b3f6920ccb9a27fde26e889a7f1f3afaf56b784f (commit)
via acbd1f40e0cb4cb5b2ba826c4825edda7ee4937b (commit)
via 24f32d9bd9aa837d777ea4187bebf3146a67ce59 (commit)
via 797b26ad3fad27e085827efb61f6b4d8b37e93f0 (commit)
via d7bd9bb8aa2003ec0a9860df26857f67255febe2 (commit)
via 77dbdf82efa60c8a7c00e489c198775b2f66e56c (commit)
via a857f643d1558c0fdab4b647695d75223b730b96 (commit)
via f2d605006cd1187f70a044c3356d436e91093d5f (commit)
via d44c2ef0b7d7bddb4115b596872748132ebd6ddc (commit)
via 26208d3e96a1e257628366709a1d71ac36f0788b (commit)
via 5dac66c82af8c87df723092a9309304846684418 (commit)
via 103a37ac8e85e9a7b8c2f4eb33e6f1cdbe01d31c (commit)
via 9448a7a298e9ed035aa6b86df18f2d41081731cc (commit)
via aeaf66c064de58c6f19d5a9d226843dedb552011 (commit)
via a99ee5e536eee1563c90e5d7f251bfe9f5d1ffbb (commit)
via 304dba6cb2184437f3edad065a530d03fb704036 (commit)
via 7460697ea42764f5f658a4f7f70872a56aeb160d (commit)
via 5b6b90900a1a3eab24cb5612d78f9678a363cf73 (commit)
via e6b60f6cad32ce8bb78abb070889dde3eca2d268 (commit)
from f65cb5d4b51e2e7b9b16b73e47cd2a8d55d5d4b0 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 1a5e5bf38f409b10c8b1da6227722c7d3976b175
Author: Michael Adam <obnox at samba.org>
Date: Fri Mar 21 02:29:09 2008 +0100
libsmbconf: reformaat - fix some whispacing/tabs
Michael
commit b3f6920ccb9a27fde26e889a7f1f3afaf56b784f
Author: Michael Adam <obnox at samba.org>
Date: Fri Mar 21 02:20:16 2008 +0100
libsmbconf: add backend specific init function.
Hide generic init function taking smbconf_ops argument
from public api.
Michael
commit acbd1f40e0cb4cb5b2ba826c4825edda7ee4937b
Author: Michael Adam <obnox at samba.org>
Date: Fri Mar 21 02:01:55 2008 +0100
libsmbconf: add shutdown handler to smbconf_ops.
Michael
commit 24f32d9bd9aa837d777ea4187bebf3146a67ce59
Author: Michael Adam <obnox at samba.org>
Date: Fri Mar 21 01:15:20 2008 +0100
libsmbconf: fix comments
Michael
commit 797b26ad3fad27e085827efb61f6b4d8b37e93f0
Author: Michael Adam <obnox at samba.org>
Date: Fri Mar 21 01:04:57 2008 +0100
libsmbconf: rename smbconf_close() to smbconf_shutdown().
Michael
commit d7bd9bb8aa2003ec0a9860df26857f67255febe2
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 23:41:39 2008 +0100
libsmbconf: rename smbconf_open() to smbconf_init().
That's more appropriate.
Michael
commit 77dbdf82efa60c8a7c00e489c198775b2f66e56c
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 18:40:09 2008 +0100
libsmbconf: add open and close operations to the smbconf_ops.
Note: currently, reg_init_smbconf opens the registry, but does
not close it. This has to be changed. so that it is closed.
And then libsmbconf will need these open/close functions
Michael
commit a857f643d1558c0fdab4b647695d75223b730b96
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 12:28:41 2008 +0100
libsmbconf: introduce a smbconf_ops layer to allow interchangeable backends.
Michael
commit f2d605006cd1187f70a044c3356d436e91093d5f
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 12:25:44 2008 +0100
libsmbconf: move smbconf_reg_initialize() down to the smbconf operations.
Michael
commit d44c2ef0b7d7bddb4115b596872748132ebd6ddc
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 11:54:30 2008 +0100
libsmbconf: add existence check for service to smbconf_delete_share().
Michael
commit 26208d3e96a1e257628366709a1d71ac36f0788b
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 11:53:40 2008 +0100
libsmbconf: add existence check for service to smbconf_get_share().
Michael
commit 5dac66c82af8c87df723092a9309304846684418
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 11:52:13 2008 +0100
libsmbconf: add check for NULL servicename to smbconf_share_exists().
Michael
commit 103a37ac8e85e9a7b8c2f4eb33e6f1cdbe01d31c
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 11:50:06 2008 +0100
libsmbconf: fix a comment
commit 9448a7a298e9ed035aa6b86df18f2d41081731cc
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 11:49:26 2008 +0100
libsmbconf: refactor out registry implementation of smbconf operations.
This leaves most of the api functions mere wrappers except for some
common initial checks.
Michael
commit aeaf66c064de58c6f19d5a9d226843dedb552011
Author: Michael Adam <obnox at samba.org>
Date: Thu Mar 20 10:43:17 2008 +0100
libsmbconf: refactor autocreation of [global] into a helper function.
Michael
commit a99ee5e536eee1563c90e5d7f251bfe9f5d1ffbb
Author: Michael Adam <obnox at samba.org>
Date: Wed Mar 19 12:37:17 2008 +0100
libsmbconf: put the smbconf context struct into a private header.
Michael
commit 304dba6cb2184437f3edad065a530d03fb704036
Author: Michael Adam <obnox at samba.org>
Date: Wed Mar 19 10:47:23 2008 +0100
libsmbconf: change the API to always take the smbconf_ctx parameter first.
..for consistency. Exception: the open/init function, where the smbconf_ctx
is created from the given talloc context.
Michael
commit 7460697ea42764f5f658a4f7f70872a56aeb160d
Author: Michael Adam <obnox at samba.org>
Date: Wed Mar 19 10:15:16 2008 +0100
libsmbconf: fix indentation.
Michael
commit 5b6b90900a1a3eab24cb5612d78f9678a363cf73
Author: Michael Adam <obnox at samba.org>
Date: Tue Mar 18 23:29:11 2008 +0100
libsmbconf: change smbconf_get_seqnum() to smbconf_changed().
The former seqnum is hidden inside a struct smbconf_csn.
And the get_seqnum is united with a changed function that
stores the seqnum inside the given csn.
Michael
commit e6b60f6cad32ce8bb78abb070889dde3eca2d268
Author: Michael Adam <obnox at samba.org>
Date: Tue Mar 18 00:51:15 2008 +0100
libsmbconf: fix a comment
Michael
-----------------------------------------------------------------------
Summary of changes:
source/lib/netapi/serverinfo.c | 4 +-
source/lib/smbconf/smbconf.c | 675 +++++++++++++++++++++-------------
source/lib/smbconf/smbconf.h | 35 +-
source/lib/smbconf/smbconf_private.h | 64 ++++
source/libnet/libnet_join.c | 8 +-
source/param/loadparm.c | 20 +-
source/utils/net_conf.c | 12 +-
7 files changed, 527 insertions(+), 291 deletions(-)
create mode 100644 source/lib/smbconf/smbconf_private.h
Changeset truncated at 500 lines:
diff --git a/source/lib/netapi/serverinfo.c b/source/lib/netapi/serverinfo.c
index a29a840..913338f 100644
--- a/source/lib/netapi/serverinfo.c
+++ b/source/lib/netapi/serverinfo.c
@@ -191,7 +191,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
- werr = smbconf_open(ctx, &conf_ctx);
+ werr = smbconf_init_reg(ctx, &conf_ctx);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -200,7 +200,7 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx,
info1005->comment);
done:
- smbconf_close(conf_ctx);
+ smbconf_shutdown(conf_ctx);
return werr;
}
diff --git a/source/lib/smbconf/smbconf.c b/source/lib/smbconf/smbconf.c
index 4ccba09..ceed349 100644
--- a/source/lib/smbconf/smbconf.c
+++ b/source/lib/smbconf/smbconf.c
@@ -19,12 +19,12 @@
*/
#include "includes.h"
+#include "smbconf_private.h"
/**********************************************************************
*
* Helper functions (mostly registry related)
- * TODO: These should be eventually static.
-
+ *
**********************************************************************/
/**
@@ -57,26 +57,6 @@ static WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-static WERROR smbconf_reg_initialize(struct smbconf_ctx *ctx)
-{
- WERROR werr = WERR_OK;
-
- if (!registry_init_smbconf()) {
- werr = WERR_REG_IO_FAILURE;
- goto done;
- }
-
- 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;
-}
-
/**
* Open a registry key specified by "path"
*/
@@ -96,7 +76,7 @@ static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
if (ctx->token == NULL) {
DEBUG(1, ("Error: token missing from smbconf_ctx. "
- "was smbconf_open() called?\n"));
+ "was smbconf_init() called?\n"));
werr = WERR_INVALID_PARAM;
goto done;
}
@@ -415,83 +395,80 @@ done:
static int smbconf_destroy_ctx(struct smbconf_ctx *ctx)
{
- return regdb_close();
+ return ctx->ops->shutdown(ctx);
+}
+
+static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
+{
+ if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
+ return smbconf_create_share(ctx, GLOBAL_NAME);
+ }
+ return WERR_OK;
}
+
/**********************************************************************
*
- * The actual net conf api functions, that are exported.
+ * smbconf operations: registry implementations
*
**********************************************************************/
/**
- * Open the configuration.
- *
- * 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
- * smbconf functions.
- *
- * After the work with the configuration is completed, smbconf_close()
- * should be called.
+ * initialize the registry smbconf backend
*/
-WERROR smbconf_open(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx)
+static WERROR smbconf_reg_init(struct smbconf_ctx *ctx)
{
WERROR werr = WERR_OK;
- struct smbconf_ctx *ctx;
-
- if (conf_ctx == NULL) {
- return WERR_INVALID_PARAM;
- }
- ctx = TALLOC_ZERO_P(mem_ctx, struct smbconf_ctx);
- if (ctx == NULL) {
- return WERR_NOMEM;
+ if (!registry_init_smbconf()) {
+ werr = WERR_REG_IO_FAILURE;
+ goto done;
}
- werr = smbconf_reg_initialize(ctx);
+ werr = ntstatus_to_werror(registry_create_admin_token(ctx,
+ &(ctx->token)));
if (!W_ERROR_IS_OK(werr)) {
- goto fail;
+ DEBUG(1, ("Error creating admin token\n"));
+ goto done;
}
- talloc_set_destructor(ctx, smbconf_destroy_ctx);
-
- *conf_ctx = ctx;
+done:
return werr;
+}
-fail:
- TALLOC_FREE(ctx);
- return werr;
+static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
+{
+ return regdb_close();
}
-/**
- * Close the configuration.
- */
-void smbconf_close(struct smbconf_ctx *ctx)
+static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
{
- /* this also closes the registry (by destructor): */
- TALLOC_FREE(ctx);
+ return regdb_open();
+}
+
+static int smbconf_reg_close(struct smbconf_ctx *ctx)
+{
+ return regdb_close();
}
/**
* Get the change sequence number of the given service/parameter.
- *
- * NOTE: Currently, for registry configuration, this is independent
- * of the service and parameter, it returns the registry-sequence
- * number.
+ * service and parameter strings may be NULL.
*/
-uint64_t smbconf_get_seqnum(struct smbconf_ctx *ctx,
- const char *service, const char *param)
+static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
+ struct smbconf_csn *csn,
+ const char *service, const char *param)
{
- return (uint64_t)regdb_get_seqnum();
+ if (csn == NULL) {
+ return;
+ }
+ csn->csn = (uint64_t)regdb_get_seqnum();
}
/**
- * Drop the whole configuration (restarting empty).
+ * Drop the whole configuration (restarting empty) - registry version
*/
-WERROR smbconf_drop(struct smbconf_ctx *ctx)
+static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
{
char *path, *p;
WERROR werr = WERR_OK;
@@ -529,97 +506,13 @@ done:
}
/**
- * 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 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 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_stackframe();
- if (tmp_ctx == NULL) {
- werr = WERR_NOMEM;
- goto done;
- }
-
- werr = smbconf_get_share_names(tmp_ctx, 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 = 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;
- }
- }
-
- 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.
+ * registry version.
*/
-WERROR smbconf_get_share_names(TALLOC_CTX *mem_ctx,
- struct smbconf_ctx *ctx,
- uint32_t *num_shares,
- char ***share_names)
+static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_shares,
+ char ***share_names)
{
uint32_t count;
uint32_t added_count = 0;
@@ -692,10 +585,10 @@ done:
}
/**
- * check if a share/service of a given name exists
+ * check if a share/service of a given name exists - registry version
*/
-bool smbconf_share_exists(struct smbconf_ctx *ctx,
- const char *servicename)
+static bool smbconf_reg_share_exists(struct smbconf_ctx *ctx,
+ const char *servicename)
{
bool ret = false;
WERROR werr = WERR_OK;
@@ -713,23 +606,17 @@ bool smbconf_share_exists(struct smbconf_ctx *ctx,
}
/**
- * Add a service if it does not already exist.
+ * Add a service if it does not already exist - registry version
*/
-WERROR smbconf_create_share(struct smbconf_ctx *ctx,
- const char *servicename)
+static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
+ const char *servicename)
{
WERROR werr;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
- if (smbconf_share_exists(ctx, servicename)) {
- werr = WERR_ALREADY_EXISTS;
- goto done;
- }
-
werr = smbconf_reg_create_service_key(mem_ctx, ctx, servicename, &key);
-done:
TALLOC_FREE(mem_ctx);
return werr;
}
@@ -737,9 +624,11 @@ done:
/**
* get a definition of a share (service) from configuration.
*/
-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)
+static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx,
+ 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;
@@ -761,7 +650,8 @@ done:
/**
* delete a service from configuration
*/
-WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
+static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
+ const char *servicename)
{
WERROR werr = WERR_OK;
struct registry_key *key = NULL;
@@ -782,20 +672,15 @@ done:
/**
* set a configuration parameter to the value provided.
*/
-WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
- const char *service,
- const char *param,
- const char *valstr)
+static WERROR smbconf_reg_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 (!smbconf_share_exists(ctx, service)) {
- werr = WERR_NO_SUCH_SERVICE;
- goto done;
- }
-
werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
REG_KEY_WRITE, &key);
if (!W_ERROR_IS_OK(werr)) {
@@ -810,100 +695,409 @@ done:
}
/**
- * Set a global parameter
- * (i.e. a parameter in the [global] service).
- *
- * This also creates [global] when it does not exist.
+ * get the value of a configuration parameter as a string
*/
-WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
- const char *param, const char *val)
+static WERROR smbconf_reg_get_parameter(struct smbconf_ctx *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *service,
+ const char *param,
+ char **valstr)
{
- WERROR werr;
+ WERROR werr = WERR_OK;
+ struct registry_key *key = NULL;
+ struct registry_value *value = NULL;
- if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
- werr = smbconf_create_share(ctx, GLOBAL_NAME);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
+ werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_READ, &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ if (!smbconf_value_exists(key, param)) {
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ werr = reg_queryvalue(mem_ctx, key, param, &value);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ *valstr = smbconf_format_registry_value(mem_ctx, value);
+
+ if (*valstr == NULL) {
+ werr = WERR_NOMEM;
}
- werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
done:
+ TALLOC_FREE(key);
+ TALLOC_FREE(value);
return werr;
}
/**
- * get the value of a configuration parameter as a string
+ * delete a parameter from configuration
*/
-WERROR smbconf_get_parameter(TALLOC_CTX *mem_ctx,
- struct smbconf_ctx *ctx,
- const char *service,
- const char *param,
- char **valstr)
+static WERROR smbconf_reg_delete_parameter(struct smbconf_ctx *ctx,
+ const char *service,
+ const char *param)
{
- WERROR werr = WERR_OK;
struct registry_key *key = NULL;
- struct registry_value *value = NULL;
+ WERROR werr = WERR_OK;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
- if (valstr == NULL) {
- werr = WERR_INVALID_PARAM;
+ werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
+ REG_KEY_ALL, &key);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
- if (!smbconf_share_exists(ctx, service)) {
- werr = WERR_NO_SUCH_SERVICE;
+ if (!smbconf_value_exists(key, param)) {
+ werr = WERR_INVALID_PARAM;
goto done;
}
- werr = smbconf_reg_open_service_key(mem_ctx, ctx, service,
- REG_KEY_READ, &key);
+ werr = reg_deletevalue(key, param);
+
+done:
+ TALLOC_FREE(mem_ctx);
+ return werr;
+}
+
+struct smbconf_ops smbconf_ops_reg = {
+ .init = smbconf_reg_init,
+ .shutdown = smbconf_reg_shutdown,
--
Samba Shared Repository
More information about the samba-cvs
mailing list