diff options
author | nachoparker <nacho@ownyourbits.com> | 2018-05-09 18:20:54 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2018-05-09 19:21:27 +0300 |
commit | 63f83da6cf26c8b74fdc4117153cd3760b66a9e7 (patch) | |
tree | e6d19e53abd4c80cb95eb37ef1ef9d8c37b958f4 /bin/ncp-update | |
parent | 2dcc66c254fb361bb5f67b7e89855d8ae9876f1e (diff) |
avoid temp dir vulnerabilitiesv0.54.4
Diffstat (limited to 'bin/ncp-update')
-rwxr-xr-x | bin/ncp-update | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bin/ncp-update b/bin/ncp-update index 0df91fa9..9e753e80 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -8,14 +8,15 @@ BRANCH="${1:-master}" [[ "$BRANCH" != "master" ]] && echo "INFO: updating to development branch '$BRANCH'" - echo -e "Downloading updates" - rm -rf /tmp/ncp-update-tmp + TMPDIR="$( mktemp -d /tmp/ncp-update.XXXXXX || ( echo "Failed to create temp dir. Exiting" >&2; exit 1 ) )" + trap "rm -rf \"${TMPDIR}\"; exit 0" 0 1 2 3 15 - git clone --depth 20 -b "$BRANCH" -q https://github.com/nextcloud/nextcloudpi.git /tmp/ncp-update-tmp || { + echo -e "Downloading updates" + git clone --depth 20 -b "$BRANCH" -q https://github.com/nextcloud/nextcloudpi.git "$TMPDIR" || { echo "No internet connectivity" exit 1 } - cd /tmp/ncp-update-tmp + cd "$TMPDIR" echo -e "Performing updates" ./update.sh && { @@ -36,7 +37,6 @@ } cd / - rm -rf /tmp/ncp-update-tmp exit } # force to read the whole thing into memory, as its contents might change in update.sh |