nsssrv.c revision 3e7d7af1953410f3f009bf3b2e481a46fb80de83
/*
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 "responder/nss/nsssrv_private.h"
#include "responder/nss/nsssrv_mmap_cache.h"
#include "responder/nss/nsssrv_netgroup.h"
#include "responder/common/negcache.h"
#include "sbus/sssd_dbus.h"
#include "responder/common/responder_packet.h"
#include "responder/common/responder.h"
#include "responder/common/responder_sbus.h"
#include "providers/data_provider.h"
#include "monitor/monitor_interfaces.h"
#include "sbus/sbus_client.h"
#include "util/util_sss_idmap.h"
#define DEFAULT_PWFIELD "*"
#define DEFAULT_NSS_FD_LIMIT 8192
#define SHELL_REALLOC_INCREMENT 5
#define SHELL_REALLOC_MAX 50
struct sbus_connection *conn);
struct sbus_connection *conn);
struct sbus_method monitor_nss_methods[] = {
};
struct sbus_interface monitor_nss_interface = {
};
struct sbus_connection *conn)
{
int memcache_timeout;
struct resp_ctx);
if (ret != 0) {
"CLEAR_MC_FLAG not found. Nothing to do.\n");
goto done;
} else {
return ret;
}
}
/* CLEAR_MC_FLAG removed successfully. Clearing memory caches. */
300, &memcache_timeout);
"Unable to get memory cache entry timeout.\n");
return ret;
}
/* TODO: read cache sizes from configuration */
&nctx->pwd_mc_ctx);
"passwd mmap cache invalidation failed\n");
return ret;
}
&nctx->grp_mc_ctx);
"group mmap cache invalidation failed\n");
return ret;
}
done:
}
struct sbus_connection *conn)
{
struct resp_ctx);
"Could not invalidate netgroups\n");
return ret;
}
}
{
int i = 0;
char *sh;
int size;
if (!shells) {
goto done;
}
setusershell();
while ((sh = getusershell())) {
if (!shells[i]) {
endusershell();
goto done;
}
i++;
if (i == size) {
if (size > SHELL_REALLOC_MAX) {
"Reached maximum number of shells [%d]. "
"Users may be denied access. "
break;
}
size);
if (!shells) {
goto done;
}
}
}
endusershell();
if (i + 1 < size) {
if (!shells) {
goto done;
}
}
done:
return ret;
}
struct confdb_ctx *cdb)
{
int ret;
&nctx->neg_timeout);
if (nctx->cache_refresh_percent < 0 ||
"Configuration error: entry_cache_nowait_percentage is "
"invalid. Disabling feature.\n");
nctx->cache_refresh_percent = 0;
}
goto done;
}
&nctx->override_homedir);
&nctx->fallback_homedir);
&nctx->override_shell);
&nctx->allowed_shells);
&nctx->vetoed_shells);
&nctx->shell_fallback);
NULL,
&nctx->default_shell);
ret = 0;
done:
return ret;
}
struct sbus_connection *conn)
{
struct resp_ctx);
return EOK;
}
struct sbus_connection *conn)
{
struct resp_ctx);
char *user;
char *domain;
int gnum;
if (!dbret) {
if (dbus_error_is_set(&dbus_error)) {
}
return EIO;
}
if (!dbret) {
return EIO;
}
/* send reply back */
return EOK;
}
static struct sbus_method nss_dp_methods[] = {
};
struct sbus_interface nss_dp_interface = {
};
{
int ret;
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
/* Identify ourselves to the data provider */
"NSS");
/* all fine */
return;
}
}
/* Failed to reconnect */
/* FIXME: kill the frontend and let the monitor restart it ? */
/* nss_shutdown(rctx); */
}
struct tevent_context *ev,
struct confdb_ctx *cdb)
{
struct sss_cmd_table *nss_cmds;
int memcache_timeout;
int ret, max_retries;
enum idmap_error_code err;
int hret;
int fd_limit;
nss_cmds = get_nss_cmds();
"NSS", &nss_dp_interface,
&rctx);
return ret;
}
if (!nctx) {
goto fail;
}
"fatal error initializing negative cache\n");
goto fail;
}
goto fail;
}
/* Enable automatic reconnection to the Data Provider */
3, &max_retries);
"Failed to set up automatic reconnection\n");
goto fail;
}
}
if (err != IDMAP_SUCCESS) {
goto fail;
}
/* Create the lookup table for netgroup results */
if (hret != HASH_SUCCESS) {
"Unable to initialize netgroup hash table\n");
goto fail;
}
/* create mmap caches */
/* Remove the CLEAR_MC_FLAG file if exists. */
"Failed to unlink file [%s]. This can cause memory cache to "
"be purged when next log rotation is requested. %d: %s\n",
}
300, &memcache_timeout);
"Failed to get 'memcache_timeout' option from confdb.\n");
goto fail;
}
/* TODO: read cache sizes from configuration */
&nctx->pwd_mc_ctx);
if (ret) {
}
&nctx->grp_mc_ctx);
if (ret) {
}
/* Set up file descriptor limits */
&fd_limit);
"Failed to set up file descriptor limit\n");
goto fail;
}
goto fail;
}
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_nss";
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;
}