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

When junctions are hidden, also hide from left pane #297

Merged
merged 3 commits into from
Feb 23, 2022

Conversation

malxau
Copy link
Contributor

@malxau malxau commented Feb 1, 2022

This is to fix #268 . Although it's not what the title says, looking closer at the screenshots, the concern is around seeing junctions in the left pane (which the user does not have access to), even though the setting for "Show Junction Points" is disabled.

This change leverages dwReserved0 to identify the reparse tag, which is now documented behavior but has existed since reparse points were added in Windows 2000. I followed the pattern of having the caller filter junctions, which is not optimal - with dwReserved0 it should be possible to use dwAttrFilter for Junctions too, but that requires carefully scrubbing the code to ensure it's propagated. Most of this change is about propagating it in the left hand pane enumerate.

Also, I'm not stepping back from my comment that the "real" fix is to not have a race condition enumerating the left pane. That change seems large and complex enough that it's likely to introduce bugs and unlikely to be accepted. But the advantage of doing it is to eliminate "network hangs" by doing file system operations on the UI thread, which the current code can't achieve.

@schinagl
Copy link
Contributor

schinagl commented Feb 17, 2022

Used it as part of #303 and it worked fine.
I guess it is smooth a solution to provide the proper attributes ATTR_SYMLINK and ATTR_JUNCTION at that low level to any place.
Also checked the code and fortunately there aren't so many place where WFFindFirst/WFFindNext is used, and they look fine.
If one was forgotten (which I doubt), then we will find out, and have to fix it, but speaking with Din Djarin 'This is the way' ;-)

src/lfn.c Outdated
lpFind->fd.dwFileAttributes |= ATTR_SYMBOLIC;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This code is a much better way to do what DecodeReparsePoint does. We should be able to remove one or both calls to DecodeReparsePoint.

Copy link
Contributor

@schinagl schinagl Feb 23, 2022

Choose a reason for hiding this comment

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

You might want to omit evaluating attributes returned from DecodeReparsePoint() in general, but you can't remove the call to it in wfdirrd.c:781, because it delivers szLinkDest, which is needed. You might omit the call to it in wfdirrd.c:915

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the one caller that can be changed.

@@ -85,8 +92,10 @@ WFFindFirst(
lpFind->nSpaceLeft = MAXPATHLEN-nLen-1;

if (lpFind->hFindFile != INVALID_HANDLE_VALUE) {
DWORD compareAttributes;
compareAttributes = lpFind->fd.dwFileAttributes & ATTR_USED;
lpFind->dwAttrFilter = dwAttrFilter;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary as lpFind->fd.dwFileAttributes was already combined with ATTR_USED.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lpFind->fd.dwFileAttributes are combined with ATTR_USED, then ATTR_JUNCTION/ATTR_SYMBOLIC are added (which are not part of ATTR_USED), then this compare occurs. The intention was not to compare against ATTR_JUNCTION/ATTR_SYMBOLIC. Another approach would be to perform this compare, and if the entry is filtered call FindNext (which adds them); if the entry is not filtered then add them here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to the alternate approach which avoids the back-and-forth conversion, effectively setting ATTR_JUNCTION/ATTR_SYMBOLIC after the decision to return the entry has already been made.

}
}
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This block and the one above at line 676 are doing essentially the same thing. Can we create a method to "SkipJunctionPoints" or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@craigwi craigwi merged commit 48164be into microsoft:master Feb 23, 2022
schinagl pushed a commit to schinagl/winfile that referenced this pull request Feb 24, 2022
craigwi pushed a commit that referenced this pull request Mar 1, 2022
* Solves to problem of winfile following reparse point during deletion of trees and causing ahrm to linked directories

* Also skip one entry in the destination. Not needed during deletion, because there is no destination during delete.

* Adapt to #297. This makes the situation much easier

* Don't follow Reparse Points by using OPER_RMDIR during delete

Co-authored-by: schinagl <hermann@schinagl.priv.at>
Co-authored-by: Hermann Schinagl <hermann.schinagl@avl.com>
@malxau malxau deleted the HideJunctions branch February 5, 2023 19:48
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.

[Symbolic Links] Please add an option to hide Symbolic Links
3 participants