sysdb_init.c revision 6d66c2c465861ff2558f2574eddf8315628ccc6d
/*
SSSD
System Database - initialization
Copyright (C) 2008-2011 Simo Sorce <ssorce@redhat.com>
Copyright (C) 2008-2011 Stephen Gallagher <ssorce@redhat.com>
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 "util/strtonum.h"
#include "util/sss_utf8.h"
#include "db/sysdb_private.h"
#include <time.h>
#define LDB_MODULES_PATH "LDB_MODULES_PATH"
/* If an entry differs only in these attributes, they are written to
* the timestamp cache only. In addition, objectclass is added so that
* we can distinguish between users and groups.
*/
const char *sysdb_ts_cache_attrs[] = {
NULL,
};
const char *filename,
int flags,
struct ldb_context **_ldb)
{
int ret;
struct ldb_context *ldb;
const char *mod_path;
return EINVAL;
}
if (!ldb) {
return EIO;
}
if (ret != LDB_SUCCESS) {
return EIO;
}
}
if (ret != LDB_SUCCESS) {
return EIO;
}
return EOK;
}
const char *ldb_file,
int flags,
struct ldb_context **ldb)
{
talloc_zfree(*ldb);
}
return ret;
}
{
if (ret != 0) {
return ret;
}
if (ret != 0) {
return ret;
}
}
return EOK;
}
const char *provider,
const char *name,
const char *base_path,
char **_ldb_file,
char **_ts_file)
{
char *ldb_file;
/* special case for the local domain */
} else {
return ENOMEM;
}
}
if (!ldb_file) {
return ENOMEM;
}
return EOK;
}
const char *domain_name)
{
struct ldb_message *msg;
int ret;
goto done;
}
/* == create base domain object == */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* do a synchronous add */
if (ret != LDB_SUCCESS) {
"for domain %s!\n",
goto done;
}
/* == create Users tree == */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* do a synchronous add */
if (ret != LDB_SUCCESS) {
"for domain %s!\n",
goto done;
}
/* == create Groups tree == */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* do a synchronous add */
if (ret != LDB_SUCCESS) {
"domain %s!\n",
goto done;
}
done:
return ret;
}
{
}
/* Compare versions of sysdb, returns ERRNO accordingly */
static errno_t
sysdb_version_check(const char *expected,
const char *received)
{
int ret;
return EOK;
}
if (ret != 2) {
return EINVAL;
}
if (ret != 2) {
return EINVAL;
}
if (recv_major > exp_major) {
return ERR_SYSDB_VERSION_TOO_NEW;
} else if (recv_major < exp_major) {
return ERR_SYSDB_VERSION_TOO_OLD;
}
if (recv_minor > exp_minor) {
return ERR_SYSDB_VERSION_TOO_NEW;
} else if (recv_minor < exp_minor) {
return ERR_SYSDB_VERSION_TOO_OLD;
}
return EOK;
}
const char *base_ldif,
const char *domain_name)
{
int ret;
if (ret != LDB_SUCCESS) {
"Failed to initialize DB (%d, [%s]) for domain %s!\n",
return EIO;
}
}
return EOK;
}
const char *base_ldif,
struct sss_domain_info *domain)
{
int ret;
return ret;
}
return ret;
}
return EOK;
}
struct ldb_context *ldb,
struct sss_domain_info *domain,
const char *cur_version,
const char **_new_version)
{
/* Currently the sysdb cache only has one version */
return EFAULT;
}
struct sysdb_dom_upgrade_ctx *upgrade_ctx,
struct ldb_context *ldb,
struct sss_domain_info *domain,
const char *cur_version,
const char **_new_version)
{
const char *version;
struct ldb_context *save_ldb;
return ENOMEM;
}
/* The upgrade process depends on having ldb around, yet the upgrade
* function shouldn't set the ldb pointer, only the connect function
* should after it's successful. To avoid hard refactoring, save the
* ldb pointer here and restore in the 'done' handler
*/
goto done;
}
"Upgrading DB [%s] from version: %s\n",
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
goto done;
}
}
done:
return ret;
}
struct sss_domain_info *domain,
const char *ldb_file,
int flags,
const char *exp_version,
const char *base_ldif,
struct ldb_context **_ldb,
const char **_version)
{
struct ldb_message_element *el;
struct ldb_result *res;
int ret;
struct ldb_context *ldb;
if (!tmp_ctx) {
goto done;
}
goto done;
}
if (!verdn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
goto done;
}
if (!el) {
goto done;
}
goto done;
}
if (!version) {
goto done;
}
/* This is not the latest version. Return what version it is
* and appropriate error
*/
goto done;
}
/* SYSDB_BASE does not exists, means db is empty, populate */
goto done;
}
/* The cache has been newly created.
* We need to reopen the LDB to ensure that
* all of the special values take effect
* (such as enabling the memberOf plugin and
* the various indexes).
*/
goto done;
}
/* If we connect to a new database, then the version is the
* latest one
*/
goto done;
}
done:
}
return ret;
}
struct sss_domain_info *domain,
struct sysdb_dom_upgrade_ctx *upgrade_ctx)
{
const char *version;
struct ldb_context *ldb;
return ENOMEM;
}
switch (ret) {
if (upgrade_ctx == NULL) {
"DB version too old [%s], expected [%s] for domain %s!\n",
goto done;
}
goto done;
}
/* The version should now match SYSDB_VERSION.
* If not, it means we didn't match any of the
* known older versions. The DB might be
* corrupt or generated by a newer version of
* SSSD.
*/
/* The cache has been upgraded.
* We need to reopen the LDB to ensure that
* any changes made above take effect.
*/
goto done;
}
break;
"DB version too new [%s], expected [%s] for domain %s!\n",
break;
default:
break;
}
done:
}
return ret;
}
struct sss_domain_info *domain,
struct sysdb_dom_upgrade_ctx *upgrade_ctx)
{
const char *version;
struct ldb_context *ldb;
return EOK;
}
return ENOMEM;
}
switch (ret) {
if (upgrade_ctx == NULL) {
"DB version too old [%s], expected [%s] for domain %s!\n",
break;
}
&version);
"Could not upgrade the timestamp ldb file (%d) (%s)\n",
break;
}
/* The version should now match SYSDB_VERSION.
* If not, it means we didn't match any of the
* known older versions. The DB might be
* corrupt or generated by a newer version of
* SSSD.
*/
/* The cache has been upgraded.
* We need to reopen the LDB to ensure that
* any changes made above take effect.
*/
&ldb);
"Could not reopen the timestamp ldb file (%d) (%s)\n",
}
}
break;
"DB version too new [%s], expected [%s] for domain %s!\n",
break;
default:
break;
}
"The timestamps cache could not be opened. "
"Throwing away the database and opening a new one\n");
"Could not delete the timestamp ldb file (%d) (%s)\n",
return ret;
}
/* Now the connect must succeed because the previous cache doesn't
* exist anymore.
*/
"Could not delete the timestamp ldb file (%d) (%s)\n",
}
}
}
return ret;
}
struct sss_domain_info *domain,
const char *db_path,
struct sysdb_dom_upgrade_ctx *upgrade_ctx,
{
int ret;
return ENOMEM;
}
if (!sysdb) {
goto done;
}
goto done;
}
if (sysdb->ldb_ts_file) {
}
"Could not open the sysdb cache [%d]: %s\n",
goto done;
}
"Could not open the timestamp cache [%d]: %s\n",
goto done;
}
done:
}
return ret;
}
struct sss_domain_info *domains)
{
}
struct sss_domain_info *domains,
struct sysdb_upgrade_ctx *upgrade_ctx,
bool chown_dbfile,
{
struct sss_domain_info *dom;
int ret;
struct sysdb_dom_upgrade_ctx *dom_upgrade_ctx;
if (upgrade_ctx != NULL) {
/* check if we have an old sssd.ldb to upgrade */
return ret;
}
}
return ENOMEM;
}
/* open a db for each domain */
if (upgrade_ctx) {
struct sysdb_dom_upgrade_ctx);
} else {
}
dom_upgrade_ctx, &sysdb);
"Cannot connect to database for %s: [%d]: %s\n",
goto done;
}
if (chown_dbfile) {
"Cannot chown databases for %s: [%d]: %s\n",
goto done;
}
}
}
done:
return ret;
}
struct sss_domain_info *domain,
const char *db_path,
{
}