responder_common.c revision 12c6b6683f8a2036578e87c659afa79d3a1d68a9
/*
SSSD
Common Responder methods
Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
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/>.
*/
/* for struct ucred */
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <popt.h>
#include "config.h"
#include "sbus/sssd_dbus.h"
#include "responder/common/responder.h"
#include "responder/common/responder_packet.h"
#include "providers/data_provider.h"
#include "monitor/monitor_interfaces.h"
#include "sbus/sbus_client.h"
static void set_nonblocking(int fd)
{
unsigned v;
}
static void set_close_on_exec(int fd)
{
unsigned v;
}
{
return 0;
}
{
int ret;
/* not all data was sent, loop again */
return;
}
DEBUG(0, ("Failed to read request, aborting client!\n"));
return;
}
/* ok all sent */
return;
}
{
int ret;
DEBUG(0, ("Failed to alloc request, aborting client!\n"));
return;
}
}
DEBUG(0, ("Failed to alloc request, aborting client!\n"));
return;
}
}
switch (ret) {
case EOK:
/* do not read anymore */
/* execute command */
DEBUG(0, ("Failed to execute request, aborting client!\n"));
}
/* past this point cctx can be freed at any time by callbacks
* in case of error, do not use it */
return;
case EAGAIN:
/* need to read still some data, loop again */
break;
case EINVAL:
break;
case ENODATA:
break;
default:
}
return;
}
{
#ifdef HAVE_UCRED
int ret;
int fd;
/* buf must be aligned on some architectures. */
union ubuf {
int align;
} u;
char dummy='s';
int enable=1;
if (cctx->creds_exchange_done != 0) {
goto failed;
}
msg.msg_namelen = 0;
switch (action) {
case 'r':
if (ret == -1) {
goto failed;
}
if (ret == -1) {
goto failed;
}
}
return;
break;
case 's':
if (ret == -1) {
goto failed;
}
return;
default:
goto failed;
}
return;
#else
"continuing without.\n"));
return;
#endif
}
{
if (cctx->creds_exchange_done == 0) {
if (flags & TEVENT_FD_READ) {
return;
}
if (flags & TEVENT_FD_WRITE) {
return;
}
}
if (flags & TEVENT_FD_READ) {
return;
}
if (flags & TEVENT_FD_WRITE) {
return;
}
}
/* TODO: this is a copy of accept_fd_handler, maybe both can be put into on
* handler. */
{
/* accept and attach new event handler */
int ret;
if (ret == -1) {
return;
}
/* TODO: what is the best response to this condition? Terminate? */
return;
}
if (!cctx) {
struct sockaddr_un addr;
int fd;
DEBUG(0, ("Out of memory trying to setup client context on privileged pipe!\n"));
/* accept and close to signal the client we have a problem */
if (fd == -1) {
return;
}
return;
}
return;
}
cctx->creds_exchange_done = 0;
}
return;
}
{
/* accept and attach new event handler */
if (!cctx) {
struct sockaddr_un addr;
int fd;
DEBUG(0, ("Out of memory trying to setup client context!\n"));
/* accept and close to signal the client we have a problem */
if (fd == -1) {
return;
}
return;
}
return;
}
cctx->creds_exchange_done = 0;
}
return;
}
struct sbus_interface *intf,
const char *svc_name,
{
char *sbus_address;
int ret;
/* Set up SBUS connection to the monitor */
DEBUG(0, ("Could not locate monitor address.\n"));
return ret;
}
DEBUG(0, ("Failed to connect to monitor services.\n"));
return ret;
}
/* Identify ourselves to the monitor */
DEBUG(0, ("Failed to identify to the monitor!\n"));
return ret;
}
return EOK;
}
struct sbus_interface *intf,
const char *cli_name,
struct sss_domain_info *domain)
{
int ret;
/* Set up SBUS connection to the monitor */
DEBUG(0, ("Could not locate DP address.\n"));
return ret;
}
DEBUG(0, ("Failed to connect to monitor services.\n"));
return ret;
}
/* Identify ourselves to the DP */
cli_name);
DEBUG(0, ("Failed to identify to the DP!\n"));
return ret;
}
return EOK;
}
/* create a unix socket and listen to it */
{
struct sockaddr_un addr;
/* for future use */
#if 0
char *default_pipe;
int ret;
if (!default_pipe) {
return ENOMEM;
}
return ret;
}
if (!default_pipe) {
return ENOMEM;
}
return ret;
}
#endif
return EIO;
}
/* Set the umask so that permissions are set right on the socket.
* It must be readable and writable by anybody on the system. */
umask(0111);
/* make sure we have no old sockets around */
goto failed;
}
goto failed;
}
DEBUG(0, ("Failed to queue handler on pipe\n"));
goto failed;
}
}
/* create privileged pipe */
return EIO;
}
umask(0177);
goto failed;
}
goto failed;
}
DEBUG(0, ("Failed to queue handler on privileged pipe\n"));
goto failed;
}
}
/* we want default permissions on created files to be very strict,
so set our umask to 0177 */
umask(0177);
return EOK;
/* we want default permissions on created files to be very strict,
so set our umask to 0177 */
umask(0177);
return EIO;
}
struct tevent_context *ev,
struct confdb_ctx *cdb,
struct sss_cmd_table sss_cmds[],
const char *sss_pipe_name,
const char *sss_priv_pipe_name,
const char *confdb_service_path,
const char *svc_name,
struct sbus_interface *monitor_intf,
const char *cli_name,
struct sbus_interface *dp_intf,
struct resp_ctx **responder_ctx)
{
struct sss_domain_info *dom;
int ret;
if (!rctx) {
DEBUG(0, ("fatal error initializing resp_ctx\n"));
return ENOMEM;
}
DEBUG(0, ("fatal error setting up domain map\n"));
return ret;
}
DEBUG(0, ("fatal error setting up message bus\n"));
return ret;
}
/* skip local domain, it doesn't have a backend */
continue;
}
DEBUG(0, ("fatal error setting up backend connector\n"));
return ret;
}
}
DEBUG(0, ("fatal error initializing resp_ctx\n"));
return ret;
}
DEBUG(0, ("fatal error initializing regex data\n"));
return ret;
}
/* after all initializations we are ready to listen on our socket */
DEBUG(0, ("fatal error initializing socket\n"));
return ret;
}
*responder_ctx = rctx;
return EOK;
}
{
}
return EOK;
}