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

Fix canonical and read_symlink for junction points #100

Merged
merged 5 commits into from
May 2, 2020

Conversation

Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Feb 3, 2019

Resolving junction points in read_symlink and canonical is wrong making it unusable: It silently returns the wrong results.

Issues identified:

  • read_symlink does not handle junction points and reads the wrong struct
  • canonical tries to resolve the root_name as a symlink. On windows this could be C: and refers to the current working directory on C. Hence depending if the current dir is a symlink canonical resolves the root_name to the current dir which is wrong

Supersedes #45

@Flamefire Flamefire changed the title Fix canonical and read_symlink for junction points WIP: Fix canonical and read_symlink for junction points Feb 3, 2019
@Flamefire Flamefire force-pushed the junction_points branch 6 times, most recently from 8ebc8cb to 4ccd0b4 Compare February 4, 2019 09:28
@Flamefire
Copy link
Contributor Author

@Flamefire Flamefire changed the title WIP: Fix canonical and read_symlink for junction points Fix canonical and read_symlink for junction points Feb 4, 2019
@Flamefire
Copy link
Contributor Author

There is a test failure remaining on MinGW resulting from a to low or missing define for _WIN32_WINNT. What shall be done about this? IMO it should be defined to the value for WinXP at the least if it is not defined and error if it is defined to low. Even WinXP is out-of-support so it can be dropped especially for new boost versions.

@Lastique
Copy link
Member

Lastique commented Feb 5, 2019

Boost doesn't drop Windows versions, it's Windows SDKs that may drop some Windows versions. Legacy MinGW is pretty conservative, it appears to have stopped evolving before it had any reasonable support for NT6 APIs, so XP is a good choice for that target. With regard to Boost.Filesystem, I'm not sure there is any NT6 API used in the library, so it may make sense to target XP on any Windows SDK.

@stima
Copy link
Contributor

stima commented Feb 6, 2019

@Flamefire I added tests for my pull request #102.

@mloskot
Copy link
Member

mloskot commented Dec 19, 2019

Is this PR related to issues and patches submitted here?
https://svn.boost.org/trac10/ticket/10900

@Flamefire
Copy link
Contributor Author

@mloskot It seems it adresses the same issue. Can't really compare the patches though. If this change is wanted, I can rebase

@GitEvgen
Copy link

How do I find out if this has been released and in which version?
Somewhat related to this issue: https://stackoverflow.com/questions/44393241/boostfilesystemrelative-cannot-access-the-file-because-it-is-being-used-by#

@Flamefire
Copy link
Contributor Author

@mloskot @pdimov Requesting review of this PR. Rebased to current develop after the latest changes (indentation and such) caused major conflicts.

Not sure why it has been pending for so long given that on Windows a wrong struct is read which could be a security vulnerability. But also forgot about this before the 1.73 release

Copy link
Member

@mloskot mloskot left a comment

Choose a reason for hiding this comment

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

@Flamefire I did skim the changes, but I'm not an expert of filesystem API. If your test passes, then I take it as all is good.

One nitpick thought, perhaps the test should be disabled on non-Windows completely with something like this <target-os>unix,<build>no

@Flamefire
Copy link
Contributor Author

@mloskot Thanks, that's a good idea. Wasn't that familiar with B2 back then. And syntax of it is hard too, needed a colon, not comma ;-)

@Flamefire
Copy link
Contributor Author

Also fixed a failed conflict resolution. Should be good now. Let's see what CI says. I'm no expert of this either but I'm confident in the changes. Especially as it now doesn't blindly reinterpret_cast a pointer but checks the "enum" first and fails for unknown values.

@mloskot
Copy link
Member

mloskot commented Apr 24, 2020

needed a colon, not comma ;-)

Right, I forgot the , is a conjunction e.g. <target-os>windows,<toolset>gcc:<build>no

@Flamefire Flamefire marked this pull request as draft April 24, 2020 14:02
@Flamefire Flamefire force-pushed the junction_points branch 2 times, most recently from c3e541a to 1a7a5d2 Compare April 24, 2020 16:04
@Flamefire Flamefire force-pushed the junction_points branch 2 times, most recently from c9c0b7d to 6c4768a Compare April 24, 2020 16:54
@Flamefire
Copy link
Contributor Author

@mloskot @Lastique Finally fixed the remaining issues with the test. Factored out some stuff into #142 to keep this PR focused on the bugfix however this is rebased on #142 so that should be merged first.

Flamefire and others added 4 commits May 1, 2020 17:02
Resolving junction points in read_symlink and canonical is wrong
Read the correct struct member depending on the tag
src/operations.cpp Outdated Show resolved Hide resolved
src/operations.cpp Outdated Show resolved Hide resolved
src/operations.cpp Outdated Show resolved Hide resolved
test/issues/99_canonical_with_junction_point.cpp Outdated Show resolved Hide resolved
// This failed before due to broken handling of absolute paths and ignored ReparseTag
int main()
{
if (std::system("mklink /?") != 0)
Copy link
Member

Choose a reason for hiding this comment

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

This check doesn't work on Windows 8.1. mklink exists, it prints help, and then the test decides it doesn't exist and exits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, any other idea? I have no clue why this would return non-zero

Last resort would be to check the below std::system("mklink /j junction real") directly but if that fails due to a bug in the code it will skip everything too.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know why std::system returns 1, but it does. It also returns 1 if the file doesn't exist. I think std::system result is not indicative and not trustworthy, we need to find another way. Possibly, from the Jamfile.

Copy link

Choose a reason for hiding this comment

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

Maybe try running it and check if the link got created. Only skip if it wasn't.
Also the test should include mklink /D ... The failures were different with that type of link. And there could be differences whether it's an absolute or relative link to absolute or relative path.

Copy link
Member

Choose a reason for hiding this comment

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

I've already implemented a different check in the Jamfile.

Copy link
Member

Choose a reason for hiding this comment

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

Another problem with this test is that it doesn't remove the temporary directory it creates. remove_all fails at removing "<temp_dir>/real/sub" with error 32 (directory used by another process).

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.

5 participants