Bug 1459737 - Move closure to module-level function; r?dustin
MozReview-Commit-ID: 2Z2qL8LaEno
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -148,16 +148,23 @@ def get_posix_user_group(user, group):
sys.exit(1)
# Find all groups to which this user is a member.
gids = [g.gr_gid for g in grp.getgrall() if group in g.gr_mem]
return user_record, group_record, gids
+def write_audit_entry(path, msg):
+ now = datetime.datetime.utcnow().isoformat()
+ with open(path, 'ab') as fh:
+ fh.write(b'[%sZ %s] %s\n' % (
+ now, os.environ.get('TASK_ID', 'UNKNOWN'), msg))
+
+
WANTED_DIR_MODE = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
def set_dir_permissions(path, uid, gid):
st = os.lstat(path)
if st.st_uid != uid or st.st_gid != gid:
os.chown(path, uid, gid)
@@ -369,22 +376,16 @@ def main(args):
# Include the UID and GID the task will run as to ensure that tasks
# with different UID and GID don't share the same cache.
if uid is not None:
our_requirements.add(b'uid=%d' % uid)
if gid is not None:
our_requirements.add(b'gid=%d' % gid)
- def write_audit_entry(path, msg):
- now = datetime.datetime.utcnow().isoformat()
- with open(path, 'ab') as fh:
- fh.write(b'[%sZ %s] %s\n' % (
- now, os.environ.get('TASK_ID', 'UNKNOWN'), msg))
-
for cache in caches:
if not os.path.isdir(cache):
print('error: cache %s is not a directory; this should never '
'happen' % cache)
return 1
requires_path = os.path.join(cache, '.cacherequires')
audit_path = os.path.join(cache, '.cachelog')