Bug 1409876 - Refuse to perform a VCS checkout into a cache root; r?dustin draft
authorGregory Szorc <gps@mozilla.com>
Wed, 25 Oct 2017 17:23:16 -0700
changeset 686954 4a8a9d1528101d3a6734839c3c7722bb58be7202
parent 686953 af411ca4a3ec46f517eec253395cbf174e9719d2
child 686955 8e5abffbc6b7ee751ad0c74404f622972ad1b154
push id86355
push usergszorc@mozilla.com
push dateThu, 26 Oct 2017 16:53:42 +0000
reviewersdustin
bugs1409876
milestone58.0a1
Bug 1409876 - Refuse to perform a VCS checkout into a cache root; r?dustin This seems like a reasonable thing to enforce. MozReview-Commit-ID: 3BZQSkwRYeN
taskcluster/docker/recipes/run-task
--- a/taskcluster/docker/recipes/run-task
+++ b/taskcluster/docker/recipes/run-task
@@ -466,16 +466,24 @@ def main(args):
             print_line(b'volume', b'changing ownership of volume %s '
                                   b'to %d:%d\n' % (volume, uid, gid))
             set_dir_permissions(volume, uid, gid)
 
     def prepare_checkout_dir(checkout):
         if not checkout:
             return
 
+        # The checkout path becomes the working directory. Since there are
+        # special cache files in the cache's root directory and working
+        # directory purging could blow them away, disallow this scenario.
+        if os.path.exists(os.path.join(checkout, '.cacherequires')):
+            print('error: cannot perform vcs checkout into cache root: %s' %
+                  checkout)
+            sys.exit(1)
+
         # 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.