Bug 1391476 - Ensure version control repository have proper permissions; r?chmanchester draft
authorGregory Szorc <gps@mozilla.com>
Thu, 17 Aug 2017 17:14:15 -0700
changeset 648612 e09dc1be296e97fa79287682d21ee2dadc02b994
parent 648580 053f0b0b48635c6a87aefe15ad73f361f0f64f79
child 726873 5b9febe1b16d2dfd8fe4b41f9e3d83b07ffd9a13
push id74810
push userbmo:gps@mozilla.com
push dateFri, 18 Aug 2017 01:20:03 +0000
reviewerschmanchester
bugs1391476
milestone57.0a1
Bug 1391476 - Ensure version control repository have proper permissions; r?chmanchester Before, we only set the owner of the root directory of the repo. If subsequent tasks on the same worker used a different uid/gid, this could lead to filesystem permissions problems. We recursively chown all version control files as a mitigation against permissions failures. This will add overhead to run-task. But it is necessary to eliminate permissions problems, especially on Try. MozReview-Commit-ID: DmS7WWEgrGZ
taskcluster/docker/recipes/run-task
--- a/taskcluster/docker/recipes/run-task
+++ b/taskcluster/docker/recipes/run-task
@@ -282,34 +282,34 @@ def main(args):
         # Ensure the directory for the source checkout exists.
         try:
             os.makedirs(os.path.dirname(checkout))
         except OSError as e:
             if e.errno != errno.EEXIST:
                 raise
 
         # And that it is owned by the appropriate user/group.
-        if running_as_root:
-            os.chown(os.path.dirname(checkout), uid, gid)
+        if running_as_root and os.path.exists(checkout):
+            chown_recursive(checkout, user.pw_name, group.gr_name, uid, gid)
 
     def prepare_hg_store_path():
         # And ensure the shared store path exists and has proper permissions.
         if 'HG_STORE_PATH' not in os.environ:
             print('error: HG_STORE_PATH environment variable not set')
             sys.exit(1)
 
         store_path = os.environ['HG_STORE_PATH']
         try:
             os.makedirs(store_path)
         except OSError as e:
             if e.errno != errno.EEXIST:
                 raise
 
         if running_as_root:
-            os.chown(store_path, uid, gid)
+            chown_recursive(store_path, user.pw_name, group.gr_name, uid, gid)
 
     prepare_checkout_dir(args.vcs_checkout)
     prepare_checkout_dir(args.tools_checkout)
     prepare_hg_store_path()
 
     if running_as_root:
         # Drop permissions to requested user.
         # This code is modeled after what `sudo` was observed to do in a Docker