commit ea4db66e941720313af2c6b1afb32a74f3e360f4 Author: Michael Bringmann Date: Tue Sep 10 14:31:42 2019 -0500 Safe bootlist update This patch is intended to prevent problems with identifying or parsing the bootlist devices from propagating into the system NVRAM configuration. A number of such problems have been observed when processing USB devices. * If 'bootlist' encounters an invalid OF_DEVPATH entry, it will print an notice, but still continue on to write invalid data to nvram. Changed to abort the script before writing bad data to nvram. * When 'ofpathname' encounters an invalid 'devspec' file or invalid value in a 'devspec' file, while trying to find the logical pathname for a scsi device, it may continue to return the invalid 'devspec' value to the caller/invoking script. Changed to abort with an error message instead of returning that invalid value to a caller like 'bootlist'. Example: # bootlist -m normal sdb # bootlist -m normal -o Could not translate (null)/scsi@0/sd@0,0 to logical device name Signed-off-by: Tyrel Datwyler diff --git a/scripts/bootlist b/scripts/bootlist index 65926d7..acdaf89 100755 --- a/scripts/bootlist +++ b/scripts/bootlist @@ -459,6 +459,7 @@ if [[ ${#LOGICAL_NAMES[*]} -ne 0 ]]; then if [[ -z ${OF_DEVPATH[$ctr]} ]]; then echo "Device ${LOGICAL_NAMES[$ctr]} does not appear to be valid." >&2 + exit 1 else # See if this is an ethernet adapter. If so, the next entries # may be parameters for the bootlist entry. diff --git a/scripts/ofpathname b/scripts/ofpathname index c37c6bd..dc452c4 100755 --- a/scripts/ofpathname +++ b/scripts/ofpathname @@ -803,9 +803,16 @@ l2of_scsi() # move up directories until we find one with devspec information goto_dir $PWD "devspec" - OF_PATH=`$CAT $PWD/devspec` + if [[ -e $PWD/devspec ]]; then + OF_PATH=`$CAT $PWD/devspec` + else + err $ERR_NO_OFPATH + fi + if [[ -z $OF_PATH ]]; then err $ERR_NO_OFPATH + elif [[ ! -e /proc/device-tree/$OF_PATH ]]; then + err $ERR_NO_OFPATH fi local vdev=${OF_PATH%/*}