summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-05-02 13:25:05 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-05-03 11:46:17 -0400
commitcff916f5352fe7c3a679571130090efdb935618a (patch)
treed510ea8b28c411b46a6ce07b8891e209c83c9c25
parent5f93f452e4a80d6b0243eaf3c583d0caf9981ca0 (diff)
downloadsssd-cff916f5352fe7c3a679571130090efdb935618a.tar.gz
sssd-cff916f5352fe7c3a679571130090efdb935618a.tar.bz2
sssd-cff916f5352fe7c3a679571130090efdb935618a.zip
SYSDB: Handle upgrade script failures better
There was a bug in finish_upgrade() where it would return EOK if it succeeded in canceling the transaction due to an error. We should instead be returning the original error.
-rw-r--r--src/db/sysdb_upgrade.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/db/sysdb_upgrade.c b/src/db/sysdb_upgrade.c
index 434cc832..4fe6afb3 100644
--- a/src/db/sysdb_upgrade.c
+++ b/src/db/sysdb_upgrade.c
@@ -29,18 +29,27 @@ static int finish_upgrade(int result, struct ldb_context *ldb,
const char *next_ver, const char **ver)
{
int ret = result;
+ int lret;
if (ret == EOK) {
- ret = ldb_transaction_commit(ldb);
- ret = sysdb_error_to_errno(ret);
+ lret = ldb_transaction_commit(ldb);
+ ret = sysdb_error_to_errno(lret);
if (ret == EOK) {
*ver = next_ver;
}
}
if (ret != EOK) {
- ret = ldb_transaction_cancel(ldb);
- ret = sysdb_error_to_errno(ret);
+ lret = ldb_transaction_cancel(ldb);
+ if (lret != LDB_SUCCESS) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Could not cancel transaction! [%s]\n",
+ ldb_strerror(lret)));
+ /* Do not overwrite ret here, we want to return
+ * the original failure, not the failure of the
+ * transaction cancellation.
+ */
+ }
}
return ret;