Skip to content

Commit 824182b

Browse files
authored
Merge pull request #4 from gsalvatella/feat/login-shell
Providing a login shell in ssh connections (thanks to @gsalvatella for the contribution)
2 parents 0d3a1be + ab1375b commit 824182b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

connection/SshTarget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def __send_key(self, original_pwd):
8787

8888
def write(self, text):
8989
if self is not None:
90-
self.stdin, self.stdout, self.stderr = self.exec_command(text, environment={'ENV': '/etc/profile'})
90+
cmd = b"/bin/sh --login -c " + text # Provide a login shell to set the environment and locate scripts
91+
self.stdin, self.stdout, self.stderr = self.exec_command(cmd, environment={'ENV': '/etc/profile'})
9192

9293
def read(self):
9394
self.result = str(self.stdout.read(), "utf-8").strip()

connection/wfx_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Standard library imports
99
import logging
1010
import os
11+
import shlex
1112
import sys
1213
import time
1314

@@ -319,7 +320,7 @@ def write(self, text):
319320
for line in text.rstrip().split('\n'):
320321
print(str.format("%-8s S>>| " % self.nickname), end='')
321322
print(line)
322-
self.link.write(bytes(text.rstrip() + '\n', 'utf-8'))
323+
self.link.write(bytes(shlex.quote(text).rstrip() + '\n', 'utf-8'))
323324

324325
def read(self):
325326
if self.link is not None:

0 commit comments

Comments
 (0)