From cff916f5352fe7c3a679571130090efdb935618a Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 2 May 2012 13:25:05 -0400 Subject: 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. --- src/db/sysdb_upgrade.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') 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; -- cgit