The branch, master has been updated
       via  89edff0 net: use smbconf_create_set_share() in "net conf import"
       via  caf83bc libsmbconf: add smbconf_create_set_share
       via  57634fd libsmbconf: fix documentation of transaction calls.
      from  277831e dsdb-repl_meta_data: Move TODO comment about conflicts and 
missing parents

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


- Log -----------------------------------------------------------------
commit 89edff08db367417f3032563df3ea1b546553c83
Author: Michael Adam <ob...@samba.org>
Date:   Tue May 21 16:50:49 2013 +0200

    net: use smbconf_create_set_share() in "net conf import"
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: David Disseldorp <dd...@samba.org>
    
    Autobuild-User(master): Michael Adam <ob...@samba.org>
    Autobuild-Date(master): Tue May 28 20:01:12 CEST 2013 on sn-devel-104

commit caf83bcb76f52b0628f6d59e95396d16b5e3c66e
Author: David Disseldorp <dd...@samba.org>
Date:   Thu May 16 11:55:04 2013 +0200

    libsmbconf: add smbconf_create_set_share
    
    This call creates a new share definition, using the parameters provided
    with a smbconf_service structure.
    Such an interface allows for simple cloning of services with:
    smbconf_get_share(conf_ctx, mem_ctx, base_sharename, &base_service_def);
    base_service_def->name = clone_sharename;
    smbconf_create_set_share(conf_ctx, base_service_def);
    
    Pair-Programmed-With: Michael Adam <ob...@samba.org>
    
    Signed-off-by: David Disseldorp <dd...@samba.org>
    Signed-off-by: Michael Adam <ob...@samba.org>

commit 57634fd87d7176a1f92281ad1b3e9a565b54cfc7
Author: Michael Adam <ob...@samba.org>
Date:   Mon May 20 23:30:14 2013 +0200

    libsmbconf: fix documentation of transaction calls.
    
    Signed-off-by: Michael Adam <ob...@samba.org>
    Reviewed-by: David Disseldorp <dd...@samba.org>

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

Summary of changes:
 lib/smbconf/smbconf.c    |   77 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/smbconf/smbconf.h    |   22 ++++++++++++-
 source3/utils/net_conf.c |   49 +----------------------------
 3 files changed, 99 insertions(+), 49 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index e0441ed..27d36ca 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -231,6 +231,83 @@ sbcErr smbconf_create_share(struct smbconf_ctx *ctx,
 }
 
 /**
+ * create and set the definition for a new share (service).
+ */
+sbcErr smbconf_create_set_share(struct smbconf_ctx *ctx,
+                               struct smbconf_service *service)
+{
+       sbcErr err, err2;
+       int i;
+       uint32_t num_includes = 0;
+       char **includes = NULL;
+       TALLOC_CTX *tmp_ctx = NULL;
+
+       if ((service->name != NULL) && smbconf_share_exists(ctx, service->name))
+       {
+               return SBC_ERR_FILE_EXISTS;
+       }
+
+       err = smbconf_transaction_start(ctx);
+       if (!SBC_ERROR_IS_OK(err)) {
+               return err;
+       }
+
+       tmp_ctx = talloc_stackframe();
+
+       err = smbconf_create_share(ctx, service->name);
+       if (!SBC_ERROR_IS_OK(err)) {
+               goto cancel;
+       }
+
+       for (i = 0; i < service->num_params; i++) {
+               if (strequal(service->param_names[i], "include")) {
+                       includes = talloc_realloc(tmp_ctx, includes, char *,
+                                                 num_includes+1);
+                       if (includes == NULL) {
+                               err = SBC_ERR_NOMEM;
+                               goto cancel;
+                       }
+                       includes[num_includes] = talloc_strdup(includes,
+                                               service->param_values[i]);
+                       if (includes[num_includes] == NULL) {
+                               err = SBC_ERR_NOMEM;
+                               goto cancel;
+                       }
+                       num_includes++;
+               } else {
+                       err = smbconf_set_parameter(ctx,
+                                                   service->name,
+                                                   service->param_names[i],
+                                                   service->param_values[i]);
+                       if (!SBC_ERROR_IS_OK(err)) {
+                               goto cancel;
+                       }
+               }
+       }
+
+       err = smbconf_set_includes(ctx, service->name, num_includes,
+                                  (const char **)includes);
+       if (!SBC_ERROR_IS_OK(err)) {
+               goto cancel;
+       }
+
+       err = smbconf_transaction_commit(ctx);
+
+       goto done;
+
+cancel:
+       err2 = smbconf_transaction_cancel(ctx);
+       if (!SBC_ERROR_IS_OK(err2)) {
+               DEBUG(5, (__location__ ": Error cancelling transaction: %s\n",
+                         sbcErrorString(err2)));
+       }
+
+done:
+       talloc_free(tmp_ctx);
+       return err;
+}
+
+/**
  * get a definition of a share (service) from configuration.
  */
 sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
index 7f62b06..69a55db 100644
--- a/lib/smbconf/smbconf.h
+++ b/lib/smbconf/smbconf.h
@@ -205,6 +205,19 @@ bool smbconf_share_exists(struct smbconf_ctx *ctx, const 
char *servicename);
 sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
 
 /**
+ * @brief create and set the definition for a new service.
+ *
+ * @param[in] ctx       The smbconf context to use.
+ *
+ * @param[in] service   The definition for the added service.
+ *
+ * @return              SBC_ERR_OK on success, a corresponding sbcErr if an
+ *                      error occured.
+ */
+sbcErr smbconf_create_set_share(struct smbconf_ctx *ctx,
+                               struct smbconf_service *service);
+
+/**
  * @brief Get a definition of a share (service) from configuration.
  *
  * @param[in] ctx       The smbconf context to use.
@@ -447,7 +460,8 @@ sbcErr smbconf_delete_global_includes(struct smbconf_ctx 
*ctx);
 /**
  * @brief Start a transaction on the configuration backend.
  *
- * This is to speed up writes to the registry based backend.
+ * Transactions are exposed in order to make it possible
+ * to create atomic compound writing commands.
  *
  * @param[in] ctx       The smbconf context to start the transaction.
  *
@@ -459,7 +473,8 @@ sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx);
 /**
  * @brief Commit a transaction on the configuration backend.
  *
- * This is to speed up writes to the registry based backend.
+ * Transactions are exposed in order to make it possible
+ * to create atomic compound writing commands.
  *
  * @param[in] ctx       The smbconf context to commit the transaction.
  *
@@ -473,6 +488,9 @@ sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx);
 /**
  * @brief Cancel a transaction on the configuration backend.
  *
+ * Transactions are exposed in order to make it possible
+ * to create atomic compound writing commands.
+ *
  * @param[in] ctx       The smbconf context to cancel the transaction.
  *
  * @return              SBC_ERR_OK on success, a corresponding sbcErr if an
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 60588c0..e43cd12 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -179,13 +179,10 @@ static sbcErr import_process_service(struct net_context 
*c,
                                     struct smbconf_ctx *conf_ctx,
                                     struct smbconf_service *service)
 {
-       uint32_t idx;
        sbcErr err = SBC_ERR_OK;
-       uint32_t num_includes = 0;
-       char **includes = NULL;
-       TALLOC_CTX *mem_ctx = talloc_stackframe();
 
        if (c->opt_testmode) {
+               uint32_t idx;
                const char *indent = "";
                if (service->name != NULL) {
                        d_printf("[%s]\n", service->name);
@@ -206,52 +203,10 @@ static sbcErr import_process_service(struct net_context 
*c,
                        goto done;
                }
        }
-       err = smbconf_create_share(conf_ctx, service->name);
-       if (!SBC_ERROR_IS_OK(err)) {
-               goto done;
-       }
 
-       for (idx = 0; idx < service->num_params; idx ++) {
-               if (strequal(service->param_names[idx], "include")) {
-                       includes = talloc_realloc(mem_ctx,
-                                                       includes,
-                                                       char *,
-                                                       num_includes+1);
-                       if (includes == NULL) {
-                               err = SBC_ERR_NOMEM;
-                               goto done;
-                       }
-                       includes[num_includes] = talloc_strdup(includes,
-                                               service->param_values[idx]);
-                       if (includes[num_includes] == NULL) {
-                               err = SBC_ERR_NOMEM;
-                               goto done;
-                       }
-                       num_includes++;
-               } else {
-                       err = smbconf_set_parameter(conf_ctx,
-                                                    service->name,
-                                                    service->param_names[idx],
-                                                    
service->param_values[idx]);
-                       if (!SBC_ERROR_IS_OK(err)) {
-                               d_fprintf(stderr,
-                                         _("Error in section [%s], parameter 
\"%s\": %s\n"),
-                                         service->name, 
service->param_names[idx],
-                                         sbcErrorString(err));
-                               goto done;
-                       }
-               }
-       }
+       err = smbconf_create_set_share(conf_ctx, service);
 
-       err = smbconf_set_includes(conf_ctx, service->name, num_includes,
-                                  (const char **)includes);
-       if (!SBC_ERROR_IS_OK(err)) {
-               goto done;
-       }
-
-       err = SBC_ERR_OK;
 done:
-       TALLOC_FREE(mem_ctx);
        return err;
 }
 


-- 
Samba Shared Repository

Reply via email to