def __init__(self,
              interface_name,
              address,
              network_prefix,
              perform_username_authentication=False):
     self._chroot = network_chroot.NetworkChroot(interface_name, address,
                                                 network_prefix)
     self._perform_username_authentication = perform_username_authentication
 def __init__(self,
              auth_type,
              interface_name,
              address,
              network_prefix,
              perform_xauth_authentication=False):
     self._auth_type = auth_type
     self._chroot = network_chroot.NetworkChroot(interface_name, address,
                                                 network_prefix)
     self._perform_xauth_authentication = perform_xauth_authentication
Ejemplo n.º 3
0
    def __init__(self, auth_type, interface_name, address, network_prefix,
                 perform_xauth_authentication=False,
                 local_ip_is_public_ip=False):
        self._auth_type = auth_type
        self._chroot = network_chroot.NetworkChroot(interface_name,
                                                    address, network_prefix)
        self._perform_xauth_authentication = perform_xauth_authentication

        if local_ip_is_public_ip:
            self.IPSEC_COMMON_CONFIGS[self.XL2TPD_CONFIG_FILE] = \
                self.IPSEC_COMMON_CONFIGS[self.XL2TPD_CONFIG_FILE].replace(
                    self.SERVER_IP_ADDRESS, address)
            self.SERVER_IP_ADDRESS = address
Ejemplo n.º 4
0
 def start(self):
     """Start up the chrooted Avahi instance."""
     # Prevent weird interactions between services which talk to Avahi.
     # TODO(wiley) Does Chrome need to die here as well?
     self._services = service_stopper.ServiceStopper(self.SERVICES_TO_STOP)
     self._services.stop_services()
     # We don't want Avahi talking to the real world, so give it a nice
     # fake interface to use.  We'll watch the other half of the pair.
     self._vif = virtual_ethernet_pair.VirtualEthernetPair(
         interface_name=self.unchrooted_interface_name,
         peer_interface_name=self.AVAHI_IF_NAME,
         interface_ip=self.MONITOR_IF_IP.netblock,
         peer_interface_ip=self.AVAHI_IF_IP.netblock,
         # Moving one end into the chroot causes errors.
         ignore_shutdown_errors=True)
     self._vif.setup()
     if not self._vif.is_healthy:
         raise error.TestError('Failed to setup virtual ethernet pair.')
     # By default, take a packet capture of everything Avahi sends out.
     self._tcpdump = tcpdump.Tcpdump(self.unchrooted_interface_name,
                                     self.TCPDUMP_FILE_PATH)
     # We're going to run Avahi in a network namespace to avoid interactions
     # with the outside world.
     self._chroot = network_chroot.NetworkChroot(
         self.AVAHI_IF_NAME, self.AVAHI_IF_IP.addr,
         self.AVAHI_IF_IP.prefix_len)
     self._chroot.add_config_templates(self.AVAHI_CONFIGS)
     self._chroot.add_root_directories(['etc/avahi', 'etc/avahi/services'])
     self._chroot.add_copied_config_files(
         ['etc/resolv.conf', 'etc/avahi/hosts'])
     self._chroot.add_startup_command(
         '/usr/sbin/avahi-daemon --file=/%s >%s 2>&1' %
         (self.AVAHI_CONFIG_FILE, self.AVAHI_LOG_FILE))
     self._chroot.bridge_dbus_namespaces()
     self._chroot.startup()
     # Wait for Avahi to come up, claim its DBus name, settle on a hostname.
     start_time = time.time()
     while time.time() - start_time < self.AVAHI_UP_TIMEOUT_SECONDS:
         if avahi_utils.avahi_ping():
             break
         time.sleep(0.2)
     else:
         raise error.TestFail('Avahi did not come up in time.')
 def __init__(self):
     self._arp_announce = 0
     peer_ip = self.IFACE_IP_BASE + '.1'
     peer_interface_ip = peer_ip + '/' + str(self.IFACE_NETWORK_PREFIX)
     self.vif = virtual_ethernet_pair.VirtualEthernetPair(
         interface_name=self.IFACE_NAME,
         peer_interface_name=self.PEER_IFACE_NAME,
         interface_ip=None,
         peer_interface_ip=peer_interface_ip,
         ignore_shutdown_errors=True)
     self.chroot = network_chroot.NetworkChroot(self.PEER_IFACE_NAME,
                                                peer_ip,
                                                self.IFACE_NETWORK_PREFIX)
     self.chroot.add_config_templates(self.NETWORK_CHROOT_CONFIG)
     self.chroot.add_startup_command(
         'iptables -I INPUT -p udp --dport 67 -j ACCEPT')
     self.chroot.add_startup_command(
         'iptables -I INPUT -p tcp --dport 80 -j ACCEPT')
     self._dnsmasq_command = self._GetDnsmasqCommand(peer_ip)
     self.chroot.add_startup_command(self._dnsmasq_command)
     self._test_endpoint_command = self._GetTestEndpointCommand()
     self.chroot.add_startup_command(self._test_endpoint_command)