Skip to content

Commit

Permalink
Don't skip links
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
  • Loading branch information
djdv committed May 22, 2018
1 parent b932bd3 commit aaeaf30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions core/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,25 +266,19 @@ func (gw *getWriter) writeExtracted(r io.Reader, fpath string) error {
return sanitizedPath, err
}
extractor.LinkFunc = func(l tar.Link) error {
//remove existing
if _, err := os.Lstat(l.Name); err == nil {
if err = os.Remove(l.Name); err != nil {
return err
}
}

err := os.Symlink(l.Target, l.Name)
if err == nil {
return nil
}
if err != nil && haveLinkCreatePriviledge { // fail only on non-privilege errors
return err
if err != nil {
if haveLinkCreatePriviledge { // non privilege errors
return err
}
return errors.New("Symlink %q->%q cannot be created, user does not have symlink creation privileges (see:https://git.io/vpHKV)\n", l.Name, l.Target)
}

// otherwise skip link creation with a warning
modified = true
fmt.Fprintf(gw.Out, "Symlink %q->%q was skipped, user does not have symlink creation privileges (see:https://git.io/vpHKV)\n", l.Name, l.Target)
return nil
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ If `ipfs.exe` executes and everything matches, then building was successful.

## Troubleshooting
- **Symlinks**
On Windows, a process must hold a special privilege(`SeCreateSymbolicLinkPrivilege`) in order to create [symlinks](<https://en.wikipedia.org/wiki/Symbolic_link>). The way symlinks are implemented on Windows and the default security policies around them have caused some compatibility difficulties. As a result, the current behavior of `go-ipfs` on Windows, is to *not* create links if we do not have the ability to, instead, warning the user which links are being skipped, while still fetching the rest of the contents.
On Windows, a process must hold a special privilege(`SeCreateSymbolicLinkPrivilege`) in order to create [symlinks](<https://en.wikipedia.org/wiki/Symbolic_link>). The way symlinks are implemented on Windows and the default security policies around them have caused some compatibility difficulties.
There are various ways to enable symlink creation, depending on your version of Windows. Currently we support users who hold the [`SeCreateSymbolicLinkPrivilege`](<https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links>), which covers Windows Vista+, as well users who have enabled "Developer Mode" in Windows 10(14972+).
W10+, see this article: <https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/>
Vista+, see this article: <http://answers.perforce.com/articles/KB/3472>
Expand Down

0 comments on commit aaeaf30

Please sign in to comment.