Skip to content

Commit

Permalink
Fix wsl.conf generation when user-mode-networking is disabled
Browse files Browse the repository at this point in the history
[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <[email protected]>
  • Loading branch information
n1hility committed Nov 27, 2023
1 parent 8e5e060 commit 8e2d5e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions pkg/machine/wsl/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,11 +1150,8 @@ func (v *MachineVM) Set(_ string, opts machine.SetOptions) ([]error, error) {
if v.isRunning() {
update = false
setErrors = append(setErrors, fmt.Errorf("user-mode networking can only be changed when the machine is not running"))
}

if update && *opts.UserModeNetworking {
} else {
dist := toDist(v.Name)

if err := changeDistUserModeNetworking(dist, v.RemoteUsername, v.ImagePath, *opts.UserModeNetworking); err != nil {
update = false
setErrors = append(setErrors, err)
Expand Down
6 changes: 5 additions & 1 deletion pkg/machine/wsl/usermodenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package wsl

import (
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -320,7 +321,10 @@ func (v *MachineVM) obtainUserModeNetLock() (*fileLock, error) {

func changeDistUserModeNetworking(dist string, user string, image string, enable bool) error {
// Only install if user-mode is being enabled and there was an image path passed
if enable && len(image) > 0 {
if enable {
if len(image) <= 0 {
return errors.New("existing machine configuration is corrupt, no image is defined")
}
if err := installUserModeDist(dist, image); err != nil {
return err
}
Expand Down

0 comments on commit 8e2d5e1

Please sign in to comment.