elif mode == "fix":
sys.stdout.write("fixing "+myid+"\n")
mergelist = myglsa.getMergeList(least_change=least_change)
+ if mergelist == None:
+ sys.stdout.write(">>> no vulnerable packages installed\n")
+ elif mergelist == []:
+ sys.stdout.write(">>> cannot fix GLSA, no unaffected packages available\n")
+ sys.exit(2)
for pkg in mergelist:
sys.stdout.write(">>> merging "+pkg+"\n")
# using emerge for the actual merging as it contains the dependency
elif mode == "pretend":
sys.stdout.write("Checking GLSA "+myid+"\n")
mergelist = myglsa.getMergeList(least_change=least_change)
+ if mergelist == None:
+ sys.stdout.write(">>> no vulnerable packages installed\n")
+ elif mergelist == []:
+ sys.stdout.write(">>> cannot fix GLSA, no unaffected packages available\n")
+ sys.exit(2)
if mergelist:
sys.stdout.write("The following updates will be performed for this GLSA:\n")
for pkg in mergelist:
I{vulnerableList} and returns string describing
the lowest version for the package that matches an atom in
I{unaffectedList} and is greater than the currently installed
- version or None if the system is not affected. Both
- I{vulnerableList} and I{unaffectedList} should have the
+ version. It will return an empty list if the system is affected,
+ and no upgrade is possible or None if the system is not affected.
+ Both I{vulnerableList} and I{unaffectedList} should have the
same base package.
@type vulnerableList: List of Strings
@return: the lowest unaffected version that is greater than
the installed version.
"""
- rValue = None
+ rValue = ""
v_installed = reduce(operator.add, [match(v, "vartree") for v in vulnerableList], [])
u_installed = reduce(operator.add, [match(u, "vartree") for u in unaffectedList], [])
install_unaffected = False
if install_unaffected:
- return rValue
-
+ return None
+
for u in unaffectedList:
mylist = match(u, "porttree", match_type="match-all")
for c in mylist:
c_pv = portage.catpkgsplit(c)
i_pv = portage.catpkgsplit(portage.best(v_installed))
if portage.pkgcmp(c_pv[1:], i_pv[1:]) > 0 \
- and (rValue == None \
+ and (rValue == "" \
or not match("="+rValue, "porttree") \
or (minimize ^ (portage.pkgcmp(c_pv[1:], portage.catpkgsplit(rValue)[1:]) > 0)) \
and match("="+c, "porttree")) \
for v in path["vul_atoms"]:
rValue = rValue \
or (len(match(v, "vartree")) > 0 \
- and getMinUpgrade(path["vul_atoms"], path["unaff_atoms"]))
+ and None != getMinUpgrade(path["vul_atoms"], path["unaff_atoms"]))
return rValue
def isApplied(self):