[SSSD] [PATCH] Check NSCD configuration file

Jakub Hrozek jhrozek at redhat.com
Tue May 21 11:16:09 UTC 2013


On Tue, May 21, 2013 at 09:02:39AM +0200, Ondrej Kos wrote:
> On 05/20/2013 11:06 PM, Jakub Hrozek wrote:
> >On Mon, May 20, 2013 at 06:08:57PM +0200, Ondrej Kos wrote:
> >>After an off-list discussion, adding another patch which precedes the
> >>original one, and moves the src/tools/nscd.c file to src/util.
> >>
> >>The actual patch for the config file parsing fixed accordingly to the list
> >>conversation.
> >>
> >>Ondra
> >
> >[PATCH 1/2] Move nscd.c from tools to util
> >Ack, but when you resend the patches, please amend the commit message to
> >say that we name the module differently now because starting from the
> >next patch it's going to include another function consumed by the
> >monitor. Maybe linking the monitor with this file could be moved to the
> >next patch.
> >
> >[PATCH 2/2] Check NSCD configuration file
> >You forgot to implement one request I made:
> >
> >You should do a NULL-check for entry and enabled.
> >Otherwise you risk a crash if the line contained one part but not the
> >other.
> >
> >For the "service" part you can either check here or just return 0 from
> >sss_nscd_check_service(), both are fine.
> >
> >>+        if (!strcmp(entry, "enable-cache") &&
> >>+            !strcmp(enabled, "yes")) {
> >>+
> >>+            occured |= sss_nscd_check_service(service);
> >>+        }
> >>+    };

I think we should squash in the attached mini-patch to make ferror
report what actually went wrong. If you agree, can you resend the
patches with the attached one squashed in and I'll ack.
-------------- next part --------------
>From 7142302bb0ff089cd7ae358c3c897096ccd27023 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Tue, 21 May 2013 13:14:44 +0200
Subject: [PATCH] report ferror

---
 src/util/nscd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/util/nscd.c b/src/util/nscd.c
index b2c765011a5c7dd4d7356d1015a5c4621f6d64df..2a06394d3b5a78ab65dcf8f40746c372488f6c05 100644
--- a/src/util/nscd.c
+++ b/src/util/nscd.c
@@ -203,13 +203,16 @@ errno_t sss_nscd_parse_conf(const char *conf_path)
         }
     };
 
-    if (ferror(fp)) {
+    ret = ferror(fp);
+    if (ret) {
         DEBUG(SSSDBG_MINOR_FAILURE, ("Reading NSCD configuration file [%s] "
-                    "ended with failure.\n", NSCD_CONF_PATH));
+              "ended with failure [%d]: %s.\n",
+              NSCD_CONF_PATH, ret, strerror(ret)));
         ret = ENOENT;
         goto done;
     }
 
+    ret = EOK;
     if (occured != 0) {
         ret = EEXIST;
         goto done;
-- 
1.8.2.1



More information about the sssd-devel mailing list