summaryrefslogtreecommitdiffstats
path: root/src/tools/sss_groupmod.c
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2012-08-16 18:48:53 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-08-23 18:09:18 +0200
commit21d485184df986e1a123f70c689517386e51a5ce (patch)
tree7b2165fdc4dadcc632d402866b704df04ede852f /src/tools/sss_groupmod.c
parent0051296f67bd7d8e2e3094638ddff4e641324d04 (diff)
downloadsssd-21d485184df986e1a123f70c689517386e51a5ce.tar.gz
sssd-21d485184df986e1a123f70c689517386e51a5ce.tar.xz
sssd-21d485184df986e1a123f70c689517386e51a5ce.zip
Unify usage of sysdb transactions
Removing bad examples of usage of sysdb_transaction_start/commit/end functions and making it more consistent (all files except of src/db/sysdb_*.c).
Diffstat (limited to 'src/tools/sss_groupmod.c')
-rw-r--r--src/tools/sss_groupmod.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/tools/sss_groupmod.c b/src/tools/sss_groupmod.c
index abab4f57f..c210bad75 100644
--- a/src/tools/sss_groupmod.c
+++ b/src/tools/sss_groupmod.c
@@ -52,8 +52,10 @@ int main(int argc, const char **argv)
struct tools_ctx *tctx = NULL;
char *addgroups = NULL, *rmgroups = NULL;
int ret;
+ errno_t sret;
const char *pc_groupname = NULL;
char *badgroup = NULL;
+ bool in_transaction = false;
debug_prg_name = argv[0];
@@ -194,20 +196,31 @@ int main(int argc, const char **argv)
tctx->error = sysdb_transaction_start(tctx->sysdb);
if (tctx->error != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n"));
goto done;
}
+ in_transaction = true;
/* groupmod */
tctx->error = groupmod(tctx, tctx->sysdb, tctx->octx);
if (tctx->error) {
- /* cancel transaction */
- sysdb_transaction_cancel(tctx->sysdb);
goto done;
}
tctx->error = sysdb_transaction_commit(tctx->sysdb);
+ if (tctx->error != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction\n"));
+ goto done;
+ }
+ in_transaction = false;
done:
+ if (in_transaction) {
+ sret = sysdb_transaction_cancel(tctx->sysdb);
+ if (sret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to cancel transaction\n"));
+ }
+ }
if (tctx->error) {
ret = tctx->error;
DEBUG(1, ("sysdb operation failed (%d)[%s]\n", ret, strerror(ret)));