[SSSD] [PATCH] sysdb: make canonicalUserPrincipalName case-insensitive

Sumit Bose sbose at redhat.com
Tue Jun 17 10:32:39 UTC 2014


Hi,

I would like to ask to add the patch to master and the planned 1.12.0
release. It is related to https://fedorahosted.org/sssd/ticket/1835
which is planned for 1.12.1. But since it upgrades the sysdb version I
think it is better suited for a .0 release.

bye,
Sumit
-------------- next part --------------
From cc3cb805ad987711c066b18adc345be5be3109d8 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Fri, 13 Jun 2014 18:38:22 +0200
Subject: [PATCH] sysdb: make canonicalUserPrincipalName case-insensitive

---
 src/db/sysdb.c         |  7 +++++++
 src/db/sysdb_private.h |  5 ++++-
 src/db/sysdb_upgrade.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 1296418..8658d47 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1201,6 +1201,13 @@ int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
             }
         }
 
+        if (strcmp(version, SYSDB_VERSION_0_15) == 0) {
+            ret = sysdb_upgrade_15(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 012a13b..8a5b8be 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_16 "0.16"
 #define SYSDB_VERSION_0_15 "0.15"
 #define SYSDB_VERSION_0_14 "0.14"
 #define SYSDB_VERSION_0_13 "0.13"
@@ -39,11 +40,12 @@
 #define SYSDB_VERSION_0_2 "0.2"
 #define SYSDB_VERSION_0_1 "0.1"
 
-#define SYSDB_VERSION SYSDB_VERSION_0_15
+#define SYSDB_VERSION SYSDB_VERSION_0_16
 
 #define SYSDB_BASE_LDIF \
      "dn: @ATTRIBUTES\n" \
      "userPrincipalName: CASE_INSENSITIVE\n" \
+     "canonicalUserPrincipalName: CASE_INSENSITIVE\n" \
      "cn: CASE_INSENSITIVE\n" \
      "dc: CASE_INSENSITIVE\n" \
      "dn: CASE_INSENSITIVE\n" \
@@ -117,6 +119,7 @@ int sysdb_upgrade_11(struct sysdb_ctx *sysdb, struct sss_domain_info *domain,
 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 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 8cd09f4..dadb745 100644
--- a/src/db/sysdb_upgrade.c
+++ b/src/db/sysdb_upgrade.c
@@ -1531,6 +1531,62 @@ done:
     return ret;
 }
 
+int sysdb_upgrade_15(struct sysdb_ctx *sysdb, const char **ver)
+{
+    TALLOC_CTX *tmp_ctx;
+    int ret;
+    struct ldb_message *msg;
+    struct upgrade_ctx *ctx;
+
+    tmp_ctx = talloc_new(NULL);
+    if (!tmp_ctx) {
+        return ENOMEM;
+    }
+
+    ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_16, &ctx);
+    if (ret) {
+        return ret;
+    }
+
+    /* Add new indexes */
+    msg = ldb_msg_new(tmp_ctx);
+    if (!msg) {
+        ret = ENOMEM;
+        goto done;
+    }
+    msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@ATTRIBUTES");
+    if (!msg->dn) {
+        ret = ENOMEM;
+        goto done;
+    }
+
+    /* Case insensitive search for originalDN */
+    ret = ldb_msg_add_empty(msg, SYSDB_CANONICAL_UPN, LDB_FLAG_MOD_ADD, NULL);
+    if (ret != LDB_SUCCESS) {
+        ret = ENOMEM;
+        goto done;
+    }
+    ret = ldb_msg_add_string(msg, SYSDB_CANONICAL_UPN, "CASE_INSENSITIVE");
+    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);
+    talloc_free(tmp_ctx);
+    return ret;
+}
+
 /*
  * Example template for future upgrades.
  * Copy and change version numbers as appropriate.
-- 
1.8.3.1



More information about the sssd-devel mailing list