[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.4] pygrub: fix non-interactive parsing of grub1 config files
commit 7962c936a4637af4c1562ebd6bcf50d5193d936b Author: Simon Rowe <simon.rowe@xxxxxxxxxxxxx> AuthorDate: Mon Oct 27 16:00:14 2014 +0000 Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CommitDate: Fri Feb 27 15:16:23 2015 +0000 pygrub: fix non-interactive parsing of grub1 config files Changes to handle non-numeric default attributes for grub2 caused run_grub() to attempt to index into the images list using a string. Pull out the code that handles submenus into a new function and use that to ensure sel is numeric. Reported-by: David Scott <dave.scott@xxxxxxxxxx> Signed-off-by: Simon Rowe <simon.rowe@xxxxxxxxxxxxx> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> Reviewed-and-tested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> (cherry picked from commit 4ee393f9d6528640c29a0554fdc6cb3e795fb6e8) --- tools/pygrub/src/pygrub | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index 21265a1..8239499 100644 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -460,11 +460,9 @@ class Grub: del f self.cf.parse(buf) - def run(self): - timeout = int(self.cf.timeout) - + def image_index(self): if self.cf.default.isdigit(): - self.selected_image = int(self.cf.default) + sel = int(self.cf.default) else: # We don't fully support submenus. Look for the leaf value in # "submenu0>submenu1>...>menuentry" and hope that it's unique. @@ -476,16 +474,23 @@ class Grub: break # Map string to index in images array - self.selected_image = 0 + sel = 0 for i in range(len(self.cf.images)): if self.cf.images[i].title == title: - self.selected_image = i + sel = i break # If the selected (default) image doesn't exist we select the first entry - if self.selected_image > len(self.cf.images): + if sel > len(self.cf.images): logging.warning("Default image not found") - self.selected_image = 0 + sel = 0 + + return sel + + def run(self): + timeout = int(self.cf.timeout) + self.selected_image = self.image_index() + self.isdone = False while not self.isdone: self.run_main(timeout) @@ -630,7 +635,7 @@ def run_grub(file, entry, fs, cfg_args): if interactive and not list_entries: curses.wrapper(run_main) else: - sel = g.cf.default + sel = g.image_index() # set the entry to boot as requested if entry is not None: -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.4 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |