@@ -7,15 +7,12 @@ import (
7
7
"fmt"
8
8
"os/exec"
9
9
"os/user"
10
- "path"
11
- "path/filepath"
12
10
"regexp"
13
11
"runtime"
14
12
"strconv"
15
13
"strings"
16
14
"sync"
17
15
18
- "github.com/lima-vm/lima/pkg/ioutilx"
19
16
. "github.com/lima-vm/lima/pkg/must"
20
17
"github.com/lima-vm/lima/pkg/version/versionutil"
21
18
"github.com/sirupsen/logrus"
45
42
// names to the fallback user as well, so the regex does not allow them.
46
43
var regexUsername = regexp .MustCompile ("^[a-z_][a-z0-9_-]*$" )
47
44
48
- // regexPath detects valid Linux path.
49
- var regexPath = regexp .MustCompile ("^[/a-zA-Z0-9_-]+$" )
50
-
51
45
func LookupUser (name string ) (User , error ) {
52
46
if users == nil {
53
47
users = make (map [string ]User )
@@ -115,9 +109,8 @@ func LimaUser(limaVersion string, warn bool) *user.User {
115
109
warnings = append (warnings , warning )
116
110
limaUser .Username = fallbackUser
117
111
}
118
- if runtime .GOOS != "windows" {
119
- limaUser .HomeDir = "/home/{{.User}}.linux"
120
- } else {
112
+ limaUser .HomeDir = "/home/{{.User}}.linux"
113
+ if runtime .GOOS == "windows" {
121
114
idu , err := call ([]string {"id" , "-u" })
122
115
if err != nil {
123
116
logrus .Debug (err )
@@ -146,38 +139,6 @@ func LimaUser(limaVersion string, warn bool) *user.User {
146
139
warnings = append (warnings , warning )
147
140
limaUser .Gid = formatUidGid (gid )
148
141
}
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
- }
181
142
}
182
143
})
183
144
if warn {
0 commit comments