summaryrefslogtreecommitdiffstats
path: root/src/providers/krb5
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/providers/krb5
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/providers/krb5')
-rw-r--r--src/providers/krb5/krb5_auth.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/providers/krb5/krb5_auth.c b/src/providers/krb5/krb5_auth.c
index 1da1d0253..c3a9e62de 100644
--- a/src/providers/krb5/krb5_auth.c
+++ b/src/providers/krb5/krb5_auth.c
@@ -121,6 +121,8 @@ static int krb5_mod_ccname(TALLOC_CTX *mem_ctx,
TALLOC_CTX *tmpctx;
struct sysdb_attrs *attrs;
int ret;
+ errno_t sret;
+ bool in_transaction = false;
if (name == NULL || ccname == NULL) {
DEBUG(1, ("Missing user or ccache name.\n"));
@@ -154,9 +156,11 @@ static int krb5_mod_ccname(TALLOC_CTX *mem_ctx,
ret = sysdb_transaction_start(sysdb);
if (ret != EOK) {
- DEBUG(6, ("Error %d starting transaction (%s)\n", ret, strerror(ret)));
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Error %d starting transaction (%s)\n", ret, strerror(ret)));
goto done;
}
+ in_transaction = true;
ret = sysdb_set_user_attr(sysdb, name, attrs, mod_op);
if (ret != EOK) {
@@ -167,10 +171,18 @@ static int krb5_mod_ccname(TALLOC_CTX *mem_ctx,
ret = sysdb_transaction_commit(sysdb);
if (ret != EOK) {
- DEBUG(1, ("Failed to commit transaction!\n"));
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction!\n"));
+ goto done;
}
+ in_transaction = false;
done:
+ if (in_transaction) {
+ sret = sysdb_transaction_cancel(sysdb);
+ if (sret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to cancel transaction\n"));
+ }
+ }
talloc_zfree(tmpctx);
return ret;
}