ipa_netgroups.c revision 0e65abe5cf2abf5d4b431cf6bd161b419f07901d
/*
SSSD
Async IPA Helper routines for netgroups
Authors:
Jan Zeleny <jzeleny@redhat.com>
Copyright (C) 2011 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "providers/ldap/sdap_async_private.h"
#include <ctype.h>
#define ENTITY_NG 1
#define ENTITY_USER 2
#define ENTITY_HOST 4
struct ipa_get_netgroups_state {
struct tevent_context *ev;
struct sdap_options *opts;
struct ipa_options *ipa_opts;
struct sdap_handle *sh;
struct sss_domain_info *dom;
const char **attrs;
int timeout;
char *filter;
const char *base_filter;
/* Entities which have been already asked for
* and are scheduled for inspection */
int current_entity;
int entities_found;
struct sysdb_attrs **netgroups;
int netgroups_count;
};
struct sss_domain_info *dom,
struct sdap_options *opts,
struct sysdb_attrs *attrs)
{
struct ldb_message_element *el;
struct sysdb_attrs *netgroup_attrs;
int ret;
size_t c;
&el);
if (el->num_values == 0) {
goto fail;
}
if (!netgroup_attrs) {
goto fail;
}
if (ret) {
goto fail;
}
if (el->num_values == 0) {
} else {
if (ret) {
goto fail;
}
}
if (ret) {
goto fail;
}
if (el->num_values == 0) {
goto fail;
}
} else {
for(c = 0; c < el->num_values; c++) {
if (ret) {
goto fail;
}
}
}
&el);
goto fail;
}
if (el->num_values == 0) {
} else {
for(c = 0; c < el->num_values; c++) {
if (ret) {
goto fail;
}
}
}
goto fail;
}
if (el->num_values == 0) {
} else {
for(c = 0; c < el->num_values; c++) {
if (ret) {
goto fail;
}
}
}
dom->netgroup_timeout, 0);
return EOK;
fail:
return ret;
}
struct tevent_context *ev,
struct sss_domain_info *dom,
struct sdap_options *opts,
struct ipa_options *ipa_options,
struct sdap_handle *sh,
const char **attrs,
const char *filter,
int timeout)
{
struct tevent_req *req;
struct ipa_get_netgroups_state *state;
int ret;
state->netgr_base_iter = 0;
("Netgroup lookup request without a search base\n"));
goto done;
}
done:
}
return req;
}
{
struct tevent_req *subreq;
struct ipa_get_netgroups_state *state;
struct sdap_search_base **netgr_bases;
return ENOMEM;
}
("Searching for netgroups with base [%s]\n",
true);
if (!subreq) {
return ENOMEM;
}
return EOK;
}
struct tevent_req *req);
struct tevent_req *req);
struct tevent_req *req);
{
struct tevent_req);
struct ipa_get_netgroups_state);
int i, ret;
struct ldb_message_element *ng_found;
struct ldb_message_element *host_found;
struct ldb_message_element *user_found;
struct sdap_search_base **netgr_bases;
struct sysdb_attrs **netgroups;
const char *orig_dn;
char *dn;
char *filter;
bool fetch_members = false;
if (ret) {
goto done;
}
if (netgroups_count == 0) {
/* No netgroups found in this search */
state->netgr_base_iter++;
/* There are more search bases to try */
}
return;
}
goto done;
}
goto done;
}
for (i = 0; i < netgroups_count; i++) {
&ng_found);
&user_found);
&host_found);
goto done;
}
if (ret != HASH_SUCCESS) {
goto done;
}
if (state->entities_found == 0) {
continue;
}
goto done;
}
/* Add this to the filter */
dn);
goto done;
}
fetch_members = true;
}
if (!fetch_members) {
} else {
}
return;
}
goto done;
}
state->netgr_base_iter = 0;
}
return;
done:
return;
}
struct tevent_req *req)
{
char *filter;
const char *base_filter;
struct tevent_req *subreq;
struct sdap_search_base **bases;
/* No more bases to try */
return ENOENT;
}
return ENOMEM;
return ENOMEM;
}
return EOK;
}
struct tevent_req *req)
{
"objectclass", NULL };
char *filter;
const char *base_filter;
struct tevent_req *subreq;
struct sdap_search_base **bases;
return ENOENT;
}
return ENOMEM;
return ENOMEM;
}
return EOK;
}
struct tevent_req *req)
{
const char **attrs;
char *filter;
const char *base_filter;
struct tevent_req *subreq;
int ret;
struct sdap_search_base **bases;
return ENOENT;
}
return ENOMEM;
return ret;
}
return ENOMEM;
}
return EOK;
}
{
struct tevent_req);
struct ipa_get_netgroups_state);
struct sysdb_attrs **entities;
int ret, i;
const char *orig_dn;
char *orig_dn_lower;
int (* next_call)(struct ipa_get_netgroups_state *,
struct tevent_req *);
bool next_batch_scheduled = false;
if (ret) {
goto fail;
}
count));
/* While processing a batch of entities from one search base,
* schedule query for another search base if there is one
*
* If there is no other search base, another class of entities
* will be scheduled for lookup after processing of current
* batch. The order of lookup is: netgroups -> users -> hosts
*/
/* We just received a batch of netgroups */
state->netgr_base_iter++;
/* If there is a member netgroup, we always have to
* ask for both member users and hosts
* -> now schedule users
*/
/* We just received a batch of users */
state->user_base_iter++;
}
/* We just received a batch of hosts */
state->host_base_iter++;
} else {
("Invalid entity type given for processing: %d\n",
state->current_entity));
goto fail;
}
/* Next search base has been scheduled for inspection,
* don't try to look for other type of entities
*/
next_batch_scheduled = true;
goto fail;
}
/* Process all member entites and store them in the designated hash table */
for (i = 0; i < count; i++) {
goto fail;
}
if (orig_dn_lower == NULL) {
goto fail;
}
/* Transform the DN to lower case.
* have the value also in lower-case
*/
while (*orig_dn_lower != '\0') {
}
if (ret != HASH_SUCCESS) {
goto fail;
}
}
if (next_batch_scheduled) {
/* The next search base is already scheduled to be searched */
return;
}
if (next_call) {
/* There is another class of members that has to be retrieved
* - schedule the lookup
*/
} else {
/* All members, that could have been fetched, were fetched */
}
return;
fail:
return;
}
{
struct ipa_get_netgroups_state *state;
struct sysdb_attrs);
state->netgroups_count++;
return true;
}
struct extract_state {
const char *group;
const char **entries;
int entries_count;
};
{
int i, ret;
struct extract_state *state;
struct sysdb_attrs *member;
struct ldb_message_element *el;
struct ldb_message_element *name_el;
return false;
}
for (i = 0; i < el->num_values; i++) {
return false;
}
state->entries_count++;
break;
}
}
return true;
}
struct sysdb_attrs *netgroup,
const char *member_type,
const char ***_ret_array,
int *_ret_count)
{
struct extract_state *state;
struct ldb_message_element *el;
struct sysdb_attrs *member;
int process_count = 0;
int ret_count = 0;
goto done;
}
goto done;
}
for (i = 0; i < el->num_values; i++) {
goto done;
}
if (ret == HASH_ERROR_KEY_NOT_FOUND) {
goto done;
}
} else {
goto done;
}
goto done;
}
ret_count++;
}
if (state->entries_count > 0) {
goto done;
}
state->entries_count*sizeof(const char *));
}
state->entries_count = 0;
}
}
} else {
}
*_ret_array = ret_array;
*_ret_count = ret_count;
done:
return ret;
}
{
int i, j, k, ret;
const char **members;
struct sysdb_attrs *member;
const char *member_name;
struct extract_state *extract_state;
struct ldb_message_element *external_hosts;
const char *dash[] = {"-"};
int uids_count = 0;
int hosts_count = 0;
const char *domain;
char *triple;
return ENOMEM;
}
if (extract_state == NULL) {
goto done;
}
for (i = 0; i < state->netgroups_count; i++) {
/* load all its member netgroups, translate */
goto done;
}
j = 0;
for (j = 0; members[j]; j++) {
if (ret != HASH_SUCCESS) {
goto done;
}
goto done;
}
goto done;
}
}
}
/* Load all UIDs */
&uids, &uids_count);
goto done;
}
&hosts, &hosts_count);
goto done;
}
goto done;
}
if (external_hosts->num_values > 0) {
goto done;
}
for (j = 0; j < external_hosts->num_values; j++) {
goto done;
}
hosts_count++;
}
}
&domain);
goto done;
}
if (uids_count > 0 || hosts_count > 0) {
if (uids_count == 0) {
uids_count = 1;
}
if (hosts_count == 0) {
hosts_count = 1;
}
"netgroup %d\n", i));
for (j = 0; j < uids_count; j++) {
for (k = 0; k < hosts_count; k++) {
domain);
goto done;
}
triple);
goto done;
}
}
}
}
goto done;
}
}
done:
return ret;
}
struct sysdb_attrs ***reply)
{
struct ipa_get_netgroups_state);
if (reply_count) {
}
if (reply) {
}
return EOK;
}