Fix nft run

This commit is contained in:
Timmy Welch 2024-12-24 11:09:11 -08:00
parent 971b8f2521
commit fc2e21cfd6
3 changed files with 18 additions and 7 deletions

View File

@ -1241,13 +1241,15 @@ func Apply(dir, root string, firewall bool) error {
log.Println("Applying custom firewall") log.Println("Applying custom firewall")
cmd := &exec.Cmd{ cmd := &exec.Cmd{
Path: "/user/nft", Path: "/user/nft",
Args: []string{"/user/nft", "-f/etc/firewall.nft"}, Args: []string{"/user/nft", "-ef", "/etc/firewall.nft"},
Env: os.Environ(), Env: cleanEnviron(os.Environ()),
Stdout: os.Stdout, Stdout: os.Stdout,
Stderr: os.Stderr, Stderr: os.Stderr,
} }
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
appendError(fmt.Errorf("firewall: nft: %v", err)) appendError(fmt.Errorf("firewall: nft: %v", err))
} else {
log.Println("Custom firewall successfully applied:", cmd.ProcessState.ExitCode())
} }
} else { } else {
log.Println("Firewall Disabled") log.Println("Firewall Disabled")
@ -1263,3 +1265,12 @@ func Apply(dir, root string, firewall bool) error {
} }
return nil return nil
} }
func cleanEnviron(environ []string) []string {
for i, env := range environ {
if strings.Contains(env, "GOKRAZY") {
environ[i] = ""
}
}
return environ
}