CVS java-package/lib
Jeroen van Wolffelaar
jeroen@haydn.debian.org
Mon Jan 3 12:27:05 2005
Update of /cvsroot/pkg-java/java-package/lib
In directory haydn:/tmp/cvs-serv26478/lib
Modified Files:
common.sh
Log Message:
* Fix security hole (inscure temp file creation) plus lots of needless I/O
in free disk checking function
--- /cvsroot/pkg-java/java-package/lib/common.sh 2004/10/11 23:10:25 1.1.1.1
+++ /cvsroot/pkg-java/java-package/lib/common.sh 2005/01/03 19:26:12 1.2
@@ -26,25 +26,26 @@
# diskfree <minimum size in MB>
function diskfree() {
local size="$1"
- local dummy="$tmp/dummy"
echo -n "Checking free diskspace:"
- dd if=/dev/zero of="$dummy" bs=1M count="$size" 2> /dev/null || true
- local real_size="$( diskusage "$dummy" )"
- rm -f "$dummy"
- if [ "$real_size" -ge "$size" ]; then
+ read dummy dummy dummy free dummy < <( df -BM "$tmp" | tail -1 )
+ free=${free%M}
+ if [ "$free" -ge "$size" ]; then
echo " done."
else
cat >&2 << EOF
-Error: Not enough free disk space in "$tmp".
+WARNING: Possibly not enough free disk space in "$tmp".
-You need at least $size MB, but only $real_size MB are free. Note: You
+You need at least $size MB, but only $free MB seems free. Note: You
can specify an alternate directory by setting the environment variable
+
+Press Ctrl+C to interrupt, or return to try to continue anyway.
+
TMPDIR.
EOF
- error_exit
+ read
fi
}