diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2015-06-25 17:33:47 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-06-25 17:33:47 +0200 |
commit | 2302b7f53869db17fe6f733f52cce94d9714eeb4 (patch) | |
tree | a2e8c98b07ba8bfd2bd60b2181d5bf7c171edfba | |
parent | d0d6956c3748ba670448edd548b8edd37c5f5c1a (diff) | |
download | sssd-sid_index.tar.gz sssd-sid_index.tar.xz sssd-sid_index.zip |
SYSDB: Index the objectSIDString attributesid_index
-rw-r--r-- | src/db/sysdb.c | 7 | ||||
-rw-r--r-- | src/db/sysdb_private.h | 5 | ||||
-rw-r--r-- | src/db/sysdb_upgrade.c | 51 |
3 files changed, 62 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 8a5b8be8c..9788206a1 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 558b4f520..816b1eff8 100644 --- a/src/db/sysdb_upgrade.c +++ b/src/db/sysdb_upgrade.c @@ -1587,6 +1587,57 @@ 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; + } + + /* add new indexes */ + 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 cached */ + 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. |