@@ -7,15 +7,12 @@ import (
77 "fmt"
88 "os/exec"
99 "os/user"
10- "path"
11- "path/filepath"
1210 "regexp"
1311 "runtime"
1412 "strconv"
1513 "strings"
1614 "sync"
1715
18- "github.com/lima-vm/lima/pkg/ioutilx"
1916 . "github.com/lima-vm/lima/pkg/must"
2017 "github.com/lima-vm/lima/pkg/version/versionutil"
2118 "github.com/sirupsen/logrus"
4542// names to the fallback user as well, so the regex does not allow them.
4643var regexUsername = regexp .MustCompile ("^[a-z_][a-z0-9_-]*$" )
4744
48- // regexPath detects valid Linux path.
49- var regexPath = regexp .MustCompile ("^[/a-zA-Z0-9_-]+$" )
50-
5145func LookupUser (name string ) (User , error ) {
5246 if users == nil {
5347 users = make (map [string ]User )
@@ -115,9 +109,8 @@ func LimaUser(limaVersion string, warn bool) *user.User {
115109 warnings = append (warnings , warning )
116110 limaUser .Username = fallbackUser
117111 }
118- if runtime .GOOS != "windows" {
119- limaUser .HomeDir = "/home/{{.User}}.linux"
120- } else {
112+ limaUser .HomeDir = "/home/{{.User}}.linux"
113+ if runtime .GOOS == "windows" {
121114 idu , err := call ([]string {"id" , "-u" })
122115 if err != nil {
123116 logrus .Debug (err )
@@ -146,38 +139,6 @@ func LimaUser(limaVersion string, warn bool) *user.User {
146139 warnings = append (warnings , warning )
147140 limaUser .Gid = formatUidGid (gid )
148141 }
149- home , err := ioutilx .WindowsSubsystemPath (limaUser .HomeDir )
150- if err != nil {
151- logrus .Debug (err )
152- } else {
153- // Trim mount prefix within Subsystem
154- // cygwin/msys2 cygpath could have prefix for drive mounts configured via /etc/fstab
155- // wsl wslpath could have prefix for drive mounts configured via [automount] section in wsl.conf
156- drivePath , err := ioutilx .WindowsSubsystemPath (filepath .VolumeName (limaUser .HomeDir ) + "/" )
157- if err != nil {
158- logrus .Debug (err )
159- } else {
160- prefix := path .Dir (strings .TrimSuffix (drivePath , "/" ))
161- if prefix != "/" {
162- home = strings .TrimPrefix (home , prefix )
163- }
164- home += ".linux"
165- }
166- }
167- if home == "" {
168- drive := filepath .VolumeName (limaUser .HomeDir )
169- home = filepath .ToSlash (limaUser .HomeDir )
170- // replace C: with /c
171- prefix := strings .ToLower (fmt .Sprintf ("/%c" , drive [0 ]))
172- home = strings .Replace (home , drive , prefix , 1 )
173- home += ".linux"
174- }
175- if ! regexPath .MatchString (limaUser .HomeDir ) {
176- warning := fmt .Sprintf ("local home %q is not a valid Linux path (must match %q); using %q home instead" ,
177- limaUser .HomeDir , regexPath .String (), home )
178- warnings = append (warnings , warning )
179- limaUser .HomeDir = home
180- }
181142 }
182143 })
183144 if warn {
0 commit comments