Skip to content

Commit

Permalink
avoid temp dir vulnerabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed May 9, 2018
1 parent a0b8c49 commit 36f4c6f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
9 changes: 4 additions & 5 deletions bin/ncp-check-version
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

# update latest available version in /var/run/.ncp-latest-version

rm -rf /tmp/ncp-check-tmp
TMPDIR="$( mktemp -d /tmp/ncp-check.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 -q --bare https://github.com/nextcloud/nextcloudpi.git /tmp/ncp-check-tmp || {
git clone --depth 20 -q --bare https://github.com/nextcloud/nextcloudpi.git "$TMPDIR" || {
echo "The git clone command failed: No connectivity to https://github.com ?"
exit 1
}

cd /tmp/ncp-check-tmp || exit 1
cd "$TMPDIR" || exit 1
VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" )
grep -qP "v\d+\.\d+\.\d+" <<< "$VER" && { # check format
echo "$VER" > /var/run/.ncp-latest-version
Expand All @@ -22,5 +23,3 @@ grep -qP "v\d+\.\d+\.\d+" <<< "$VER" && { # check format
sed 's|* \[tag: |[|' > /usr/local/etc/ncp-changelog
}
cd / || exit 1

rm -rf /tmp/ncp-check-tmp
10 changes: 5 additions & 5 deletions bin/ncp-update
Original file line number Diff line number Diff line change
Expand Up @@ -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 && {
Expand All @@ -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
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[v0.54.3](https://github.com/nextcloud/nextcloudpi/commit/921b583) (2018-05-03) nc-datadir: avoid using occ for faster execution
[v0.54.4](https://github.com/nextcloud/nextcloudpi/commit/36fed66) (2018-05-09) avoid temp dir vulnerabilities

[v0.54.3 ](https://github.com/nextcloud/nextcloudpi/commit/66dfbd0) (2018-05-03) nc-datadir: avoid using occ for faster execution

[v0.54.2 ](https://github.com/nextcloud/nextcloudpi/commit/ebfb7f1) (2018-05-03) samba: restart after configuration change

Expand Down

0 comments on commit 36f4c6f

Please sign in to comment.