Merge pull request #13381 from nitzmahone/winrm_extension_fix
allow shell plugin to affect remote module filename
This commit is contained in:
commit
e1bcb43e76
4 changed files with 13 additions and 6 deletions
|
@ -400,7 +400,8 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
tmp = self._make_tmp_path()
|
tmp = self._make_tmp_path()
|
||||||
|
|
||||||
if tmp:
|
if tmp:
|
||||||
remote_module_path = self._connection._shell.join_path(tmp, module_name)
|
remote_module_filename = self._connection._shell.get_remote_filename(module_name)
|
||||||
|
remote_module_path = self._connection._shell.join_path(tmp, remote_module_filename)
|
||||||
if module_style == 'old':
|
if module_style == 'old':
|
||||||
# we'll also need a temp file to hold our module arguments
|
# we'll also need a temp file to hold our module arguments
|
||||||
args_file_path = self._connection._shell.join_path(tmp, 'args')
|
args_file_path = self._connection._shell.join_path(tmp, 'args')
|
||||||
|
|
|
@ -301,11 +301,6 @@ class Connection(ConnectionBase):
|
||||||
}}
|
}}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# FUTURE: this sucks- why can't the module/shell stuff do this?
|
|
||||||
with open(in_path, 'r') as temp_file:
|
|
||||||
if temp_file.read(15).lower().startswith('#!powershell') and not out_path.lower().endswith('.ps1'):
|
|
||||||
out_path = out_path + '.ps1'
|
|
||||||
|
|
||||||
script = script_template.format(self._shell._escape(out_path))
|
script = script_template.format(self._shell._escape(out_path))
|
||||||
cmd_parts = self._shell._encode_script(script, as_list=True, strict_mode=False)
|
cmd_parts = self._shell._encode_script(script, as_list=True, strict_mode=False)
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,13 @@ class ShellModule(object):
|
||||||
return path
|
return path
|
||||||
return '"%s"' % path
|
return '"%s"' % path
|
||||||
|
|
||||||
|
# powershell requires that script files end with .ps1
|
||||||
|
def get_remote_filename(self, base_name):
|
||||||
|
if not base_name.strip().lower().endswith('.ps1'):
|
||||||
|
return base_name.strip() + '.ps1'
|
||||||
|
|
||||||
|
return base_name.strip()
|
||||||
|
|
||||||
def path_has_trailing_slash(self, path):
|
def path_has_trailing_slash(self, path):
|
||||||
# Allow Windows paths to be specified using either slash.
|
# Allow Windows paths to be specified using either slash.
|
||||||
path = self._unquote(path)
|
path = self._unquote(path)
|
||||||
|
|
|
@ -47,6 +47,10 @@ class ShellModule(object):
|
||||||
def join_path(self, *args):
|
def join_path(self, *args):
|
||||||
return os.path.join(*args)
|
return os.path.join(*args)
|
||||||
|
|
||||||
|
# some shells (eg, powershell) are snooty about filenames/extensions, this lets the shell plugin have a say
|
||||||
|
def get_remote_filename(self, base_name):
|
||||||
|
return base_name.strip()
|
||||||
|
|
||||||
def path_has_trailing_slash(self, path):
|
def path_has_trailing_slash(self, path):
|
||||||
return path.endswith('/')
|
return path.endswith('/')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue