On Tue, 2007-05-08 at 09:51 +0200, Tim Lauridsen wrote: > I have added the latest 2 patches to the security plugin in yum-utils > CVS, please checkout that every thing works as expected. > Sorry, here's another one.
It seems that on RHEL5 there are update metadata entries with
references == None (in my FC6 testing they were always == []). This
gives a traceback with the current code. The current CVS version plus
the following patch, which basically does:
def ysp__safe_refs(refs):
""" Sometimes refs == None, if so return the empty list here.
So we don't have to check everywhere. """
if refs == None:
return []
return refs
...around every access of md['references'], works fine.
You didn't break it, and I'm not 100% sure this can happen on Fedora
7 ... but it's better to be safe :). I've also included the one liner to
remove the sys.exit() call, which just plays better with the rest of yum
now that zero length transactions are fixed.
Anyway here is the patch, let me know what you think:
--
James Antill <[EMAIL PROTECTED]>
? refs_eq_None_exit.py
Index: security.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum-utils/plugins/security/security.py,v
retrieving revision 1.3
diff -u -r1.3 security.py
--- security.py 8 May 2007 07:54:18 -0000 1.3
+++ security.py 14 May 2007 14:42:41 -0000
@@ -60,12 +60,19 @@
continue # No metadata found for this repo
return md_info
+def ysp__safe_refs(refs):
+ """ Sometimes refs == None, if so return the empty list here.
+ So we don't have to check everywhere. """
+ if refs == None:
+ return []
+ return refs
+
def ysp_should_filter_pkg(opts, pkg, md, used_map):
""" Do the package filtering for should_show and should_keep. """
def has_id(refs, ref_type, ref_ids):
''' Check if the given ID is a match. '''
- for ref in refs:
+ for ref in ysp__safe_refs(refs):
if ref['type'] != ref_type:
continue
if ref['id'] not in ref_ids:
@@ -92,7 +99,7 @@
if rname == "security":
if md['type'] == 'security':
return md
- for ref in md['references']:
+ for ref in ysp__safe_refs(md['references']):
if ref['type'] != rname:
continue
return md
@@ -146,7 +153,7 @@
# Make the list view much smaller
# ysp_show_pkg_md_info(pkg, md, msg)
if disp and ysp_has_info_md(disp, md):
- for ref in md['references']:
+ for ref in ysp__safe_refs(md['references']):
if ref['type'] != disp:
continue
msg(" %s %-8s %s" % (str(ref['id']), md['type'], pkg))
@@ -374,7 +381,6 @@
conduit.info(2, 'Needed %d packages, for security' % (cnt))
else:
conduit.info(2, 'No packages needed, for security')
- sys.exit(0)
if __name__ == '__main__':
print "This is a plugin that is supposed to run from inside YUM"
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Yum-devel mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
