[s3]libsmbconf: add utility function smbconf_is_writeable_bystring()
authorMichael Adam <obnox@samba.org>
Fri, 24 Oct 2008 08:36:29 +0000 (10:36 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 27 Oct 2008 12:02:41 +0000 (13:02 +0100)
This checks the writeability of a config source specified by the
config source name.

Michael

source3/lib/smbconf/smbconf.c
source3/lib/smbconf/smbconf.h

index e5a865a62bb22762a82a7d20a6a79b9cd382149b..86c16925749e44586752ae0c346c8b792aed9282 100644 (file)
@@ -59,6 +59,32 @@ 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.
  */
index 9ff9a83fad281539b821f25c78d034c4852afd86..f65842ee342c60797d34bfd652d0b71cdaeef1c0 100644 (file)
@@ -58,6 +58,7 @@ WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
  */
 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);