summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/libnet/libnet_conf.c31
-rw-r--r--source3/utils/net_conf.c13
2 files changed, 38 insertions, 6 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index ebdfd75744..2c67d4735e 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -612,6 +612,27 @@ bool libnet_smbconf_share_exists(const char *servicename)
}
/**
+ * Add a service if it does not already exist.
+ */
+WERROR libnet_smbconf_create_share(const char *servicename)
+{
+ WERROR werr;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+ struct registry_key *key = NULL;
+
+ if (libnet_smbconf_share_exists(servicename)) {
+ werr = WERR_ALREADY_EXISTS;
+ goto done;
+ }
+
+ werr = libnet_smbconf_reg_createkey_internal(mem_ctx, servicename, &key);
+
+done:
+ TALLOC_FREE(mem_ctx);
+ return werr;
+}
+
+/**
* get a definition of a share (service) from configuration.
*/
WERROR libnet_smbconf_getshare(TALLOC_CTX *mem_ctx, const char *servicename,
@@ -668,12 +689,12 @@ WERROR libnet_smbconf_setparm(const char *service,
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (!libnet_smbconf_share_exists(service)) {
- werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service,
- &key);
- } else {
- werr = libnet_smbconf_reg_open_service_key(mem_ctx, service,
- REG_KEY_WRITE, &key);
+ werr = WERR_NO_SUCH_SERVICE;
+ goto done;
}
+
+ werr = libnet_smbconf_reg_open_service_key(mem_ctx, service,
+ REG_KEY_WRITE, &key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 07eb3b890f..feee16f564 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -628,7 +628,18 @@ static int net_conf_addshare(int argc, const char **argv)
}
/*
- * create the share by adding the parameters
+ * create the share
+ */
+
+ werr = libnet_smbconf_create_share(sharename);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, "Error creating share %s: %s\n",
+ sharename, dos_errstr(werr));
+ goto done;
+ }
+
+ /*
+ * fill the share with parameters
*/
werr = libnet_smbconf_setparm(sharename, "path", path);