Add additional CLI input validation

This commit is contained in:
icenine451 2023-03-20 09:23:04 -04:00
parent 501889e954
commit c35cd00ba4
4 changed files with 21 additions and 1 deletions

View file

@ -0,0 +1,5 @@
uuddlrlrstart^set_setting_value /var/config/retrodeck/retrodeck.cfg developer_options true retrodeck
uuddlrlrstart^echo Visit the Configurator to behold your new-found powers.
uuddlrlrstart^echo But beware, with great power comes great responsibility...
gameovermangameover^set_setting_value /var/config/retrodeck/retrodeck.cfg developer_options false retrodeck
gameovermangameover^echo You have relinquished your powers in the name of saftey.

View file

@ -631,6 +631,17 @@ check_network_connectivity() {
fi
}
validate_input() {
while IFS="^" read -r input action
do
if [[ "$input" == "$1" ]]; then
# $action line must be completely literal in the $input_validation file. No shell expansion or extra characters.
$action
input_validated="true"
fi
done < $input_validation
}
update_rd_conf() {
# This function will import a default retrodeck.cfg file and update it with any current settings. This will allow us to expand the file over time while retaining current user settings.
# USAGE: update_rd_conf

View file

@ -13,6 +13,7 @@ rd_update_patch="/var/config/retrodeck/rd_update.patch"
bios_checklist="$emuconfigs/defaults/retrodeck/bios_checklist.cfg" # A config file listing BIOS file information that can be verified
compression_targets="$emuconfigs/defaults/retrodeck/compression_targets.cfg" # A config file containing supported compression types per system
easter_egg_checklist="$emuconfigs/defaults/retrodeck/easter_egg_checklist.cfg" # A config file listing days and times when special splash screens should show up
input_validation="$emuconfigs/defaults/retrodeck/input_validation.cfg" # List of valid CLI inputs
splashscreen_dir="/var/config/emulationstation/.emulationstation/resources/graphics/extra-splashes" # The default location of extra splash screens
current_splash_file="/var/config/emulationstation/.emulationstation/resources/graphics/splash.svg" # The active splash file that will be shown on boot
default_splash_file="/var/config/emulationstation/.emulationstation/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen

View file

@ -96,7 +96,10 @@ https://retrodeck.net
exit 1
;;
*)
validate_input "$i"
if [[ ! $input_validated == "true" ]]; then
echo "Please specify a valid option. Use -h for more information."
fi
;;
esac
done