Skip to content

Cygwin support - #499

Merged
benrubson merged 9 commits into
vgough:masterfrom
benrubson:cygwin
Mar 26, 2018
Merged

benrubson merged 9 commits into
vgough:masterfrom
benrubson:cygwin

Conversation

@benrubson

@benrubson benrubson commented Mar 25, 2018 •

Copy link
Copy Markdown
Contributor

Hi,

This PR adds support to compile and run EncFS on Cygwin (thus closes #66).
The FUSE layer is handled by WinFsp.
Port history can be found here.

All tests pass, but symlink ones.

The symlink tests results depend one :

There is no real consensus, as no combination of the 2 options make all symlink tests successful, and their configuration may depend on usage / requirements.

See the wiki for installation instructions.

WinFsp may give nice performance improvements possibilities, especially thanks to READDIR_PLUS.
Some work may however be needed to use the WIN readdir API.

Thank you 👍

Ben

sc

@benrubson
benrubson requested a review from rfjakob March 25, 2018 15:58
@benrubson benrubson added this to the 1.9.5 milestone Mar 25, 2018

@rfjakob rfjakob left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! However, please at least fix the shell injection

Comment thread encfs/DirNode.cpp Outdated

int res = 0;
if ((ctx != nullptr) && ctx->lookupNode(plaintextName)) {
if ((ctx != nullptr) && (ctx->numberOfNode(plaintextName) > maxopen)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows does not allow deleting open files, so we can just skip the check.
In other words:

if ( !windows && (ctx != nullptr) && (ctx->numberOfNode(plaintextName) > maxopen)) {

@benrubson benrubson Mar 26, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this yes, thus this will be even more simple 👍

Btw, one question regarding deletion.
Why do we check that the file is no more opened before deleting it ?

fuse(8) :

hard_remove
              The default behavior is that if an open  file  is  deleted,  the
              file  is  renamed  to  a hidden file (.fuse_hiddenXXX), and only
              removed when the file is finally released.   This  relieves  the
              filesystem  implementation  of having to deal with this problem.
              This option disables the hiding behavior, and files are  removed
              immediately  in  an  unlink  operation (or in a rename operation
              which overwrites an existing file).

Just to avoid weird things if hard_remove is in use ?
Can't we rely on the user he knows what he does ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked myself the same thing yesterday, but this code is even older than the git history, and I am not completely sure. It may be related to how encfs shares backing file descriptors between multiple open FUSE file descriptors. I believe they are stored in a table indexed by path.

Comment thread encfs/FileUtils.cpp Outdated
unmount(mountPoint, MNT_FORCE);
#endif
#ifdef __CYGWIN__
system(string("/usr/bin/pkill -f '(^|/)encfs .*/.* ").append(mountPoint).append("?( |$)'").c_str());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell injection vulnerabilty!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review 👍
I think a regex match of mountPoint would do the trick ?
Perhaps you thought about something else ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way is to avoid the shell by using something like execl

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

benrubson added 4 commits March 26, 2018 22:09
When deleting a file, Windows first opens it, deletes it, and closes it.
But Windows does not allow deleting opened files, so no need to check before deletion.
When renaming a file, Windows first opens it, renames it and then closes it.
We then must decrease the target openFiles count.
@benrubson

Copy link
Copy Markdown
Contributor Author

Thank you for your review & approval @rfjakob 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

encfs in cygwin?

2 participants