fs: Return blank contents for zero-size files lacking a realfile.

This allows reading from files newly created by touch without error.
This commit is contained in:
Sam Edwards
2016-10-06 14:25:52 -07:00
committed by Michel Oosterhof
parent 731ec40492
commit b5e7d4cc14

View File

@@ -235,6 +235,11 @@ class HoneyPotFilesystem(object):
raise IsADirectoryError
elif f[A_TYPE] == T_FILE and f[A_REALFILE]:
return file(f[A_REALFILE], 'rb').read()
elif f[A_TYPE] == T_FILE and f[A_SIZE] == 0:
# Zero-byte file lacking A_REALFILE backing: probably empty.
# (The exceptions to this are some system files in /proc and /sys,
# but it's likely better to return nothing than suspiciously fail.)
return ''
def mkfile(self, path, uid, gid, size, mode, ctime=None):