[SCM] Samba Shared Repository - branch master updated - e4fe3320ec75f0ba542c689b3072fa8a2ed9e232

Michael Adam obnox at samba.org
Mon Oct 27 12:02:30 GMT 2008


The branch, master has been updated
       via  e4fe3320ec75f0ba542c689b3072fa8a2ed9e232 (commit)
       via  3a06201086e77b1c6bd8cf9374f02e5f667aa86c (commit)
       via  9c09d545bfae9e4abde317364b1586b691ba4d89 (commit)
       via  b23106745c500e0e440eacd1bcd3250979df9db6 (commit)
       via  64ab71d2d7e60c1511fd223bb05ef157ef5a2374 (commit)
       via  e453bf70c94e99364233734bb228df2c649b1c70 (commit)
       via  9299d53ef95a72f10d3ccde175ae5c90d2c95333 (commit)
       via  0ee8992331ea52e3be64a21f87a3495fe22c4112 (commit)
      from  1d3dcd1e420104c23769b691d0b8b7958d5c58a7 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e4fe3320ec75f0ba542c689b3072fa8a2ed9e232
Author: Michael Adam <obnox at samba.org>
Date:   Fri Oct 24 10:36:29 2008 +0200

    [s3]libsmbconf: add utility function smbconf_is_writeable_bystring()
    
    This checks the writeability of a config source specified by the
    config source name.
    
    Michael

commit 3a06201086e77b1c6bd8cf9374f02e5f667aa86c
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 23 11:16:50 2008 +0200

    [s3]libsmbconf: add method is_writeable() and wrapper smbconf_is_writeable()
    
    This allows for per-config-source checking of write support.
    
    Michael

commit 9c09d545bfae9e4abde317364b1586b691ba4d89
Author: Michael Adam <obnox at samba.org>
Date:   Fri Oct 24 00:00:20 2008 +0200

    [s3]libsmbconf: create text config in smbconftort
    
    Michael

commit b23106745c500e0e440eacd1bcd3250979df9db6
Author: Michael Adam <obnox at samba.org>
Date:   Thu Oct 23 16:05:19 2008 +0200

    [s3]libsmbconf: return WERR_BADFILE when no path to text backend is provided.
    
    Michael

commit 64ab71d2d7e60c1511fd223bb05ef157ef5a2374
Author: Michael Adam <obnox at samba.org>
Date:   Tue Oct 21 23:20:57 2008 +0200

    [s3]libsmbconf: fall back to file backend when no valid backend was found
    
    Interpret the source string as a file name when it contains
    a ':' sign but the initial part is not a known backend.
    This might occur even implicitly when "%T" is used in an
    include file name (even though this is not realistic..).
    
    Michael

commit e453bf70c94e99364233734bb228df2c649b1c70
Author: Michael Adam <obnox at samba.org>
Date:   Tue Oct 21 23:20:31 2008 +0200

    [s3]libsmbconf: fix comment typo.
    
    Michael

commit 9299d53ef95a72f10d3ccde175ae5c90d2c95333
Author: Michael Adam <obnox at samba.org>
Date:   Mon Oct 20 23:52:02 2008 +0200

    [s3]libsmbconf: add backend_requires_messaging() method to libsmbconf.
    
    In a clustered environment, the registry backend needs messaging
    to be set up since ctdb requires this.
    
    Michael

commit 0ee8992331ea52e3be64a21f87a3495fe22c4112
Author: Michael Adam <obnox at samba.org>
Date:   Mon Oct 20 16:10:54 2008 +0200

    [s3]libsmbconf: remove unused define.
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/smbconf/smbconf.c         |   43 +++++++++++++++++++++++++++++++++
 source3/lib/smbconf/smbconf.h         |    3 ++
 source3/lib/smbconf/smbconf_init.c    |   14 ++++------
 source3/lib/smbconf/smbconf_private.h |    2 +
 source3/lib/smbconf/smbconf_reg.c     |   23 +++++++++++++++++
 source3/lib/smbconf/smbconf_txt.c     |   15 ++++++++++-
 source3/lib/smbconf/testsuite.c       |   39 +++++++++++++++++++++++++++++-
 7 files changed, 129 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c
index 77a4380..86c1692 100644
--- a/source3/lib/smbconf/smbconf.c
+++ b/source3/lib/smbconf/smbconf.c
@@ -43,6 +43,49 @@ static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
  **********************************************************************/
 
 /**
+ * Tell whether the backend requires messaging to be set up
+ * for the backend to work correctly.
+ */
+bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx)
+{
+	return ctx->ops->requires_messaging(ctx);
+}
+
+/**
+ * Tell whether the source is writeable.
+ */
+bool smbconf_is_writeable(struct smbconf_ctx *ctx)
+{
+	return ctx->ops->is_writeable(ctx);
+}
+
+/**
+ * utitlity function:
+ * check whether a config source is writeable,
+ * given only the name of the config source.
+ */
+bool smbconf_is_writeable_bystring(const char *configsource)
+{
+	struct smbconf_ctx *conf_ctx;
+	WERROR err;
+	bool ret;
+	TALLOC_CTX *mem_ctx = talloc_stackframe;
+
+	err = smbconf_init_reg(mem_ctx, &conf_ctx, configsource);
+	if (!W_ERROR_IS_OK(err)) {
+		      ret = false;
+		      goto done;
+	}
+
+	ret = smbconf_is_writeable(conf_ctx);
+
+done:
+	smbconf_shutdown(conf_ctx);
+	TALLOC_FREE(mem_ctx);
+	return ret;
+}
+
+/**
  * Close the configuration.
  */
 void smbconf_shutdown(struct smbconf_ctx *ctx)
diff --git a/source3/lib/smbconf/smbconf.h b/source3/lib/smbconf/smbconf.h
index e337476..f65842e 100644
--- a/source3/lib/smbconf/smbconf.h
+++ b/source3/lib/smbconf/smbconf.h
@@ -56,6 +56,9 @@ WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
 /*
  * the smbconf API functions
  */
+bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
+bool smbconf_is_writeable(struct smbconf_ctx *ctx);
+bool smbconf_is_writeable_bystring(const char *configsource);
 void smbconf_shutdown(struct smbconf_ctx *ctx);
 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
 		     const char *service, const char *param);
diff --git a/source3/lib/smbconf/smbconf_init.c b/source3/lib/smbconf/smbconf_init.c
index 4efc440..a362a66 100644
--- a/source3/lib/smbconf/smbconf_init.c
+++ b/source3/lib/smbconf/smbconf_init.c
@@ -20,9 +20,6 @@
 #include "includes.h"
 #include "smbconf_private.h"
 
-#define INCLUDES_VALNAME "includes"
-
-
 /**
  * smbconf initialization dispatcher
  *
@@ -75,18 +72,19 @@ WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
 	} else if (sep == NULL) {
 		/*
 		 * If no separator was given in the source, and the string is
-		 * not a know backend, assume file backend and use the source
+		 * not a known backend, assume file backend and use the source
 		 * string as a path argument.
 		 */
 		werr = smbconf_init_txt(mem_ctx, conf_ctx, backend);
 	} else {
 		/*
 		 * Separator was specified but this is not a known backend.
-		 * Can't handle this.
+		 * As a last resort, try to interpret the original source
+		 * string as a file name that contains a ":" sign.
+		 * This may occur with an include directive like this:
+		 * 'include = /path/to/file.%T'
 		 */
-		DEBUG(1, ("smbconf_init: ERROR - unknown backend '%s' given\n",
-			  backend));
-		werr = WERR_INVALID_PARAM;
+		werr = smbconf_init_txt(mem_ctx, conf_ctx, source);
 	}
 
 done:
diff --git a/source3/lib/smbconf/smbconf_private.h b/source3/lib/smbconf/smbconf_private.h
index 8e7d6a9..b0333e9 100644
--- a/source3/lib/smbconf/smbconf_private.h
+++ b/source3/lib/smbconf/smbconf_private.h
@@ -23,6 +23,8 @@
 struct smbconf_ops {
 	WERROR (*init)(struct smbconf_ctx *ctx, const char *path);
 	int (*shutdown)(struct smbconf_ctx *ctx);
+	bool (*requires_messaging)(struct smbconf_ctx *ctx);
+	bool (*is_writeable)(struct smbconf_ctx *ctx);
 	WERROR (*open_conf)(struct smbconf_ctx *ctx);
 	int (*close_conf)(struct smbconf_ctx *ctx);
 	void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index 1aa345d..c509289 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -642,6 +642,27 @@ static int smbconf_reg_shutdown(struct smbconf_ctx *ctx)
 	return ctx->ops->close_conf(ctx);
 }
 
+static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx)
+{
+#ifdef CLUSTER_SUPPORT
+	if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) {
+		return true;
+	}
+#endif
+	return false;
+}
+
+static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx)
+{
+	/*
+	 * The backend has write support.
+	 *
+	 *  TODO: add access checks whether the concrete
+	 *  config source is really writeable by the calling user.
+	 */
+	return true;
+}
+
 static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
 {
 	WERROR werr;
@@ -1119,6 +1140,8 @@ done:
 struct smbconf_ops smbconf_ops_reg = {
 	.init			= smbconf_reg_init,
 	.shutdown		= smbconf_reg_shutdown,
+	.requires_messaging	= smbconf_reg_requires_messaging,
+	.is_writeable		= smbconf_reg_is_writeable,
 	.open_conf		= smbconf_reg_open,
 	.close_conf		= smbconf_reg_close,
 	.get_csn		= smbconf_reg_get_csn,
diff --git a/source3/lib/smbconf/smbconf_txt.c b/source3/lib/smbconf/smbconf_txt.c
index 1393a09..70d5f82 100644
--- a/source3/lib/smbconf/smbconf_txt.c
+++ b/source3/lib/smbconf/smbconf_txt.c
@@ -221,7 +221,7 @@ static WERROR smbconf_txt_load_file(struct smbconf_ctx *ctx)
 static WERROR smbconf_txt_init(struct smbconf_ctx *ctx, const char *path)
 {
 	if (path == NULL) {
-		path = get_dyn_CONFIGFILE();
+		return WERR_BADFILE;
 	}
 	ctx->path = talloc_strdup(ctx, path);
 	if (ctx->path == NULL) {
@@ -243,6 +243,17 @@ static int smbconf_txt_shutdown(struct smbconf_ctx *ctx)
 	return ctx->ops->close_conf(ctx);
 }
 
+static bool smbconf_txt_requires_messaging(struct smbconf_ctx *ctx)
+{
+	return false;
+}
+
+static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx)
+{
+	/* no write support in this backend yet... */
+	return false;
+}
+
 static WERROR smbconf_txt_open(struct smbconf_ctx *ctx)
 {
 	return smbconf_txt_load_file(ctx);
@@ -604,6 +615,8 @@ static WERROR smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
 static struct smbconf_ops smbconf_ops_txt = {
 	.init			= smbconf_txt_init,
 	.shutdown		= smbconf_txt_shutdown,
+	.requires_messaging	= smbconf_txt_requires_messaging,
+	.is_writeable		= smbconf_txt_is_writeable,
 	.open_conf		= smbconf_txt_open,
 	.close_conf		= smbconf_txt_close,
 	.get_csn		= smbconf_txt_get_csn,
diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c
index cffd239..100fbe8 100644
--- a/source3/lib/smbconf/testsuite.c
+++ b/source3/lib/smbconf/testsuite.c
@@ -173,17 +173,46 @@ done:
 	return ret;
 }
 
+static bool create_conf_file(const char *filename)
+{
+	FILE *f;
+
+	printf("creating file\n");
+	f = sys_fopen(filename, "w");
+	if (!f) {
+		printf("failure: failed to open %s for writing: %s\n",
+		       filename, strerror(errno));
+		return false;
+	}
+
+	fprintf(f, "[global]\n");
+	fprintf(f, "\tserver string = smbconf testsuite\n");
+	fprintf(f, "\tworkgroup = SAMBA\n");
+	fprintf(f, "\tsecurity = user\n");
+
+	fclose(f);
+
+	printf("success: create file\n");
+	return true;
+}
+
 static bool torture_smbconf_txt(void)
 {
 	WERROR werr;
 	bool ret = true;
+	const char *filename = "/tmp/smb.conf.smbconf_testsuite";
 	struct smbconf_ctx *conf_ctx = NULL;
 	TALLOC_CTX *mem_ctx = talloc_stackframe();
 
 	printf("test: text backend\n");
 
+	if (!create_conf_file(filename)) {
+		ret = false;
+		goto done;
+	}
+
 	printf("test: init\n");
-	werr = smbconf_init_txt(mem_ctx, &conf_ctx, NULL);
+	werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
 	if (!W_ERROR_IS_OK(werr)) {
 		printf("failure: init failed: %s\n", dos_errstr(werr));
 		ret = false;
@@ -195,6 +224,14 @@ static bool torture_smbconf_txt(void)
 
 	smbconf_shutdown(conf_ctx);
 
+	printf("unlinking file\n");
+	if (unlink(filename) != 0) {
+		printf("failure: unlink failed: %s\n", strerror(errno));
+		ret = false;
+		goto done;
+	}
+	printf("success: unlink file\n");
+
 	printf("%s: text backend\n", ret ? "success" : "failure");
 
 done:


-- 
Samba Shared Repository


More information about the samba-cvs mailing list