this remedies an issue when twistd is run with -n flag.

it will no longer read from stdin in that case
This commit is contained in:
Michel Oosterhof
2016-04-16 10:07:57 +00:00
parent c63339ba65
commit 7fa2178629
2 changed files with 2 additions and 5 deletions

View File

@ -136,8 +136,7 @@ class HoneyPotShell(object):
""" """
""" """
log.msg('CMD: %s' % (line,)) log.msg('CMD: %s' % (line,))
self.lexer = shlex.shlex(punctuation_chars=True); self.lexer = shlex.shlex(instream=line, punctuation_chars=True);
self.lexer.push_source(line)
tokens = [] tokens = []
while True: while True:
try: try:

View File

@ -23,8 +23,7 @@ class shlex:
def __init__(self, instream=None, infile=None, posix=False, def __init__(self, instream=None, infile=None, posix=False,
punctuation_chars=False): punctuation_chars=False):
if isinstance(instream, str): if isinstance(instream, str):
instream = StringIO(instream) instream = BytesIO(instream)
#instream = BytesIO(instream)
if instream is not None: if instream is not None:
self.instream = instream self.instream = instream
self.infile = infile self.infile = infile
@ -83,7 +82,6 @@ class shlex:
def push_source(self, newstream, newfile=None): def push_source(self, newstream, newfile=None):
"Push an input source onto the lexer's input source stack." "Push an input source onto the lexer's input source stack."
if isinstance(newstream, str): if isinstance(newstream, str):
#newstream = StringIO(newstream)
newstream = BytesIO(newstream) newstream = BytesIO(newstream)
self.filestack.appendleft((self.infile, self.instream, self.lineno)) self.filestack.appendleft((self.infile, self.instream, self.lineno))
self.infile = newfile self.infile = newfile