From c122a142618900e4344fc289fd68f442062b01d7 Mon Sep 17 00:00:00 2001 From: Henric Andersson Date: Wed, 16 Nov 2016 22:21:24 -0800 Subject: [PATCH] Stop users from saving config with invalid download directory --- plexupdate.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 7a69840..35b1cbb 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -295,7 +295,7 @@ do (-U) IGNOREAUTOUPDATE=yes;; (--config) shift; CONFIGFILE="$1"; CONFIGFILE=$(trimQuotes ${CONFIGFILE});; - (--dldir) shift; DOWNLOADDIR_CL="$1"; DOWNLOADDIR_CL=$(trimQuotes ${DOWNLOADDIR_CL});; + (--dldir) shift; DOWNLOADDIR_CL="$1"; DOWNLOADDIR_CL=$(trimQuotes ${DOWNLOADDIR_CL});; (--email) shift; EMAIL_CL="$1"; EMAIL_CL=$(trimQuotes ${EMAIL_CL});; (--pass) shift; PASS_CL="$1"; PASS_CL=$(trimQuotes ${PASS_CL});; (--server) shift; PLEXSERVER_CL="$1"; PLEXSERVER_CL=$(trimQuotes ${PLEXSERVER_CL});; @@ -382,6 +382,10 @@ done # This will destroy and recreate the config file. Any settings that are set in the config file but are no longer # valid will NOT be saved. if [ "${SAVECONFIG}" = "yes" ]; then + if [ ! -d "$(eval cd ${DOWNLOADDIR// /\\ } 2>/dev/null && pwd)" ]; then + error "Download directory does not exist or is not a directory (tried \"${DOWNLOADDIR}\")" + exit 1 + fi echo "# Config file for plexupdate" >${CONFIGFILE:="${HOME}/.plexupdate"} for VAR in AUTOINSTALL CRON AUTODELETE DOWNLOADDIR EMAIL PASS FORCE FORCEALL PUBLIC QUIET AUTOSTART AUTOUPDATE PLEXSERVER PLEXPORT CHECKUPDATE