diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py index af14e3f..4808bb4 100644 --- a/nova/virt/disk/api.py +++ b/nova/virt/disk/api.py @@ -335,10 +335,11 @@ def _join_and_check_path_within_fs(fs, *args): mounted guest fs. Trying to be clever and specifying a path with '..' in it will hit this safeguard. ''' - absolute_path = os.path.realpath(os.path.join(fs, *args)) - if not absolute_path.startswith(os.path.realpath(fs) + '/'): + abs_path, _err = utils.execute('readlink', '-m', os.path.join(fs, *args), + run_as_root=True) + if not abs_path.startswith(os.path.realpath(fs) + '/'): raise exception.Invalid(_('injected file path not valid')) - return absolute_path + return abs_path def _inject_file_into_fs(fs, path, contents, append=False):