FUSE: fix negative uid/gid crash, fixes #2674

they could come into archives e.g. when backing up
external drives under cygwin.

(cherry picked from commit ccd066f0af)
This commit is contained in:
Thomas Waldmann 2017-06-13 18:30:42 +02:00
parent 34a821178f
commit 961a2587dc
1 changed files with 6 additions and 3 deletions

View File

@ -60,7 +60,10 @@ class FuseOperations(llfuse.Operations):
self.items = {} self.items = {}
self.parent = {} self.parent = {}
self.contents = defaultdict(dict) self.contents = defaultdict(dict)
self.default_dir = {b'mode': 0o40755, b'mtime': int(time.time() * 1e9), b'uid': os.getuid(), b'gid': os.getgid()} self.default_uid = os.getuid()
self.default_gid = os.getgid()
self.default_dir = {b'mode': 0o40755, b'mtime': int(time.time() * 1e9),
b'uid': self.default_uid, b'gid': self.default_gid}
self.pending_archives = {} self.pending_archives = {}
self.accounted_chunks = {} self.accounted_chunks = {}
self.cache = ItemCache() self.cache = ItemCache()
@ -209,8 +212,8 @@ class FuseOperations(llfuse.Operations):
entry.attr_timeout = 300 entry.attr_timeout = 300
entry.st_mode = item[b'mode'] entry.st_mode = item[b'mode']
entry.st_nlink = item.get(b'nlink', 1) entry.st_nlink = item.get(b'nlink', 1)
entry.st_uid = item[b'uid'] entry.st_uid = item[b'uid'] if item[b'uid'] >= 0 else self.default_uid
entry.st_gid = item[b'gid'] entry.st_gid = item[b'gid'] if item[b'gid'] >= 0 else self.default_gid
entry.st_rdev = item.get(b'rdev', 0) entry.st_rdev = item.get(b'rdev', 0)
entry.st_size = size entry.st_size = size
entry.st_blksize = 512 entry.st_blksize = 512