title: Running iptables on a rooted xoom (android 3 honeycomb)
body: <p>I am trying to add some rules to filter network traffic from/to the device (Xoom WiFi) using iptables. The iptables command is located at /system/bin/iptables in the xoom device running android 3.0.1. I am abel add rules using the adb shell. However i can't seem to do the same through a android app.</p>
  
  <p><strong>With SU</strong></p>
  
  <p>(<code>su -c command</code>). The Xoom has been rooted. And iptables has been granted su permissions thougth the Superuser app(latest version, uptodate su binary):</p>
  
  <p>iptables</p>
  
  <blockquote>
    <p>07-18 09:00:32.990: DEBUG/su(17539): 10054 com.iptables executing 0
    /system/bin/iptables using shell /system/bin/sh : sh 07-18
    09:00:33.010: WARN/su(17546): request rejected (0->0
    /system/bin/iptables)</p>
  </blockquote>
  
  <p>chown</p>
  
  <blockquote>
    <p>07-18 09:02:21.380: WARN/su(17594): request rejected (0->0
    /system/bin/chmod)</p>
  </blockquote>
  
  <p><strong>Without SU</strong></p>
  
  <p>iptables</p>
  
  <blockquote>
    <p>no output. nothing happens. rules don't get added.</p>
  </blockquote>
  
  <p>chown</p>
  
  <blockquote>
    <p>no output. works as expected!?!.</p>
  </blockquote>
  
  <p>How i run the iptables command:</p>
  
  <pre><code>runCommand(new String[] { "su", "-c", "/system/bin/iptables", "-F" });
              runCommand(new String[] { "su", "-c", "/system/bin/iptables", "-A", "OUTPUT", "-d", "184.72.45.145", "-j", "ACCEPT" });
  </code></pre>
  
  <p>The method for running a command:</p>
  
  <pre><code>public static String runCommand(String[] ars) {
      try {
          Process p = Runtime.getRuntime().exec(ars);
          BufferedReader bufferedReader = new BufferedReader(
                  new InputStreamReader(p.getInputStream()));
  
          StringBuffer buffer = new StringBuffer();
          String sCurrentLine;
          while ((sCurrentLine = bufferedReader.readLine()) != null) {
              buffer.append(sCurrentLine);
          }
          return buffer.toString();
      } catch (IOException e) {
          e.printStackTrace();
          return "ERROR";
      }
  }
  </code></pre>
  
  <p>Any ideas? I am hitting a wall. Any help highly appreciated. Thanks!</p>