Example #1
0
 def _run_route_add(self, command):
     if platform.system() == 'Linux':
         # TODO(linus) make sure this works. Sadly we can't rely on
         # exit code or output. Maybe get a routing lib for python?
         proc.run(command)
     else:
         proc.run_assert_ok(command)
Example #2
0
 def _verify(self, signature):
     sig_fd, sig_path = tempfile.mkstemp()
     os.write(sig_fd, signature)
     os.close(sig_fd)
     with open(self.ssl_keys.get_master_cert_path(), 'rb') as key_f:
         pubkey = key_f.read()
     command = [bins.openssl, 'rsautl', '-verify',
                '-certin', '-in', sig_path]
     (exitcode, stdout, _) = proc.run(command, pubkey)
     os.remove(sig_path)
     return stdout if exitcode == 0 else None
Example #3
0
 def enable(self):
     """Enable packet filtering."""
     proc.run([self.pfctl, self.pfctl_enable])
Example #4
0
 def _check_commands(self):
     proc.run(self.iptables)
     if self.has_ipv6:
         proc.run(self.ip6tables)
Example #5
0
 def run_command(self, command, must_work=True):
     full_command = ['netsh', 'advfirewall'] + command
     code, out, __ = proc.run(full_command)
     if code != 0 and must_work:
         raise RuntimeError('{} gives stdout: {}'.format(full_command, out))
Example #6
0
 def _run_route_del(self, command):
     if platform.system() == 'Linux':
         # TODO(linus) Same as _run_route_add, better handling.
         proc.run(command)
     else:
         proc.run_assert_ok(command)