summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Židek <mzidek@redhat.com>2015-07-07 15:15:32 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-09-14 10:23:04 +0200
commitc35eb4aa64a67d34d343d608be40d60b61fb7d11 (patch)
treee6a85ddfe1885526592b127fd3c98dad69751588
parent7dd51b427d4e5c047c831d82456a3d8769c30e04 (diff)
downloadsssd-c35eb4aa64a67d34d343d608be40d60b61fb7d11.tar.gz
sssd-c35eb4aa64a67d34d343d608be40d60b61fb7d11.tar.xz
sssd-c35eb4aa64a67d34d343d608be40d60b61fb7d11.zip
CONFDB: Assume config file version 2 if missing
Default to config file version 2 if the version is not specified explicitly. Ticket: https://fedorahosted.org/sssd/ticket/2688 Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/confdb/confdb.h1
-rw-r--r--src/confdb/confdb_setup.c48
-rw-r--r--src/config/SSSDConfig/__init__.py.in5
-rw-r--r--src/config/SSSDConfig/sssd_upgrade_config.py3
-rwxr-xr-xsrc/config/SSSDConfigTest.py11
5 files changed, 29 insertions, 39 deletions
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
index e97c46b34..68009fa99 100644
--- a/src/confdb/confdb.h
+++ b/src/confdb/confdb.h
@@ -38,6 +38,7 @@
* @{
*/
+#define CONFDB_DEFAULT_CFG_FILE_VER 2
#define CONFDB_FILE "config.ldb"
#define CONFDB_DEFAULT_CONFIG_FILE SSSD_CONF_DIR"/sssd.conf"
#define SSSD_MIN_ID 1
diff --git a/src/confdb/confdb_setup.c b/src/confdb/confdb_setup.c
index 93a1a1b53..694a7f016 100644
--- a/src/confdb/confdb_setup.c
+++ b/src/confdb/confdb_setup.c
@@ -224,30 +224,30 @@ int confdb_init_db(const char *config_file, struct confdb_ctx *cdb)
ret = sss_ini_check_config_obj(init_data);
if (ret != EOK) {
- /* No known version. Assumed to be version 1 */
- DEBUG(SSSDBG_FATAL_FAILURE,
- "Config file is an old version. "
- "Please run configuration upgrade script.\n");
- ret = EINVAL;
- goto done;
- }
-
- version = sss_ini_get_int_config_value(init_data, 1, -1, &ret);
- if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE,
- "Config file version could not be determined\n");
- goto done;
- } else if (version < CONFDB_VERSION_INT) {
- DEBUG(SSSDBG_FATAL_FAILURE,
- "Config file is an old version. "
- "Please run configuration upgrade script.\n");
- ret = EINVAL;
- goto done;
- } else if (version > CONFDB_VERSION_INT) {
- DEBUG(SSSDBG_FATAL_FAILURE,
- "Config file version is newer than confdb\n");
- ret = EINVAL;
- goto done;
+ /* No known version. Use default. */
+ DEBUG(SSSDBG_CONF_SETTINGS,
+ "Value of config_file_version option not found. "
+ "Assumed to be version %d.\n", CONFDB_DEFAULT_CFG_FILE_VER);
+ } else {
+ version = sss_ini_get_int_config_value(init_data,
+ CONFDB_DEFAULT_CFG_FILE_VER,
+ -1, &ret);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Config file version could not be determined\n");
+ goto done;
+ } else if (version < CONFDB_VERSION_INT) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Config file is an old version. "
+ "Please run configuration upgrade script.\n");
+ ret = EINVAL;
+ goto done;
+ } else if (version > CONFDB_VERSION_INT) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "Config file version is newer than confdb\n");
+ ret = EINVAL;
+ goto done;
+ }
}
/* Set up a transaction to replace the configuration */
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
index d72b8929a..fc87a2b0e 100644
--- a/src/config/SSSDConfig/__init__.py.in
+++ b/src/config/SSSDConfig/__init__.py.in
@@ -731,11 +731,6 @@ class SSSDService(SSSDConfigObject):
# Set up default options for this service
self.options.update(self.schema.get_defaults(self.name))
- # For the [sssd] service, force the config file version
- if servicename == 'sssd':
- self.options['config_file_version'] = 2
- self.hidden_options.append('config_file_version')
-
def list_options_with_mandatory(self):
"""
List options for the service, including the mandatory flag.
diff --git a/src/config/SSSDConfig/sssd_upgrade_config.py b/src/config/SSSDConfig/sssd_upgrade_config.py
index 282d6c46f..767d06ddc 100644
--- a/src/config/SSSDConfig/sssd_upgrade_config.py
+++ b/src/config/SSSDConfig/sssd_upgrade_config.py
@@ -47,7 +47,8 @@ class SSSDConfigFile(SSSDChangeConf):
def get_version(self):
ver = self.get_option_index('sssd', 'config_file_version')[1]
if not ver:
- return 1
+ # config_file_version not found -> default to version 2
+ return 2
try:
return int(ver['value'])
except ValueError:
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
index aed76e5a0..868d1a56d 100755
--- a/src/config/SSSDConfigTest.py
+++ b/src/config/SSSDConfigTest.py
@@ -396,9 +396,6 @@ class SSSDConfigTestSSSDService(unittest.TestCase):
def testGetOption(self):
service = SSSDConfig.SSSDService('sssd', self.schema)
- # Positive test - Single-valued
- self.assertEqual(service.get_option('config_file_version'), 2)
-
# Positive test - List of values
self.assertEqual(service.get_option('services'), ['nss', 'pam'])
@@ -410,9 +407,7 @@ class SSSDConfigTestSSSDService(unittest.TestCase):
#Positive test
options = service.get_all_options()
- control_list = [
- 'config_file_version',
- 'services']
+ control_list = ['services']
self.assertTrue(type(options) == dict,
"Options should be a dictionary")
@@ -1253,9 +1248,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase):
for section in sssdconfig.sections():
self.assertTrue(section['name'] in control_list)
- control_list = [
- 'config_file_version',
- 'services']
+ control_list = ['services']
for option in control_list:
self.assertTrue(sssdconfig.has_option('sssd', option),
"Option [%s] missing from [sssd]" %