Skip to content

Commit

Permalink
Use mktemp when creating temporary files.
Browse files Browse the repository at this point in the history
Before this change, the Java binary shell stub created temporary files in the
directory containing the binary, but that fails when the binary is stored in a
read-only file system or the directory is write protected.

Fixes issue #6289

Closes #6471.

PiperOrigin-RevId: 218314425
  • Loading branch information
brown authored and Copybara-Service committed Oct 23, 2018
1 parent a55714c commit a0a9da8
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,8 @@ function create_and_run_classpath_jar() {
done
unset IFS

RAND_ID=$(cat /dev/urandom | head -c 128 | md5func)
# Create manifest file
MANIFEST_FILE="${self}-${RAND_ID}.jar_manifest"
MANIFEST_FILE="$(mktemp XXXXXXXX.jar_manifest)"

(
echo "Manifest-Version: 1.0"
Expand All @@ -325,7 +324,7 @@ function create_and_run_classpath_jar() {
) >$MANIFEST_FILE

# Create classpath JAR file
MANIFEST_JAR_FILE="${self}-${RAND_ID}-classpath.jar"
MANIFEST_JAR_FILE="$(mktemp XXXXXXXX-classpath.jar)"
if is_windows; then
MANIFEST_JAR_FILE="$(cygpath --windows "$MANIFEST_JAR_FILE")"
MANIFEST_FILE="$(cygpath --windows "$MANIFEST_FILE")"
Expand Down

0 comments on commit a0a9da8

Please sign in to comment.