jetwhiz / encfs4win

Windows port of EncFS
https://encfs.win
Other
400 stars 41 forks source link

Reverse mode not showing all files ? #98

Closed benrubson closed 5 years ago

benrubson commented 6 years ago

Environment

Description

Using reverse mode does not show all files / directories, even if command is run with administrator rights.

Expected behavior vs. actual behavior

All directories and files should be shown in reverse mode.

Steps to reproduce problem

  1. Start cmd with administrator rights
  2. encfs --reverse "C:\Users" X: (use Null ciphername encryption)
  3. Browse X: and compare to C:\Users

Relevant logs

[DirNode.cpp:667] created FileNode for C:\Users/Default User
[encfs.cpp:129] op: getattr : C:\Users/Default User
[default] [Usr@VMSEVEN] [int __thiscall encfs::RawFileIO::getAttr(struct stat64_cygwin *) const] [RawFileIO.cpp:169] get
Attr error on C:\Users/Default User: Permission denied
[default] [Usr@VMSEVEN] [int __cdecl encfs::withFileNode(const char *,const char *,struct fuse_file_info *,class std::fu
nction<int __cdecl(class encfs::FileNode *)>)] [encfs.cpp:146] op: getattr error: Permission denied

Investigation

Going further, there are some symbolic links in C:\Users, as well as in other directories where I can reproduce the issue. Sounds like as soon as a symlink is encountered, dir listing stops. Could we then simply ignore symlinks in reverse mode (until they are supported by Dokany) ?

Thank you 👍

benrubson commented 6 years ago

I think https://github.com/benrubson/encfs/commit/10c0ddf0deeee81af0e5d60ab0b47890b66b5e59 should correct the issue where a directory listing is interrupted after a non-readable element is encountered. @jetwhiz could it be possible to have a compiled version of encfs4win including this tiny patch, so that I can test if bug is corrected, and then submit this patch to upstream encfs ? Many thx 👍

jetwhiz commented 6 years ago

Hi @benrubson -- it looks like the patch doesn't get rid of it on the Windows side -- I think the error is occurring in the getAttr portion of the code:

2018-03-11 21:44:01,137 VER [encfs.cpp:129] op: getattr : C:\Users/Default/AppData
2018-03-11 21:44:01,152 VER [DirNode.cpp:675] created FileNode for C:\Users/Default/Application Data
2018-03-11 21:44:01,168 VER [encfs.cpp:129] op: getattr : C:\Users/Default/Application Data
2018-03-11 21:44:01,184 DEBUG [default] [jetwhiz@QUAD7] [int __thiscall encfs::RawFileIO::getAttr(struct stat64_cygwin *) const] [RawFileIO.cpp:169] g
etAttr error on C:\Users/Default/Application Data: Permission denied
2018-03-11 21:44:01,215 DEBUG [default] [jetwhiz@QUAD7] [int __cdecl encfs::withFileNode(const char *,const char *,struct fuse_file_info *,class std::
function<int __cdecl(class encfs::FileNode *)>)] [encfs.cpp:146] op: getattr error: Permission denied
2018-03-11 21:44:01,262 VER [DirNode.cpp:675] created FileNode for C:\Users/
2018-03-11 21:44:01,277 VER [encfs.cpp:129] op: getattr : C:\Users/
2018-03-11 21:44:01,277 VER [DirNode.cpp:675] op: getattr : C:\Users/created FileNode for C:\Users/Default

I've included the patched encfs.exe here (zipped up so github will let it be uploaded): encfs.zip

benrubson commented 6 years ago

Thank you very much @jetwhiz 👍 I gave a try to your patched version, and unfortunately it does not correct the issue. Certainly that readdir() does not set errno as expected / explained in readdir(3).

benrubson commented 6 years ago

~~If you then have time to compile the following one with readdir_r() : https://github.com/benrubson/encfs/commit/bb99bd4d66421f7c807db7833356399c5499c9db Thank you !~~

jetwhiz commented 6 years ago

I'm not sure how easy this patch will be to apply, since we aren't using readdir in the Windows version (built-in Windows calls are being used to implement this -- see https://github.com/jetwhiz/encfs4win/blob/master/encfs/compatwin.cpp#L751)

benrubson commented 6 years ago

I think the error is occurring in the getAttr portion of the code

You're right, unix::lstat() returns permission denied on links, which is rather strange.

Do you think this is due to Dokany ?

Dokany mirror does not manage to stat them but does not crash on directory listing (its "getAttr" function must not return the error) :

sc

Dokany fuse_mirror shows them as directories (but it's not a nice solution).

Cygwin itself shows them correctly :

cyg

benrubson commented 6 years ago

I tried to add FILE_FLAG_OPEN_REPARSE_POINT flag to CreateFileW() in order to stat links themselves : https://github.com/jetwhiz/encfs4win/blob/v1.10.1-RC13/encfs/compatwin.cpp#L645 But it does not help...

benrubson commented 6 years ago

Reverse mode also fails on some specific files such as C:\pagefile.sys Error is the same as above, permission denied in getattr, leading to incomplete readdir. Dokany mirror correctly show these files.

benrubson commented 6 years ago

103 may partially help 👍

jetwhiz commented 6 years ago

Great, nice find, @benrubson ! I'll try this out with the modern and legacy Dokan builds