From 757ac4fc654e8f982b526d12291a74ed7f52f80e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 20 Apr 2016 15:49:11 +0200 Subject: [PATCH 02/14] UTIL: Add error codes for sysdb too old or too new We used really strange errno codes for detecting whether the database is too old or too new. We should use our sssd-specific error coded instead. --- src/db/sysdb.h | 4 ++-- src/db/sysdb_init.c | 8 ++++---- src/util/util_errors.c | 2 ++ src/util/util_errors.h | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 6567e904ffe7e2f8d80ad1775fb1408cf926b8d6..42f845033b8d828d3fbb1315df6cc8be54f8c8a2 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -265,14 +265,14 @@ "cached credentials.\n") #define SYSDB_VERSION_LOWER_ERROR(ret) do { \ - if (ret == EUCLEAN) { \ + if (ret == ERR_SYSDB_VERSION_TOO_NEW) { \ ERROR("Lower version of database is expected!\n"); \ SYSDB_VERSION_ERROR_HINT; \ } \ } while(0) #define SYSDB_VERSION_HIGHER_ERROR(ret) do { \ - if (ret == EMEDIUMTYPE) { \ + if (ret == ERR_SYSDB_VERSION_TOO_OLD) { \ ERROR("Higher version of database is expected!\n"); \ ERROR("In order to upgrade the database, you must run SSSD.\n"); \ SYSDB_VERSION_ERROR_HINT; \ diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c index 76783d619623c9528577ae2757660d0efd0c27a2..637b41a650f23437d8b5fd5d8bde2f5a5310ef2b 100644 --- a/src/db/sysdb_init.c +++ b/src/db/sysdb_init.c @@ -215,15 +215,15 @@ sysdb_version_check(const char *expected, } if (recv_major > exp_major) { - return EUCLEAN; + return ERR_SYSDB_VERSION_TOO_NEW; } else if (recv_major < exp_major) { - return EMEDIUMTYPE; + return ERR_SYSDB_VERSION_TOO_OLD; } if (recv_minor > exp_minor) { - return EUCLEAN; + return ERR_SYSDB_VERSION_TOO_NEW; } else if (recv_minor < exp_minor) { - return EMEDIUMTYPE; + return ERR_SYSDB_VERSION_TOO_OLD; } return EOK; diff --git a/src/util/util_errors.c b/src/util/util_errors.c index 3c95af82a062345375513c1d5a4372ae5ecfb20a..458321a080b5499df64d31fcc611cd3c1d2e0135 100644 --- a/src/util/util_errors.c +++ b/src/util/util_errors.c @@ -89,6 +89,8 @@ struct err_string error_to_str[] = { { "Account is locked" }, /* ERR_ACCOUNT_LOCKED */ { "AD renewal child failed" }, /* ERR_RENEWAL_CHILD */ { "SBUS request already handled" }, /* ERR_SBUS_REQUEST_HANDLED */ + { "Sysdb version is too old" }, /* ERR_SYSDB_VERSION_TOO_OLD */ + { "Sysdb version is too new" }, /* ERR_SYSDB_VERSION_TOO_NEW */ { "ERR_LAST" } /* ERR_LAST */ }; diff --git a/src/util/util_errors.h b/src/util/util_errors.h index 066f8abf5d98880bef49dc134ba94dbbcd16f142..2f4791522872345a4ffbf6680b39e59014a6f0d0 100644 --- a/src/util/util_errors.h +++ b/src/util/util_errors.h @@ -111,6 +111,8 @@ enum sssd_errors { ERR_ACCOUNT_LOCKED, ERR_RENEWAL_CHILD, ERR_SBUS_REQUEST_HANDLED, + ERR_SYSDB_VERSION_TOO_OLD, + ERR_SYSDB_VERSION_TOO_NEW, ERR_LAST /* ALWAYS LAST */ }; -- 2.4.11