From: Sun Lihong Date: Thu, 5 Sep 2013 10:24:57 +0000 (+0800) Subject: Confirm user from pwd.getpwuid to avoid compress failure X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b4dbc88c485d1dce76eb9e5382cb0bc997ae26e;p=tools%2Fmic.git Confirm user from pwd.getpwuid to avoid compress failure 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 --- diff --git a/mic/creator.py b/mic/creator.py index ecacf04..bacea03 100644 --- a/mic/creator.py +++ b/mic/creator.py @@ -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):