Hi Martin,

thanks for the review and the suggestion. Please find the updated patch attached.

Flo.

On 05/30/2016 11:00 AM, Martin Basti wrote:



On 27.05.2016 11:35, Florence Blanc-Renaud wrote:

Hi all,

this patch adds information to the output of ipa-client-install when it fails due to invalid format in a configuration file: ipa-client-install failing with SyntaxError: Syntax Error: Unknown line format

Fixes: https://fedorahosted.org/freeipa/ticket/5811

--
Florence Blanc-Renaud
Identity Management Team, Red Hat


Thank you for your patch, I have just one nitpick. Can you please reuse the original exception?

-            curopts.append(self.parseLine(line))
+            try:
+                curopts.append(self.parseLine(line))
+            except SyntaxError as e:
+ raise SyntaxError('{error} in file {fname}: [{line}]'.format(
+                    error=e, fname=f.name, line=line))

Martin^2

--
Florence Blanc-Renaud
Identity Management Team, Red Hat

From 9fd8c3005905bb2e3eccc0b6b43cf5a5cbdfef3c Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <fren...@redhat.com>
Date: Mon, 23 May 2016 17:18:15 +0200
Subject: [PATCH] Add the culprit line when a configuration file has an
 incorrect format

For instance if /etc/nsswitch.conf contains an incorrect line
sudoers		file sss
(Note the missing : after sudoers)
ipa-client-install exits with a SyntaxError traceback but does not state
which line caused the issue.
With the fix, the filename and the line are displayed in the SyntaxError message.

https://fedorahosted.org/freeipa/ticket/5811
---
 ipaclient/ipachangeconf.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ipaclient/ipachangeconf.py b/ipaclient/ipachangeconf.py
index e73f2978cf512fdfe055f349dba80f4d3275c433..683efee5e7faaba7d2c840bb8d80b6a6863ceac9 100644
--- a/ipaclient/ipachangeconf.py
+++ b/ipaclient/ipachangeconf.py
@@ -460,7 +460,11 @@ class IPAChangeConf:
                 continue
 
             # Copy anything else as is.
-            curopts.append(self.parseLine(line))
+            try:
+                curopts.append(self.parseLine(line))
+            except SyntaxError as e:
+                raise SyntaxError('{error} in file {fname}: [{line}]'.format(
+                    error=e, fname=f.name, line=line))
 
         #Add last section if any
         if len(sectopts) is not 0:
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to