Justin Azoff avatar Justin Azoff committed 916bda1

When writing out scripts, respect the users umask

Comments (0)

Files changed (2)

setuptools/command/easy_install.py

 __ http://packages.python.org/distribute/easy_install.html
 
 """
-import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random
+import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random
 from glob import glob
 from setuptools import Command, _dont_write_bytecode
 from setuptools.sandbox import run_setup
         target = os.path.join(self.script_dir, script_name)
         self.add_output(target)
 
+        mask = current_umask()
         if not self.dry_run:
             ensure_directory(target)
             f = open(target,"w"+mode)
             f.write(contents)
             f.close()
-            chmod(target,0755)
+            chmod(target, 0777-mask)
 
 
 
     except os.error:
         onerror(os.rmdir, path, sys.exc_info())
 
+def current_umask():
+    tmp = os.umask(022)
+    os.umask(tmp)
+    return tmp
+
 def bootstrap():
     # This function is called when setuptools*.egg is run using /bin/sh
     import setuptools; argv0 = os.path.dirname(setuptools.__path__[0])

setuptools/command/install_scripts.py

 
     def write_script(self, script_name, contents, mode="t", *ignored):
         """Write an executable file to the scripts directory"""
-        from setuptools.command.easy_install import chmod
+        from setuptools.command.easy_install import chmod, current_umask
         log.info("Installing %s script to %s", script_name, self.install_dir)
         target = os.path.join(self.install_dir, script_name)
         self.outfiles.append(target)
 
+        mask = current_umask()
         if not self.dry_run:
             ensure_directory(target)
             f = open(target,"w"+mode)
             f.write(contents)
             f.close()
-            chmod(target,0755)
+            chmod(target, 0777-mask)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.