Skip to content

Commit

Permalink
Allow privileged ports on WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-iwaniec authored and medyagh committed Aug 8, 2024
1 parent ab81991 commit 75893b3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ func validateFlags(cmd *cobra.Command, drvName string) { //nolint:gocyclo
validateInsecureRegistry()
}

// validatePorts validates that the --ports are not below 1024 for the host and not outside range
// validatePorts validates that the --ports are not outside range
func validatePorts(ports []string) error {
var exposedPorts, hostPorts, portSpecs []string
for _, p := range ports {
Expand All @@ -1386,29 +1386,26 @@ func validatePorts(ports []string) error {
}
}
for _, p := range exposedPorts {
if err := validatePort(p, false); err != nil {
if err := validatePort(p); err != nil {
return err
}
}
for _, p := range hostPorts {
if err := validatePort(p, true); err != nil {
if err := validatePort(p); err != nil {
return err
}
}
return nil
}

func validatePort(port string, isHost bool) error {
func validatePort(port string) error {
p, err := strconv.Atoi(port)
if err != nil {
return errors.Errorf("Sorry, one of the ports provided with --ports flag is not valid: %s", port)
}
if p > 65535 || p < 1 {
return errors.Errorf("Sorry, one of the ports provided with --ports flag is outside range: %s", port)
}
if isHost && detect.IsMicrosoftWSL() && p < 1024 {
return errors.Errorf("Sorry, you cannot use privileged ports on the host (below 1024): %s", port)
}
return nil
}

Expand Down

0 comments on commit 75893b3

Please sign in to comment.