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

lib/config: Support symlinked root (fixes #4542, fixes #4353) #4545

Closed

Conversation

AudriusButkevicius
Copy link
Member

Well Tested (TM)

@AudriusButkevicius
Copy link
Member Author

Also, interestingly:

Is it a regular: No
Is it a directory: No
Is it a symlink: Yes


// Users might have the root directory as a symlink or reparse point.
// Furthermore, OneDrive bullcrap uses a magic reparse point to the cloudz...
if !fi.IsDir() && !fi.IsSymlink() {
return errPathMissing
Copy link
Member

Choose a reason for hiding this comment

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

Given that there is now a separate check I think it would be nice to have an errPathNotDir or something that is more descriptive than "missing", as users will not consider it missing.

Maybe even check if the first error os.IsNotExist and only then return errPathMissing, otherwise the error as is? In the name of getting a possibly more concrete and specific error in front of the user.

Oh, and how about a test for this? Just something that creates a directory, creates a symlink to it, and verifies that checkpath on the symlink succeeds. If goos=="windows" and the symlink create fails, t.Skip

@@ -430,6 +431,76 @@ func TestFolderPath(t *testing.T) {
}
}

func TestFolderCheckPath(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("windows")
Copy link
Member

Choose a reason for hiding this comment

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

The test should run on Windows, this already worked afaik on other platforms. The build server runs in developer mode and we should be able to create symlinks just fine, so this test should pass. Not everywhere is the same of course which is why I suggest a t.Skip on error from os.Symlink

Copy link
Member

@calmh calmh Nov 25, 2017

Choose a reason for hiding this comment

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

... in theory. I tested it now, and while I can mklink just fine from a command prompt without any elevation I still get symlink foo ~windows-symlink-test-8366981916958631613: A required privilege is not held by the client. from tests which is annoying. I even rebooted it for good measure with no effect.

Copy link
Member

Choose a reason for hiding this comment

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

Ah. Not only must symlinks be enabled for normal users, the application must also say "please let me create a symlink even though I'm just a normal process", using the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag in the symlink call. That's so fucking stupid.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363866(v=vs.85).aspx

Copy link
Member

Choose a reason for hiding this comment

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

So I guess this is fine, once working, I filed the other one on Go. Maybe you want to contribute the fix there. :)

@calmh
Copy link
Member

calmh commented Nov 25, 2017

With #4548 merged, this test could run on Windows as well.

@imsodin
Copy link
Member

imsodin commented Nov 25, 2017

@st-review lgtm

@st-review
Copy link

@imsodin: Noted! Need another LGTM or explicit merge command.

@calmh
Copy link
Member

calmh commented Nov 26, 2017

@st-review lgtm

@st-review
Copy link

👌 Merged as 95a65bf. Thanks, @AudriusButkevicius!

@st-review st-review closed this Nov 26, 2017
st-review pushed a commit that referenced this pull request Nov 26, 2017
GitHub-Pull-Request: #4545
LGTM: imsodin, calmh
@st-review st-review added the pr-merged Legacy label used in the past for pull requests merged to the main tree label Jan 15, 2018
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 27, 2018
@syncthing syncthing locked and limited conversation to collaborators Nov 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion pr-merged Legacy label used in the past for pull requests merged to the main tree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants