Jakub Hrozek <jhro...@redhat.com> wrote:
> On Tue, Apr 17, 2012 at 11:00:12AM +0200, Jan Zelený wrote:
> > #111
> > I found this while closely going through the file to implement ghost
> > users. After discovering this, I re-checked it twice to be sure. To
> > enter the block of code, it would require RFC2307 and populate_members
> > set to false.
> > 
> > But when you go through the file, the only place where sdap_save_groups()
> > is called for RFC2307 is in sdap_get_groups_done() and it is called with
> > populate_users = true.
> 
> Ack
> 
> > #112
> > Because of the change in previous patch, there is only one place where
> > this function is called and it is bound with RFC230bis.
> 
> Ack
> 
> You can also remove sysdb_attrs_users_from_ldb_vals() now

Here are all three patches

Jan
From bd6b5aa7cb132c5b5d74f90ab06e3cf9f68784ee Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzel...@redhat.com>
Date: Tue, 17 Apr 2012 04:23:36 -0400
Subject: [PATCH 1/2] Removed a block of dead code in sdap_async_groups.c

---
 src/providers/ldap/sdap_async_groups.c |   21 +--------------------
 1 files changed, 1 insertions(+), 20 deletions(-)

diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index aad2990c5a26e2d8ce720097d6afb9724cc4b993..e616c2794d9da290f622025bd3aecb65ed09e5c8 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -212,7 +212,6 @@ static int sdap_save_group(TALLOC_CTX *memctx,
                            struct sdap_options *opts,
                            struct sss_domain_info *dom,
                            struct sysdb_attrs *attrs,
-                           bool store_members,
                            bool populate_members,
                            char **_usn_value,
                            time_t now)
@@ -328,24 +327,6 @@ static int sdap_save_group(TALLOC_CTX *memctx,
         }
         el->values = el1->values;
         el->num_values = el1->num_values;
-    } else if (store_members) {
-        ret = sysdb_attrs_get_el(attrs,
-                        opts->group_map[SDAP_AT_GROUP_MEMBER].sys_name, &el);
-        if (ret != EOK) {
-            goto fail;
-        }
-        if (el->num_values == 0) {
-            DEBUG(7, ("No members for group [%s]\n", name));
-
-        } else {
-            DEBUG(7, ("Adding member users to group [%s]\n", name));
-
-            ret = sdap_fill_memberships(group_attrs, ctx, opts, dom,
-                                        el->values, el->num_values);
-            if (ret) {
-                goto fail;
-            }
-        }
     }
 
     ret = sdap_save_all_names(name, attrs, !dom->case_sensitive, group_attrs);
@@ -502,7 +483,7 @@ static int sdap_save_groups(TALLOC_CTX *memctx,
         /* if 2 pass savemembers = false */
         ret = sdap_save_group(tmpctx, sysdb,
                               opts, dom, groups[i],
-                              (!twopass), populate_members, &usn_value, now);
+                              populate_members, &usn_value, now);
 
         /* Do not fail completely on errors.
          * Just report the failure to save and go on */
-- 
1.7.6.5

From 9f370dfece05dbffd944e46c52a919651af8bec0 Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzel...@redhat.com>
Date: Tue, 17 Apr 2012 04:47:21 -0400
Subject: [PATCH 2/2] Removed unused block of code is sdap_fill_memberships()

---
 src/providers/ldap/sdap_async_groups.c |   94 +++++++++++---------------------
 1 files changed, 33 insertions(+), 61 deletions(-)

diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index e616c2794d9da290f622025bd3aecb65ed09e5c8..b19e2b67005ecae4464ae10a7d75da5fa6e2b77b 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -102,70 +102,42 @@ static int sdap_fill_memberships(struct sysdb_attrs *group_attrs,
     int i, j;
     int ret;
 
-    switch (opts->schema_type) {
-    case SDAP_SCHEMA_RFC2307:
-        DEBUG(9, ("[RFC2307 Schema]\n"));
-
-        ret = sysdb_attrs_users_from_ldb_vals(group_attrs, SYSDB_MEMBER,
-                                              domain->name,
-                                              values, num_values);
-        if (ret) {
-            goto done;
-        }
-
-        break;
-
-    case SDAP_SCHEMA_RFC2307BIS:
-    case SDAP_SCHEMA_IPA_V1:
-    case SDAP_SCHEMA_AD:
-        DEBUG(9, ("[IPA or AD Schema]\n"));
-
-        ret = sysdb_attrs_get_el(group_attrs, SYSDB_MEMBER, &el);
-        if (ret) {
-            goto done;
-        }
-
-        /* Just allocate both big enough to contain all members for now */
-        el->values = talloc_realloc(el, el->values, struct ldb_val,
-                                    el->num_values + num_values);
-        if (!el->values) {
-            ret = ENOMEM;
-            goto done;
-        }
-
-        for (i = 0, j = el->num_values; i < num_values; i++) {
-
-            /* sync search entry with this as origDN */
-            ret = sdap_find_entry_by_origDN(el->values, ctx, domain,
-                                            (char *)values[i].data,
-                                            (char **)&el->values[j].data);
-            if (ret != EOK) {
-                if (ret != ENOENT) {
-                    goto done;
-                }
-
-                DEBUG(7, ("    member #%d (%s): not found!\n",
-                          i, (char *)values[i].data));
-            } else {
-                DEBUG(7, ("    member #%d (%s): [%s]\n",
-                          i, (char *)values[i].data,
-                          (char *)el->values[j].data));
-
-                el->values[j].length = strlen((char *)el->values[j].data);
-                j++;
+    ret = sysdb_attrs_get_el(group_attrs, SYSDB_MEMBER, &el);
+    if (ret) {
+        goto done;
+    }
+
+    /* Just allocate both big enough to contain all members for now */
+    el->values = talloc_realloc(el, el->values, struct ldb_val,
+                                el->num_values + num_values);
+    if (!el->values) {
+        ret = ENOMEM;
+        goto done;
+    }
+
+    for (i = 0, j = el->num_values; i < num_values; i++) {
+
+        /* sync search entry with this as origDN */
+        ret = sdap_find_entry_by_origDN(el->values, ctx, domain,
+                                        (char *)values[i].data,
+                                        (char **)&el->values[j].data);
+        if (ret != EOK) {
+            if (ret != ENOENT) {
+                goto done;
             }
+
+            DEBUG(7, ("    member #%d (%s): not found!\n",
+                      i, (char *)values[i].data));
+        } else {
+            DEBUG(7, ("    member #%d (%s): [%s]\n",
+                      i, (char *)values[i].data,
+                      (char *)el->values[j].data));
+
+            el->values[j].length = strlen((char *)el->values[j].data);
+            j++;
         }
-        el->num_values = j;
-
-        break;
-
-    default:
-        DEBUG(0, ("FATAL ERROR: Unhandled schema type! (%d)\n",
-                  opts->schema_type));
-        ret = EFAULT;
-        goto done;
     }
-
+    el->num_values = j;
     ret = EOK;
 
 done:
-- 
1.7.6.5

From efd6b9e0b4cd5d3853739d2ef81bafc9dd4c213f Mon Sep 17 00:00:00 2001
From: Jan Zeleny <jzel...@redhat.com>
Date: Tue, 17 Apr 2012 08:43:50 -0400
Subject: [PATCH] Removed unused function sysdb_attrs_users_from_ldb_vals()

---
 src/db/sysdb.c |   46 ----------------------------------------------
 src/db/sysdb.h |    5 -----
 2 files changed, 0 insertions(+), 51 deletions(-)

diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 5436fb832f13247064ee7739f2254dcfa2aafda4..65b413da54f7e1c31dc727d2066bca22bbd562f7 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -650,52 +650,6 @@ int sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
     return EOK;
 }
 
-int sysdb_attrs_users_from_ldb_vals(struct sysdb_attrs *attrs,
-                                    const char *attr_name,
-                                    const char *domain,
-                                    struct ldb_val *values,
-                                    int num_values)
-{
-    struct ldb_message_element *el = NULL;
-    struct ldb_val *vals;
-    int i, j;
-    char *member;
-    int ret;
-
-    ret = sysdb_attrs_get_el(attrs, attr_name, &el);
-    if (ret) {
-        return ret;
-    }
-
-    vals = talloc_realloc(attrs->a, el->values, struct ldb_val,
-                          el->num_values + num_values);
-    if (!vals) {
-        return ENOMEM;
-    }
-    el->values = vals;
-
-    DEBUG(9, ("Adding %d members to existing %d ones\n",
-              num_values, el->num_values));
-
-    for (i = 0, j = el->num_values; i < num_values; i++) {
-        member = sysdb_user_strdn(el->values, domain,
-                                  (char *)values[i].data);
-        if (!member) {
-            DEBUG(4, ("Failed to get user dn for [%s]\n",
-                      (char *)values[i].data));
-            return ENOMEM;
-        }
-        el->values[j].data = (uint8_t *)member;
-        el->values[j].length = strlen(member);
-        j++;
-
-        DEBUG(7, ("    member #%d: [%s]\n", i, member));
-    }
-    el->num_values = j;
-
-    return EOK;
-}
-
 static char *build_dom_dn_str_escape(TALLOC_CTX *mem_ctx, const char *template,
                                      const char *domain, const char *name)
 {
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 53dbd7c10289fa326b9c2a1c0064a98b542be947..6a1006d052bffcfe5ada87a1d241d5f3b0f060a4 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -242,11 +242,6 @@ int sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
                                     const char *attr_name,
                                     const char *domain,
                                     const char *const *list);
-int sysdb_attrs_users_from_ldb_vals(struct sysdb_attrs *attrs,
-                                    const char *attr_name,
-                                    const char *domain,
-                                    struct ldb_val *values,
-                                    int num_values);
 errno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
                                  struct sysdb_attrs *attrs,
                                  const char *ldap_attr,
-- 
1.7.6.5

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to