sysdb_init.c revision e732d23f3ec986a463d757781a334040e03d1f59
/*
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"
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;
}
{
char *ldb_file;
/* special case for the local domain */
} else {
}
if (!ldb_file) {
return ENOMEM;
}
return EOK;
}
{
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;
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;
}
struct sss_domain_info *domain,
const char *db_path,
bool allow_upgrade,
{
const char *base_ldif;
struct ldb_message_element *el;
struct ldb_result *res;
int ret;
if (!sysdb) {
return ENOMEM;
}
goto done;
}
goto done;
}
if (!tmp_ctx) {
goto done;
}
if (!verdn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
goto done;
}
if (!el) {
goto done;
}
goto done;
}
if (!version) {
goto done;
}
/* all fine, return */
goto done;
}
if (!allow_upgrade) {
"Wrong DB version (got %s expected %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;
}
}
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;
}
"Unknown DB version [%s], expected [%s] for domain %s!\n",
goto done;
}
/* SYSDB_BASE does not exists, means db is empty, populate */
if (ret != LDB_SUCCESS) {
"Failed to initialize DB (%d, [%s]) for domain %s!\n",
goto done;
}
}
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).
*/
}
done:
} else {
}
return ret;
}
struct sss_domain_info *domains,
bool allow_upgrade)
{
}
struct sss_domain_info *domains,
bool allow_upgrade,
bool chown_dbfile,
{
struct sss_domain_info *dom;
int ret;
if (allow_upgrade) {
/* check if we have an old sssd.ldb to upgrade */
return ret;
}
}
/* open a db for each domain */
allow_upgrade, &sysdb);
return ret;
}
if (chown_dbfile) {
if (ret != 0) {
return ret;
}
}
}
return EOK;
}
struct sss_domain_info *domain,
const char *db_path,
{
}