diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2009-09-22 09:47:41 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-09-25 09:03:29 -0400 |
commit | 8263230a0c543a737ab17a071a0ea964dcab4259 (patch) | |
tree | 373caef346d1b73f3dcf6d0d168402f3eecc4d23 /server/confdb/confdb_setup.c | |
parent | c65b34ae1d5794fc4456a25705163f56283047d2 (diff) | |
download | sssd-8263230a0c543a737ab17a071a0ea964dcab4259.tar.gz sssd-8263230a0c543a737ab17a071a0ea964dcab4259.tar.bz2 sssd-8263230a0c543a737ab17a071a0ea964dcab4259.zip |
Upgrade confdb to version 2
This converts a great many configuration options to the new
standard format.
Diffstat (limited to 'server/confdb/confdb_setup.c')
-rw-r--r-- | server/confdb/confdb_setup.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/server/confdb/confdb_setup.c b/server/confdb/confdb_setup.c index 00bba7f1..9110a5e9 100644 --- a/server/confdb/confdb_setup.c +++ b/server/confdb/confdb_setup.c @@ -57,9 +57,15 @@ int confdb_test(struct confdb_ctx *cdb) } if (strcmp(values[0], CONFDB_VERSION) != 0) { - /* bad version get out */ + /* Existing version does not match executable version */ + DEBUG(1, ("Upgrading confdb version from %s to %s\n", + values[0], CONFDB_VERSION)); + + /* This is recoverable, since we purge the confdb file + * when we re-initialize it. + */ talloc_free(values); - return EIO; + return ENOENT; } talloc_free(values); @@ -266,12 +272,14 @@ int confdb_init_db(const char *config_file, struct confdb_ctx *cdb) int ret, i; struct collection_item *sssd_config = NULL; struct collection_item *error_list = NULL; + struct collection_item *item = NULL; char *config_ldif; struct ldb_ldif *ldif; TALLOC_CTX *tmp_ctx; char *lasttimestr, timestr[21]; const char *vals[2] = { timestr, NULL }; struct stat cstat; + int version; tmp_ctx = talloc_new(cdb); if (tmp_ctx == NULL) return ENOMEM; @@ -327,6 +335,35 @@ int confdb_init_db(const char *config_file, struct confdb_ctx *cdb) goto done; } + /* Make sure that the config file version matches the confdb version */ + ret = get_config_item("sssd", "config_file_version", + sssd_config, &item); + if (ret != EOK) { + DEBUG(0, ("Internal error determining config_file_version\n")); + goto done; + } + if (item == NULL) { + /* No known version. Assumed to be version 1 */ + DEBUG(0, ("Config file is an old version. " + "Please run configuration upgrade script.\n")); + ret = EINVAL; + goto done; + } + version = get_int_config_value(item, 1, -1, &ret); + if (ret != EOK) { + DEBUG(0, ("Config file version could not be determined\n")); + goto done; + } else if (version < CONFDB_VERSION_INT) { + DEBUG(0, ("Config file is an old version. " + "Please run configuration upgrade script.\n")); + ret = EINVAL; + goto done; + } else if (version > CONFDB_VERSION_INT) { + DEBUG(0, ("Config file version is newer than confdb\n")); + ret = EINVAL; + goto done; + } + ret = confdb_create_ldif(tmp_ctx, sssd_config, &config_ldif); free_ini_config(sssd_config); if (ret != EOK) { |