/*
SSSD
Configuration Database
Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "confdb.h"
#include "confdb_private.h"
#include "confdb_setup.h"
#ifndef SSSD_FALLBACK_CONFIG_LDIF
#define SSSD_FALLBACK_CONFIG_LDIF \
"dn: cn=config\n" \
"version: 2\n\n" \
"dn: cn=sssd,cn=config\n" \
"cn: sssd\n" \
"enable_files_domain: true\n" \
"services: nss\n\n"
#endif /* SSSD_FALLBACK_CONFIG_LDIF */
{
char **values;
int ret;
"config",
"version",
&values);
return ret;
}
/* empty database, will need to init */
return ENOENT;
}
/* more than 1 value?? */
return EIO;
}
/* Existing version does not match executable version */
values[0], CONFDB_VERSION);
/* This is recoverable, since we purge the confdb file
* when we re-initialize it.
*/
return ENOENT;
}
return EOK;
}
{
int ret;
unsigned int i;
/* Get the list of all DNs */
if (ret != LDB_SUCCESS) {
goto done;
}
/* Delete this DN */
if (ret != LDB_SUCCESS) {
goto done;
}
}
done:
return ret;
}
{
int ret;
if (ret != LDB_SUCCESS) {
"Failed to initialize DB (%d,[%s]), aborting!\n",
return EIO;
}
}
return EOK;
}
const char *config_file,
const char *config_dir,
struct sss_ini_initdata *init_data,
const char **_timestr,
const char **_ldif)
{
int version;
"Permission check on config file failed.\n");
return EPERM;
}
"Status check on config file failed.\n");
return ret;
}
errno = 0;
"Failed to convert time_t to string??\n");
return ret;
}
/* FIXME: Determine if the conf file or any snippet has changed
* since we last updated the confdb or if some snippet was
* added or removed.
*/
return ret;
}
SSSDDATADIR"/cfg_rules.ini");
/* This is not fatal, continue */
}
/* Make sure that the config file version matches the confdb version */
"Internal error determining config_file_version\n");
return ret;
}
/* No known version. Use default. */
"Value of config_file_version option not found. "
"Assumed to be version %d.\n", CONFDB_DEFAULT_CFG_FILE_VER);
} else {
-1, &ret);
"Config file version could not be determined\n");
return ret;
} else if (version < CONFDB_VERSION_INT) {
"Config file is an old version. "
"Please run configuration upgrade script.\n");
return EINVAL;
} else if (version > CONFDB_VERSION_INT) {
"Config file version is newer than confdb\n");
return EINVAL;
}
}
return ret;
}
return ENOMEM;
}
return EOK;
}
const char **_timestr,
const char **_ldif)
{
return ENOMEM;
}
return EOK;
}
struct confdb_ctx *cdb)
{
int ret;
bool in_transaction = false;
const char *config_ldif;
return ENOMEM;
}
if (!init_data) {
goto done;
}
/* Open config file */
×tr,
&config_ldif);
"Cannot convert INI to LDIF [%d]: [%s]\n",
goto done;
}
"Cannot create a fallback configuration [%d]: [%s]\n",
goto done;
}
} else {
ret);
goto done;
}
/* Set up a transaction to replace the configuration */
if (ret != LDB_SUCCESS) {
"Failed to start a transaction for "
"updating the configuration\n");
goto done;
}
in_transaction = true;
/* Purge existing database */
"Could not purge existing configuration\n");
goto done;
}
if (ret != LDB_SUCCESS) {
"Failed to initialize DB (%d,[%s]), aborting!\n",
goto done;
}
}
/* now store the lastUpdate time so that we do not re-init if nothing
* changed on restart */
"Failed to set last update time on db!\n");
goto done;
}
goto done;
}
in_transaction = false;
done:
if (in_transaction) {
}
}
return ret;
}
const char *cdb_file,
const char *config_file,
const char *config_dir,
struct confdb_ctx **_cdb)
{
return ENOMEM;
}
goto done;
}
/* Initialize the CDB from the configuration file */
/* First-time setup */
/* Purge any existing confdb in case an old
* misconfiguration gets in the way
*/
"Purging existing confdb failed: %d [%s].\n",
goto done;
}
}
/* Load special entries */
"Unable to load special entries into confdb\n");
goto done;
}
goto done;
}
goto done;
}
done:
return ret;
}