diff --git a/board/common/rootfs/lib/infix/probe b/board/common/rootfs/lib/infix/probe index a324c729..726af7e7 100755 --- a/board/common/rootfs/lib/infix/probe +++ b/board/common/rootfs/lib/infix/probe @@ -2,13 +2,21 @@ # Probe for various types of harware features #TODO Rewrite this script in python before extending it further -#TODO Remove fallback temporary development hash +#TODO Remove fallback temporary development hash for real hw -gen_qemu_system_file() { +# Fallback for Qemu system, clear text pass: admin +gen_fallback_hash() +{ + # shellcheck disable=SC2016 + echo '{"pwhash": "$5$n2xoZAmITmPYjOTO$pbWHoa1Mu25a0e.akViAf9uWRvUgbq9BbcmzWWaNP0A"}' > /run/system.json +} + +gen_qemu_system_file() +{ vbd_json="$(onieprom /sys/firmware/qemu_fw_cfg/by_name/opt/vbd/raw)" if [ $? -ne 0 ]; then logger -p user.crit -t "probe" "Error, running onieprom tool" - exit 1 + return 1 fi pwhash="$(echo "$vbd_json" | jq -r '.["vendor-extension"][0][1]' | jq -r '.pwhash')" @@ -20,16 +28,19 @@ gen_qemu_system_file() { system_json="$(echo "$vbd_json" | jq -r 'del(."vendor-extension")')" system_json="$(echo "$system_json" | jq --arg val "$pwhash" '. += {"pwhash": $val}')" echo "$system_json" > /run/system.json + + return 0 } -if dmesg | grep -q QEMU || test -d /sys/module/qemu_fw_cfg; then +if [ -f /sys/firmware/qemu_fw_cfg/rev ]; then initctl cond set qemu - gen_qemu_system_file + # NOTE: eventually we want to remove this fallback too, but it needs a bit + # more work, e.g. new qeneth template, to roll out. + gen_qemu_system_file || gen_fallback_hash else # NOTE: All this code will soon go away. echo -e "\n\n\e[31mWARNING! Probe failed to get password hash from hardware\n" \ "Falling back to temporary hash\e[0m\n" > /dev/console - # Clear Test = admin - echo '{"pwhash": "$5$n2xoZAmITmPYjOTO$pbWHoa1Mu25a0e.akViAf9uWRvUgbq9BbcmzWWaNP0A"}' > /run/system.json -fi + gen_fallback_hash +fi