aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/parse/parse_py/ConfHandler.py
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2015-07-31 11:16:46 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-01 11:31:06 +0100
commite691312a3add222b04e7b2f52f8df6abcb9068bf (patch)
treec6fdde1aa3b8db426b3b1393ba63b0fc17fdaa0c /lib/bb/parse/parse_py/ConfHandler.py
parent9b95fa94eaae452ac7814f1e67c2f7a6314c52f1 (diff)
downloadbitbake-e691312a3add222b04e7b2f52f8df6abcb9068bf.tar.gz
bb.parse: properly error out on filesystem errors
We've had a long-standing bug where a legitimate error reading a file (IOError or OSError) is always suppressed as though it was a 'file not found' case. As a concrete example, if you do a `chmod 000 conf/local.conf`, it'll silently not parse local.conf, rather than erroring to let the user know about the problem. Fix this by handling the ENOENT case specifically. Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/parse/parse_py/ConfHandler.py')
-rw-r--r--lib/bb/parse/parse_py/ConfHandler.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/bb/parse/parse_py/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py
index 250a557cb..fbd75b14a 100644
--- a/lib/bb/parse/parse_py/ConfHandler.py
+++ b/lib/bb/parse/parse_py/ConfHandler.py
@@ -24,8 +24,9 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import re, os
-import logging
+import errno
+import re
+import os
import bb.utils
from bb.parse import ParseError, resolve_file, ast, logger, handle
@@ -92,11 +93,17 @@ def include(parentfn, fn, lineno, data, error_out):
logger.warn("Duplicate inclusion for %s in %s" % (fn, data.getVar('FILE', True)))
try:
- ret = bb.parse.handle(fn, data, True)
- except (IOError, OSError):
- if error_out:
- raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), parentfn, lineno)
- logger.debug(2, "CONF file '%s' not found", fn)
+ bb.parse.handle(fn, data, True)
+ except (IOError, OSError) as exc:
+ if exc.errno == errno.ENOENT:
+ if error_out:
+ raise ParseError("Could not %s file %s" % (error_out, fn), parentfn, lineno)
+ logger.debug(2, "CONF file '%s' not found", fn)
+ else:
+ if error_out:
+ raise ParseError("Could not %s file %s: %s" % (error_out, fn, exc.strerror), parentfn, lineno)
+ else:
+ raise ParseError("Error parsing %s: %s" % (fn, exc.strerror), parentfn, lineno)
# We have an issue where a UI might want to enforce particular settings such as
# an empty DISTRO variable. If configuration files do something like assigning