On (01/07/16 17:26), Michal Židek wrote:
>Hello!
>
>This patch adds new command config-check
>for sssctl tool. The output looks like this:
>
>
>Issues identified by validators: 3
>[rule/allowed_sections]: Section [SectionFOO] is not allowed. Check for
>typos.
>[rule/allowed_sssd_options]: Attribute 'unlknowww' is not allowed in section
>'sssd'. Check for typos.
>[rule/allowed_sssd_options]: Attribute 'unknown_option' is not allowed in
>section 'sssd'. Check for typos.
>
>Messages generated during configuration merging: 4
>File conf.dd did not match provided patterns. Skipping.
>Errors detected while parsing: /etc/sssd/conf.d/snip-bad.conf.
>Error (5) on line 5: Equal sign is missing.
>Due to errors file /etc/sssd/conf.d/snip-bad.conf is not considered.
>Skipping.
>
>Used configuration snippet files: 1
>/etc/sssd/conf.d/snip-good.conf
>
>
>Currently it can only be used by root and checks only
>configuration in default path.
>
>Michal

>From 864091da5010b75d9c38e87ab3be467b8bc6f8f2 Mon Sep 17 00:00:00 2001
>From: =?UTF-8?q?Michal=20=C5=BDidek?= <[email protected]>
>Date: Fri, 1 Jul 2016 15:10:30 +0200
>Subject: [PATCH 1/4] sss_ini: Small refacoring of  sss_ini_call_validators
>
>Separate logic to fill errobj so that
>the errors can be printed by the caller.
>---
> src/util/sss_ini.c | 49 ++++++++++++++++++++++++++++++++++++-------------
> src/util/sss_ini.h | 12 ++++++++++++
> 2 files changed, 48 insertions(+), 13 deletions(-)
>
>diff --git a/src/util/sss_ini.c b/src/util/sss_ini.c
>index b4dbb07..78f5490 100644
>--- a/src/util/sss_ini.c
>+++ b/src/util/sss_ini.c
>@@ -549,7 +549,6 @@ int sss_ini_call_validators(struct sss_ini_initdata *data,
> {
> #ifdef HAVE_LIBINI_CONFIG_V1_3
>     int ret;
>-    struct ini_cfgobj *rules_cfgobj = NULL;
>     struct ini_errobj *errobj = NULL;
> 
>     ret = ini_errobj_create(&errobj);
>@@ -558,17 +557,12 @@ int sss_ini_call_validators(struct sss_ini_initdata 
>*data,
>         goto done;
>     }
> 
>-    ret = ini_rules_read_from_file(rules_path, &rules_cfgobj);
>+    ret = sss_ini_call_validators_errobj(data,
>+                                         rules_path,
>+                                         errobj);
>     if (ret != EOK) {
>-        DEBUG(SSSDBG_FATAL_FAILURE,
>-              "Failed to read sssd.conf schema %d [%s]\n", ret, 
>strerror(ret));
>-        goto done;
>-    }
>-
>-    ret = ini_rules_check(rules_cfgobj, data->sssd_config, NULL, errobj);
>-    if (ret != EOK) {
>-        DEBUG(SSSDBG_FATAL_FAILURE,
>-              "ini_rules_check failed %d [%s]\n", ret, strerror(ret));
>+        DEBUG(SSSDBG_CRIT_FAILURE,
>+              "Failed to get errors from validators.\n");
>         goto done;
>     }
> 
>@@ -579,10 +573,10 @@ int sss_ini_call_validators(struct sss_ini_initdata 
>*data,
>         ini_errobj_next(errobj);
>     }
> 
>+    ret = EOK;
>+
> done:
>-    if (rules_cfgobj) ini_config_destroy(rules_cfgobj);
>     ini_errobj_destroy(&errobj);
>-
>     return ret;
> #else
>     DEBUG(SSSDBG_TRACE_FUNC,
>@@ -590,3 +584,32 @@ done:
>     return EOK;
> #endif /* HAVE_LIBINI_CONFIG_V1_3 */
> }
>+
>+#ifdef HAVE_LIBINI_CONFIG_V1_3
>+int sss_ini_call_validators_errobj(struct sss_ini_initdata *data,
>+                                   const char *rules_path,
>+                                   struct ini_errobj *errobj)
>+{
>+    int ret;
>+    struct ini_cfgobj *rules_cfgobj = NULL;
>+
>+    ret = ini_rules_read_from_file(rules_path, &rules_cfgobj);
>+    if (ret != EOK) {
>+        DEBUG(SSSDBG_FATAL_FAILURE,
>+              "Failed to read sssd.conf schema %d [%s]\n", ret, 
>strerror(ret));
>+        goto done;
>+    }
>+
>+    ret = ini_rules_check(rules_cfgobj, data->sssd_config, NULL, errobj);
>+    if (ret != EOK) {
>+        DEBUG(SSSDBG_FATAL_FAILURE,
>+              "ini_rules_check failed %d [%s]\n", ret, strerror(ret));
>+        goto done;
>+    }
>+
>+done:
>+    if (rules_cfgobj) ini_config_destroy(rules_cfgobj);
>+
>+    return ret;
>+}
>+#endif /* HAVE_LIBINI_CONFIG_V1_3 */
>diff --git a/src/util/sss_ini.h b/src/util/sss_ini.h
>index 7734bab..77943d6 100644
>--- a/src/util/sss_ini.h
>+++ b/src/util/sss_ini.h
>@@ -27,6 +27,10 @@
> #ifndef __SSS_INI_H__
> #define __SSS_INI_H__
> 
>+#ifdef HAVE_LIBINI_CONFIG_V1_3
>+#include <ini_configobj.h>
>+#endif
>+
> /* Structure declarations */
> 
> /* INI data structure */
>@@ -83,4 +87,12 @@ int sss_confdb_create_ldif(TALLOC_CTX *mem_ctx,
> int sss_ini_call_validators(struct sss_ini_initdata *data,
>                             const char *rules_path);
> 
>+#ifdef HAVE_LIBINI_CONFIG_V1_3
>+/* Get errors from validators with ini_errobj */
>+int sss_ini_call_validators_errobj(struct sss_ini_initdata *data,
>+                                   const char *rules_path,
>+                                   struct ini_errobj *errobj);
>+#endif /* HAVE_LIBINI_CONFIG_V1_3 */
>+
NACK

src/util/sss_ini.h must not contain conditional build.
That's the putpose of implementation file.

Header file shoudl contain just a prototypes
becuase there might be missing prototypes if you forgot
include "config.h" before this header file.

LS
_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to