summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-06-25 17:33:47 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-08-19 18:00:58 +0200
commite61b0e41cb44004d2b260ad9d05802995f7bcb2e (patch)
tree348574072d8386cda667e253f90e4f65e59fe24c
parent06987186fb528271d6c208d2abf326049c0e168b (diff)
downloadsssd-e61b0e41cb44004d2b260ad9d05802995f7bcb2e.tar.gz
sssd-e61b0e41cb44004d2b260ad9d05802995f7bcb2e.tar.xz
sssd-e61b0e41cb44004d2b260ad9d05802995f7bcb2e.zip
SYSDB: Index the objectSIDString attribute
Reviewed-by: Michal Židek <mzidek@redhat.com>
-rw-r--r--src/db/sysdb.c7
-rw-r--r--src/db/sysdb_private.h5
-rw-r--r--src/db/sysdb_upgrade.c50
3 files changed, 61 insertions, 1 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 9da655759..07a83a8a8 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1265,6 +1265,13 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
}
}
+ if (strcmp(version, SYSDB_VERSION_0_16) == 0) {
+ ret = sysdb_upgrade_16(sysdb, &version);
+ if (ret != EOK) {
+ 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
diff --git a/src/db/sysdb_private.h b/src/db/sysdb_private.h
index 2adb9ff91..c2c8d7a05 100644
--- a/src/db/sysdb_private.h
+++ b/src/db/sysdb_private.h
@@ -23,6 +23,7 @@
#ifndef __INT_SYS_DB_H__
#define __INT_SYS_DB_H__
+#define SYSDB_VERSION_0_17 "0.17"
#define SYSDB_VERSION_0_16 "0.16"
#define SYSDB_VERSION_0_15 "0.15"
#define SYSDB_VERSION_0_14 "0.14"
@@ -40,7 +41,7 @@
#define SYSDB_VERSION_0_2 "0.2"
#define SYSDB_VERSION_0_1 "0.1"
-#define SYSDB_VERSION SYSDB_VERSION_0_16
+#define SYSDB_VERSION SYSDB_VERSION_0_17
#define SYSDB_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
@@ -68,6 +69,7 @@
"@IDXATTR: serviceProtocol\n" \
"@IDXATTR: sudoUser\n" \
"@IDXATTR: sshKnownHostsExpire\n" \
+ "@IDXATTR: objectSIDString\n" \
"@IDXONE: 1\n" \
"\n" \
"dn: @MODULES\n" \
@@ -120,6 +122,7 @@ int sysdb_upgrade_12(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_13(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_14(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_15(struct sysdb_ctx *sysdb, const char **ver);
+int sysdb_upgrade_16(struct sysdb_ctx *sysdb, const char **ver);
int add_string(struct ldb_message *msg, int flags,
const char *attr, const char *value);
diff --git a/src/db/sysdb_upgrade.c b/src/db/sysdb_upgrade.c
index 6cebc877b..113f24644 100644
--- a/src/db/sysdb_upgrade.c
+++ b/src/db/sysdb_upgrade.c
@@ -1584,6 +1584,56 @@ done:
return ret;
}
+int sysdb_upgrade_16(struct sysdb_ctx *sysdb, const char **ver)
+{
+ struct ldb_message *msg;
+ struct upgrade_ctx *ctx;
+ errno_t ret;
+
+ ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_17, &ctx);
+ if (ret) {
+ return ret;
+ }
+
+ msg = ldb_msg_new(ctx);
+ if (msg == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ msg->dn = ldb_dn_new(msg, sysdb->ldb, "@INDEXLIST");
+ if (msg->dn == NULL) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ /* add index for objectSIDString */
+ ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
+ if (ret != LDB_SUCCESS) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = ldb_msg_add_string(msg, "@IDXATTR", "objectSIDString");
+ if (ret != LDB_SUCCESS) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = ldb_modify(sysdb->ldb, msg);
+ if (ret != LDB_SUCCESS) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ /* conversion done, update version number */
+ ret = update_version(ctx);
+
+done:
+ ret = finish_upgrade(ret, &ctx, ver);
+ return ret;
+}
+
/*
* Example template for future upgrades.
* Copy and change version numbers as appropriate.