Skip to content

Commit

Permalink
Merge pull request #38804 from alexbleotu/root_dir_fix-2016.3-gh
Browse files Browse the repository at this point in the history
Second attempt to fix prepending of root_dir to paths
  • Loading branch information
cro committed Feb 2, 2017
2 parents 6ffeda3 + b3bdd3b commit cd8077a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,11 +1753,22 @@ def prepend_root_dir(opts, path_options):
'''
root_dir = os.path.abspath(opts['root_dir'])
root_opt = opts['root_dir'].rstrip(os.sep)
def_root_dir = salt.syspaths.ROOT_DIR.rstrip(os.sep)
for path_option in path_options:
if path_option in opts:
path = opts[path_option]
if path == root_opt or path.startswith(root_opt + os.sep):
# When running testsuite, salt.syspaths.ROOT_DIR is often empty
if def_root_dir != '' and (path == def_root_dir or path.startswith(def_root_dir + os.sep)):
# Remove the default root dir so we can add the override
path = path[len(def_root_dir):]
elif path == root_opt or path.startswith(root_opt + os.sep):
# Remove relative root dir so we can add the absolute root dir
path = path[len(root_opt):]
elif os.path.isabs(path_option):
# Absolute path (not default or overriden root_dir)
# No prepending required
continue
# Prepending the root dir
opts[path_option] = salt.utils.path_join(root_dir, path)


Expand Down

0 comments on commit cd8077a

Please sign in to comment.