diff options
author | Ubuntu <ubuntu@cert-jenkins-slave-1-201406-15260.maas> | 2022-08-24 06:05:28 +0000 |
---|---|---|
committer | Ubuntu <ubuntu@cert-jenkins-slave-1-201406-15260.maas> | 2022-08-24 06:05:28 +0000 |
commit | 257202c07dfd4ee8e9f3ac7701a58863a9ddf6ad (patch) | |
tree | 48b02217763961aae3f293de118bc396e476a74a /bin | |
parent | 40b110f7ec11ebe2446501420d6bfe46424dd0d1 (diff) | |
parent | fb7d99717e362b278cf0a350128b048cd172a6bd (diff) |
Merge #428354 from ~narahuang/plainbox-provider-checkbox:lp-1900814-mac-address-passthrough
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mac_passthrough.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/bin/mac_passthrough.py b/bin/mac_passthrough.py index 1707a1e..d57d0f4 100755 --- a/bin/mac_passthrough.py +++ b/bin/mac_passthrough.py @@ -21,7 +21,7 @@ def get_system_mac(): List: Mac addresses of ethernet devices """ mac_addresses = [] - for interface in glob.glob("/sys/class/net/en*/address"): + for interface in glob.glob("/sys/class/net/e*/address"): try: with open(interface, 'r') as iface: mac = iface.read() @@ -69,7 +69,8 @@ def check_mac_passthrough(mac, bios_mac): mac: A list contains MAC addresses from system bios_mac: A string of MAC address from BIOS DSDT table """ - if len(mac) == 2 and mac[0] == mac[1]: + # Check duplicate item in mac list first + if len(mac) != len(set(mac)): print('AUXMAC in DSDT table is identical to onboard NIC MAC, which ' 'means in BIOS setting, it is set to ' '"Integrated NIC 1 MAC Address".') @@ -96,16 +97,14 @@ def check_smbios_token(index): """ smbios_token_cmd = ['smbios-token-ctl', '--token-id='] smbios_token_cmd[1] += index - try: - out = subprocess.check_output(smbios_token_cmd) - for line in out.decode("utf-8").splitlines(): - if 'value: bool' in line: - if 'true' in line: - raise SystemExit('MAC address pass-through ' - 'is disabled in BIOS setting.') - except Exception as err: - raise SystemExit(err) - print('MAC address pass-through is enabled in BIOS setting.') + out = subprocess.run(smbios_token_cmd, check=False, capture_output=True) + for line in out.stdout.decode("utf-8").splitlines(): + if 'value: bool' in line: + if 'true' in line: + raise SystemExit('MAC address pass-through ' + 'is disabled in BIOS setting.') + else: + print('MAC address pass-through is enabled in BIOS setting.') def main(): |