Browse Source

feat:firewalld和ufw同时存在时,不进行操作 (#6688)

Co-authored-by: zengzz01 <zengzz01@mingyuanyun.com>
pull/6698/head
zzz 1 month ago committed by GitHub
parent
commit
175b7b89e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      backend/utils/firewall/client.go

11
backend/utils/firewall/client.go

@ -29,10 +29,17 @@ type FirewallClient interface {
} }
func NewFirewallClient() (FirewallClient, error) { func NewFirewallClient() (FirewallClient, error) {
if _, err := os.Stat("/usr/sbin/firewalld"); err == nil { _, firewalldErr := os.Stat("/usr/sbin/firewalld")
_, ufwErr := os.Stat("/usr/sbin/ufw")
if firewalldErr == nil && ufwErr == nil {
return nil, buserr.New("firewalld and ufw both found, only one firewall should be active")
}
if firewalldErr == nil {
return client.NewFirewalld() return client.NewFirewalld()
} }
if _, err := os.Stat("/usr/sbin/ufw"); err == nil { if ufwErr == nil {
return client.NewUfw() return client.NewUfw()
} }
return nil, buserr.New(constant.ErrFirewall) return nil, buserr.New(constant.ErrFirewall)

Loading…
Cancel
Save