mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Second attempt to fix prepending of root_dir to paths
This commit is contained in:
parent
3417adc617
commit
97521b3468
1 changed files with 16 additions and 2 deletions
|
@ -1747,12 +1747,26 @@ def prepend_root_dir(opts, path_options):
|
|||
'root_dir' option.
|
||||
'''
|
||||
root_dir = os.path.abspath(opts['root_dir'])
|
||||
root_opt = opts['root_dir'].rstrip(os.sep)
|
||||
root_opt = opts['root_dir']
|
||||
if root_opt.endswith(os.sep):
|
||||
root_opt = root_opt.rstrip(os.sep)
|
||||
def_root_dir = salt.syspaths.ROOT_DIR
|
||||
if def_root_dir.endswith(os.sep):
|
||||
def_root_dir = def_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):
|
||||
if 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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue