Added is_link() to core/fs.py to enable cd into symbolic link in

commands/fs.py
This commit is contained in:
HonigBij
2015-08-25 11:07:21 +02:00
parent b81eb226c0
commit c409459272
2 changed files with 10 additions and 0 deletions

View File

@@ -52,6 +52,9 @@ class command_cd(HoneyPotCommand):
if newdir is None:
self.writeln('bash: cd: %s: No such file or directory' % path)
return
if self.fs.is_link(newpath):
f = self.fs.getfile(newpath)
newpath = f[A_TARGET]
if not self.fs.is_dir(newpath):
self.writeln('bash: cd: %s: Not a directory' % path)
return

View File

@@ -185,6 +185,13 @@ class HoneyPotFilesystem(object):
self.newcount += 1
return True
def is_link(self, path):
try:
f = self.getfile(path)
except:
return False
return f[A_TYPE] == T_LINK
def is_dir(self, path):
if path == '/':
return True