diff options
-rw-r--r-- | pym/portage/glsa.py | 4 | ||||
-rw-r--r-- | pym/portage/sets/__init__.py | 4 | ||||
-rw-r--r-- | pym/portage/sets/security.py | 33 |
3 files changed, 33 insertions, 8 deletions
diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py index ee6343640..d8053a820 100644 --- a/pym/portage/glsa.py +++ b/pym/portage/glsa.py @@ -556,7 +556,7 @@ class Glsa: @rtype: Boolean @returns: True if the GLSA was applied, False if not """ - aList = grabfile(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep))) + aList = grabfile(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa")) return (self.nr in aList) def inject(self): @@ -569,7 +569,7 @@ class Glsa: @returns: None """ if not self.isApplied(): - checkfile = open(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep)), "a+") + checkfile = open(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa"), "a+") checkfile.write(self.nr+"\n") checkfile.close() return None diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index d355823cd..ceebab5a2 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -103,7 +103,7 @@ def make_default_sets(configroot, root, profile_paths, settings=None, vdbapi=None, portdbapi=None): from portage.sets.files import StaticFileSet, ConfigFileSet from portage.sets.profiles import PackagesSystemSet - from portage.sets.security import AffectedSet + from portage.sets.security import NewAffectedSet from portage.sets.dbapi import EverythingSet rValue = set() @@ -114,7 +114,7 @@ def make_default_sets(configroot, root, profile_paths, settings=None, rValue.add(myset) rValue.add(PackagesSystemSet("system", profile_paths)) if settings != None and portdbapi != None: - rValue.add(AffectedSet("security", settings, vdbapi, portdbapi)) + rValue.add(NewAffectedSet("security", settings, vdbapi, portdbapi)) else: rValue.add(InternalPackageSet("security")) if vdbapi != None: diff --git a/pym/portage/sets/security.py b/pym/portage/sets/security.py index 4827886a8..cf4af0940 100644 --- a/pym/portage/sets/security.py +++ b/pym/portage/sets/security.py @@ -3,20 +3,34 @@ # $Id$ import portage.glsa as glsa +from portage.util import grabfile +from portage.const import CACHE_PATH +import os from portage.sets import PackageSet class SecuritySet(PackageSet): _operations = ["merge"] - + _skip_applied = False + def __init__(self, name, settings, vardbapi, portdbapi): super(SecuritySet, self).__init__(name) self._settings = settings self._vardbapi = vardbapi self._portdbapi = portdbapi + self._checkfile = os.path.join(os.sep, self._settings["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa") + + def getGlsaList(self, skip_applied): + glsaindexlist = glsa.get_glsa_list(self._settings) + if skip_applied: + applied_list = grabfile(self._checkfile) + glsaindexlist = set(glsaindexlist).difference(applied_list) + glsaindexlist = list(glsaindexlist) + glsaindexlist.sort() + return glsaindexlist def load(self): - glsaindexlist = glsa.get_glsa_list(self._settings) + glsaindexlist = self.getGlsaList(self._skip_applied) atomlist = [] for glsaid in glsaindexlist: myglsa = glsa.Glsa(glsaid, self._settings, self._vardbapi, self._portdbapi) @@ -27,11 +41,22 @@ class SecuritySet(PackageSet): def useGlsa(self, myglsa): return True + + def updateAppliedList(self): + glsaindexlist = self.getGlsaList(True) + applied_list = grabfile(self._checkfile) + for glsaid in glsaindexlist: + myglsa = glsa.Glsa(glsaid, self._settings, self._vardbapi, self._portdbapi) + if not myglsa.isVulnerable(): + applied_list.append(glsaid) + write_atomic(self._checkfile, "\n".join(applied_list)) class NewGlsaSet(SecuritySet): - def useGlsa(self, myglsa): - return not myglsa.isApplied() + _skip_applied = True class AffectedSet(SecuritySet): def useGlsa(self, myglsa): return myglsa.isVulnerable() + +class NewAffectedSet(AffectedSet): + _skip_applied = True |