Hi,

sorry, I do not have working AD so I did
not test the patches. My testing
was only SSSD compilation :)

But I made a small ap that parses
ini files and treats the errors
the same way as in these patches
and it worked fine.

It prints the problematic line
with short error description
(like missing equal sign).

The patch is quite simple. It does not
solve any GPO issues, just logs found
parsing errors for easier debugging.

Michal
>From 0bff25243b18406f88910a88705397365e2e37f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzi...@redhat.com>
Date: Wed, 16 Mar 2016 16:38:34 +0100
Subject: [PATCH] GPO: log specific ini parse error messages

We should log error messages generated by
libini if there are problems with parsing
gpo files.
---
 src/providers/ad/ad_gpo.c       | 19 +++++++++++++++++++
 src/providers/ad/ad_gpo_child.c | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/src/providers/ad/ad_gpo.c b/src/providers/ad/ad_gpo.c
index 069196c..360aca5 100644
--- a/src/providers/ad/ad_gpo.c
+++ b/src/providers/ad/ad_gpo.c
@@ -1131,8 +1131,27 @@ ad_gpo_store_policy_settings(struct sss_domain_info *domain,
 
     ret = ini_config_parse(file_ctx, INI_STOP_ON_NONE, 0, 0, ini_config);
     if (ret != 0) {
+        int lret;
+        char **errors;
+
         DEBUG(SSSDBG_CRIT_FAILURE,
               "ini_config_parse failed [%d][%s]\n", ret, strerror(ret));
+
+        /* Now get specific errors if there are any */
+        lret = ini_config_get_errors(ini_config, &errors);
+        if (lret != 0) {
+            DEBUG(SSSDBG_CRIT_FAILURE,
+                  "Failed to get specific parse error [%d][%s]\n", lret,
+                  strerror(lret));
+            goto done;
+        }
+
+        for (int a = 0; errors[a]; a++) {
+             DEBUG(SSSDBG_CRIT_FAILURE,
+                   "ini_config_parse error %d: %s", a + 1, errors[a]);
+        }
+        ini_config_free_errors(errors);
+
         goto done;
     }
 
diff --git a/src/providers/ad/ad_gpo_child.c b/src/providers/ad/ad_gpo_child.c
index 1b59971..5f21be4 100644
--- a/src/providers/ad/ad_gpo_child.c
+++ b/src/providers/ad/ad_gpo_child.c
@@ -463,8 +463,27 @@ ad_gpo_parse_ini_file(const char *smb_path,
 
     ret = ini_config_parse(file_ctx, INI_STOP_ON_NONE, 0, 0, ini_config);
     if (ret != 0) {
+        int lret;
+        char **errors;
+
         DEBUG(SSSDBG_CRIT_FAILURE,
               "ini_config_parse failed [%d][%s]\n", ret, strerror(ret));
+
+        /* Now get specific errors if there are any */
+        lret = ini_config_get_errors(ini_config, &errors);
+        if (lret != 0) {
+            DEBUG(SSSDBG_CRIT_FAILURE,
+                  "Failed to get specific parse error [%d][%s]\n", lret,
+                  strerror(lret));
+            goto done;
+        }
+
+        for (int i = 0; errors[i]; i++) {
+             DEBUG(SSSDBG_CRIT_FAILURE,
+                   "ini_config_parse error %d: %s", i + 1, errors[i]);
+        }
+        ini_config_free_errors(errors);
+
         goto done;
     }
 
-- 
2.5.0

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/sssd-devel@lists.fedorahosted.org

Reply via email to