dp_targets.c revision 35fa5a83ce8badf6bc868937047f44c3f32b7c28
/*
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 <talloc.h>
#include <dlfcn.h>
#include "config.h"
#include "providers/data_provider/dp.h"
#include "providers/data_provider/dp_private.h"
#include "providers/data_provider/dp_builtin.h"
#define DP_TARGET_INIT_FN "sssm_%s_%s_init"
#define DP_PROVIDER_OPT "%s_provider"
#define DP_ACCESS_PERMIT "permit"
#define DP_ACCESS_DENY "deny"
#define DP_NO_PROVIDER "none"
const char *module_name,
...)
{
enum dp_targets type;
bool bret;
return false;
}
bret = false;
continue;
}
if (module_name == NULL) {
bret = true;
goto done;
}
bret = true;
goto done;
}
}
done:
return bret;
}
enum dp_targets target)
{
return NULL;
}
return NULL;
}
}
{
}
{
switch (target) {
case DPT_ID:
return "id";
case DPT_AUTH:
return "auth";
case DPT_ACCESS:
return "access";
case DPT_CHPASS:
return "chpass";
case DPT_SUDO:
return "sudo";
case DPT_AUTOFS:
return "autofs";
case DPT_SELINUX:
return "selinux";
case DPT_HOSTID:
return "hostid";
case DPT_SUBDOMAINS:
return "subdomains";
case DP_TARGET_SENTINEL:
return NULL;
}
return NULL;
}
{
return false;
}
}
{
char **services;
char *module;
bool responder_enabled;
bool enable;
int i;
/* Do not disable it in case of error. */
enable = true;
return enable;
}
goto done;
}
responder_enabled = false;
responder_enabled = true;
break;
}
}
goto done;
}
if (!responder_enabled) {
"disabling SUDO module.\n");
enable = false;
goto done;
"listed in active services. SUDO support will not work!\n");
enable = true;
goto done;
}
}
enable = true;
done:
return enable;
}
enum dp_targets type)
{
return NULL;
}
}
enum dp_targets target)
{
switch (target) {
case DPT_ID:
return NULL;
case DPT_ACCESS:
return "permit";
case DPT_CHPASS:
case DP_TARGET_SENTINEL:
return NULL;
default:
}
}
{
char *error;
return ENOMEM;
}
dlerror(); /* clear any error */
goto done;
}
} else {
/* Not found. */
goto done;
} else {
/* Error. */
goto done;
}
}
target->initialized = true;
done:
return ret;
}
const char *module_name)
{
target->initialized = false;
return EOK;
}
target->initialized = true;
return EOK;
}
target->initialized = true;
return EOK;
}
}
if (dp_target_sudo_enabled(be_ctx)) {
return EAGAIN;
} else {
target->initialized = false;
return EOK;
}
}
return EAGAIN;
}
struct data_provider *provider,
{
/* We have already name, module name and target set. We just load
* the module and initialize it. */
DP_METHOD_SENTINEL + 1);
goto done;
}
/* Handle special cases that do not require opening a module. */
goto done;
}
/* Load module first. Memory context is modules, not target here. */
goto done;
}
/* Run constructor. */
/* Target not found but it wasn't explicitly
* configured so we shall just continue. */
goto done;
goto done;
}
done:
}
return ret;
}
struct confdb_ctx *confdb_ctx,
const char *conf_path,
enum dp_targets type,
bool *_is_default)
{
const char *name;
const char *default_module;
char *module;
char *option;
return NULL;
}
return NULL;
}
return NULL;
}
*_is_default = false;
return module;
}
*_is_default = true;
}
const char *conf_path,
{
enum dp_targets type;
const char *name;
bool is_default;
char *module;
ret = ERR_INTERNAL;
goto done;
}
type, &is_default);
" [%s]\n", name);
continue;
} else {
}
}
done:
return ret;
}
struct data_provider *provider,
{
enum dp_targets type;
/* We load the configuration first and store module name to each target.
* This way we ensure that we have this information available during
* module initialization. */
goto done;
}
ret = ERR_INTERNAL;
goto done;
}
}
done:
return ret;
}
struct data_provider *provider,
{
enum dp_targets type;
/* Even though we know the exact number of targets we will allocate
* them all dynamically so we can have correct talloc hierarchy where
* all private data are attached to the target they belong to. */
DP_TARGET_SENTINEL + 1);
goto done;
}
goto done;
}
}
/* We want this to be already available. */
done:
}
return ret;
}