-
Notifications
You must be signed in to change notification settings - Fork 12
Consider supporting Windows #15
Description
Your upstream fusepy supports Windows using winfsp.
I was able to get standardnotes-fs to run on Windows but wasn't able to get it to actually work. Because I was originally using dummy gid and uid values, I would get permission denied errors (similar to this user doing a similar migration)
It seems the only change that needs to be made is to have Windows call it's equivalent of getuid() and getgid() and then register the conversion from Windows sid to uid/gid with winfsp. I tried my best but got stuck when trying to convert between the pywin32 sid object and the winfspy cffi binding sid object. They're not the same size and the latter doesn't expose anything do me to use and I'm not familiar enough with the intricacies of these frameworks to get further.
Here's what I ended up with, replaced a few lines in sn_fuse.py
from platform import system
_system = system()
if _system == 'Windows' or _system.startswith('CYGWIN'):
#Convert windows sid to uid and gid with WinFSP
#use WinFSP bindings
from win32security import GetTokenInformation, OpenProcessToken, TOKEN_QUERY, TokenUser
from win32process import GetCurrentProcess
from winfspy.operations import lib
sid = GetTokenInformation(OpenProcessToken(GetCurrentProcess(), TOKEN_READ), TokenUser)
lib.FspPosixMapSidToUid(sid[0], 2) #Errors, here, sid is a PySID (from pywin32), where lib FspPosixMapSidToUid expects a cffi PSID
lib.FspPosixMapSidToUid(sid[0], 3)
self.uid = 2
self.gid = 3
else:
self.uid = os.getuid()
self.gid = os.getgid()