summaryrefslogtreecommitdiff
path: root/server/db
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-11-17 09:47:04 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-11-18 06:47:24 -0500
commitb49f7338305081759cca445d83d4e1d3d7f97763 (patch)
tree8adda55d0fb6f90c61cba21194226fadce88ebfe /server/db
parente5d8e5e436667166facdce454b240549dcfd04cd (diff)
downloadsssd-b49f7338305081759cca445d83d4e1d3d7f97763.tar.gz
sssd-b49f7338305081759cca445d83d4e1d3d7f97763.tar.bz2
sssd-b49f7338305081759cca445d83d4e1d3d7f97763.zip
Upgrade cache and local databases to case-sensitive names
Diffstat (limited to 'server/db')
-rw-r--r--server/db/sysdb.c94
-rw-r--r--server/db/sysdb_private.h4
2 files changed, 96 insertions, 2 deletions
diff --git a/server/db/sysdb.c b/server/db/sysdb.c
index e4131f11..db687945 100644
--- a/server/db/sysdb.c
+++ b/server/db/sysdb.c
@@ -777,7 +777,7 @@ done:
return EIO;
}
- *ver = "0.2";
+ *ver = SYSDB_VERSION_0_2;
return ret;
}
@@ -1065,6 +1065,93 @@ done:
return ret;
}
+static int sysdb_upgrade_03(struct sysdb_ctx *ctx, const char **ver)
+{
+ TALLOC_CTX *tmp_ctx;
+ int ret;
+ struct ldb_message *msg;
+
+ tmp_ctx = talloc_new(ctx);
+ if (!tmp_ctx) {
+ return ENOMEM;
+ }
+
+ ret = ldb_transaction_start(ctx->ldb);
+ if (ret != LDB_SUCCESS) {
+ ret = EIO;
+ goto done;
+ }
+
+ /* Make this database case-sensitive */
+ msg = ldb_msg_new(tmp_ctx);
+ if (!msg) {
+ ret = ENOMEM;
+ goto done;
+ }
+ msg->dn = ldb_dn_new(tmp_ctx, ctx->ldb, "@ATTRIBUTES");
+ if (!msg->dn) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = ldb_msg_add_empty(msg, "name", LDB_FLAG_MOD_DELETE, NULL);
+ if (ret != LDB_SUCCESS) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = ldb_modify(ctx->ldb, msg);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ /* conversion done, upgrade version number */
+ msg = ldb_msg_new(tmp_ctx);
+ if (!msg) {
+ ret = ENOMEM;
+ goto done;
+ }
+ msg->dn = ldb_dn_new(tmp_ctx, ctx->ldb, "cn=sysdb");
+ if (!msg->dn) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = ldb_msg_add_empty(msg, "version", LDB_FLAG_MOD_REPLACE, NULL);
+ if (ret != LDB_SUCCESS) {
+ ret = ENOMEM;
+ goto done;
+ }
+ ret = ldb_msg_add_string(msg, "version", SYSDB_VERSION_0_4);
+ if (ret != LDB_SUCCESS) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = ldb_modify(ctx->ldb, msg);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ ret = EOK;
+
+done:
+ talloc_zfree(tmp_ctx);
+
+ if (ret != EOK) {
+ ret = ldb_transaction_cancel(ctx->ldb);
+ } else {
+ ret = ldb_transaction_commit(ctx->ldb);
+ }
+ if (ret != LDB_SUCCESS) {
+ ret = EIO;
+ }
+
+ *ver = SYSDB_VERSION_0_4;
+ return ret;
+}
static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -1201,6 +1288,11 @@ static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
goto done;
}
+ if (strcmp(version, SYSDB_VERSION_0_3) == 0) {
+ ret = sysdb_upgrade_03(ctx, &version);
+ if (ret != EOK) goto done;
+ }
+
}
DEBUG(0,("Unknown DB version [%s], expected [%s] for domain %s!\n",
diff --git a/server/db/sysdb_private.h b/server/db/sysdb_private.h
index ea4b2468..4400665c 100644
--- a/server/db/sysdb_private.h
+++ b/server/db/sysdb_private.h
@@ -23,11 +23,13 @@
#ifndef __INT_SYS_DB_H__
#define __INT_SYS_DB_H__
-#define SYSDB_VERSION "0.3"
+#define SYSDB_VERSION_0_4 "0.4"
#define SYSDB_VERSION_0_3 "0.3"
#define SYSDB_VERSION_0_2 "0.2"
#define SYSDB_VERSION_0_1 "0.1"
+#define SYSDB_VERSION SYSDB_VERSION_0_4
+
#define SYSDB_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
"userPrincipalName: CASE_INSENSITIVE\n" \