set owner of cachedir and outdir to SUDO_USER
authorGui Chen <gui.chen@intel.com>
Wed, 16 Oct 2013 08:56:20 +0000 (04:56 -0400)
committerGui Chen <gui.chen@intel.com>
Wed, 16 Oct 2013 10:20:38 +0000 (06:20 -0400)
Change-Id: I95236292fad8d4593631e2defc53fb42a08840c0
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/creator.py

index cfdf208..8a36f03 100644 (file)
@@ -201,6 +201,12 @@ class Creator(cmdln.Cmdln):
               and not os.path.isdir(configmgr.create[cdir]):
                 msger.error('Invalid directory specified: %s' \
                             % configmgr.create[cdir])
+            if not os.path.exists(configmgr.create[cdir]):
+                os.makedirs(configmgr.create[cdir])
+                if os.getenv('SUDO_UID', '') and os.getenv('SUDO_GID', ''):
+                    os.chown(configmgr.create[cdir],
+                             int(os.getenv('SUDO_UID')),
+                             int(os.getenv('SUDO_GID')))
 
         if self.options.local_pkgs_path is not None:
             if not os.path.exists(self.options.local_pkgs_path):