summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-08-15 17:19:50 +0000
committerZac Medico <zmedico@gentoo.org>2008-08-15 17:19:50 +0000
commit09ac9d49e8fc3f50d0be5fb7a9acb54c32e865b9 (patch)
treef4706d223315e1f82f95697e077e338d70b98e29
parent9e6fdfbcb6dbfe57c844a9cd4b00924e1c7758d9 (diff)
downloadportage-09ac9d49e8fc3f50d0be5fb7a9acb54c32e865b9.tar.gz
portage-09ac9d49e8fc3f50d0be5fb7a9acb54c32e865b9.tar.bz2
portage-09ac9d49e8fc3f50d0be5fb7a9acb54c32e865b9.zip
In order to avoid an unhandled InvalidAtom exception, validate atoms from
command line arguments before passing them to unmerge(). Thanks to Cardoe for reporting. svn path=/main/trunk/; revision=11413
-rw-r--r--pym/_emerge/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index d21960449..fcf4ab4a8 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -13678,6 +13678,20 @@ def emerge_main():
elif myaction in ("clean", "unmerge") or \
(myaction == "prune" and "--nodeps" in myopts):
validate_ebuild_environment(trees)
+
+ # Ensure atoms are valid before calling unmerge().
+ # For backward compat, leading '=' is not required.
+ for x in myfiles:
+ if is_valid_package_atom(x) or \
+ is_valid_package_atom("=" + x):
+ continue
+ msg = []
+ msg.append("'%s' is not a valid package atom." % (x,))
+ msg.append("Please check ebuild(5) for full details.")
+ writemsg_level("".join("!!! %s\n" % line for line in msg),
+ level=logging.ERROR, noiselevel=-1)
+ return 1
+
# When given a list of atoms, unmerge
# them in the order given.
ordered = myaction == "unmerge"