diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-03-31 11:09:56 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-04-01 15:36:26 -0400 |
commit | 89e594e4c5fb392a3ec9507b3f12a4edd339c5c9 (patch) | |
tree | 8d69a4585f50d53b60f32a1171ef78a1a7b65634 /src | |
parent | 11f42ffa09d15417929b397fb756f00691cd9d31 (diff) | |
download | sssd-89e594e4c5fb392a3ec9507b3f12a4edd339c5c9.tar.gz sssd-89e594e4c5fb392a3ec9507b3f12a4edd339c5c9.tar.xz sssd-89e594e4c5fb392a3ec9507b3f12a4edd339c5c9.zip |
Only save members for successfully saved groups
Diffstat (limited to 'src')
-rw-r--r-- | src/providers/ldap/sdap_async_accounts.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c index 29a0f9f64..8fd7cf2a3 100644 --- a/src/providers/ldap/sdap_async_accounts.c +++ b/src/providers/ldap/sdap_async_accounts.c @@ -909,6 +909,8 @@ static int sdap_save_groups(TALLOC_CTX *memctx, bool twopass; int ret; int i; + struct sysdb_attrs **saved_groups = NULL; + int nsaved_groups = 0; switch (opts->schema_type) { case SDAP_SCHEMA_RFC2307: @@ -935,6 +937,15 @@ static int sdap_save_groups(TALLOC_CTX *memctx, goto done; } + if (twopass && !populate_members) { + saved_groups = talloc_array(tmpctx, struct sysdb_attrs *, + num_groups); + if (!saved_groups) { + ret = ENOMEM; + goto done; + } + } + for (i = 0; i < num_groups; i++) { usn_value = NULL; @@ -949,6 +960,10 @@ static int sdap_save_groups(TALLOC_CTX *memctx, DEBUG(2, ("Failed to store group %d. Ignoring.\n", i)); } else { DEBUG(9, ("Group %d processed!\n", i)); + if (twopass && !populate_members) { + saved_groups[nsaved_groups] = groups[i]; + nsaved_groups++; + } } if (usn_value) { @@ -968,9 +983,9 @@ static int sdap_save_groups(TALLOC_CTX *memctx, if (twopass && !populate_members) { - for (i = 0; i < num_groups; i++) { + for (i = 0; i < nsaved_groups; i++) { - ret = sdap_save_grpmem(tmpctx, sysdb, opts, dom, groups[i]); + ret = sdap_save_grpmem(tmpctx, sysdb, opts, dom, saved_groups[i]); /* Do not fail completely on errors. * Just report the failure to save and go on */ if (ret) { |