From e732d23f3ec986a463d757781a334040e03d1f59 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Jun 23 2016 11:40:11 +0000 Subject: 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. Reviewed-by: Sumit Bose --- diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 6567e90..42f8450 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 76783d6..637b41a 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 3c95af8..458321a 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 066f8ab..2f47915 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 */ };