sss_cache.c revision 044868b388b4e47499f12a9105310b247bbe1ce2
/*
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 sss_domain_info *domain,
const char *sub_filter, const char **attrs,
struct cache_tool_ctx {
struct confdb_ctx *confdb;
struct sss_domain_info *domains;
struct sss_names_ctx *nctx;
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;
bool update_user_filter;
bool update_group_filter;
bool update_netgroup_filter;
bool update_service_filter;
bool update_autofs_filter;
};
struct sss_domain_info *domain,
const char *name, int entry_type);
struct sss_domain_info *dinfo,
enum sss_cache_entry entry_type,
char *domain_name);
{
bool skipped = true;
struct sss_domain_info *dinfo;
("Error initializing context for the application\n"));
goto done;
}
/* Update filters for each domain */
goto done;
}
goto done;
}
}
}
}
if (skipped == true) {
ERROR("No cache object matched the specified search\n");
goto done;
} else {
goto done;
}
}
done:
return ret;
}
char **filter)
{
char *parsed_domain = NULL;
char *parsed_name = NULL;
&parsed_domain, &parsed_name);
goto done;
}
if (parsed_domain) {
if (fmt) {
} else {
}
goto done;
}
} else {
/* Set to NULL to indicate that it will not be used
* in this domain */
}
} else {
if (fmt) {
} else {
}
goto done;
}
}
}
done:
return ret;
}
/* This function updates all filters for specified domain using this
* domains regex to parse string into domain and name (if exists). */
char *domain_name)
{
return ret;
}
/* Update user filter */
&tctx->user_filter);
return ret;
}
/* Update group filter */
&tctx->group_filter);
return ret;
}
/* Update netgroup filter */
&tctx->netgroup_filter);
return ret;
}
/* Update service filter */
&tctx->service_filter);
return ret;
}
/* Update autofs filter */
&tctx->autofs_filter);
return ret;
}
return EOK;
}
struct sss_domain_info *dinfo,
enum sss_cache_entry entry_type,
{
struct ldb_message **msgs;
const char *type_string = "unknown";
int i;
const char *c_name;
bool iret;
if (!filter) return false;
switch (entry_type) {
case TYPE_USER:
type_string = "user";
break;
case TYPE_GROUP:
type_string = "group";
break;
case TYPE_NETGROUP:
type_string = "netgroup";
break;
case TYPE_SERVICE:
type_string = "service";
break;
case TYPE_AUTOFSMAP:
type_string = "autofs map";
break;
}
("Searching for %s in domain %s with filter %s failed\n",
if (name) {
ERROR("No such %1$s named %2$s in domain %3$s, skipping\n",
} else {
ERROR("No objects of type %1$s from domain %2$s in the cache, "
}
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;
}
struct sss_domain_info *domain,
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) {
return ret;
}
} else {
return ret;
}
return ret;
}
}
return EOK;
}
{
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) {
ctx->update_user_filter = false;
} else if (user) {
ctx->update_user_filter = true;
}
if (idb & INVALIDATE_GROUPS) {
ctx->update_group_filter = false;
} else if (group) {
ctx->update_group_filter = true;
}
if (idb & INVALIDATE_NETGROUPS) {
ctx->update_netgroup_filter = false;
} else if (netgroup) {
ctx->update_netgroup_filter = true;
}
if (idb & INVALIDATE_SERVICES) {
ctx->update_service_filter = false;
} else if (service) {
ctx->update_service_filter = true;
}
if (idb & INVALIDATE_AUTOFSMAPS) {
ctx->update_autofs_filter = false;
} else if (map) {
ctx->update_autofs_filter = true;
}
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
struct sss_domain_info *domain,
const char *sub_filter, const char **attrs,
{
#ifdef BUILD_AUTOFS
msgs_count, msgs);
#else
return ENOSYS;
#endif /* BUILD_AUTOFS */
}