nsssrv.c revision 57df88bb0b4ce656855410a8c2969d93475c2f11
/*
SSSD
NSS Responder
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/>.
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "popt.h"
#include "sbus/sssd_dbus.h"
#include "util/btreemap.h"
#include "providers/data_provider.h"
#include "monitor/monitor_sbus.h"
#include "monitor/monitor_interfaces.h"
#include "sbus/sbus_client.h"
#define SSS_NSS_PIPE_NAME "nss"
struct sbus_method nss_sbus_methods[] = {
};
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;
}
{
if (flags & EVENT_FD_READ) {
return;
}
if (flags & EVENT_FD_WRITE) {
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;
}
}
return;
}
{
const char *name = NSS_SBUS_SERVICE_NAME;
if (!ret) {
return EIO;
}
/* send reply back */
return EOK;
}
{
if (!ret) {
return EIO;
}
/* send reply back */
return EOK;
}
{
/* Monitor calls this function when we need to reload
* our configuration information. Perform whatever steps
* are needed to update the configuration objects.
*/
/* Send an empty reply to acknowledge receipt */
}
{
int ret;
char *sbus_address;
struct service_sbus_ctx *ss_ctx;
struct sbus_method_ctx *sm_ctx;
/* Set up SBUS connection to the monitor */
DEBUG(0, ("Could not locate monitor address.\n"));
return ret;
}
DEBUG(0, ("Could not initialize SBUS methods.\n"));
return ret;
}
NULL /* Private Data */,
NULL /* Destructor */,
&ss_ctx);
DEBUG(0, ("Failed to connect to monitor services.\n"));
return ret;
}
/* Set up NSS-specific listeners */
/* None currently used */
return EOK;
}
/* create a unix socket and listen to it */
{
struct sockaddr_un addr;
char *default_pipe;
int ret;
if (!default_pipe) {
return ENOMEM;
}
return ret;
}
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;
}
/* 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;
}
/* domain names are case insensitive for now
* NOTE: this function is not utf-8 safe,
* only ASCII names for now */
{
}
{
char *path;
char **domains;
char *provider;
struct nss_domain_info *info;
int ret, i, c;
int retval;
goto done;
}
i = 0;
c = 0;
if (!path) {
goto done;
}
/* alloc on tmp_ctx, it will be stolen by btreemap_set_value */
if (!info) {
goto done;
}
/* Build the basedn for this domain */
}
}
}
goto done;
}
i++;
c++;
}
if (c == 0) {
/* No domains configured!
* Note: this should never happen, since LOCAL should
* always be configured */
DEBUG(0, ("No domains configured on this client!\n"));
goto done;
}
goto done;
}
done:
return retval;
}
struct event_context *ev,
struct confdb_ctx *cdb)
{
int ret;
if (!nctx) {
DEBUG(0, ("fatal error initializing nss_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;
}
DEBUG(0, ("fatal error setting up backend connector\n"));
return ret;
}
DEBUG(0, ("fatal error initializing nss_ctx\n"));
return ret;
}
/* after all initializations we are ready to listen on our socket */
DEBUG(0, ("fatal error initializing socket\n"));
return ret;
}
return EOK;
}
{
int opt;
struct main_context *main_ctx;
int ret;
struct poptOption long_options[] = {
{ NULL }
};
switch(opt) {
default:
return 1;
}
}
/* set up things like debug , signals, daemonization, etc... */
/* loop on main */
return 0;
}