summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-05-21 04:41:13 +0000
committerZac Medico <zmedico@gentoo.org>2006-05-21 04:41:13 +0000
commitb8b2a3ee61134fd9595b7fe53ed83060eb69796b (patch)
treec26c068c477708b51c0f83280497c57e771d7dc0
parent715675785e93a55c3a7579005868770dbf984d27 (diff)
downloadportage-b8b2a3ee61134fd9595b7fe53ed83060eb69796b.tar.gz
portage-b8b2a3ee61134fd9595b7fe53ed83060eb69796b.tar.bz2
portage-b8b2a3ee61134fd9595b7fe53ed83060eb69796b.zip
Validate the CATEGORY data in portage.config.load_infodir() and print a warning message if corruption is detected.
svn path=/main/trunk/; revision=3382
-rw-r--r--pym/portage.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 2a3ec7baa..7522dc18a 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -1448,9 +1448,17 @@ class config:
self.configdict["pkg"][filename] = "-* "+mydata
else:
self.configdict["pkg"][filename] = mydata
- except SystemExit, e:
- raise
- except:
+ # CATEGORY is important because it's used in doebuild
+ # to infer the cpv. If it's corrupted, it leads to
+ # strange errors later on, so we'll validate it and
+ # print a warning if necessary.
+ if filename == "CATEGORY":
+ matchobj = re.match("[-a-zA-Z0-9_.+]+", mydata)
+ if not matchobj or matchobj.start() != 0 or \
+ matchobj.end() != len(mydata):
+ writemsg("!!! CATEGORY file is corrupt: %s\n" % \
+ os.path.join(infodir, filename))
+ except (OSError, IOError):
writemsg("!!! Unable to read file: %s\n" % infodir+"/"+filename)
pass
return 1