sysdb_upgrade.c revision c2352a73f52f600d95966ebe0b0819649ba923fa
/*
SSSD
Authors:
Simo Sorce <ssorce@redhat.com>
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2008-2011 Simo Sorce <ssorce@redhat.com>
Copyright (C) 2008-2011 Stephen Gallagher
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 "db/sysdb_private.h"
{
}
}
}
return ret;
}
/* serach all groups that have a memberUid attribute.
* change it into a member attribute for a user of same domain.
* remove the memberUid attribute
* add the new member attribute
* finally stop indexing memberUid
* upgrade version to 0.2
*/
{
struct ldb_message_element *el;
struct ldb_result *res;
struct ldb_message *msg;
const char *filter = "(&(memberUid=*)(objectclass=group))";
const char *mdn;
char *domain;
int ret, i, j;
if (!tmp_ctx) {
goto done;
}
if (!basedn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (!el) {
continue;
}
/* create modification message */
if (!msg) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* get domain name component value */
if (!domain) {
goto done;
}
for (j = 0; j < el->num_values; j++) {
if (!mem_dn) {
goto done;
}
if (!mdn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
}
/* ok now we are ready to modify the entry */
if (ret != LDB_SUCCESS) {
goto done;
}
}
/* conversion done, upgrade version number */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
done:
return ret;
}
const char *db_path)
{
struct ldb_context *ldb;
char *ldb_file;
struct sss_domain_info *dom;
struct ldb_message_element *el;
struct ldb_message *msg;
struct ldb_result *res;
bool do_02_upgrade = false;
bool ctx_trans = false;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
"local", "UPGRADE",
goto exit;
}
return ret;
}
if (!verdn) {
goto exit;
}
if (ret != LDB_SUCCESS) {
goto exit;
}
goto exit;
}
if (el) {
goto exit;
}
if (!version) {
goto exit;
}
/* all fine, return */
goto exit;
}
/* convert database */
}
/* need to convert database to split files */
do_02_upgrade = true;
}
}
}
if (!do_02_upgrade) {
/* not a v2 upgrade, return and let the normal code take over any
* further upgrade */
goto exit;
}
/* == V2->V3 UPGRADE == */
/* ldb uses posix locks,
* posix is stupid and kills all locks when you close *any* file
* descriptor associated to the same file.
* Therefore we must close and reopen the ldb file here */
/* == Backup and reopen ldb == */
/* close */
/* backup*/
goto exit;
}
/* reopen */
return ret;
}
/* open a transaction */
if (ret != LDB_SUCCESS) {
goto exit;
}
/* == Upgrade contents == */
int i;
/* skip local */
continue;
}
/* create new dom db */
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
ctx_trans = true;
/* search all entries for this domain in local,
* copy them all in the new database,
* then remove them from local */
if (!domain_dn) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (!users_dn) {
goto done;
}
if (!groups_dn) {
goto done;
}
/* skip pre-created congtainers */
continue;
}
/* regenerate the DN against the new ldb as it may have different
* casefolding rules (example: name changing from case insensitive
* to case sensitive) */
goto done;
}
if (ret != LDB_SUCCESS) {
DEBUG(0, ("WARNING: Could not add entry %s,"
" to new ldb file! (%d [%s])\n",
}
if (ret != LDB_SUCCESS) {
DEBUG(0, ("WARNING: Could not remove entry %s,"
" from old ldb file! (%d [%s])\n",
}
}
/* now remove the basic containers from local */
/* these were optional so debug at level 9 in case
* of failure just for tracing */
if (ret != LDB_SUCCESS) {
" from old ldb file! (%d [%s])\n",
}
if (ret != LDB_SUCCESS) {
" from old ldb file! (%d [%s])\n",
}
if (ret != LDB_SUCCESS) {
" from old ldb file! (%d [%s])\n",
}
if (ret != LDB_SUCCESS) {
goto done;
}
ctx_trans = false;
}
/* conversion done, upgrade version number */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto exit;
}
done:
if (ctx_trans) {
if (ret != LDB_SUCCESS) {
}
}
if (ret != LDB_SUCCESS) {
}
}
exit:
return ret;
}
{
int ret;
struct ldb_message *msg;
if (!tmp_ctx) {
return ENOMEM;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* Make this database case-sensitive */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* conversion done, upgrade version number */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
done:
return ret;
}
{
int ret;
struct ldb_message *msg;
if (!tmp_ctx) {
return ENOMEM;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* Add new index */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* Rebuild memberuid and memberoif attributes */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* conversion done, upgrade version number */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
done:
return ret;
}
{
int ret;
struct ldb_message *msg;
if (!tmp_ctx) {
return ENOMEM;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* Add new indexes */
if (!msg) {
goto done;
}
goto done;
}
/* Add Index for dataExpireTimestamp */
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* Add index to speed up ONELEVEL searches */
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* conversion done, upgrade version number */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
done:
return ret;
}
{
int ret;
struct ldb_message *msg;
if (!tmp_ctx) {
return ENOMEM;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* Add new indexes */
if (!msg) {
goto done;
}
goto done;
}
/* Case insensitive search for originalDN */
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
/* conversion done, upgrade version number */
if (!msg) {
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
done:
return ret;
}