play around with Popen until it works
authorgregor herrmann <gregoa@debian.org>
Fri, 1 Jul 2016 12:58:29 +0000 (14:58 +0200)
committergregor herrmann <gregoa@debian.org>
Fri, 1 Jul 2016 12:58:29 +0000 (14:58 +0200)
bin/tdyndns_update

index b43286e..ea15832 100755 (executable)
@@ -51,9 +51,8 @@ def blockip_whitelist_add(ip):
        """
        :param ip: ipv4 address
        :raises a BlockipError in case of errors."""
-       command = "-I blockip -s {ip} -j ACCEPT\n\n".format(ip=ip)
-       p = Popen(['iptables'], stdin=PIPE)
-       p.communicate(command)
+       command = "iptables -I blockip -s {ip} -j ACCEPT".format(ip=ip)
+       p = Popen(command, shell=True)
        if p.returncode != 0:
                raise NsupdateError(p.returncode)
 
@@ -62,9 +61,8 @@ def blockip_whitelist_delete(ip):
        """
        :param ip: ipv4 address
        :raises a BlockipError in case of errors."""
-       command = "-D blockip -s {ip} -j ACCEPT\n\n".format(ip=ip)
-       p = Popen(['iptables'], stdin=PIPE)
-       p.communicate(command)
+       command = "iptables -D blockip -s {ip} -j ACCEPT".format(ip=ip)
+       p = Popen(command, shell=True)
        if p.returncode != 0:
                raise NsupdateError(p.returncode)