nsssrv.c revision 99c99e557020775714f028b28a147edda290c783
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina NSS Responder
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina This program is free software; you can redistribute it and/or modify
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina it under the terms of the GNU General Public License as published by
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina the Free Software Foundation; either version 3 of the License, or
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina (at your option) any later version.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina This program is distributed in the hope that it will be useful,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina GNU General Public License for more details.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina You should have received a copy of the GNU General Public License
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic int nss_clear_memcache(DBusMessage *message,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina { MON_CLI_METHOD_RES_INIT, monitor_common_res_init },
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina { MON_CLI_METHOD_ROTATE, responder_logrotate },
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina { MON_CLI_METHOD_CLEAR_MEMCACHE, nss_clear_memcache},
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastruct sbus_interface monitor_nss_interface = {
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic int nss_clear_memcache(DBusMessage *message,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(conn),
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina struct nss_ctx *nctx = (struct nss_ctx*) rctx->pvt_ctx;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = unlink(SSS_NSS_MCACHE_DIR"/"CLEAR_MC_FLAG);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ("CLEAR_MC_FLAG not found. Nothing to do.\n"));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to unlink file: %s.\n",
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* CLEAR_MC_FLAG removed successfully. Clearing memory caches. */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ("Unable to get memory cache entry timeout.\n"));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* TODO: read cache sizes from configuration */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, ("Clearing memory caches.\n"));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = sss_mmap_cache_reinit(nctx, SSS_MC_CACHE_ELEMENTS,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ("passwd mmap cache invalidation failed\n"));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = sss_mmap_cache_reinit(nctx, SSS_MC_CACHE_ELEMENTS,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ("group mmap cache invalidation failed\n"));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic errno_t nss_get_etc_shells(TALLOC_CTX *mem_ctx, char ***_shells)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina shells = talloc_array(tmp_ctx, char *, SHELL_REALLOC_INCREMENT);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(6, ("Found shell %s in /etc/shells\n", shells[i]));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(0, ("Reached maximum number of shells [%d]. "
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina "Users may be denied access. "
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina "Please check /etc/shells for sanity\n",
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina shells = talloc_realloc(NULL, shells, char *, i + 1);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic int nss_get_config(struct nss_ctx *nctx,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = confdb_get_int(cdb, CONFDB_NSS_CONF_ENTRY,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = confdb_get_int(cdb, CONFDB_NSS_CONF_ENTRY,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = confdb_get_bool(cdb, CONFDB_NSS_CONF_ENTRY,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = confdb_get_int(cdb, CONFDB_NSS_CONF_ENTRY,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina DEBUG(0,("Configuration error: entry_cache_nowait_percentage is "
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina "invalid. Disabling feature.\n"));
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina ret = sss_ncache_prepopulate(nctx->ncache, cdb, nctx->rctx);
goto done;
NULL,
ret = 0;
done:
return ret;
int ret;
int memcache_timeout;
int hret;
int fd_limit;
if (!nctx) {
return ENOMEM;
return ret;
return ret;
return ret;
return ret;
return EIO;
return ret;
if (ret) {
if (ret) {
&fd_limit);
return ret;
return EOK;
int opt;
int ret;
switch(opt) {