From 8895b5a9505b19fbaba48cac126fc6e50f054cb1 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 18 Nov 2016 12:29:34 +0100 Subject: Do some sanity checks on set credential strings. --- bin/impressive-display | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/impressive-display b/bin/impressive-display index 965fc6c..ced9141 100755 --- a/bin/impressive-display +++ b/bin/impressive-display @@ -106,6 +106,11 @@ else OUTPUT="logger -t impressive-display" fi +# FIXME: find good regexp for usernames (incl. email addresses) +if ! echo ${DEFAULT_PDF_URL_CREDS} | grep -q -E '(^$|[-@_a-z0-9A-Z]+:.+)'; then + $OUTPUT "DEFAULT_PDF_URL_CREDS does not seem to have valid credentials (expected format: :)." +fi + workdir="$HOME/.impressive-display" mkdir -p "$workdir" pdffile_previous="$workdir/impressive-pdffile-previous.pdf" @@ -167,13 +172,15 @@ else RESOLUTION="$DEFAULT_RESOLUTION" fi -set -x if echo ${!CREDS[@]} | grep -q "$THIS_HOSTNAME"; then - PDF_URL_CREDS=`echo ${CREDS[$THIS_HOSTNAME]} | sed -r -e 's/.*creds=([^|]*).*/\1/'` + if echo ${CREDS[$THIS_HOSTNAME]} | grep ":"; then + PDF_URL_CREDS="${CREDS[$THIS_HOSTNAME]}" + else + $OUTPUT "Display host '$THIS_HOSTNAME' does not seem to have valid credentials (expected format: :)." + fi else PDF_URL_CREDS="$DEFAULT_PDF_URL_CREDS" fi -set +x if [ -n "${RESOLUTION}" ]; then if type -p xrandr 1>/dev/null; then -- cgit v1.2.3