Пример #1
0
 def set_unmanaged_by_network_manager(cls, interface):
     Logger.debug(
         "Adding interface \"%s-%s\" as an unmanaged interface to network manager",
         interface, cls.get_mac(interface))
     with open(constants.PATH_CONF_NETWORK_MANAGER, "r") as conf_read:
         conf = conf_read.read().splitlines()
     added = False
     entry = "mac:" + cls.get_mac(interface)
     # Add Entry
     for line in range(0, len(conf)):
         # Add keyfile plugin if it's not enabled
         if conf[line].startswith(
                 "plugins=") and "keyfile" not in conf[line]:
             conf[line] += ",keyfile"
         # Add unmanaged device
         if conf[line].startswith(
                 "unmanaged-devices=") and entry not in conf[line]:
             conf[line] += ";" + entry
             added = True
     # Add the initial unmanaged entry if it was not present
     if not added:
         conf.append("[keyfile]")
         conf.append("unmanaged-devices=" + entry)
     # Write
     with open(constants.PATH_CONF_NETWORK_MANAGER, "w") as conf_write:
         for line in conf:
             conf_write.write(line + "\n")
     # Restart the service
     ProcessUtil.call(["service", "network-manager", "restart"])
     ProcessUtil.call(["service", "networking", "restart"])
Пример #2
0
 def stop(self):
     LoggerCli.info("Stopping")
     ProcessUtil.call(["killall", "dhclient"])
     self.getting_key = False
     if self.drc_sim_c:
         self.drc_sim_c.stop()
     if self.wpa_supplicant:
         self.wpa_supplicant.stop()
Пример #3
0
 def is_interface_wiiu_compatible(cls, interface):
     if not OsUtil.is_linux():
         Logger.extra("Ignoring interface compatibility check for %s",
                      interface)
         return False
     frequency_info = ProcessUtil.get_output(
         ["iwlist", interface, "frequency"])
     return "5." in frequency_info
Пример #4
0
 def wpa_cli(command):
     """
     Makes a system call to wpa_cli_drc
     :param command: command to pass to wpa_cli_drc
     :return: command output
     """
     if isinstance(command, str):
         command = [command]
     return ProcessUtil.get_output(
         ["wpa_cli_drc", "-p", "/var/run/wpa_supplicant_drc"] + command,
         silent=True)
Пример #5
0
 def get_device_unmanaged_entry(cls, interface):
     # Ubuntu 17.04+ and any other Distro after 2017 randomizes the MAC address of the device each time network manager restarts.
     # No Python Library is able to get the Hardware Address so I needed to use a Linux Command
     hwaddress = ProcessUtil.get_output(["ethtool", "-P", interface])
     hwaddressstr = hwaddress[-18:]
     return "interface-name:" + interface + ";mac:" + hwaddressstr
Пример #6
0
 def dhclient(cls, interface):
     ProcessUtil.call(["killall", "dhclient"])
     ProcessUtil.call(["dhclient", interface])
Пример #7
0
 def set_metric(cls, interface, metric):
     ProcessUtil.call(["ifmetric", interface, str(metric)])
Пример #8
0
 def unblock_wlan():
     """
     Make a system call to unblock wlan
     :return: None
     """
     ProcessUtil.call(["rfkill", "unblock", "wlan"])
Пример #9
0
 def kill_wpa():
     """
     Makes a system call to kill wpa_supplicant_drc
     :return: None
     """
     ProcessUtil.call(["killall", "wpa_supplicant_drc"])
Пример #10
0
 def kill_drc_sim_c():
     ProcessUtil.call(["killall", "drc_sim_c"])