summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-05-17 22:15:02 +0200
committerMichael Adam <obnox@samba.org>2009-05-17 22:19:24 +0200
commit2722dd357cedcd3fad1e3739a4a64f924d53eccb (patch)
tree2c9c40060c157acbc496c176ca4648e311414141 /source3/utils
parent834fc3786e60b16ff86be3ea47a5d6ed8da6c7b8 (diff)
downloadsamba-2722dd357cedcd3fad1e3739a4a64f924d53eccb.tar.gz
samba-2722dd357cedcd3fad1e3739a4a64f924d53eccb.tar.bz2
samba-2722dd357cedcd3fad1e3739a4a64f924d53eccb.zip
s3:fix bug #6371, unsuccessful net conf setparm leaves empty share
Wrap creation of share and setting of parameter into a transaction. Michael
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_conf.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 864ca9cc18..69a41e30d9 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -787,12 +787,19 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
}
value_str = argv[2];
+ werr = smbconf_transaction_start(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error starting transaction: %s\n",
+ win_errstr(werr));
+ goto done;
+ }
+
if (!smbconf_share_exists(conf_ctx, service)) {
werr = smbconf_create_share(conf_ctx, service);
if (!W_ERROR_IS_OK(werr)) {
d_fprintf(stderr, "Error creating share '%s': %s\n",
service, win_errstr(werr));
- goto done;
+ goto cancel;
}
}
@@ -801,10 +808,25 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
if (!W_ERROR_IS_OK(werr)) {
d_fprintf(stderr, "Error setting value '%s': %s\n",
param, win_errstr(werr));
- goto done;
+ goto cancel;
}
- ret = 0;
+ werr = smbconf_transaction_commit(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error committing transaction: %s\n",
+ win_errstr(werr));
+ } else {
+ ret = 0;
+ }
+
+ goto done;
+
+cancel:
+ werr = smbconf_transaction_cancel(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error cancelling transaction: %s\n",
+ win_errstr(werr));
+ }
done:
TALLOC_FREE(mem_ctx);