Ticket #6994: 6994.2.patch

File 6994.2.patch, 2.3 KB (added by Antonis Christofides <anthony@…>, 17 years ago)

Updated patch, default umask now 022 instead of 027

  • django/core/servers/fastcgi.py

     
    4040  workdir=DIRECTORY    change to this directory when daemonizing.
    4141  outlog=FILE          write stdout to this file.
    4242  errlog=FILE          write stderr to this file.
     43  umask=UMASK          umask to use when daemonizing (default 022).
    4344
    4445Examples:
    4546  Run a "standard" fastcgi process on a file-descriptor
     
    7374    'maxrequests': 0,
    7475    'outlog': None,
    7576    'errlog': None,
     77    'umask': None,
    7678}
    7779
    7880def fastcgi_help(message=None):
     
    159161        daemon_kwargs['out_log'] = options['outlog']
    160162    if options['errlog']:
    161163        daemon_kwargs['err_log'] = options['errlog']
     164    if options['umask']:
     165        daemon_kwargs['umask'] = int(options['umask'])
    162166
    163167    if daemonize:
    164168        from django.utils.daemonize import become_daemon
  • django/utils/daemonize.py

     
    22import sys
    33
    44if os.name == 'posix':
    5     def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null'):
     5    def become_daemon(our_home_dir='.', out_log='/dev/null',
     6                      err_log='/dev/null', umask=022):
    67        "Robustly turn into a UNIX daemon, running in our_home_dir."
    78        # First fork
    89        try:
     
    1314            sys.exit(1)
    1415        os.setsid()
    1516        os.chdir(our_home_dir)
    16         os.umask(0)
     17        os.umask(umask)
    1718
    1819        # Second fork
    1920        try:
     
    3233        # Set custom file descriptors so that they get proper buffering.
    3334        sys.stdout, sys.stderr = so, se
    3435else:
    35     def become_daemon(our_home_dir='.', out_log=None, err_log=None):
     36    def become_daemon(our_home_dir='.', out_log=None, err_log=None, umask=022):
    3637        """
    3738        If we're not running under a POSIX system, just simulate the daemon
    3839        mode by doing redirections and directory changing.
    3940        """
    4041        os.chdir(our_home_dir)
    41         os.umask(0)
     42        os.umask(umask)
    4243        sys.stdin.close()
    4344        sys.stdout.close()
    4445        sys.stderr.close()
Back to Top