Looking for iptables in PATH

Upstream-commit: dfc3904f778996a449ef5199e36fce6cabfb803a
Component: engine
This commit is contained in:
Shawn Siefkas
2013-03-28 14:02:50 -05:00
parent 7627c4db8d
commit ef4aab72d7
+5 -1
View File
@@ -68,7 +68,11 @@ func networkSize(mask net.IPMask) (int32, error) {
// Wrapper around the iptables command
func iptables(args ...string) error {
if err := exec.Command("/sbin/iptables", args...).Run(); err != nil {
path, err := exec.LookPath("iptables")
if err != nil {
log.Fatal("command not found: iptables")
}
if err := exec.Command(path, args...).Run(); err != nil {
return fmt.Errorf("iptables failed: iptables %v", strings.Join(args, " "))
}
return nil