summaryrefslogtreecommitdiff
path: root/src/tools/sss_usermod.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/sss_usermod.c')
-rw-r--r--src/tools/sss_usermod.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c
index b761de22..a45005ca 100644
--- a/src/tools/sss_usermod.c
+++ b/src/tools/sss_usermod.c
@@ -60,9 +60,11 @@ int main(int argc, const char **argv)
poptContext pc = NULL;
char *addgroups = NULL, *rmgroups = NULL;
int ret;
+ errno_t sret;
const char *pc_username = NULL;
struct tools_ctx *tctx = NULL;
char *badgroup = NULL;
+ bool in_transaction = false;
debug_prg_name = argv[0];
@@ -216,18 +218,23 @@ 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;
/* usermod */
tctx->error = usermod(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) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction\n"));
+ goto done;
+ }
+ in_transaction = false;
/* Set SELinux login context - must be done after transaction is done
* b/c libselinux calls getpwnam */
@@ -239,6 +246,13 @@ int main(int argc, const char **argv)
}
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;
switch (ret) {