Commit 8dde28ee authored by Justin Azoff's avatar Justin Azoff

When writing out scripts, respect the users umask

--HG--
branch : distribute
extra : rebase_source : d4fc14bcdcd3e1a45da8bdcdef490537863ece35
parent 5be712ee
...@@ -10,7 +10,7 @@ file, or visit the `EasyInstall home page`__. ...@@ -10,7 +10,7 @@ file, or visit the `EasyInstall home page`__.
__ http://packages.python.org/distribute/easy_install.html __ 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 glob import glob
from setuptools import Command, _dont_write_bytecode from setuptools import Command, _dont_write_bytecode
from setuptools.sandbox import run_setup from setuptools.sandbox import run_setup
...@@ -762,12 +762,13 @@ Please make the appropriate changes for your system and try again. ...@@ -762,12 +762,13 @@ Please make the appropriate changes for your system and try again.
target = os.path.join(self.script_dir, script_name) target = os.path.join(self.script_dir, script_name)
self.add_output(target) self.add_output(target)
mask = current_umask()
if not self.dry_run: if not self.dry_run:
ensure_directory(target) ensure_directory(target)
f = open(target,"w"+mode) f = open(target,"w"+mode)
f.write(contents) f.write(contents)
f.close() f.close()
chmod(target,0755) chmod(target, 0777-mask)
...@@ -1870,6 +1871,11 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod): ...@@ -1870,6 +1871,11 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod):
except os.error: except os.error:
onerror(os.rmdir, path, sys.exc_info()) onerror(os.rmdir, path, sys.exc_info())
def current_umask():
tmp = os.umask(022)
os.umask(tmp)
return tmp
def bootstrap(): def bootstrap():
# This function is called when setuptools*.egg is run using /bin/sh # This function is called when setuptools*.egg is run using /bin/sh
import setuptools; argv0 = os.path.dirname(setuptools.__path__[0]) import setuptools; argv0 = os.path.dirname(setuptools.__path__[0])
......
...@@ -39,15 +39,16 @@ class install_scripts(_install_scripts): ...@@ -39,15 +39,16 @@ class install_scripts(_install_scripts):
def write_script(self, script_name, contents, mode="t", *ignored): def write_script(self, script_name, contents, mode="t", *ignored):
"""Write an executable file to the scripts directory""" """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) log.info("Installing %s script to %s", script_name, self.install_dir)
target = os.path.join(self.install_dir, script_name) target = os.path.join(self.install_dir, script_name)
self.outfiles.append(target) self.outfiles.append(target)
mask = current_umask()
if not self.dry_run: if not self.dry_run:
ensure_directory(target) ensure_directory(target)
f = open(target,"w"+mode) f = open(target,"w"+mode)
f.write(contents) f.write(contents)
f.close() f.close()
chmod(target,0755) chmod(target, 0777-mask)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment