Skip to content

Commit

Permalink
Fix security vulnerability with chmod in tdisplay script
Browse files Browse the repository at this point in the history
  • Loading branch information
epiccurious committed Dec 3, 2023
1 parent e1ec600 commit cd26cd4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions device_specific/flash_the_ttgo_tdisplay
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ fi

echo "LINUX ONLY. Flashing the ${device}..."

if ! command -v cmake &>/dev/null; then
if ! command -v cmake &> /dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
elif ! command -v git &> /dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
elif ! command -v pip &> /dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
elif ! command -v virtualenv &> /dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
elif ! command -v esptool &> /dev/null; then
echo -e "\nERROR:\esptool was not found on your system.\nPlease install esptool by running:\n\nsudo apt update && sudo apt install -y esptool\n"
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
Expand All @@ -73,15 +75,13 @@ sed -i.bak '/CONFIG_DEBUG_MODE/d' ./sdkconfig.defaults
sed -i.bak '1s/^/CONFIG_LOG_DEFUALT_LEVEL_NONE=y\n/' sdkconfig.defaults
rm sdkconfig.defaults.bak

idf.py build

while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${device} and PRESS ANY KEY to continue... " && echo
done
tty_device_permissions="$(stat -c '%a' ${tty_device})"
if [ "${tty_device_permissions:2}" -lt 6 ]; then
echo -e "ERROR:\nYou need elevated permissions to write to the device.\nPlease update your device permissoins by running:\n\nsudo chmod o+rw ${tty_device}\n"
exit 1
fi

idf.py flash
# TODO: Read the esptool arguments from jade/build/flasher_args.json like how esptool.py does, rather than hard-code
sudo esptool --port "${tty_device}" write_flash --flash_mode dio --flash_size 4MB --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x10000 build/jade.bin 0x9000 build/partition_table/partition-table.bin 0xe000 build/ota_data_initial.bin

echo -e "\nSUCCESS! Your ${device} is now running Jade."

0 comments on commit cd26cd4

Please sign in to comment.