netd: all: use system() instead of logwrap() for now.

The logwrapper uses a blocking read() which does not always
correctly detect when the child process at the other end is gone.
This is a quick workaround for http://b/5144246
A cleaner logwrapper parent() will follow.

Add support for BandwidthController() to use either system() or
logwrap(). It looks at "persist.bandwidth.uselogwrap" to be 0 or 1.

Change-Id: I2d17732214f1a7fef6838eee05d827695b707ab0
Signed-off-by: JP Abgrall <jpa@google.com>
diff --git a/NatController.cpp b/NatController.cpp
index 6406b95..c05aa7b 100644
--- a/NatController.cpp
+++ b/NatController.cpp
@@ -41,29 +41,20 @@
 }
 
 int NatController::runIptablesCmd(const char *cmd) {
-    char buffer[255];
+    char *buffer;
+    size_t len = strnlen(cmd, 255);
+    int res;
 
-    strncpy(buffer, cmd, sizeof(buffer)-1);
-
-    const char *args[16];
-    char *next = buffer;
-    char *tmp;
-
-    args[0] = IPTABLES_PATH;
-    args[1] = "--verbose";
-    int i = 2;
-
-    while ((tmp = strsep(&next, " "))) {
-        args[i++] = tmp;
-        if (i == 16) {
-            LOGE("iptables argument overflow");
-            errno = E2BIG;
-            return -1;
-        }
+    if (len == 255) {
+        LOGE("iptables command too long");
+        errno = E2BIG;
+        return -1;
     }
-    args[i] = NULL;
 
-    return logwrap(i, args, 0);
+    asprintf(&buffer, "%s %s", IPTABLES_PATH, cmd);
+    res = system(buffer);
+    free(buffer);
+    return res;
 }
 
 int NatController::setDefaults() {