cache_req.c revision 7be55c7de03da57f43fae3db7e6114eebb117a2e
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2016 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 <ldb.h>
#include <talloc.h>
#include <tevent.h>
#include <errno.h>
#include "responder/common/cache_req/cache_req_private.h"
#include "responder/common/cache_req/cache_req_plugin.h"
static struct cache_req_plugin *
{
};
if (type >= CACHE_REQ_SENTINEL) {
return NULL;
}
}
enum cache_req_type type)
{
struct cache_req_plugin *plugin;
return EINVAL;
}
return EOK;
}
static struct cache_req *
struct cache_req_data *data,
struct sss_nc_ctx *ncache,
int midpoint)
{
return NULL;
}
/* It is perfectly fine to just overflow here. */
return NULL;
}
return cr;
}
static errno_t
{
const char *dup_name;
return ENOMEM;
}
return EOK;
}
static bool
struct sss_domain_info *domain)
{
return true;
}
return false;
}
return true;
}
static errno_t
struct cache_req_result **_result)
{
return ENOENT;
}
(*_result)->well_known_object = true;
"Unable to prepare data [%d]: %s\n",
}
return ret;
}
static errno_t
struct sss_domain_info *domain)
{
return EOK;
}
"Preparing input data for domain [%s] rules\n",
"Unable to prepare data [%d]: %s\n",
return ret;
}
return EOK;
}
static errno_t
struct sss_domain_info *domain)
{
"Bug: no create debug name function specified!\n");
return ERR_INTERNAL;
}
"Unable to create debug name!\n");
return ENOMEM;
}
return EOK;
}
static errno_t
struct sss_domain_info *domain)
{
return ret;
}
return ret;
}
return EOK;
}
{
"This request type does not support "
"global negative cache\n");
return;
}
"Cannot set negative cache for [%s] [%d]: %s\n",
/* not fatal */
}
return;
}
static bool
{
return false;
}
return false;
}
return false;
}
return true;
}
struct cache_req_state {
/* input data */
struct tevent_context *ev;
/* work data */
struct sss_domain_info *domain;
struct sss_domain_info *selected_domain;
struct cache_req_result **results;
bool check_next;
};
struct cache_req_result *new);
struct tevent_req *req,
const char *domain);
const char *domain);
struct tevent_context *ev,
struct sss_nc_ctx *ncache,
int midpoint,
const char *domain,
struct cache_req_data *data)
{
struct cache_req_state *state;
struct cache_req_result *result;
struct tevent_req *req;
return NULL;
}
goto done;
}
goto done;
goto done;
}
goto done;
}
done:
}
return req;
}
struct tevent_req *req,
const char *domain)
{
struct tevent_req *subreq;
/* Input was not name, there is no need to process it further. */
return EOK;
}
/* We do not want to parse the name. */
}
/* Parse name since it may contain a domain name. */
return ENOMEM;
}
return EAGAIN;
}
{
struct tevent_req *req;
struct cache_req_state *state;
char *name;
char *domain;
bool maybe_upn;
switch (ret) {
case EOK:
return;
}
break;
case ERR_DOMAIN_NOT_FOUND:
if (!maybe_upn) {
return;
}
break;
default:
return;
}
return;
}
}
const char *domain)
{
"Performing a single domain search\n");
return ERR_DOMAIN_NOT_FOUND;
}
state->check_next = false;
} else {
"Performing a multi-domain search\n");
state->check_next = true;
}
return cache_req_next_domain(req);
}
{
struct cache_req_state *state;
struct tevent_req *subreq;
bool is_domain_valid;
bool allow_no_fqn;
/* Check if this domain is valid for this request. */
if (!is_domain_valid) {
continue;
}
/* If not specified otherwise, we skip domains that require fully
* qualified names on domain less search. We do not descend into
* subdomains here since those are implicitly qualified.
*/
continue;
}
break;
}
return ret;
}
return ENOMEM;
}
/* we will continue with the following domain the next time */
if (state->check_next) {
}
return EAGAIN;
}
/* If we've got some result from previous searches we want to return
* EOK here so the whole cache request is successfully finished. */
if (state->num_results > 0) {
return EOK;
}
/* We have searched all available domains and no result was found.
*
* If the plug-in uses a negative cache which is shared among all domains
* (e.g. unique identifires such as user or group id or sid), we add it
* here and return object not found error. */
return ENOENT;
}
static errno_t
struct cache_req_result *new)
{
/* Make space for new results. */
return ENOMEM;
}
return EOK;
}
static errno_t
struct sss_domain_info *domain,
struct ldb_result *ldb_result,
const char *name)
{
struct cache_req_result *item;
"Found %u entries in domain %s\n",
return ENOMEM;
}
}
return ret;
}
{
struct cache_req_state *state;
struct ldb_result *result;
struct tevent_req *req;
switch (ret) {
case EOK:
/* We got some data from this search. Save it. */
/* We were unable to save data. */
goto done;
}
/* We are not interested in more results. */
goto done;
}
break;
case ENOENT:
if (state->check_next == false) {
/* Lookup domain was specified as input.
* We don't want to try the next domain,
* but we may want to try UPN search. */
/* Try UPN now. */
goto done;
}
/* Not found. */
goto done;
}
break;
default:
/* Some serious error has happened. Finish. */
goto done;
}
/* This is a domain less search, continue with the next domain. */
done:
/* We have at least one result. */
}
switch (ret) {
case EOK:
break;
case EAGAIN:
break;
case ENOENT:
break;
default:
break;
}
return;
}
struct tevent_req *req,
struct cache_req_result ***_results)
{
struct cache_req_state *state;
}
return EOK;
}
struct tevent_req *req,
struct cache_req_result **_result)
{
struct cache_req_state *state;
}
return EOK;
}
struct tevent_req *
struct tevent_context *ev,
struct sss_nc_ctx *ncache,
const char *domain,
struct cache_req_data *data)
{
struct tevent_req *req;
return NULL;
}
return req;
}
struct cache_req_result *
struct sss_domain_info *domain,
struct ldb_result *ldb_result,
const char *lookup_name,
const char *well_known_domain)
{
struct cache_req_result *result;
return NULL;
}
if (lookup_name != NULL) {
return NULL;
}
}
if (well_known_domain != NULL) {
return NULL;
}
}
return result;
}
struct cache_req_result *
struct sss_domain_info *domain,
struct ldb_message *ldb_msg,
const char *lookup_name,
const char *well_known_domain)
{
struct cache_req_result *result;
struct ldb_result *ldb_result;
return NULL;
}
if (ldb_result == NULL) {
return NULL;
}
goto done;
}
goto done;
}
done:
return NULL;
}
return result;
}
struct cache_req_result *
struct cache_req_result *result,
{
struct ldb_result *ldb_result;
unsigned int left;
goto done;
}
goto done;
}
if (ldb_result == NULL) {
goto done;
}
done:
return NULL;
}
return out;
}