使用自定义 executils.LookPath() 代替 exec.LookPath() 避免因$PATH环境变量被破坏而无法工作

This commit is contained in:
刘祥超
2023-07-03 10:37:36 +08:00
parent d0bd7bb88d
commit 2c59ae4a5b
14 changed files with 95 additions and 33 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
"github.com/TeaOSLab/EdgeNode/internal/utils"
executils "github.com/TeaOSLab/EdgeNode/internal/utils/exec"
"os/exec"
"runtime"
"strings"
"time"
@@ -87,7 +86,7 @@ func (this *IPTablesAction) runActionSingleIP(action string, listType IPListType
var path = this.config.Path
var err error
if len(path) == 0 {
path, err = exec.LookPath("iptables")
path, err = executils.LookPath("iptables")
if err != nil {
if this.iptablesNotFound {
return nil