diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-11-16 13:57:26 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-12-16 14:46:16 -0500 |
commit | 70a33bdf7db34fe4d1ba194cf9ea28c758719b4b (patch) | |
tree | 4f93e18380fe1ca2d41fca0b5c8fb9d8b77ee781 /src/providers/ldap/sdap_async_netgroups.c | |
parent | b3b42c49656e192787a983aaa8b9ec744ba4cb9d (diff) | |
download | sssd-70a33bdf7db34fe4d1ba194cf9ea28c758719b4b.tar.gz sssd-70a33bdf7db34fe4d1ba194cf9ea28c758719b4b.tar.bz2 sssd-70a33bdf7db34fe4d1ba194cf9ea28c758719b4b.zip |
Refactor saving sdap entities
There was too much code duplication between
sdap_save_{user,group,netgroup}. This patch removes the most egregious ones.
Diffstat (limited to 'src/providers/ldap/sdap_async_netgroups.c')
-rw-r--r-- | src/providers/ldap/sdap_async_netgroups.c | 77 |
1 files changed, 15 insertions, 62 deletions
diff --git a/src/providers/ldap/sdap_async_netgroups.c b/src/providers/ldap/sdap_async_netgroups.c index 0f486ded..88efc5e2 100644 --- a/src/providers/ldap/sdap_async_netgroups.c +++ b/src/providers/ldap/sdap_async_netgroups.c @@ -48,7 +48,6 @@ static errno_t sdap_save_netgroup(TALLOC_CTX *memctx, const char *name = NULL; int ret; char *timestamp = NULL; - size_t c; ret = sysdb_attrs_get_el(attrs, opts->netgroup_map[SDAP_AT_NETGROUP_NAME].sys_name, @@ -66,21 +65,12 @@ static errno_t sdap_save_netgroup(TALLOC_CTX *memctx, goto fail; } - ret = sysdb_attrs_get_el(attrs, SYSDB_ORIG_DN, &el); - if (ret) { + ret = sdap_attrs_add_string(attrs, SYSDB_ORIG_DN, + "original DN", + name, netgroup_attrs); + if (ret != EOK) { goto fail; } - if (el->num_values == 0) { - DEBUG(7, ("Original DN is not available for [%s].\n", name)); - } else { - DEBUG(7, ("Adding original DN [%s] to attributes of [%s].\n", - el->values[0].data, name)); - ret = sysdb_attrs_add_string(netgroup_attrs, SYSDB_ORIG_DN, - (const char *)el->values[0].data); - if (ret) { - goto fail; - } - } ret = sysdb_attrs_get_el(attrs, opts->netgroup_map[SDAP_AT_NETGROUP_MODSTAMP].sys_name, @@ -105,64 +95,27 @@ static errno_t sdap_save_netgroup(TALLOC_CTX *memctx, } } - ret = sysdb_attrs_get_el(attrs, - opts->netgroup_map[SDAP_AT_NETGROUP_TRIPLE].sys_name, - &el); - if (ret) { + ret = sdap_attrs_add_list(attrs, + opts->netgroup_map[SDAP_AT_NETGROUP_TRIPLE].sys_name, + "netgroup triple", + name, netgroup_attrs); + if (ret != EOK) { goto fail; } - if (el->num_values == 0) { - DEBUG(7, ("No netgroup triples for netgroup [%s].\n", name)); - } else { - for(c = 0; c < el->num_values; c++) { - ret = sysdb_attrs_add_string(netgroup_attrs, - opts->netgroup_map[SDAP_AT_NETGROUP_TRIPLE].sys_name, - (const char*)el->values[c].data); - if (ret) { - goto fail; - } - } - } - ret = sysdb_attrs_get_el(attrs, - opts->netgroup_map[SDAP_AT_NETGROUP_MEMBER].sys_name, - &el); + ret = sdap_attrs_add_list(attrs, + opts->netgroup_map[SDAP_AT_NETGROUP_MEMBER].sys_name, + "original members", + name, netgroup_attrs); if (ret != EOK) { goto fail; } - if (el->num_values == 0) { - DEBUG(7, ("No original members for netgroup [%s]\n", name)); - - } else { - DEBUG(7, ("Adding original members to netgroup [%s]\n", name)); - for(c = 0; c < el->num_values; c++) { - ret = sysdb_attrs_add_string(netgroup_attrs, - opts->netgroup_map[SDAP_AT_NETGROUP_MEMBER].sys_name, - (const char*)el->values[c].data); - if (ret) { - goto fail; - } - } - } - - ret = sysdb_attrs_get_el(attrs, SYSDB_NETGROUP_MEMBER, &el); + ret = sdap_attrs_add_list(attrs, SYSDB_NETGROUP_MEMBER, + "members", name, netgroup_attrs); if (ret != EOK) { goto fail; } - if (el->num_values == 0) { - DEBUG(7, ("No members for netgroup [%s]\n", name)); - - } else { - DEBUG(7, ("Adding members to netgroup [%s]\n", name)); - for(c = 0; c < el->num_values; c++) { - ret = sysdb_attrs_add_string(netgroup_attrs, SYSDB_NETGROUP_MEMBER, - (const char*)el->values[c].data); - if (ret) { - goto fail; - } - } - } DEBUG(6, ("Storing info for netgroup %s\n", name)); |