Browse code

Looking for iptables in PATH

Shawn Siefkas authored on 2013/03/28 03:29:58
Showing 1 changed files
... ...
@@ -68,7 +68,11 @@ func networkSize(mask net.IPMask) (int32, error) {
68 68
 
69 69
 // Wrapper around the iptables command
70 70
 func iptables(args ...string) error {
71
-	if err := exec.Command("/sbin/iptables", args...).Run(); err != nil {
71
+	path, err := exec.LookPath("iptables")
72
+	if err != nil {
73
+		log.Fatal("command not found: iptables")
74
+	}
75
+	if err := exec.Command(path, args...).Run(); err != nil {
72 76
 		return fmt.Errorf("iptables failed: iptables %v", strings.Join(args, " "))
73 77
 	}
74 78
 	return nil