Ticket #4282: permissions.patch

File permissions.patch, 1.4 KB (added by talex5+django@…, 8 years ago)

Fix.

  • django/core/management.py

     
    55from django.core.exceptions import ImproperlyConfigured
    66from optparse import OptionParser
    77from django.utils import termcolors
    8 import os, re, shutil, sys, textwrap
     8import os, re, stat, sys, textwrap
    99
    1010try:
    1111    set
     
    791791flush.help_doc = "Executes ``sqlflush`` on the current database."
    792792flush.args = '[--verbosity] [--noinput]'
    793793
     794def _copy_execute_permission(path_old, path_new):
     795    if hasattr(os, 'chmod'):
     796        st = os.stat(path_old)
     797        mode = stat.S_IMODE(st.st_mode)
     798        if mode & 0111:
     799            new_mode = stat.S_IMODE(os.stat(path_new).st_mode)
     800            os.chmod(path_new, new_mode | 0111)
     801
    794802def _start_helper(app_or_project, name, directory, other_name=''):
    795803    other = {'project': 'app', 'app': 'project'}[app_or_project]
    796804    if not _is_valid_dir_name(name):
     
    821829            fp_old.close()
    822830            fp_new.close()
    823831            try:
    824                 shutil.copymode(path_old, path_new)
     832                _copy_execute_permission(path_old, path_new)
    825833            except OSError:
    826834                sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new))
    827835
Back to Top