[SSSD] [PATCH] Fix returning groups when gidNumber attribute is not ordered

Jakub Hrozek jhrozek at redhat.com
Thu Aug 4 18:46:29 UTC 2011


On Thu, Aug 04, 2011 at 06:26:44PM +0200, Jakub Hrozek wrote:
> https://fedorahosted.org/sssd/ticket/951

Attached is a patch that applies cleanly on the 1.5 branch.
-------------- next part --------------
>From d1e57bc981c2631fbd7ba1a2fafaae7fd7a73db2 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Thu, 4 Aug 2011 16:55:36 +0200
Subject: [PATCH] Fix returning groups when gidNumber attribute is not ordered

https://fedorahosted.org/sssd/ticket/951
---
 src/providers/ldap/ldap_id.c             |    4 +++-
 src/providers/ldap/ldap_id_enum.c        |    6 ++++--
 src/providers/ldap/sdap_async_accounts.c |    4 +++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
index f58af61..c6a11f4 100644
--- a/src/providers/ldap/ldap_id.c
+++ b/src/providers/ldap/ldap_id.c
@@ -336,10 +336,12 @@ struct tevent_req *groups_get_send(TALLOC_CTX *memctx,
     }
 
     state->filter =
-            talloc_asprintf(state, "(&(%s=%s)(objectclass=%s)(%s=*)(%s>=1))",
+            talloc_asprintf(state,
+                            "(&(%s=%s)(objectclass=%s)(%s=*)(&(%s=*)(!(%s=0))))",
                             attr_name, clean_name,
                             ctx->opts->group_map[SDAP_OC_GROUP].name,
                             ctx->opts->group_map[SDAP_AT_GROUP_NAME].name,
+                            ctx->opts->group_map[SDAP_AT_GROUP_GID].name,
                             ctx->opts->group_map[SDAP_AT_GROUP_GID].name);
     if (!state->filter) {
         DEBUG(2, ("Failed to build filter\n"));
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
index 6899b87..2e47722 100644
--- a/src/providers/ldap/ldap_id_enum.c
+++ b/src/providers/ldap/ldap_id_enum.c
@@ -554,10 +554,11 @@ static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
     if (ctx->srv_opts && ctx->srv_opts->max_group_value && !purge) {
         state->filter = talloc_asprintf(
                 state,
-                "(&(objectclass=%s)(%s=*)(%s=*)(%s>=%s)(!(%s=%s)))",
+                "(&(objectclass=%s)(%s=*)(&(%s=*)(!(%s=0)))(%s>=%s)(!(%s=%s)))",
                 ctx->opts->group_map[SDAP_OC_GROUP].name,
                 ctx->opts->group_map[SDAP_AT_GROUP_NAME].name,
                 ctx->opts->group_map[SDAP_AT_GROUP_GID].name,
+                ctx->opts->group_map[SDAP_AT_GROUP_GID].name,
                 ctx->opts->group_map[SDAP_AT_GROUP_USN].name,
                 ctx->srv_opts->max_group_value,
                 ctx->opts->group_map[SDAP_AT_GROUP_USN].name,
@@ -565,9 +566,10 @@ static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
     } else {
         state->filter = talloc_asprintf(
                 state,
-                "(&(objectclass=%s)(%s=*)(%s=*))",
+                "(&(objectclass=%s)(%s=*)(&(%s=*)(!(%s=0))))",
                 ctx->opts->group_map[SDAP_OC_GROUP].name,
                 ctx->opts->group_map[SDAP_AT_GROUP_NAME].name,
+                ctx->opts->group_map[SDAP_AT_GROUP_GID].name,
                 ctx->opts->group_map[SDAP_AT_GROUP_GID].name);
     }
     if (!state->filter) {
diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c
index c8a2209..1497c93 100644
--- a/src/providers/ldap/sdap_async_accounts.c
+++ b/src/providers/ldap/sdap_async_accounts.c
@@ -2220,11 +2220,13 @@ struct tevent_req *sdap_initgr_rfc2307_send(TALLOC_CTX *memctx,
         return NULL;
     }
 
-    filter = talloc_asprintf(state, "(&(%s=%s)(objectclass=%s)(%s=*)(%s>=1))",
+    filter = talloc_asprintf(state,
+                             "(&(%s=%s)(objectclass=%s)(%s=*)(&(%s=*)(!(%s=0))))",
                              opts->group_map[SDAP_AT_GROUP_MEMBER].name,
                              clean_name,
                              opts->group_map[SDAP_OC_GROUP].name,
                              opts->group_map[SDAP_AT_GROUP_NAME].name,
+                             opts->group_map[SDAP_AT_GROUP_GID].name,
                              opts->group_map[SDAP_AT_GROUP_GID].name);
     if (!filter) {
         talloc_zfree(req);
-- 
1.7.6



More information about the sssd-devel mailing list