mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
fs: Remove symlink-handling logic from file_contents; that's handled by getfile.
This commit is contained in:
committed by
Michel Oosterhof
parent
6ad3a2ae6b
commit
7f301dfc20
@ -211,22 +211,18 @@ class HoneyPotFilesystem(object):
|
|||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
def file_contents(self, target, count=0):
|
def file_contents(self, target):
|
||||||
"""
|
"""
|
||||||
Retrieve the content of a file in the honeyfs
|
Retrieve the content of a file in the honeyfs
|
||||||
It follows links.
|
It follows links.
|
||||||
It tries A_REALFILE first and then tries honeyfs directory
|
It tries A_REALFILE first and then tries honeyfs directory
|
||||||
"""
|
"""
|
||||||
if count > 8:
|
|
||||||
raise TooManyLevels
|
|
||||||
path = self.resolve_path(target, os.path.dirname(target))
|
path = self.resolve_path(target, os.path.dirname(target))
|
||||||
if not path or not self.exists(path):
|
if not path or not self.exists(path):
|
||||||
raise FileNotFound
|
raise FileNotFound
|
||||||
f = self.getfile(path)
|
f = self.getfile(path)
|
||||||
if f[A_TYPE] == T_DIR:
|
if f[A_TYPE] == T_DIR:
|
||||||
raise IsADirectoryError
|
raise IsADirectoryError
|
||||||
elif f[A_TYPE] == T_LINK:
|
|
||||||
return self.file_contents(f[A_TARGET], count + 1)
|
|
||||||
elif f[A_TYPE] == T_FILE and f[A_REALFILE]:
|
elif f[A_TYPE] == T_FILE and f[A_REALFILE]:
|
||||||
return file(f[A_REALFILE], 'rb').read()
|
return file(f[A_REALFILE], 'rb').read()
|
||||||
realfile = self.realfile(f, '%s/%s' % \
|
realfile = self.realfile(f, '%s/%s' % \
|
||||||
|
|||||||
Reference in New Issue
Block a user