Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse mode not showing all files ? #98

Closed
benrubson opened this issue Mar 9, 2018 · 10 comments
Closed

Reverse mode not showing all files ? #98

benrubson opened this issue Mar 9, 2018 · 10 comments
Assignees
Labels

Comments

@benrubson
Copy link

Environment

  • Windows version: 7 SP1
  • Processor architecture: 64 bits
  • Encfs4win version: v1.10.1-RC12
  • Dokan version (legacy, modern): built-in modern, and last modern (1.1.0.2000)

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
Copy link
Author

benrubson commented Mar 9, 2018

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
Copy link
Owner

jetwhiz commented Mar 11, 2018

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
Copy link
Author

benrubson commented Mar 11, 2018

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
Copy link
Author

benrubson commented Mar 11, 2018

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

@jetwhiz jetwhiz self-assigned this Mar 12, 2018
@jetwhiz jetwhiz added the bug label Mar 12, 2018
@jetwhiz
Copy link
Owner

jetwhiz commented Mar 12, 2018

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
Copy link
Author

benrubson commented Mar 13, 2018

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

benrubson commented Mar 16, 2018

#103 may partially help 👍

@jetwhiz
Copy link
Owner

jetwhiz commented Mar 18, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants