mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 08:07:42 +00:00
cmd/tailscale/cli: [serve] fix MinGW path conversion (#7964)
Fixes #7963 Signed-off-by: Shayne Sweeney <shayne@tailscale.com>
This commit is contained in:
parent
2e07245384
commit
018a382729
@ -16,6 +16,7 @@
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -412,6 +413,7 @@ func cleanMountPoint(mount string) (string, error) {
|
|||||||
if mount == "" {
|
if mount == "" {
|
||||||
return "", errors.New("mount point cannot be empty")
|
return "", errors.New("mount point cannot be empty")
|
||||||
}
|
}
|
||||||
|
mount = cleanMinGWPathConversionIfNeeded(mount)
|
||||||
if !strings.HasPrefix(mount, "/") {
|
if !strings.HasPrefix(mount, "/") {
|
||||||
mount = "/" + mount
|
mount = "/" + mount
|
||||||
}
|
}
|
||||||
@ -422,6 +424,26 @@ func cleanMountPoint(mount string) (string, error) {
|
|||||||
return "", fmt.Errorf("invalid mount point %q", mount)
|
return "", fmt.Errorf("invalid mount point %q", mount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanMinGWPathConversionIfNeeded strips the EXEPATH prefix from the given
|
||||||
|
// path if the path is a MinGW(ish) (Windows) shell arg.
|
||||||
|
//
|
||||||
|
// MinGW(ish) (Windows) shells perform POSIX-to-Windows path conversion
|
||||||
|
// converting the leading "/" of any shell arg to the EXEPATH, which mangles the
|
||||||
|
// mount point. Strip the EXEPATH prefix if it exists. #7963
|
||||||
|
//
|
||||||
|
// "/C:/Program Files/Git/foo" -> "/foo"
|
||||||
|
func cleanMinGWPathConversionIfNeeded(path string) string {
|
||||||
|
// Only do this on Windows.
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
if _, ok := os.LookupEnv("MSYSTEM"); ok {
|
||||||
|
exepath := filepath.ToSlash(os.Getenv("EXEPATH"))
|
||||||
|
path = strings.TrimPrefix(path, exepath)
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
func expandProxyTarget(source string) (string, error) {
|
func expandProxyTarget(source string) (string, error) {
|
||||||
if !strings.Contains(source, "://") {
|
if !strings.Contains(source, "://") {
|
||||||
source = "http://" + source
|
source = "http://" + source
|
||||||
|
Loading…
x
Reference in New Issue
Block a user