From bdff0c2c935157f8f4945a62d0a12b93447e0438 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 11b680f3f67319abd8856ea42045f6b8f0cef4ba..3a57ff74b7ffe0fa4167d75d1ba7372cac86a364 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -264,14 +264,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 c998e14c26e43c3cd6a5a060bb6f74698b9e93ae..a2f0f543655ffa6277dfe7467e0db25402bafb6e 100644 --- a/src/util/util_errors.c +++ b/src/util/util_errors.c @@ -85,6 +85,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 c0d9622a431a9946fdfa5e5c60ecf7b9e1ae66a5..aa6898cd9e1f534b534f27ad8ca76115d078e723 100644 --- a/src/util/util_errors.h +++ b/src/util/util_errors.h @@ -107,6 +107,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