ifpsrv.c revision 8a1fd0633e85221da1fb63451516a70d66c0af31
/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2013 Red Hat
InfoPipe responder: the responder server
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 <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <popt.h>
#include "sbus/sssd_dbus.h"
#include "monitor/monitor_interfaces.h"
#include "responder/ifp/ifp_private.h"
#include "responder/ifp/ifp_domains.h"
#include "responder/ifp/ifp_components.h"
#include "responder/common/responder_sbus.h"
#define DEFAULT_ALLOWED_UIDS "0"
struct mon_cli_iface monitor_ifp_methods = {
{ &mon_cli_iface_meta, 0 },
.resetOffline = NULL,
};
static struct data_provider_iface ifp_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
.pamHandler = NULL,
.sudoHandler = NULL,
.autofsHandler = NULL,
.hostHandler = NULL,
.getDomains = NULL,
.getAccountInfo = NULL,
};
struct infopipe_iface ifp_iface = {
{ &infopipe_iface_meta, 0 },
/* components */
};
struct infopipe_component ifp_component = {
{ &infopipe_component_meta, 0 },
/* FIXME: This should be part of Components.Backends interface, onece
* SSSD supports multiple interfaces per object path. */
};
struct infopipe_domain ifp_domain = {
{ &infopipe_domain_meta, 0 },
};
struct sysbus_iface {
const char *path;
struct sbus_vtable *iface_vtable;
};
static struct sysbus_iface ifp_ifaces[] = {
};
struct sss_cmd_table *get_ifp_cmds(void)
{
static struct sss_cmd_table ifp_cmds[] = {
{ SSS_CLI_NULL, NULL}
};
return ifp_cmds;
}
{
int ret;
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
/* Identify ourselves to the data provider */
"InfoPipe");
/* all fine */
return;
}
}
/* Failed to reconnect */
}
static errno_t
struct tevent_context *ev,
const char *dbus_name,
struct sysbus_iface *sysbus_ifaces,
void *pvt,
struct sysbus_ctx **sysbus)
{
struct sbus_interface *sif;
int i;
if (system_bus == NULL) {
return ENOMEM;
}
/* Connect to the well-known system bus */
("Failed to connect to D-BUS system bus.\n"));
goto fail;
}
/* We want exclusive access */
&dbus_error);
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
/* We were unable to register on the system bus */
("Unable to request name on the system bus.\n"));
goto fail;
}
/* Integrate with tevent loop */
&system_bus->conn);
"Could not integrate D-BUS into mainloop.\n");
goto fail;
}
sysbus_ifaces[i].path,
pvt);
"Could not add the sbus interface\n");
goto fail;
}
"Could not add the interface\n");
goto fail;
}
}
*sysbus = system_bus;
return EOK;
fail:
if (dbus_error_is_set(&dbus_error)) {
}
return ret;
}
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
struct sss_cmd_table *ifp_cmds;
int ret;
int max_retries;
char *uid_str;
char *attr_list_str;
ifp_cmds = get_ifp_cmds();
"InfoPipe",
&rctx);
return ret;
}
goto fail;
}
"(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
goto fail;
}
goto fail;
}
goto fail;
}
/* Set up the negative cache */
&ifp_ctx->neg_timeout);
goto fail;
}
goto fail;
}
NULL, &attr_list_str);
goto fail;
}
("Failed to parse the allowed attribute list\n"));
goto fail;
}
/* Enable automatic reconnection to the Data Provider */
3, &max_retries);
"Failed to set up automatic reconnection\n");
goto fail;
}
}
/* Connect to the D-BUS system bus and set up methods */
"Failed to connect to the system message bus\n");
return EIO;
}
"schedule_get_domains_tasks failed.\n");
goto fail;
}
return EOK;
fail:
return ret;
}
{
int opt;
struct main_context *main_ctx;
int ret;
struct poptOption long_options[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* set up things like debug, signals, daemonization, etc... */
debug_log_file = "sssd_ifp";
ret = die_if_parent_died();
/* This is not fatal, don't return */
"Could not set up to exit when parent process does\n");
}
/* loop on main */
return 0;
}