sss_cache.c revision 99c99e557020775714f028b28a147edda290c783
/*
SSSD
sss_cache
Copyright (C) Jan Zeleny <jzeleny@redhat.com> 2011
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 <stdlib.h>
#include <talloc.h>
#include <popt.h>
#include "tools/sss_sync_ops.h"
#include "db/sysdb_services.h"
#include "db/sysdb_autofs.h"
#define INVALIDATE_NONE 0
#define INVALIDATE_USERS 1
#define INVALIDATE_GROUPS 2
#define INVALIDATE_NETGROUPS 4
#define INVALIDATE_SERVICES 8
#define INVALIDATE_AUTOFSMAPS 16
enum sss_cache_entry {
TYPE_USER=0,
};
struct entry_type_t {
const char *type_string;
const char *, const char **, size_t *, struct ldb_message ***);
};
const char *sub_filter, const char **attrs,
const char *sub_filter, const char **attrs,
static struct entry_type_t entry_types[] = {
{"user", sysdb_search_users},
{"group", sysdb_search_groups},
{"netgroup", sysdb_search_netgroups},
{"service", search_services},
{"autofs map", search_autofsmaps}
};
struct cache_tool_ctx {
struct confdb_ctx *confdb;
struct sss_domain_info *domains;
struct sysdb_ctx_list *sysdb_list;
char *user_filter;
char *group_filter;
char *netgroup_filter;
char *service_filter;
char *autofs_filter;
char *user_name;
char *group_name;
char *netgroup_name;
char *service_name;
char *autofs_name;
};
const char *name, int entry_type);
const char *name);
{
int i;
bool skipped;
("Error initializing context for the application\n"));
goto done;
}
goto done;
}
skipped = true;
}
}
if (skipped == true) {
ERROR("No cache object matched the specified search\n");
goto done;
} else {
/*Local cache changed -> signal monitor to invalidate fastcache */
if (clear_mc_flag == NULL) {
("Failed to create clear_mc_flag file. "
"Memory cache will not be cleared.\n"));
goto done;
}
if (ret != 0) {
("Unable to close file descriptor: %s\n",
goto done;
}
("Failed to send SIGHUP to monitor.\n"));
goto done;
}
}
}
done:
return ret;
}
const char *name)
{
struct ldb_message **msgs;
struct entry_type_t type_rec;
int i;
const char *c_name;
bool iret;
if (!filter) return false;
("Searching for %s with filter %s failed\n",
if (name) {
ERROR("No such %1$s named %2$s, skipping\n",
} else {
ERROR("No objects of type %1$s in the cache, skipping\n",
}
return false;
}
iret = true;
for (i = 0; i < msg_count; i++) {
("Something bad happened, can't find attribute %s", SYSDB_NAME));
iret = false;
} else {
iret = false;
}
}
}
return iret;
}
const char *name, int entry_type)
{
if (sys_attrs) {
SYSDB_CACHE_EXPIRE, 1);
switch (entry_type) {
case TYPE_USER:
break;
case TYPE_GROUP:
break;
case TYPE_NETGROUP:
break;
case TYPE_SERVICE:
break;
case TYPE_AUTOFSMAP:
break;
default:
return EINVAL;
}
}
} else {
}
} else {
}
return ret;
}
{
char *confdb_path;
int ret;
if (confdb_path == NULL) {
return ENOMEM;
}
/* Connect to the conf db */
return ret;
}
if (domain) {
goto fail;
}
goto fail;
}
} else {
goto fail;
}
}
return EOK;
fail:
if (ctx->sysdb_list) {
} else {
}
return ret;
}
{
int idb = INVALIDATE_NONE;
int debug = SSSDBG_DEFAULT;
struct poptOption long_options[] = {
0, _("The debug level to run with"), NULL },
_("Invalidate particular user"), NULL },
_("Invalidate all users"), NULL },
_("Invalidate particular group"), NULL },
_("Invalidate all groups"), NULL },
_("Invalidate particular netgroup"), NULL },
_("Invalidate all netgroups"), NULL },
_("Invalidate particular service"), NULL },
_("Invalidate all services"), NULL },
#ifdef BUILD_AUTOFS
_("Invalidate particular autofs map"), NULL },
_("Invalidate all autofs maps"), NULL },
#endif /* BUILD_AUTOFS */
_("Only invalidate entries from a particular domain"), NULL },
};
ret = set_locale();
ERROR("Error setting the locale\n");
goto fini;
}
switch (ret) {
case 'u':
idb |= INVALIDATE_USERS;
break;
case 'g':
idb |= INVALIDATE_GROUPS;
break;
case 'n':
break;
case 's':
break;
case 'a':
break;
}
}
if (ret != -1) {
}
_("Please select at least one object to invalidate\n"),
}
debug_prg_name = argv[0];
goto fini;
}
if (idb & INVALIDATE_USERS) {
} else if (user) {
}
if (idb & INVALIDATE_GROUPS) {
} else if (group) {
}
if (idb & INVALIDATE_NETGROUPS) {
} else if (netgroup) {
netgroup);
}
if (idb & INVALIDATE_SERVICES) {
} else if (service) {
}
if (idb & INVALIDATE_AUTOFSMAPS) {
} else if (map) {
SYSDB_NAME, map);
}
goto fini;
}
if (domain) {
} else {
ERROR("Could not open available domains\n");
}
("Initialization of sysdb connections failed\n"));
goto fini;
}
fini:
}
}
return ret;
}
static errno_t
const char *sub_filter, const char **attrs,
{
struct ldb_result *res;
/* All services */
} else {
/* Get service by name */
}
return ret;
}
return EOK;
}
static errno_t
const char *sub_filter, const char **attrs,
{
#ifdef BUILD_AUTOFS
msgs_count, msgs);
#else
return ENOSYS;
#endif /* BUILD_AUTOFS */
}