negcache.c revision 42604cc8d11743febf5aa892cb3a7d3c32bfed48
/*
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 "responder/common/responder.h"
#include "responder/common/negcache.h"
#include <fcntl.h>
#include <time.h>
#include "tdb.h"
#define NC_ENTRY_PREFIX "NCE/"
struct sss_nc_ctx {
struct tdb_context *tdb;
};
typedef int (*ncache_set_byname_fn_t)(struct sss_nc_ctx *, bool,
const char *, const char *);
{
return EOK;
}
{
struct sss_nc_ctx *ctx;
errno = 0;
/* open a memory only tdb with default hash size */
return EOK;
};
{
unsigned long long int timestamp;
bool expired = false;
char *ep;
int ret;
goto done;
}
if (ttl == -1) {
/* a negative ttl means: never expires */
goto done;
}
errno = 0;
/* Malformed entry, remove it and return no entry */
expired = true;
goto done;
}
if (timestamp == 0) {
/* a 0 timestamp means this is a permanent entry */
goto done;
}
/* still valid */
goto done;
}
expired = true;
done:
if (expired) {
/* expired, remove and return no entry */
}
return ret;
}
{
char *timest;
int ret;
if (permanent) {
} else {
}
if (ret != 0) {
}
done:
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *str;
int ret;
return ret;
}
int ttl,
const char *domain,
const char *name)
{
char *str;
int ret;
name);
return ret;
}
typedef int (*ncache_check_byname_fn_t)(struct sss_nc_ctx *, int,
const char *, const char *);
{
char *lower;
if (dom->case_sensitive == false) {
} else {
}
return ret;
}
{
}
{
}
{
}
{
char *str;
int ret;
return ret;
}
struct sss_domain_info *dom,
{
int ret;
name,
if (!service_and_protocol) return ENOMEM;
return ret;
}
struct sss_domain_info *dom,
const char *name,
const char *proto)
{
int ret;
name,
if (!service_and_protocol) return ENOMEM;
return ret;
}
struct sss_domain_info *dom,
{
int ret;
port,
if (!service_and_protocol) return ENOMEM;
return ret;
}
struct sss_domain_info *dom,
const char *proto)
{
int ret;
port,
if (!service_and_protocol) return ENOMEM;
return ret;
}
{
char *str;
int ret;
uid);
} else {
}
return ret;
}
{
char *str;
int ret;
gid);
} else {
}
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *str;
int ret;
return ret;
}
{
char *lower;
if (dom->case_sensitive == false) {
} else {
}
return ret;
}
{
}
{
}
{
}
{
char *str;
int ret;
uid);
} else {
}
return ret;
}
{
char *str;
int ret;
gid);
} else {
}
return ret;
}
{
char *str;
int ret;
return ret;
}
const char *cert)
{
char *str;
int ret;
return ret;
}
{
unsigned long long int timestamp;
bool remove_key = false;
char *ep;
/* not interested in this key */
return 0;
}
errno = 0;
/* Malformed entry, remove it */
remove_key = true;
goto done;
}
if (timestamp == 0) {
/* a 0 timestamp means this is a permanent entry */
remove_key = true;
}
done:
if (remove_key) {
}
return 0;
}
{
int ret;
if (ret < 0)
return EIO;
return EOK;
}
struct confdb_ctx *cdb,
{
bool filter_set = false;
char **filter_list = NULL;
char *domainname = NULL;
int i;
/* Populate domain-specific negative cache entries */
if (!conf_path) {
goto done;
}
&filter_list);
filter_set = true;
for (i = 0; (filter_list && filter_list[i]); i++) {
filter_list[i],
&domainname, &name);
"cannot add [%s] to negcache because the required or "
"default domain are not known yet\n", filter_list[i]);
"Invalid name in filterUsers list: [%s] (%d)\n",
filter_list[i], ret);
continue;
}
"Mismatch between domain name (%s) and name "
"set in FQN (%s), skipping user %s\n",
continue;
}
"Failed to store permanent user filter for [%s]"
" (%d [%s])\n", filter_list[i],
continue;
}
}
}
if (!filter_set) {
if (!filter_list) {
goto done;
}
if (!filter_list[0]) {
goto done;
}
}
}
for (i = 0; (filter_list && filter_list[i]); i++) {
&domainname, &name);
"Cannot add [%s] to negcache because the required or "
"default domain are not known yet\n", filter_list[i]);
"Invalid name in filterUsers list: [%s] (%d)\n",
filter_list[i], ret);
continue;
}
if (domainname) {
if (!dom) {
"Invalid domain name [%s]\n", domainname);
continue;
}
"Failed to store permanent user filter for [%s]"
" (%d [%s])\n", filter_list[i],
continue;
}
} else {
"Failed to store permanent user filter for"
" [%s:%s] (%d [%s])\n",
continue;
}
}
}
}
filter_set = false;
if (!conf_path) {
goto done;
}
filter_set = true;
for (i = 0; (filter_list && filter_list[i]); i++) {
&domainname, &name);
"Invalid name in filterGroups list: [%s] (%d)\n",
filter_list[i], ret);
continue;
}
"Mismatch between domain name (%s) and name "
"set in FQN (%s), skipping group %s\n",
continue;
}
"Failed to store permanent group filter for [%s]"
" (%d [%s])\n", filter_list[i],
continue;
}
}
}
if (!filter_set) {
if (!filter_list) {
goto done;
}
if (!filter_list[0]) {
goto done;
}
}
}
for (i = 0; (filter_list && filter_list[i]); i++) {
&domainname, &name);
"Cannot add [%s] to negcache because the required or "
"default domain are not known yet\n", filter_list[i]);
"Invalid name in filterGroups list: [%s] (%d)\n",
filter_list[i], ret);
continue;
}
if (domainname) {
if (!dom) {
"Invalid domain name [%s]\n", domainname);
continue;
}
"Failed to store permanent group filter for"
" [%s] (%d [%s])\n", filter_list[i],
continue;
}
} else {
"Failed to store permanent group filter for"
" [%s:%s] (%d [%s])\n",
continue;
}
}
}
}
done:
return ret;
}
/* Reset permanent negcache after checking the domains */
struct sss_nc_ctx *ncache)
{
int ret;
}
return ret;
}