summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2010-05-28 14:29:15 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-06-02 11:11:51 -0400
commit1f77bdebb06d9d1e2d3ca5479904afa292f09658 (patch)
tree1b68a668be18580fd7605b7d762db94e58bf49a2 /src/providers
parent5fad9a3d700ba24783e66c6941f68f84459b4d61 (diff)
downloadsssd-1f77bdebb06d9d1e2d3ca5479904afa292f09658.tar.gz
sssd-1f77bdebb06d9d1e2d3ca5479904afa292f09658.tar.xz
sssd-1f77bdebb06d9d1e2d3ca5479904afa292f09658.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.
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ipa/ipa_access.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/providers/ipa/ipa_access.c b/src/providers/ipa/ipa_access.c
index 590ae78..56bb269 100644
--- a/src/providers/ipa/ipa_access.c
+++ b/src/providers/ipa/ipa_access.c
@@ -431,7 +431,6 @@ static void hbac_get_host_memberof(struct tevent_req *req,
bool in_transaction = false;
int ret;
int i;
- int v;
struct ldb_message_element *el;
struct hbac_host_info **hhi;
char *object_name;
@@ -524,33 +523,23 @@ static void hbac_get_host_memberof(struct tevent_req *req,
goto fail;
}
- ret = sysdb_attrs_get_el(state->host_reply_list[i],
- state->offline ? SYSDB_ORIG_MEMBEROF :
- IPA_HOST_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;
- }
+ if (ret != ENOENT) {
+ DEBUG(1, ("sysdb_attrs_get_string_array 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));
-
- for(v = 0; v < el->num_values; v++) {
- DEBUG(9, ("%s: [%.*s].\n", IPA_HOST_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;
}
}