From 99a57cc5a4ad7d0f2b2f597b9a034c6935bd0cc2 Mon Sep 17 00:00:00 2001 From: desaster Date: Wed, 18 Nov 2009 21:04:35 +0000 Subject: [PATCH] New command: rmdir git-svn-id: https://kippo.googlecode.com/svn/trunk@25 951d7100-d841-11de-b865-b3884708a8e2 --- commands/base.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/commands/base.py b/commands/base.py index b2134f8..4c9e4a3 100644 --- a/commands/base.py +++ b/commands/base.py @@ -72,9 +72,26 @@ class command_mkdir(HoneyPotCommand): if f in [x[A_NAME] for x in dir]: self.writeln( 'mkdir: cannot create directory `test\': File exists') - return + continue dir.append([f, T_DIR, 0, 0, 4096, 16877, time.time(), [], None]) +class command_rmdir(HoneyPotCommand): + def call(self, args): + for f in args.split(' '): + path = self.fs.resolve_path(f, self.honeypot.cwd) + try: + dir = self.fs.get_path('/'.join(path.split('/')[:-1])) + except IndexError: + dir = None + if not dir or f not in [x[A_NAME] for x in dir]: + self.writeln( + 'rmdir: failed to remove `%s\': ' % f + \ + 'No such file or directory') + continue + for i in dir[:]: + if i[A_NAME] == f: + dir.remove(i) + class command_uptime(HoneyPotCommand): def call(self, args): self.writeln(