From 34a99b876fc0cdda0a3719aa834d94242c2b318c Mon Sep 17 00:00:00 2001 From: desaster Date: Mon, 25 Oct 2010 14:11:55 +0000 Subject: [PATCH] Fix exception on a command line without a command, like: PATH=. git-svn-id: https://kippo.googlecode.com/svn/trunk@174 951d7100-d841-11de-b865-b3884708a8e2 --- kippo/core/honeypot.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/kippo/core/honeypot.py b/kippo/core/honeypot.py index d36a418..ac93a53 100644 --- a/kippo/core/honeypot.py +++ b/kippo/core/honeypot.py @@ -69,6 +69,12 @@ class HoneyPotShell(object): self.showPrompt() def runCommand(self): + def runOrPrompt(): + if len(self.cmdpending): + self.runCommand() + else: + self.showPrompt() + if not len(self.cmdpending): self.showPrompt() return @@ -85,15 +91,21 @@ class HoneyPotShell(object): # probably no reason to be this comprehensive for just PATH... envvars = copy(self.envvars) + cmd = None while len(cmdAndArgs): - cmd = cmdAndArgs.pop(0) - if cmd.count('='): - key, value = cmd.split('=', 1) + piece = cmdAndArgs.pop(0) + if piece.count('='): + key, value = piece.split('=', 1) envvars[key] = value continue + cmd = piece break args = cmdAndArgs + if not cmd: + runOrPrompt() + return + rargs = [] for arg in args: matches = self.honeypot.fs.resolve_path_wc(arg, self.honeypot.cwd) @@ -109,10 +121,7 @@ class HoneyPotShell(object): print 'Command not found: %s' % (line,) if len(line): self.honeypot.writeln('bash: %s: command not found' % cmd) - if len(self.cmdpending): - self.runCommand() - else: - self.showPrompt() + runOrPrompt() def resume(self): self.honeypot.setInsertMode()