From 8cd50a92ea913b05327b8291da3d2164993e726e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 25 Jan 2014 13:47:05 -0500 Subject: [PATCH] I realized that the coercion to oct string I was doing was incorrect. >>> oct(int(str('744'), 8)) '0744' >>> oct(int(str(744), 8)) '0744' The second should be '1305'. I just went ahead and made the coercion very explicit with an if switch. I verified that all the unit tests and the previously affected integration test succeed. --- salt/modules/file.py | 10 +++++++++- salt/states/file.py | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 3fde87d988..cd904e86da 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -2795,12 +2795,20 @@ def makedirs_perms(name, raise if tail == os.curdir: # xxx/newdir/. exists if xxx/newdir exists return + + if type(mode) == int: + mode = oct(mode) + elif type(mode) == str: + mode = oct(int(mode, 8)) + else: + mode = None + os.mkdir(name) check_perms(name, None, user, group, - oct(int(str(mode), 8)) if mode else None) + mode) def get_devmm(name): diff --git a/salt/states/file.py b/salt/states/file.py index a3d9462814..63103db224 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -1703,6 +1703,13 @@ def recurse(name, ) return ret + if type(dir_mode) == int: + dir_mode = oct(dir_mode) + elif type(dir_mode) == str: + dir_mode = oct(int(dir_mode, 8)) + else: + dir_mode = None + # Verify the target directory if not os.path.isdir(name): if os.path.exists(name): @@ -1711,7 +1718,7 @@ def recurse(name, ret, 'The path {0} exists and is not a directory'.format(name)) if not __opts__['test']: __salt__['file.makedirs_perms']( - name, user, group, oct(int(str(dir_mode), 8)) if dir_mode else None) + name, user, group, dir_mode) def add_comment(path, comment): comments = ret['comment'].setdefault(path, [])