From 1b4dbc88c485d1dce76eb9e5382cb0bc997ae26e Mon Sep 17 00:00:00 2001 From: Sun Lihong Date: Thu, 5 Sep 2013 18:24:57 +0800 Subject: [PATCH] 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 --- mic/creator.py | 6 ++++++ 1 file changed, 6 insertions(+) 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): -- 2.7.4