From 6ef429550e828cc0092b7e6ee592731e0c2a6812 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Thu, 22 Jun 2023 14:57:39 -0700 Subject: [PATCH] QEMU: Made firewall detction simplier and more robust --- cmd/minikube/cmd/start.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index b919819e83..a248c95135 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -427,7 +427,7 @@ func isBootpdBlocked(cc config.ClusterConfig) bool { klog.Warningf("failed to get firewall state: %v", err) return false } - if !strings.Contains(string(out), "Firewall is enabled") { + if regexp.MustCompile(`Firewall is disabled`).Match(out) { return false } out, err = exec.Command("/usr/libexec/ApplicationFirewall/socketfilterfw", "--listapps").Output() @@ -435,17 +435,7 @@ func isBootpdBlocked(cc config.ClusterConfig) bool { klog.Warningf("failed to list firewall apps: %v", err) return false } - if !strings.Contains(string(out), "/usr/libexec/bootpd") { - return true - } - parts := strings.Split(string(out), `/usr/libexec/bootpd - ( `) - // if bootpd is not in application list it's blocked - if len(parts) == 1 { - return true - } - - return strings.HasPrefix(parts[1], "Block") + return !regexp.MustCompile(`\/usr\/libexec\/bootpd.*\n.*\( Allow`).Match(out) } // unblockBootpdFirewall adds bootpd to the built-in macOS firewall and then unblocks it