summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-10-09 11:41:15 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-10-09 11:41:15 +0200
commit2f93cce4dc3e659ce11ccae93fb256cec1258062 (patch)
treebb1b47441eb37e68042dab7a004e9db2b016b219
parent7b060df85dd4ad3cc2236886fab2e7541ae58cb9 (diff)
downloadscripts-2f93cce4dc3e659ce11ccae93fb256cec1258062.tar.gz
tmp-upload: fix upload when open_basedir is set
-rwxr-xr-xtmp-upload10
1 files changed, 7 insertions, 3 deletions
diff --git a/tmp-upload b/tmp-upload
index 670a2e5..e72f98f 100755
--- a/tmp-upload
+++ b/tmp-upload
@@ -11,9 +11,12 @@ if [ -n "$1" ]; then
fi
fi
-out="$(mktemp /tmp/tmp-upload-php.XXXXXXXX)"
+# Temporary directory for storing uploads and PHP script
+tmpdir="$(mktemp -d)"
+
+out="$tmpdir/upload.php"
cleanup() {
- rm -v "$out"
+ rm -rvf "$tmpdir"
}
trap cleanup EXIT
@@ -22,7 +25,8 @@ startline=$(grep -hn -F -m 1 "# stuff ""below" "$0" | cut -d: -f1)
tail -n+$((startline+1)) "$0" > "$out"
php -d post_max_size=128M -d upload_max_filesize=128M \
- -d open_basedir="$out:$(pwd)/" \
+ -d upload_tmp_dir="$tmpdir/" \
+ -d open_basedir="$tmpdir/:$(pwd)/" \
-S "$host:$port" "$out"
exit
# stuff below