diff --git a/backend/utils/firewall/client/firewalld.go b/backend/utils/firewall/client/firewalld.go index 9ddb7e7f8..db5f70d79 100644 --- a/backend/utils/firewall/client/firewalld.go +++ b/backend/utils/firewall/client/firewalld.go @@ -25,7 +25,7 @@ func (f *Firewall) Name() string { } func (f *Firewall) Status() (string, error) { - stdout, _ := cmd.Exec("firewall-cmd --state") + stdout, _ := cmd.Exec("LANGUAGE=en_US:en firewall-cmd --state") if stdout == "running\n" { return "running", nil } @@ -33,7 +33,7 @@ func (f *Firewall) Status() (string, error) { } func (f *Firewall) Version() (string, error) { - stdout, err := cmd.Exec("firewall-cmd --version") + stdout, err := cmd.Exec("LANGUAGE=en_US:en firewall-cmd --version") if err != nil { return "", fmt.Errorf("load the firewall version failed, err: %s", stdout) } diff --git a/backend/utils/firewall/client/ufw.go b/backend/utils/firewall/client/ufw.go index 3da4b8e1e..e82e29ada 100644 --- a/backend/utils/firewall/client/ufw.go +++ b/backend/utils/firewall/client/ufw.go @@ -17,9 +17,9 @@ type Ufw struct { func NewUfw() (*Ufw, error) { var ufw Ufw if cmd.HasNoPasswordSudo() { - ufw.CmdStr = "sudo ufw" + ufw.CmdStr = "LANGUAGE=en_US:en sudo ufw" } else { - ufw.CmdStr = "ufw" + ufw.CmdStr = "LANGUAGE=en_US:en ufw" } return &ufw, nil } @@ -33,10 +33,6 @@ func (f *Ufw) Status() (string, error) { if stdout == "Status: active\n" { return "running", nil } - stdout1, _ := cmd.Execf("%s status | grep 状态", f.CmdStr) - if stdout1 == "状态: 激活\n" { - return "running", nil - } return "not running", nil }