Check the output of iptables command.

This commit is contained in:
Guillaume J. Charmes
2013-11-05 08:33:13 -08:00
parent dcaaecc815
commit ff8a4ba0aa
4 changed files with 46 additions and 17 deletions
+6 -2
View File
@@ -141,9 +141,11 @@ func CreateBridgeIface(config *DaemonConfig) error {
}
if config.EnableIptables {
if err := iptables.Raw("-t", "nat", "-A", "POSTROUTING", "-s", ifaceAddr,
if output, err := iptables.Raw("-t", "nat", "-A", "POSTROUTING", "-s", ifaceAddr,
"!", "-d", ifaceAddr, "-j", "MASQUERADE"); err != nil {
return fmt.Errorf("Unable to enable network bridge NAT: %s", err)
} else if len(output) != 0 {
return fmt.Errorf("Error iptables postrouting: %s", output)
}
}
return nil
@@ -656,8 +658,10 @@ func newNetworkManager(config *DaemonConfig) (*NetworkManager, error) {
if !config.InterContainerCommunication {
if !iptables.Exists(args...) {
utils.Debugf("Disable inter-container communication")
if err := iptables.Raw(append([]string{"-A"}, args...)...); err != nil {
if output, err := iptables.Raw(append([]string{"-A"}, args...)...); err != nil {
return nil, fmt.Errorf("Unable to prevent intercontainer communication: %s", err)
} else if len(output) != 0 {
return nil, fmt.Errorf("Error enabling iptables: %s", output)
}
}
} else {