[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] pygrub: Fix command line argument error handling


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Tue, 13 Nov 2012 00:55:14 +0000
  • Delivery-date: Tue, 13 Nov 2012 00:55:25 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Matthew Daley <mattjd@xxxxxxxxx>
# Date 1352739801 0
# Node ID a3cde70320ada4a5424c37f65b8fe3753fc95205
# Parent  1678c7db9b0da1c9de04d0044107251c080b6da4
pygrub: Fix command line argument error handling

pygrub's individual config file parsers do not correctly check the
amount of command line arguments given to them. In addition, the LILO
config parser would report an incorrect message.

Use len() to correctly check the amount of arguments, and fix the LILO
error message.

Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 1678c7db9b0d -r a3cde70320ad tools/pygrub/src/ExtLinuxConf.py
--- a/tools/pygrub/src/ExtLinuxConf.py  Mon Nov 12 17:03:20 2012 +0000
+++ b/tools/pygrub/src/ExtLinuxConf.py  Mon Nov 12 17:03:21 2012 +0000
@@ -207,7 +207,7 @@ class ExtLinuxConfigFile(object):
                  }
         
 if __name__ == "__main__":
-    if sys.argv < 2:
+    if len(sys.argv) < 2:
         raise RuntimeError, "Need a configuration file to read"
     g = ExtLinuxConfigFile(sys.argv[1])
     for i in g.images:
diff -r 1678c7db9b0d -r a3cde70320ad tools/pygrub/src/GrubConf.py
--- a/tools/pygrub/src/GrubConf.py      Mon Nov 12 17:03:20 2012 +0000
+++ b/tools/pygrub/src/GrubConf.py      Mon Nov 12 17:03:21 2012 +0000
@@ -454,7 +454,7 @@ class Grub2ConfigFile(_GrubConfigFile):
                 }
         
 if __name__ == "__main__":
-    if sys.argv < 3:
+    if len(sys.argv) < 3:
         raise RuntimeError, "Need a grub version (\"grub\" or \"grub2\") and a 
grub.conf or grub.cfg to read"
     if sys.argv[1] == "grub":
         g = GrubConfigFile(sys.argv[2])
diff -r 1678c7db9b0d -r a3cde70320ad tools/pygrub/src/LiloConf.py
--- a/tools/pygrub/src/LiloConf.py      Mon Nov 12 17:03:20 2012 +0000
+++ b/tools/pygrub/src/LiloConf.py      Mon Nov 12 17:03:21 2012 +0000
@@ -169,8 +169,8 @@ class LiloConfigFile(object):
                  }
 
 if __name__ == "__main__":
-    if sys.argv < 2:
-        raise RuntimeError, "Need a grub.conf to read"
+    if len(sys.argv) < 2:
+        raise RuntimeError, "Need a lilo.conf to read"
     g = LiloConfigFile(sys.argv[1])
     for i in g.images:
         print i #, i.title, i.root, i.kernel, i.args, i.initrd

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.