/*
SSSD
Data Provider Helpers
Copyright (C) Simo Sorce <ssorce@redhat.com> 2009
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 <netdb.h>
#include "resolv/async_resolv.h"
struct be_svc_callback {
void *private_data;
};
{
}
struct fo_options *opts)
{
return EOK;
}
{
int ret;
return EOK;
}
return ENOMEM;
}
"fatal error initializing resolver context\n");
return ret;
}
return ret;
}
return ENOMEM;
}
return EOK;
}
{
/* callbacks removes themselves from the list,
* so this while will freem them all and then terminate */
}
return 0;
}
/*
* Find registered be_svc_data by service name.
*/
const char *service_name)
{
return 0;
}
return svc;
}
}
return 0;
}
{
int ret;
if (svc) {
/* we already have a service up and configured,
* can happen when using both id and auth provider
*/
return EOK;
}
/* if not in the be service list, try to create new one */
&service);
return ret;
}
if (!svc) {
return ENOMEM;
}
return ENOMEM;
}
return EOK;
}
{
}
return 0;
}
{
return ENOENT;
}
if (!callback) {
return ENOMEM;
}
return EOK;
}
void *pvt,
const char *plugin_name)
{
bool bret;
if (bret) {
} else {
"another plugin may be already in place\n");
}
}
const char *hostname)
{
return ret;
}
}
return ENOMEM;
}
return EOK;
}
const char *service_name,
const char *query_service,
const char *default_discovery_domain,
enum be_fo_protocol proto,
bool proto_fallback, void *user_data)
{
const char *domain;
int ret;
int i;
return ENOENT;
}
if (!domain) {
}
/* Add the first protocol as the primary lookup */
"Failed to add SRV lookup reference to failover service "
return ret;
}
if (proto_fallback) {
/* All the rest as fallback */
while (i != proto) {
proto_table[i], user_data);
"Failed to add SRV lookup reference to failover "
return ret;
}
i = (i + 1) % BE_FO_PROTO_SENTINEL;
}
}
return EOK;
}
{
if (!svc_data) {
return 0;
}
}
bool primary)
{
int ret;
return ENOENT;
}
"Failed to add server to failover service [%d]: %s\n",
return ret;
}
return EOK;
}
struct be_resolve_server_state {
int attempts;
bool first_try;
};
struct be_primary_server_ctx {
unsigned long timeout;
int attempts;
};
struct be_resolve_server_state *state,
struct tevent_req **new_subreq);
static errno_t
struct tevent_context *ev,
struct be_svc_data *svc,
const unsigned long timeout_seconds);
static void
struct tevent_timer *te,
{
return;
}
}
{
if (resolve_state == NULL) {
return;
}
resolve_state->first_try = true;
return;
/* Schedule another lookup
* (either no server could be found or it was not primary)
*/
"Could not schedule primary server lookup [%d]: %s\n",
}
}
/* If an error occurred just end the routine */
}
static errno_t
struct tevent_context *ev,
struct be_svc_data *svc,
const unsigned long timeout_seconds)
{
"is already scheduled\n");
return EOK;
}
return ENOMEM;
}
tv = tevent_timeval_current();
return ENOMEM;
}
"to %lu seconds\n", timeout_seconds);
return EOK;
}
struct tevent_context *ev,
const char *service_name,
bool first_try)
{
return req;
}
svc->fo_service);
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct be_resolve_server_state);
int ret;
return;
goto fail;
}
/* FIXME: make the timeout configurable */
timeout);
goto fail;
}
}
return;
fail:
}
struct be_resolve_server_state *state,
struct tevent_req **new_subreq)
{
switch (ret) {
case EOK:
return EFAULT;
}
break;
case ENOENT:
/* all servers have been tried and none
* was found good, go offline */
return EIO;
default:
/* mark server as bad and retry */
return EFAULT;
}
"Couldn't resolve server (%s), resolver returned [%d]: %s\n",
return EIO;
}
/* now try next one */
if (!subreq) {
return ENOMEM;
}
if (new_subreq) {
*new_subreq = subreq;
}
return EAGAIN;
}
/* all fine we got the server */
"The fail over cycled through all available servers\n");
return ENOENT;
}
if (!srvaddr) {
"FATAL: No hostent available for server (%s)\n",
return EFAULT;
}
ipaddr, 128);
}
/* now call all svc callbacks if server changed or if it is explicitly
* requested or if the server is the same but changed status since last time*/
}
}
return EOK;
}
{
struct be_resolve_server_state);
if (srv) {
}
return EOK;
}
{
if (svc) {
}
}
const char *service_name)
{
return fo_get_server_name(server);
}
}
return NULL;
}
const char *service_name)
{
return ENOENT;
}
svc->run_callbacks = true;
return EOK;
}
{
}
const char *svc_name)
{
int ret;
"Resetting all servers in service %s\n", svc_name);
"Cannot retrieve service [%s]\n", svc_name);
return;
}
}
const char *service_name,
enum port_status status,
int line,
const char *file,
const char *function)
{
/* Print debug info */
switch (status) {
case PORT_NEUTRAL:
"Setting status: PORT_NEUTRAL. Called from: %s: %s: %d\n",
break;
case PORT_WORKING:
"Setting status: PORT_WORKING. Called from: %s: %s: %d\n",
break;
case PORT_NOT_WORKING:
"Setting status: PORT_NOT_WORKING. Called from: %s: %s: %d\n",
break;
}
"No service associated with name %s\n", service_name);
return;
}
"The server %p is not valid anymore, cannot set its status\n",
server);
return;
}
/* Now we know that the server is valid */
if (status == PORT_WORKING) {
/* We were successful in connecting to the server. Cycle through all
* available servers next time */
}
}
/* Resolver back end interface */
};
struct confdb_ctx *cdb,
const char *conf_path)
{
const char *str_family;
return ret;
}
} else {
return EINVAL;
}
return EOK;
}
{
return EOK;
}
return ENOMEM;
}
return ret;
}
return ret;
}
return EOK;
}