Skip to content

Commit

Permalink
Excluded RD_EXEC_COMMAND from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Abarca committed Jul 20, 2021
1 parent 953ab28 commit b163192
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions contents/winrm_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
PY34 = sys.version_info[0:2] >= (3, 4)
RD = "RD_"
RD_COMMAND = "RD_EXEC_COMMAND"

if PY3:
string_types = str,
Expand All @@ -53,12 +55,9 @@ def run_cmd(self, command, args=(), out_stream=None, err_stream=None):

envs = {}
for a in os.environ:
if a.startswith('RD_'):
if a.startswith(RD) and a != RD_COMMAND:
envs.update({a:os.getenv(a)})

if "RD_EXEC_COMMAND" in envs:
del envs["RD_EXEC_COMMAND"]

# TODO optimize perf. Do not call open/close shell every time
shell_id = self.protocol.open_shell(codepage=65001, env_vars=envs)
command_id = self.protocol.run_command(shell_id, command, args)
Expand Down

0 comments on commit b163192

Please sign in to comment.