1. Michael Bayer
  2. mako
  3. Issues

Issues

Issue #101 resolved

verify_directory should respect umask

guest
created an issue

Currently util.verify_directory is hardcoding the mode of 0750 in its call to os.makedirs. The following patch checks the umask and passes mode along accordingly:

Index: lib/mako/util.py

--- lib/mako/util.py (revision 439) +++ lib/mako/util.py (working copy) @@ -17,6 +17,7 @@ from StringIO import StringIO

import codecs, re, weakref, os, time +import subprocess

try: import threading @@ -38,7 +39,10 @@ while not os.path.exists(dir): try: tries += 1 - os.makedirs(dir, 0750) + umask, _ = subprocess.Popen(['sh', '-c', 'umask'], stdout=subprocess.PIPE).communicate() + umask = int(umask, 8) + mode = int(oct(0777 ^ umask), 8) + os.makedirs(dir, mode) except: if tries > 5: raise

Comments (7)

  1. guest reporter

    note: the line

    mode = int(oct(0777 ^ umask), 8)

    could of course be simplified to

    mode = 0777 ^ umask

    if you're into the whole brevity thing.

  2. guest reporter

    alternatively it may be preferable to effect more permissions-sensitive behavior via configuration options mako.umask or some such.

  3. Log in to comment