[PATCH] No longer need root access for --help

Andrej Manduch amanduch at gmail.com
Tue Jun 9 16:08:29 UTC 2015


From: Andrej Manduch <amanduch at redhat.com>

Previously when user wanted to print out --help message user was forced
to do it under root account which is a quite inpractical.

By moveing `getuid() != 0` check after parse_args it will be
asured that this is no longer the case

Before this patch:
burlak at borg /m/c/liveusb-creator (develop) $ liveusb-creator --help
You must run this application as root

After this patch:
burlak at borg /m/c/liveusb-creator (develop) $ ./liveusb-creator --help
Usage: liveusb-creator [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -c, --console         Use console mode instead of the GUI

Signed-off-by: Andrej Manduch <amanduch at redhat.com>
---
 liveusb-creator | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/liveusb-creator b/liveusb-creator
index 2fcc667..e4d5965 100755
--- a/liveusb-creator
+++ b/liveusb-creator
@@ -72,6 +72,11 @@ def parse_args():
 
 def main():
     opts, args = parse_args()
+    if sys.platform != 'win32':
+        if os.getuid() != 0:
+            print >> sys.stderr, _("You must run this application as root")
+            sys.exit(1)
+
     if opts.console:
         from liveusb import LiveUSBCreator
         try:
@@ -93,8 +98,4 @@ def main():
             pass
 
 if __name__ == '__main__':
-    if sys.platform != 'win32':
-        if os.getuid() != 0:
-            print >> sys.stderr, _("You must run this application as root")
-            sys.exit(1)
     main()
-- 
2.1.0



More information about the liveusb-creator mailing list