MAC spoofing failure handling code tries to reads unexisting files and may not be able to find interface name
Hi,
While working on #17779 (closed), I noticed that mac spoofing (or more precisely tails-shell-library/hardware.sh
's get_name_of_nic
try to read files that may not exists, I believe depending of the driver and its status (the one I tested with, r8188eu
, is in staging).
with bash -x
:
++ get_module_used_by_nic wlan1
+++ readlink /sys/class/net/wlan1/device/driver/module
++ basename ../../../../module/r8188eu
+ module=r8188eu
++ get_name_of_nic wlan1
+++ sed 's/^0x\(.*\)$/\1/' /sys/class/net/wlan1/device/vendor
sed: can't read /sys/class/net/wlan1/device/vendor: No such file or directory
++ vendor=
+++ sed 's/^0x\(.*\)$/\1/' /sys/class/net/wlan1/device/device
sed: can't read /sys/class/net/wlan1/device/device: No such file or directory
++ device=
++ lspci -nn
++ sed -n 's/^\S\+\s\+[^:]\+:\s\+\(.*\)\s\+\[:\].*$/\1/p'
+ nic_name=
+ nic_exists wlan1
+ '[' -e /sys/class/net/wlan1 ']'
It makes the parsing of lspci fragile and seems error prone as it could ends with more unset or empty variables.
Additionally, it rely solely on lspci, and would obviously not find USB adapters, that are quite common.
Parent Task: #14534
Related to: #16707 (closed), #11941 (closed), #16260