From ab8feff92e06d872259014220bbe0a2a5a12dede Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 5 Jan 2025 07:48:50 +0000 Subject: vendor.sh: set random MAC address *by default* MAC addresses are generic, inside Libreboot images where an Intel GbE region is specified. We commonly get users flashing multiple systems for their own use, and sometimes they complain that they networking broke, because they don't know that the MAC address is identical on each machine. This still doesn't work around the case where the same machine is used, e.g. multiple T440p thinkpads, but if they have one of each model, it can work nicely, because we do in fact change it for various platforms. This change will also reduce the number of people at conferences in the future, where there are multiple Libreboot users, having MAC address conflicts. Changing the MAC address is a good practise, so we enforce good practise. The user can still retain the old behaviour by using this command: ./mk inject libreboot-YYYYMMDD_boardname.tar.xz setmac keep The "keep" argument clears new_mac, which will then skip changing the MAC address. They can also still set an arbitrary MAC address as an argument for setmac, e.g.: ./mk inject libreboot-YYYYMMDD_boardname.tar.xz setmac 00:de:ad:c0:ff:ee This change will be covered in the documentation. Signed-off-by: Leah Rowe --- include/vendor.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/vendor.sh b/include/vendor.sh index 525d04ad..b7a54caf 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -349,15 +349,34 @@ vendor_inject() set +u +e; [ $# -lt 1 ] && $err "No options specified. - $dontflash" eval "`setvars "" nukemode new_mac xchanged`" + # randomise the MAC address by default + # TODO: support setting CBFS MAC address for GA-G41M-ES2L + new_mac="??:??:??:??:??:??" + archive="$1"; [ $# -gt 1 ] && case "$2" in - nuke) nukemode="nuke" ;; + nuke) + new_mac="" + nukemode="nuke" ;; setmac) - new_mac="??:??:??:??:??:??" - [ $# -gt 2 ] && new_mac="$3" ;; + [ $# -gt 2 ] && new_mac="$3" && \ + [ -z "$new_mac" ] && $err \ + "You set an empty MAC address string" ;; *) $err "Unrecognised inject mode: '$2'" esac + # allow the user to skip setting MAC addresses. + # if new_mac is empty, this script skips running nvmutil + [ "$new_mac" = "keep" ] && new_mac="" + + # we don't allow the *user* to clear new_mac, in the setmac + # command, in case the build system is being integrated with + # another, where setmac is relied upon and is being set + # explicitly. this is a preventative error handle, as a courtes + # to that hypothetical user e.g. Linux distro package maintainer + # integrating this build system into their distro. if they used + # a variable for that, and they forgot to initialise it, they'll know. + check_release "$archive" || \ $err "You must run this script on a release archive. - $dontflash" -- cgit v1.2.1