summaryrefslogtreecommitdiffstats
path: root/ipaclient
diff options
context:
space:
mode:
authorFlorence Blanc-Renaud <frenaud@redhat.com>2016-05-23 17:18:15 +0200
committerMartin Basti <mbasti@redhat.com>2016-06-06 19:06:32 +0200
commitc4a8e64cdf06cf87112bed383a13e865c8550c5b (patch)
tree98c7e7b9a38cea2a4542bbf145b3e32b3c6df460 /ipaclient
parent91ac959fe5df817e2322428acff392d735fa414e (diff)
downloadfreeipa-c4a8e64cdf06cf87112bed383a13e865c8550c5b.tar.gz
freeipa-c4a8e64cdf06cf87112bed383a13e865c8550c5b.tar.xz
freeipa-c4a8e64cdf06cf87112bed383a13e865c8550c5b.zip
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 Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipaclient')
-rw-r--r--ipaclient/ipachangeconf.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/ipaclient/ipachangeconf.py b/ipaclient/ipachangeconf.py
index e73f2978c..1b5167c55 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.rstrip()))
#Add last section if any
if len(sectopts) is not 0: