dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0030-NSS-avoid-excessive-log-messages.patch

1bb595
From e12340e7d9efe5f272e58d69333c1c09c3bcc44d Mon Sep 17 00:00:00 2001
1bb595
From: Alexey Tikhonov <atikhono@redhat.com>
1bb595
Date: Wed, 4 Mar 2020 21:09:33 +0100
1bb595
Subject: [PATCH 30/35] NSS: avoid excessive log messages
1bb595
1bb595
 - do not log error message if mem-cache was disabled explicitly
1bb595
 - increase message severity in case of fail to store entry in mem-cache
1bb595
1bb595
Reviewed-by: Sumit Bose <sbose@redhat.com>
1bb595
---
1bb595
 src/responder/nss/nss_protocol_grent.c | 12 +++++++-----
1bb595
 src/responder/nss/nss_protocol_pwent.c |  7 ++++---
1bb595
 2 files changed, 11 insertions(+), 8 deletions(-)
1bb595
1bb595
diff --git a/src/responder/nss/nss_protocol_grent.c b/src/responder/nss/nss_protocol_grent.c
1bb595
index 2f6d869ef..8f1d3fe81 100644
1bb595
--- a/src/responder/nss/nss_protocol_grent.c
1bb595
+++ b/src/responder/nss/nss_protocol_grent.c
1bb595
@@ -292,16 +292,17 @@ nss_protocol_fill_grent(struct nss_ctx *nss_ctx,
1bb595
         num_results++;
1bb595
 
1bb595
         /* Do not store entry in memory cache during enumeration or when
1bb595
-         * requested. */
1bb595
+         * requested or if cache explicitly disabled. */
1bb595
         if (!cmd_ctx->enumeration
1bb595
-                && (cmd_ctx->flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) == 0) {
1bb595
+                && ((cmd_ctx->flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) == 0)
1bb595
+                && (nss_ctx->grp_mc_ctx != NULL)) {
1bb595
             members = (char *)&body[rp_members];
1bb595
             members_size = body_len - rp_members;
1bb595
             ret = sss_mmap_cache_gr_store(&nss_ctx->grp_mc_ctx, name, &pwfield,
1bb595
                                           gid, num_members, members,
1bb595
                                           members_size);
1bb595
             if (ret != EOK) {
1bb595
-                DEBUG(SSSDBG_MINOR_FAILURE,
1bb595
+                DEBUG(SSSDBG_OP_FAILURE,
1bb595
                       "Failed to store group %s (%s) in mem-cache [%d]: %s!\n",
1bb595
                       name->str, result->domain->name, ret, sss_strerror(ret));
1bb595
             }
1bb595
@@ -423,7 +424,8 @@ nss_protocol_fill_initgr(struct nss_ctx *nss_ctx,
1bb595
     }
1bb595
 
1bb595
     if (nss_ctx->initgr_mc_ctx
1bb595
-                && (cmd_ctx->flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) == 0) {
1bb595
+                && ((cmd_ctx->flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) == 0)
1bb595
+                && (nss_ctx->initgr_mc_ctx != NULL)) {
1bb595
         to_sized_string(&rawname, cmd_ctx->rawname);
1bb595
         to_sized_string(&unique_name, result->lookup_name);
1bb595
 
1bb595
@@ -431,7 +433,7 @@ nss_protocol_fill_initgr(struct nss_ctx *nss_ctx,
1bb595
                                           &unique_name, num_results,
1bb595
                                           body + 2 * sizeof(uint32_t));
1bb595
         if (ret != EOK) {
1bb595
-            DEBUG(SSSDBG_MINOR_FAILURE,
1bb595
+            DEBUG(SSSDBG_OP_FAILURE,
1bb595
                   "Failed to store initgroups %s (%s) in mem-cache [%d]: %s!\n",
1bb595
                   rawname.str, domain->name, ret, sss_strerror(ret));
1bb595
             sss_packet_set_size(packet, 0);
1bb595
diff --git a/src/responder/nss/nss_protocol_pwent.c b/src/responder/nss/nss_protocol_pwent.c
1bb595
index 31fd01698..f9f3f0cf0 100644
1bb595
--- a/src/responder/nss/nss_protocol_pwent.c
1bb595
+++ b/src/responder/nss/nss_protocol_pwent.c
1bb595
@@ -301,13 +301,14 @@ nss_protocol_fill_pwent(struct nss_ctx *nss_ctx,
1bb595
         num_results++;
1bb595
 
1bb595
         /* Do not store entry in memory cache during enumeration or when
1bb595
-         * requested. */
1bb595
+         * requested or if cache explicitly disabled. */
1bb595
         if (!cmd_ctx->enumeration
1bb595
-                && (cmd_ctx->flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) == 0) {
1bb595
+                && ((cmd_ctx->flags & SSS_NSS_EX_FLAG_INVALIDATE_CACHE) == 0)
1bb595
+                && (nss_ctx->pwd_mc_ctx != NULL)) {
1bb595
             ret = sss_mmap_cache_pw_store(&nss_ctx->pwd_mc_ctx, name, &pwfield,
1bb595
                                           uid, gid, &gecos, &homedir, &shell);
1bb595
             if (ret != EOK) {
1bb595
-                DEBUG(SSSDBG_MINOR_FAILURE,
1bb595
+                DEBUG(SSSDBG_OP_FAILURE,
1bb595
                       "Failed to store user %s (%s) in mmap cache [%d]: %s!\n",
1bb595
                       name->str, result->domain->name, ret, sss_strerror(ret));
1bb595
             }
1bb595
-- 
1bb595
2.21.3
1bb595