Fix potential infinite loop with no error when using recursive makedirs

This commit is contained in:
Nathan Delhaye 2016-08-29 10:30:58 +02:00
parent e4dfc21581
commit 86d5398b28

View file

@ -4609,8 +4609,15 @@ def makedirs_(path,
break
directories_to_create.append(dirname)
current_dirname = dirname
dirname = os.path.dirname(dirname)
if current_dirname == dirname:
raise SaltInvocationError(
'Recursive creation for path \'{0}\' would result in an '
'infinite loop. Please use an absolute path.'.format(dirname)
)
# create parent directories from the topmost to the most deeply nested one
directories_to_create.reverse()
for directory_to_create in directories_to_create: