Confirm user from pwd.getpwuid to avoid compress failure
authorSun Lihong <lihongx.sun@intel.com>
Thu, 5 Sep 2013 10:24:57 +0000 (18:24 +0800)
committerSun Lihong <lihongx.sun@intel.com>
Mon, 9 Sep 2013 03:24:57 +0000 (11:24 +0800)
In case mic compresses the image by tarfile module,it might fail
by pwd.getpwuid blocking; to avoid this,mic takes a comfirm for
user id from pwd.getpwuid after comfirming root permission.

Fixes: #1207

Change-Id: Iaa6a886936d5d6d60ba3b21608fa81d9f4c1a238

mic/creator.py

index ecacf04..bacea03 100644 (file)
@@ -16,6 +16,7 @@
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import os, sys, re
+import pwd
 from optparse import SUPPRESS_HELP
 
 from mic import msger, rt_util
@@ -304,6 +305,11 @@ class Creator(cmdln.Cmdln):
         if os.geteuid() != 0:
             raise msger.error("Root permission is required, abort")
 
+        try:
+            w = pwd.getpwuid(os.geteuid())
+        except KeyError:
+            msger.warning("Might fail in compressing stage for undetermined user")
+
         return argv
 
     def do_auto(self, subcmd, opts, *args):