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.
This commit is contained in:
root 2014-01-25 13:47:05 -05:00
parent 30e9864d66
commit 8cd50a92ea
2 changed files with 17 additions and 2 deletions

View File

@ -2795,12 +2795,20 @@ def makedirs_perms(name,
raise raise
if tail == os.curdir: # xxx/newdir/. exists if xxx/newdir exists if tail == os.curdir: # xxx/newdir/. exists if xxx/newdir exists
return return
if type(mode) == int:
mode = oct(mode)
elif type(mode) == str:
mode = oct(int(mode, 8))
else:
mode = None
os.mkdir(name) os.mkdir(name)
check_perms(name, check_perms(name,
None, None,
user, user,
group, group,
oct(int(str(mode), 8)) if mode else None) mode)
def get_devmm(name): def get_devmm(name):

View File

@ -1703,6 +1703,13 @@ def recurse(name,
) )
return ret 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 # Verify the target directory
if not os.path.isdir(name): if not os.path.isdir(name):
if os.path.exists(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)) ret, 'The path {0} exists and is not a directory'.format(name))
if not __opts__['test']: if not __opts__['test']:
__salt__['file.makedirs_perms']( __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): def add_comment(path, comment):
comments = ret['comment'].setdefault(path, []) comments = ret['comment'].setdefault(path, [])