changeset 14103:9d8aaa3200a3

make mx respect umask when making jar files
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 06 Mar 2014 18:43:40 -0800
parents 43a80ad2730a
children a38a54030ea2
files mxtool/mx.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Thu Mar 06 18:41:48 2014 -0800
+++ b/mxtool/mx.py	Thu Mar 06 18:43:40 2014 -0800
@@ -2067,6 +2067,8 @@
                 shutil.rmtree(services)
                 # Atomic on Unix
                 shutil.move(tmp, d.path)
+                # Correct the permissions on the temporary file which is created with restrictive permissions
+                os.chmod(d.path, 0o666 & ~currentUmask)
                 archives.append(d.path)
                 # print time.time(), 'move:', tmp, '->', d.path
                 d.notify_updated()
@@ -2092,6 +2094,8 @@
                 # Atomic on Unix
                 jarFile = join(p.dir, p.name + '.jar')
                 shutil.move(tmp, jarFile)
+                # Correct the permissions on the temporary file which is created with restrictive permissions
+                os.chmod(jarFile, 0o666 & ~currentUmask)
                 archives.append(jarFile)
             finally:
                 if exists(tmp):
@@ -2839,6 +2843,8 @@
         os.close(fd)
         # Atomic on Unix
         shutil.move(tmp, zipPath)
+        # Correct the permissions on the temporary file which is created with restrictive permissions
+        os.chmod(zipPath, 0o666 & ~currentUmask)
     finally:
         if exists(tmp):
             os.remove(tmp)
@@ -4039,8 +4045,14 @@
 
 version = VersionSpec("1.0")
 
+currentUmask = None
+
 if __name__ == '__main__':
     # rename this module as 'mx' so it is not imported twice by the commands.py modules
     sys.modules['mx'] = sys.modules.pop('__main__')
 
+    # Capture the current umask since there's no way to query it without mutating it.
+    currentUmask = os.umask(0)
+    os.umask(currentUmask)
+
     main()