From: Mark Wooding Date: Tue, 22 Dec 2015 21:24:23 +0000 (+0000) Subject: lib/lib.sh: Sanitize the tag when making a temporary directory. X-Git-Url: https://git.distorted.org.uk/~mdw/distorted-letsencrypt/commitdiff_plain/98f7510dc1dd5f05f4c235a6c1ec44b9b6737b6f lib/lib.sh: Sanitize the tag when making a temporary directory. The configuration-file reader is terrible and doesn't cope with values which contain `#'. --- diff --git a/lib/lib.sh b/lib/lib.sh index 467f1ca..dd85bbf 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -15,10 +15,12 @@ run_as_user () { PATH=$home/bin:/usr/local/bin:/bin:/usr/bin; export PATH } +sanitize () { echo "$1" | tr -c 'A-Za-z0-9-\n' _; } + prepare_tmp () { tag=$1 - tmp=$home/tmp/$tag.$$ + tmp=$home/tmp/$(sanitize "$tag").$$ rm -rf $tmp mkdir $tmp trap 'cd $home; rm -rf $tmp' EXIT INT TERM