|
|
6cf099 |
From c50681fc7a1296c278466e834eaddfbf2bc54afb Mon Sep 17 00:00:00 2001
|
|
|
6cf099 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
6cf099 |
Date: Thu, 25 Jun 2015 17:33:47 +0200
|
|
|
6cf099 |
Subject: [PATCH] SYSDB: Index the objectSIDString attribute
|
|
|
6cf099 |
|
|
|
6cf099 |
---
|
|
|
6cf099 |
src/db/sysdb.c | 7 +++++++
|
|
|
6cf099 |
src/db/sysdb_private.h | 5 ++++-
|
|
|
6cf099 |
src/db/sysdb_upgrade.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
6cf099 |
3 files changed, 61 insertions(+), 1 deletion(-)
|
|
|
6cf099 |
|
|
|
6cf099 |
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
|
|
|
6cf099 |
index 9da655759c0c35d52854b668693195b3360c5f8b..07a83a8a8e30df1b8e461a8d04866f2dbc53baf8 100644
|
|
|
6cf099 |
--- a/src/db/sysdb.c
|
|
|
6cf099 |
+++ b/src/db/sysdb.c
|
|
|
6cf099 |
@@ -1265,6 +1265,13 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
}
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
+ if (strcmp(version, SYSDB_VERSION_0_16) == 0) {
|
|
|
6cf099 |
+ ret = sysdb_upgrade_16(sysdb, &version);
|
|
|
6cf099 |
+ if (ret != EOK) {
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
/* The version should now match SYSDB_VERSION.
|
|
|
6cf099 |
* If not, it means we didn't match any of the
|
|
|
6cf099 |
* known older versions. The DB might be
|
|
|
6cf099 |
diff --git a/src/db/sysdb_private.h b/src/db/sysdb_private.h
|
|
|
6cf099 |
index 2adb9ff9166441014a8b446ffc170225f2a9629d..c2c8d7a0585463806997c43bd020436edddd8517 100644
|
|
|
6cf099 |
--- a/src/db/sysdb_private.h
|
|
|
6cf099 |
+++ b/src/db/sysdb_private.h
|
|
|
6cf099 |
@@ -23,6 +23,7 @@
|
|
|
6cf099 |
#ifndef __INT_SYS_DB_H__
|
|
|
6cf099 |
#define __INT_SYS_DB_H__
|
|
|
6cf099 |
|
|
|
6cf099 |
+#define SYSDB_VERSION_0_17 "0.17"
|
|
|
6cf099 |
#define SYSDB_VERSION_0_16 "0.16"
|
|
|
6cf099 |
#define SYSDB_VERSION_0_15 "0.15"
|
|
|
6cf099 |
#define SYSDB_VERSION_0_14 "0.14"
|
|
|
6cf099 |
@@ -40,7 +41,7 @@
|
|
|
6cf099 |
#define SYSDB_VERSION_0_2 "0.2"
|
|
|
6cf099 |
#define SYSDB_VERSION_0_1 "0.1"
|
|
|
6cf099 |
|
|
|
6cf099 |
-#define SYSDB_VERSION SYSDB_VERSION_0_16
|
|
|
6cf099 |
+#define SYSDB_VERSION SYSDB_VERSION_0_17
|
|
|
6cf099 |
|
|
|
6cf099 |
#define SYSDB_BASE_LDIF \
|
|
|
6cf099 |
"dn: @ATTRIBUTES\n" \
|
|
|
6cf099 |
@@ -68,6 +69,7 @@
|
|
|
6cf099 |
"@IDXATTR: serviceProtocol\n" \
|
|
|
6cf099 |
"@IDXATTR: sudoUser\n" \
|
|
|
6cf099 |
"@IDXATTR: sshKnownHostsExpire\n" \
|
|
|
6cf099 |
+ "@IDXATTR: objectSIDString\n" \
|
|
|
6cf099 |
"@IDXONE: 1\n" \
|
|
|
6cf099 |
"\n" \
|
|
|
6cf099 |
"dn: @MODULES\n" \
|
|
|
6cf099 |
@@ -120,6 +122,7 @@ int sysdb_upgrade_12(struct sysdb_ctx *sysdb, const char **ver);
|
|
|
6cf099 |
int sysdb_upgrade_13(struct sysdb_ctx *sysdb, const char **ver);
|
|
|
6cf099 |
int sysdb_upgrade_14(struct sysdb_ctx *sysdb, const char **ver);
|
|
|
6cf099 |
int sysdb_upgrade_15(struct sysdb_ctx *sysdb, const char **ver);
|
|
|
6cf099 |
+int sysdb_upgrade_16(struct sysdb_ctx *sysdb, const char **ver);
|
|
|
6cf099 |
|
|
|
6cf099 |
int add_string(struct ldb_message *msg, int flags,
|
|
|
6cf099 |
const char *attr, const char *value);
|
|
|
6cf099 |
diff --git a/src/db/sysdb_upgrade.c b/src/db/sysdb_upgrade.c
|
|
|
6cf099 |
index 6cebc877b86df7a8035bf95cfa51aa4dae464372..113f24644e3e3de1d4c46d375492c2fe1e6b2f83 100644
|
|
|
6cf099 |
--- a/src/db/sysdb_upgrade.c
|
|
|
6cf099 |
+++ b/src/db/sysdb_upgrade.c
|
|
|
6cf099 |
@@ -1584,6 +1584,56 @@ done:
|
|
|
6cf099 |
return ret;
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
+int sysdb_upgrade_16(struct sysdb_ctx *sysdb, const char **ver)
|
|
|
6cf099 |
+{
|
|
|
6cf099 |
+ struct ldb_message *msg;
|
|
|
6cf099 |
+ struct upgrade_ctx *ctx;
|
|
|
6cf099 |
+ errno_t ret;
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_17, &ctx;;
|
|
|
6cf099 |
+ if (ret) {
|
|
|
6cf099 |
+ return ret;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ msg = ldb_msg_new(ctx);
|
|
|
6cf099 |
+ if (msg == NULL) {
|
|
|
6cf099 |
+ ret = ENOMEM;
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ msg->dn = ldb_dn_new(msg, sysdb->ldb, "@INDEXLIST");
|
|
|
6cf099 |
+ if (msg->dn == NULL) {
|
|
|
6cf099 |
+ ret = ENOMEM;
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ /* add index for objectSIDString */
|
|
|
6cf099 |
+ ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
|
|
|
6cf099 |
+ if (ret != LDB_SUCCESS) {
|
|
|
6cf099 |
+ ret = ENOMEM;
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ret = ldb_msg_add_string(msg, "@IDXATTR", "objectSIDString");
|
|
|
6cf099 |
+ if (ret != LDB_SUCCESS) {
|
|
|
6cf099 |
+ ret = ENOMEM;
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ ret = ldb_modify(sysdb->ldb, msg);
|
|
|
6cf099 |
+ if (ret != LDB_SUCCESS) {
|
|
|
6cf099 |
+ ret = sysdb_error_to_errno(ret);
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ /* conversion done, update version number */
|
|
|
6cf099 |
+ ret = update_version(ctx);
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+done:
|
|
|
6cf099 |
+ ret = finish_upgrade(ret, &ctx, ver);
|
|
|
6cf099 |
+ return ret;
|
|
|
6cf099 |
+}
|
|
|
6cf099 |
+
|
|
|
6cf099 |
/*
|
|
|
6cf099 |
* Example template for future upgrades.
|
|
|
6cf099 |
* Copy and change version numbers as appropriate.
|
|
|
6cf099 |
--
|
|
|
6cf099 |
2.4.3
|
|
|
6cf099 |
|