On 11/01/2012 12:09 PM, Jakub Hrozek wrote:
On Thu, Oct 25, 2012 at 06:53:47PM +0200, Michal Židek wrote:
I found this bug while working on:
https://fedorahosted.org/sssd/ticket/1584
If no objects for deletion were found in the currently searched
sysdb database, the other sysdb databases were not searched at all.
Also the ERROR message informing about specific object not found was
changed to DEBUG message. It was really annoying seeing this message
for all domains, but it can be useful for debugging (it helped me by
testing this patch). Now only one ERROR message is printed if no
matching objects where found and all domains were searched.
Patch is attached.
Thanks
Michal
This patch works as advertised.
However, the per-domain per-type ERROR messages are now superseded by a generic
ERROR message when no objects match in any domain. I'm thinking we might
want to keep the per-domain ERROR message and at least include the
domain index number (...user not found in domain 1/2..) or even the
domain name.
You can obtain it via sss_domain_info structure that can be returned
using sysdb_ctx_get_domain.
I did it as you suggested. The output looks good with the domain name.
New patch is attached.
Thanks
Michal
>From b88fc282a2db68480e40e238443aafb65ec4cae0 Mon Sep 17 00:00:00 2001
From: Michal Zidek <[email protected]>
Date: Thu, 25 Oct 2012 18:07:01 +0200
Subject: [PATCH] sss_cache: Multiple domains not handled properly
When working with multiple domains and no
matching objects for deletion were found in the first
domain, the other domains were not searched at all.
Also the ERROR message informing about object not found
(the one printed for each domain) was changed to
DEBUG message.
---
src/tools/sss_cache.c | 72 ++++++++++++++++++++++++++-------------------------
1 file changed, 37 insertions(+), 35 deletions(-)
diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c
index 9b91f98..84a53dd 100644
--- a/src/tools/sss_cache.c
+++ b/src/tools/sss_cache.c
@@ -99,7 +99,7 @@ int main(int argc, const char *argv[])
struct cache_tool_ctx *tctx = NULL;
struct sysdb_ctx *sysdb;
int i;
- bool skipped;
+ bool skipped = true;
FILE *clear_mc_flag;
ret = init_context(argc, argv, &tctx);
@@ -117,7 +117,6 @@ int main(int argc, const char *argv[])
goto done;
}
- skipped = true;
skipped &= !invalidate_entries(tctx, sysdb, TYPE_USER,
tctx->user_filter, tctx->user_name);
skipped &= !invalidate_entries(tctx, sysdb, TYPE_GROUP,
@@ -137,36 +136,36 @@ int main(int argc, const char *argv[])
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to cancel transaction\n"));
}
}
+ }
- if (skipped == true) {
- ERROR("No cache object matched the specified search\n");
- ret = ENOENT;
+ if (skipped == true) {
+ ERROR("No cache object matched the specified search\n");
+ ret = ENOENT;
+ goto done;
+ } else {
+ /*Local cache changed -> signal monitor to invalidate fastcache */
+ clear_mc_flag = fopen(SSS_NSS_MCACHE_DIR"/"CLEAR_MC_FLAG, "w");
+ if (clear_mc_flag == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Failed to create clear_mc_flag file. "
+ "Memory cache will not be cleared.\n"));
goto done;
- } else {
- /*Local cache changed -> signal monitor to invalidate fastcache */
- clear_mc_flag = fopen(SSS_NSS_MCACHE_DIR"/"CLEAR_MC_FLAG, "w");
- if (clear_mc_flag == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("Failed to create clear_mc_flag file. "
- "Memory cache will not be cleared.\n"));
- goto done;
- }
- ret = fclose(clear_mc_flag);
- if (ret != 0) {
- ret = errno;
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("Unable to close file descriptor: %s\n",
- strerror(ret)));
- goto done;
- }
+ }
+ ret = fclose(clear_mc_flag);
+ if (ret != 0) {
+ ret = errno;
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Unable to close file descriptor: %s\n",
+ strerror(ret)));
+ goto done;
+ }
- DEBUG(SSSDBG_TRACE_FUNC, ("Sending SIGHUP to monitor.\n"));
- ret = signal_sssd(SIGHUP);
- if (ret != EOK) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("Failed to send SIGHUP to monitor.\n"));
- goto done;
- }
+ DEBUG(SSSDBG_TRACE_FUNC, ("Sending SIGHUP to monitor.\n"));
+ ret = signal_sssd(SIGHUP);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Failed to send SIGHUP to monitor.\n"));
+ goto done;
}
}
@@ -187,22 +186,25 @@ bool invalidate_entries(TALLOC_CTX *ctx, struct sysdb_ctx *sysdb,
int i;
const char *c_name;
bool iret;
+ struct sss_domain_info *dinfo;
if (!filter) return false;
+ dinfo = sysdb_ctx_get_domain(sysdb);
+
type_rec = entry_types[entry_type];
ret = type_rec.search_fn(ctx, sysdb, filter, attrs,
&msg_count, &msgs);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
- ("Searching for %s with filter %s failed\n",
- type_rec.type_string, filter));
+ ("Searching for %s in domain %s with filter %s failed\n",
+ type_rec.type_string, dinfo->name, filter));
if (name) {
- ERROR("No such %1$s named %2$s, skipping\n",
- type_rec.type_string, name);
+ ERROR("No such %1$s named %2$s in domain %3$s, skipping\n",
+ type_rec.type_string, name, dinfo->name);
} else {
- ERROR("No objects of type %1$s in the cache, skipping\n",
- type_rec.type_string);
+ ERROR("No objects of type %1$s from domain %2$s in the cache, "
+ "skipping\n", type_rec.type_string, dinfo->name);
}
return false;
}
--
1.7.11.2
_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel