diff options
author | Sumit Bose <sbose@redhat.com> | 2010-05-28 14:29:15 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-02 11:06:20 -0400 |
commit | 044ea5762423f930151306a1596aaf686d64845d (patch) | |
tree | e1db90d9399a7cdaf948634f0a31022123fe6051 | |
parent | ee613f42cc2dd75fde6402581f22a2acb0a26597 (diff) | |
download | sssd-044ea5762423f930151306a1596aaf686d64845d.tar.gz sssd-044ea5762423f930151306a1596aaf686d64845d.tar.xz sssd-044ea5762423f930151306a1596aaf686d64845d.zip |
Use sysdb_attrs_get_string_array() instead of sysdb_attrs_get_el()
sysdb_attrs_get_el() creates an empty element in the sysdb_attrs
structure if the requested element does not exist. Recent versions of
libldb do not accept empty elements when writing new objects to disk.
sysdb_attrs_get_string_array() does not create an empty element but
returns ENOENT.
-rw-r--r-- | src/providers/ipa/ipa_access.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/providers/ipa/ipa_access.c b/src/providers/ipa/ipa_access.c index 176da2458..c90d63a05 100644 --- a/src/providers/ipa/ipa_access.c +++ b/src/providers/ipa/ipa_access.c @@ -1180,7 +1180,6 @@ static void hbac_get_host_memberof_done(struct tevent_req *subreq) struct hbac_get_host_info_state); int ret; int i; - int v; struct ldb_message_element *el; struct hbac_host_info **hhi; struct ldb_message **msgs; @@ -1286,33 +1285,23 @@ static void hbac_get_host_memberof_done(struct tevent_req *subreq) goto fail; } - ret = sysdb_attrs_get_el(state->host_reply_list[i], - state->offline ? SYSDB_ORIG_MEMBEROF : - IPA_MEMBEROF, - &el); + ret = sysdb_attrs_get_string_array(state->host_reply_list[i], + state->offline ? SYSDB_ORIG_MEMBEROF : + IPA_MEMBEROF, + hhi, &(hhi[i]->memberof)); if (ret != EOK) { - DEBUG(1, ("sysdb_attrs_get_el failed.\n")); - goto fail; - } - - hhi[i]->memberof = talloc_array(hhi, const char *, el->num_values + 1); - if (hhi[i]->memberof == NULL) { - ret = ENOMEM; - goto fail; - } - memset(hhi[i]->memberof, 0, - sizeof(const char *) * (el->num_values + 1)); + if (ret != ENOENT) { + DEBUG(1, ("sysdb_attrs_get_string_array failed.\n")); + goto fail; + } - for(v = 0; v < el->num_values; v++) { - DEBUG(9, ("%s: [%.*s].\n", IPA_MEMBEROF, el->values[v].length, - (const char *)el->values[v].data)); - hhi[i]->memberof[v] = talloc_strndup(hhi, - (const char *)el->values[v].data, - el->values[v].length); - if (hhi[i]->memberof[v] == NULL) { + hhi[i]->memberof = talloc_array(hhi, const char *, 1); + if (hhi[i]->memberof == NULL) { + DEBUG(1, ("talloc_array failed.\n")); ret = ENOMEM; goto fail; } + hhi[i]->memberof[0] = NULL; } } |