Browse Source

OS-8428 sysinfo may fail on strings "sanitized" by smbios but are toxic to json (#1065)

Reviewed by: Dan McDonald <danmcd@mnx.io>
Reviewed by: Travis Paul <travis.paul@mnx.io>
Approved by: Dan McDonald <danmcd@mnx.io>
pull/1066/head
Brian Bennett 2 months ago committed by GitHub
parent
commit
27dee23aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/sysinfo

15
src/sysinfo

@ -1,6 +1,7 @@
#!/bin/bash
#
# Copyright 2020 Joyent, Inc.
# Copyright 2022 MNX Cloud, Inc.
#
# Output some info representing the system. Default: JSON
#
@ -113,6 +114,20 @@ function get_smbios_system_info()
-e 's/Family/HW_Family/' \
-e 's/UUID (Endian-corrected)/Fixed_UUID/')
# Platforms that include illumos#13560, smbios may emit "sanitized" strings
# that are not valid json. So we need to pass these through
# JSON.stringify.
eval $(/usr/node/bin/node -e '
console.log("Manufacturer=" + JSON.stringify("'"$Manufacturer"'"))
console.log("Product=" + JSON.stringify("'"$Product"'"))
console.log("HW_Version=" + JSON.stringify("'"$HW_Version"'"))
console.log("Serial_Number=" + JSON.stringify("'"$Serial_Number"'"))
console.log("UUID=" + JSON.stringify("'"$UUID"'"))
console.log("Fixed_UUID=" + JSON.stringify("'"$Fixed_UUID"'"))
console.log("SKU_Number=" + JSON.stringify("'"$SKU_Number"'"))
console.log("HW_Family=" + JSON.stringify("'"$HW_Family"'"))
')
vendor=$(smbios -t SMB_TYPE_BIOS | grep "Vendor: " \
| sed -e 's/^.*Vendor: //;s/ *$//')

Loading…
Cancel
Save