/hg/icedtea6: 5 new changesets

andrew at icedtea.classpath.org andrew at icedtea.classpath.org
Tue Oct 12 16:26:09 PDT 2010


changeset d8115f447e6f in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=d8115f447e6f
author: andrew
date: Tue Oct 05 13:56:11 2010 +0100

	Security updates for 2010/10/12.

	2010-10-05 Andrew John Hughes <ahughes at redhat.com>

	 * patches/security/20100330/hotspot/original/6626217.patch:
	Remove dead security patch.
		* Makefile.am: Add new patches.
		* NEWS: List security updates.
		* patches/security/20101012/6559775.patch,
		* patches/security/20101012/6891766.patch,
		* patches/security/20101012/6914943.patch,
		* patches/security/20101012/6925710.patch,
		* patches/security/20101012/6938813.patch,
		* patches/security/20101012/6957564.patch,
		* patches/security/20101012/6958060.patch,
		* patches/security/20101012/6963023.patch,
		* patches/security/20101012/6963489.patch,
		* patches/security/20101012/6966692.patch: New security
	patches.


changeset 420a4eede08d in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=420a4eede08d
author: andrew
date: Mon Oct 11 21:05:13 2010 +0100

	Second batch of security updates.

	2010-10-11 Andrew John Hughes <ahughes at redhat.com>

	 * patches/icedtea-timerqueue.patch: Dropped;
	superceded by 6623943.
		* Makefile.am: Add new security patches.
		* NEWS: List new security patches.
		* patches/security/20101012/6622002.patch,
		* patches/security/20101012/6623943.patch,
		* patches/security/20101012/6952017.patch,
		* patches/security/20101012/6952603.patch,
		* patches/security/20101012/6961084.patch,
		* patches/security/20101012/6963285.patch,
		* patches/security/20101012/6981426.patch,
		* patches/security/20101012/6990437.patch: Added.


changeset f4f7b88ae02c in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=f4f7b88ae02c
author: andrew
date: Mon Oct 11 21:06:13 2010 +0100

	Merge


changeset 2c5c2c6f314a in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=2c5c2c6f314a
author: andrew
date: Mon Oct 11 22:31:47 2010 +0100

	Add CVE numbers.

	2010-10-11 Andrew John Hughes <ahughes at redhat.com>

	 * NEWS: Add CVE numbers and list 6925672 which is
	covered by the 6891766 fix.


changeset c66cf32a25db in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=c66cf32a25db
author: andrew
date: Wed Oct 13 00:25:56 2010 +0100

	Merge


diffstat:

29 files changed, 5419 insertions(+), 210 deletions(-)
ChangeLog                                                |   67 
Makefile.am                                              |   63 
NEWS                                                     |   22 
netx/net/sourceforge/jnlp/Launcher.java                  |   77 
netx/net/sourceforge/jnlp/cache/CacheUtil.java           |   71 
netx/net/sourceforge/jnlp/resources/Messages.properties  |    2 
netx/net/sourceforge/jnlp/runtime/Boot.java              |   13 
netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java       |   10 
netx/net/sourceforge/jnlp/util/FileUtils.java            |   35 
patches/icedtea-timerqueue.patch                         |   18 
patches/security/20100330/hotspot/original/6626217.patch |  180 -
patches/security/20101012/6559775.patch                  |  317 ++
patches/security/20101012/6622002.patch                  |   64 
patches/security/20101012/6623943.patch                  |  138 
patches/security/20101012/6891766.patch                  | 1147 +++++++
patches/security/20101012/6914943.patch                  | 2129 ++++++++++++++
patches/security/20101012/6925710.patch                  |  198 +
patches/security/20101012/6938813.patch                  |  196 +
patches/security/20101012/6952017.patch                  |   50 
patches/security/20101012/6952603.patch                  |   38 
patches/security/20101012/6957564.patch                  |   77 
patches/security/20101012/6958060.patch                  |   15 
patches/security/20101012/6961084.patch                  |  325 ++
patches/security/20101012/6963023.patch                  |   95 
patches/security/20101012/6963285.patch                  |   20 
patches/security/20101012/6963489.patch                  |   31 
patches/security/20101012/6966692.patch                  |   91 
patches/security/20101012/6981426.patch                  |   24 
patches/security/20101012/6990437.patch                  |  116 

diffs (truncated from 5953 to 500 lines):

diff -r f41b0a7fbd70 -r c66cf32a25db ChangeLog
--- a/ChangeLog	Mon Oct 04 18:13:02 2010 -0400
+++ b/ChangeLog	Wed Oct 13 00:25:56 2010 +0100
@@ -1,3 +1,70 @@ 2010-10-04  Paul Ebermann  <Paul-Eberman
+2010-10-12  Matthias Klose  <doko at ubuntu.com>
+
+	* Makefile.am (stamps/add-plugin.stamp, stamps/add-plugin-debug.stamp,
+	stamps/add-pulseaudio-debug.stamp, stamps/add-plugin-ecj.stamp): Robustify.
+	(ADD_ZERO_CONFIGURE_ARGS): Adjust to new configure flags.
+	(stamps/add-zero.stamp): Explicitly create directories that icedtea
+	components assume to be created by the jdk build (not built in zerovm).
+
+2010-10-11  Andrew John Hughes  <ahughes at redhat.com>
+
+	* NEWS: Add CVE numbers and list 6925672
+	which is covered by the 6891766 fix.
+
+2010-10-11  Andrew John Hughes  <ahughes at redhat.com>
+
+	* patches/icedtea-timerqueue.patch:
+	Dropped; superceded by 6623943.
+	* Makefile.am: Add new security patches.
+	* NEWS: List new security patches.
+	* patches/security/20101012/6622002.patch,
+	* patches/security/20101012/6623943.patch,
+	* patches/security/20101012/6952017.patch,
+	* patches/security/20101012/6952603.patch,
+	* patches/security/20101012/6961084.patch,
+	* patches/security/20101012/6963285.patch,
+	* patches/security/20101012/6981426.patch,
+	* patches/security/20101012/6990437.patch:
+	Added.
+
+2010-10-08  Omair Majid  <omajid at redhat.com>
+
+	* NEWS: Updated
+	* net/sourceforge/jnlp/Launcher.java: Add fileLock.
+	(launchApplication): Call markNetxRunning and install a shutdown hook for
+	markNetxStopped.
+	(markNetxRunning): New method.
+	(markNetxStopped): New method.
+	* net/sourceforge/jnlp/cache/CacheUtil.java
+	(R): New method.
+	(clearCache): New method.
+	(okToClearCache): New method.
+	* net/sourceforge/jnlp/resources/Messages.properties: Add BXclearcache and
+	CCannotClearCache.
+	* net/sourceforge/jnlp/runtime/Boot.java
+	(run): Clear the cache.
+	* net/sourceforge/jnlp/runtime/JNLPRuntime.java: Add NETX_RUNNING_FILE.
+	* net/sourceforge/jnlp/util/FileUtils.java
+	(recursiveDelete): New method.
+
+2010-10-05  Andrew John Hughes  <ahughes at redhat.com>
+
+	* patches/security/20100330/hotspot/original/6626217.patch:
+	Remove dead security patch.
+	* Makefile.am: Add new patches.
+	* NEWS: List security updates.
+	* patches/security/20101012/6559775.patch,
+	* patches/security/20101012/6891766.patch,
+	* patches/security/20101012/6914943.patch,
+	* patches/security/20101012/6925710.patch,
+	* patches/security/20101012/6938813.patch,
+	* patches/security/20101012/6957564.patch,
+	* patches/security/20101012/6958060.patch,
+	* patches/security/20101012/6963023.patch,
+	* patches/security/20101012/6963489.patch,
+	* patches/security/20101012/6966692.patch:
+	New security patches.
+
 2010-10-04  Paul Ebermann  <Paul-Ebermann at gmx.de>
 	        Omair Majid <omajid at redhat.com>
 
diff -r f41b0a7fbd70 -r c66cf32a25db Makefile.am
--- a/Makefile.am	Mon Oct 04 18:13:02 2010 -0400
+++ b/Makefile.am	Wed Oct 13 00:25:56 2010 +0100
@@ -197,7 +197,30 @@ REWRITER_SRCS = $(abs_top_srcdir)/rewrit
 
 ICEDTEA_FSG_PATCHES =
 
+BROKEN = 
+
+SECURITY_PATCHES = \
+	patches/security/20101012/6891766.patch \
+	patches/security/20101012/6925710.patch \
+	patches/security/20101012/6938813.patch \
+	patches/security/20101012/6957564.patch \
+	patches/security/20101012/6958060.patch \
+	patches/security/20101012/6963023.patch \
+	patches/security/20101012/6963489.patch \
+	patches/security/20101012/6966692.patch \
+	patches/security/20101012/6914943.patch \
+	patches/security/20101012/6559775.patch \
+	patches/security/20101012/6622002.patch \
+	patches/security/20101012/6623943.patch \
+	patches/security/20101012/6952017.patch \
+	patches/security/20101012/6952603.patch \
+	patches/security/20101012/6961084.patch \
+	patches/security/20101012/6963285.patch \
+	patches/security/20101012/6981426.patch \
+	patches/security/20101012/6990437.patch
+
 ICEDTEA_PATCHES = \
+	$(SECURITY_PATCHES) \
 	patches/icedtea-notice-safepoints.patch \
 	patches/icedtea-parisc-opt.patch \
 	patches/icedtea-lucene-crash.patch \
@@ -219,7 +242,6 @@ ICEDTEA_PATCHES = \
 	patches/icedtea-javafiles.patch \
 	patches/icedtea-jvmtiEnv.patch \
 	patches/icedtea-lcms.patch \
-	patches/icedtea-timerqueue.patch \
 	patches/hotspot/$(HSBUILD)/print_lsb_release.patch \
 	patches/icedtea-jpegclasses.patch \
 	patches/icedtea-uname.patch \
@@ -1340,9 +1362,9 @@ stamps/add-plugin.stamp: stamps/plugin.s
 stamps/add-plugin.stamp: stamps/plugin.stamp stamps/icedtea.stamp
 if ENABLE_PLUGIN
 	cp -pPRf $(PLUGIN_DIR)/IcedTeaPlugin.so \
-	  $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)
+	  $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(PLUGIN_DIR)/IcedTeaPlugin.so \
-	  $(BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)
+	  $(BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(abs_top_builddir)/liveconnect/lib/classes.jar \
 	  $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/plugin.jar
 	cp -pPRf $(abs_top_builddir)/liveconnect/lib/classes.jar \
@@ -1360,9 +1382,9 @@ stamps/add-plugin-debug.stamp: stamps/pl
 stamps/add-plugin-debug.stamp: stamps/plugin.stamp stamps/icedtea-debug.stamp
 if ENABLE_PLUGIN
 	cp -pPRf $(PLUGIN_DIR)/IcedTeaPlugin.so \
-	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(PLUGIN_DIR)/IcedTeaPlugin.so \
-	  $(DEBUG_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(abs_top_builddir)/liveconnect/lib/classes.jar \
 	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/plugin.jar
 	cp -pPRf $(abs_top_builddir)/liveconnect/lib/classes.jar \
@@ -1387,9 +1409,9 @@ stamps/add-netx.stamp: stamps/netx-dist.
 	cp $(NETX_RESOURCE_DIR)/about.jnlp extra-lib/about.jar \
 	  $(BUILD_OUTPUT_DIR)/j2re-image/lib
 	cp $(NETX_SRCDIR)/javaws.1 \
-	  $(BUILD_OUTPUT_DIR)/j2sdk-image/man/man1; \
+	  $(BUILD_OUTPUT_DIR)/j2sdk-image/man/man1
 	cp $(NETX_SRCDIR)/javaws.1 \
-	  $(BUILD_OUTPUT_DIR)/j2re-image/man/man1; \
+	  $(BUILD_OUTPUT_DIR)/j2re-image/man/man1
 	touch stamps/add-netx.stamp
 
 clean-add-netx:
@@ -1507,9 +1529,9 @@ stamps/add-pulseaudio-debug.stamp: stamp
 stamps/add-pulseaudio-debug.stamp: stamps/icedtea-debug.stamp $(PULSE_JAVA_TARGET)
 if ENABLE_PULSE_JAVA
 	cp -pPRf $(PULSE_JAVA_NATIVE_BUILDDIR)/libpulse-java.so \
-	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(PULSE_JAVA_NATIVE_BUILDDIR)/libpulse-java.so \
-	  $(DEBUG_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(PULSE_JAVA_BUILDDIR)/pulse-java.jar \
 	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/ext
 	cp -pPRf $(PULSE_JAVA_BUILDDIR)/pulse-java.jar \
@@ -1598,9 +1620,9 @@ stamps/add-plugin-ecj.stamp: stamps/plug
 stamps/add-plugin-ecj.stamp: stamps/plugin.stamp stamps/icedtea-ecj.stamp
 if ENABLE_PLUGIN
 	cp -pPRf $(PLUGIN_DIR)/IcedTeaPlugin.so \
-	  $(ECJ_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)
+	  $(ECJ_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(PLUGIN_DIR)/IcedTeaPlugin.so \
-	  $(ECJ_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)
+	  $(ECJ_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR)/
 	cp -pPRf $(abs_top_builddir)/liveconnect/lib/classes.jar \
 	  $(ECJ_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/plugin.jar
 	cp -pPRf $(abs_top_builddir)/liveconnect/lib/classes.jar \
@@ -2086,7 +2108,7 @@ endif
 endif
 ADD_ZERO_CONFIGURE_ARGS += \
 	--disable-docs \
-	$(filter-out '--with-gcj-home=% '--with-ecj=% \
+	$(filter-out '--with-jdk-home=% '--with-ecj=% \
 			'--with-java=% '--with-javah=% \
 			'--with-rmic=% '--with-additional-vms=% \
 			'--with-openjdk '--with-openjdk=% , \
@@ -2098,6 +2120,7 @@ ADD_ZERO_CONFIGURE_ARGS += \
 	$(if $(findstring --with-hotspot-src-zip=, $(CONFIGURE_ARGS)),, \
 	  --with-hotspot-src-zip=$(abs_top_builddir)/$(HOTSPOT_SRC_ZIP))
 endif
+ADD_ZERO_CONFIGURE_ARGS += --disable-plugin --disable-bootstrap
 
 ADD_ZERO_EXTRA_BUILD_ENV = \
 	BUILD_LANGTOOLS=false ALT_LANGTOOLS_DIST=$(BUILD_OUTPUT_DIR)/langtools/dist \
@@ -2114,6 +2137,22 @@ if ADD_ZERO_BUILD
 	cd zerovm && \
 	    $(ADD_ZERO_EXTRA_BUILD_ENV) \
 		$(ARCH_PREFIX) $(abs_top_srcdir)/configure $(ADD_ZERO_CONFIGURE_ARGS)
+
+	: # create directories which are expected by icedtea components,
+	: # implicitly assumed to be created by the jdk build.
+	mkdir -p $(patsubst $(abs_top_builddir)/%,$(abs_top_builddir)/zerovm/%, \
+	  $(ECJ_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR) \
+	  $(ECJ_BUILD_OUTPUT_DIR)/j2sdk-image/man/man1 \
+	  $(ECJ_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR) \
+	  $(ECJ_BUILD_OUTPUT_DIR)/j2re-image/man/man1 \
+	  $(BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR) \
+	  $(BUILD_OUTPUT_DIR)/j2sdk-image/man/man1 \
+	  $(BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR) \
+	  $(BUILD_OUTPUT_DIR)/j2re-image/man/man1 \
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/jre/lib/$(INSTALL_ARCH_DIR) \
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2sdk-image/man/man1 \
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2re-image/lib/$(INSTALL_ARCH_DIR) \
+	  $(DEBUG_BUILD_OUTPUT_DIR)/j2re-image/man/man1)
 
 	$(ADD_ZERO_EXTRA_BUILD_ENV) \
 		$(ARCH_PREFIX) $(MAKE) -C zerovm $(ICEDTEA_BUILD_TARGET)
diff -r f41b0a7fbd70 -r c66cf32a25db NEWS
--- a/NEWS	Mon Oct 04 18:13:02 2010 -0400
+++ b/NEWS	Wed Oct 13 00:25:56 2010 +0100
@@ -10,6 +10,27 @@ CVE-XXXX-YYYY: http://www.cve.mitre.org/
 
 New in release 1.10 (2010-XX-XX):
 
+* Security updates
+  - S6914943, CVE-2009-3555: TLS: MITM attacks via session renegotiation 
+  - S6559775, CVE-2010-3568: OpenJDK Deserialization Race condition
+  - S6891766, CVE-2010-3554: OpenJDK corba reflection vulnerabilities
+  - S6925710, CVE-2010-3562: OpenJDK IndexColorModel double-free
+  - S6938813, CVE-2010-3557: OpenJDK Swing mutable static
+  - S6957564, CVE-2010-3548: OpenJDK DNS server IP address information leak
+  - S6958060, CVE-2010-3564: OpenJDK kerberos vulnerability
+  - S6963023, CVE-2010-3565: OpenJDK JPEG writeImage remote code execution
+  - S6963489, CVE-2010-3566: OpenJDK ICC Profile remote code execution
+  - S6966692, CVE-2010-3569: OpenJDK Serialization inconsistencies
+  - S6622002, CVE-2010-3553: UIDefault.ProxyLazyValue has unsafe reflection usage
+  - S6623943: javax.swing.TimerQueue's thread occasionally fails to start
+  - S6925672, CVE-2010-3561: Privileged ServerSocket.accept allows receiving connections from any host
+  - S6952017, CVE-2010-3549: HttpURLConnection chunked encoding issue (Http request splitting)
+  - S6952603, CVE-2010-3551: NetworkInterface reveals local network address to untrusted code
+  - S6961084, CVE-2010-3541: limit setting of some request headers in HttpURLConnection
+  - S6963285, CVE-2010-3567: Crash in ICU Opentype layout engine due to mismatch in character counts
+  - S6980004, CVE-2010-3573: limit HTTP request cookie headers in HttpURLConnection
+  - S6981426, CVE-2010-3574: limit use of TRACE method in HttpURLConnection
+  - S6990437: Update with correct copyright info for source and test files from SSR10_02 fixes
 * Backports from OpenJDK6
   - S4356282, RH525870: RFE: T2K should be used to rasterize CID/CFF fonts
   - S6954424: Support OpenType/CFF fonts in JDK 7
@@ -18,6 +39,7 @@ New in release 1.10 (2010-XX-XX):
   - S6650759: Inference of formal type parameter (unused in formal parameters) is not performed
 * Netx
   - A new man page for javaws.
+  - Add a new option -Xclearcache
 * Plugin  
   - PR554: System.err writes content two times
   - PR556: Applet initialization code is prone to race conditions
diff -r f41b0a7fbd70 -r c66cf32a25db netx/net/sourceforge/jnlp/Launcher.java
--- a/netx/net/sourceforge/jnlp/Launcher.java	Mon Oct 04 18:13:02 2010 -0400
+++ b/netx/net/sourceforge/jnlp/Launcher.java	Wed Oct 13 00:25:56 2010 +0100
@@ -20,12 +20,17 @@ import java.applet.Applet;
 import java.applet.Applet;
 import java.awt.Container;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.lang.management.ThreadMXBean;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.net.URL;
 import java.net.UnknownHostException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.jar.JarFile;
@@ -78,6 +83,9 @@ public class Launcher {
     /** If the application should call System.exit on fatal errors */
     private boolean exitOnFailure = true;
 
+    /** a lock which is held to indicate that an instance of netx is running */
+    private FileLock fileLock;
+
     /**
      * Create a launcher with the runtime's default update policy
      * and launch handler.
@@ -127,6 +135,7 @@ public class Launcher {
 
         this.handler = handler;
         this.updatePolicy = policy;
+
     }
 
     /**
@@ -385,6 +394,11 @@ public class Launcher {
         if (!file.isApplication())
             throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplication"), R("LNotApplicationInfo")));
 
+        markNetxRunning();
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() { markNetxStopped(); }
+         });
+
         try {
 
             try {
@@ -686,6 +700,69 @@ public class Launcher {
         return null; // chose to continue, or no handler
     }
 
+    /**
+     * Indicate that netx is running by creating the {@link JNLPRuntime#INSTANCE_FILE} and
+     * acquiring a shared lock on it
+     */
+    private void markNetxRunning() {
+        try {
+            String message = "This file is used to check if netx is running";
+
+            File netxRunningFile = new File(JNLPRuntime.NETX_RUNNING_FILE);
+            netxRunningFile.getParentFile().mkdirs();
+            if (netxRunningFile.createNewFile()) {
+                FileOutputStream fos = new FileOutputStream(netxRunningFile);
+                try {
+                    fos.write(message.getBytes());
+                } finally {
+                    fos.close();
+                }
+            }
+
+            if (!netxRunningFile.isFile()) {
+                if (JNLPRuntime.isDebug()) {
+                    System.err.println("Unable to create instance file");
+                }
+                fileLock = null;
+                return;
+            }
+
+            FileInputStream is = new FileInputStream(netxRunningFile);
+            FileChannel channel = is.getChannel();
+            fileLock = channel.tryLock(0, Long.MAX_VALUE, true);
+            if (fileLock != null && fileLock.isShared()) {
+                if (JNLPRuntime.isDebug()) {
+                    System.out.println("Acquired shared lock on " +
+                            JNLPRuntime.NETX_RUNNING_FILE + " to indicate javaws is running");
+                }
+            } else {
+                fileLock = null;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * Indicate that netx is stopped by releasing the shared lock on
+     * {@link JNLPRuntime#INSTANCE_FILE}.
+     */
+    private void markNetxStopped() {
+        if (fileLock == null) {
+            return;
+        }
+        try {
+            fileLock.release();
+            fileLock.channel().close();
+            fileLock = null;
+            if (JNLPRuntime.isDebug()) {
+                System.out.println("Release shared lock on " + JNLPRuntime.NETX_RUNNING_FILE);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 
 
     /**
diff -r f41b0a7fbd70 -r c66cf32a25db netx/net/sourceforge/jnlp/cache/CacheUtil.java
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java	Mon Oct 04 18:13:02 2010 -0400
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java	Wed Oct 13 00:25:56 2010 +0100
@@ -19,6 +19,7 @@ package net.sourceforge.jnlp.cache;
 
 import java.io.*;
 import java.net.*;
+import java.nio.channels.FileChannel;
 import java.util.*;
 import java.lang.reflect.*;
 import java.security.*;
@@ -36,6 +37,10 @@ import net.sourceforge.jnlp.util.FileUti
  * @version $Revision: 1.17 $
  */
 public class CacheUtil {
+
+    private static String R(String key) {
+        return JNLPRuntime.getMessage(key);
+    }
 
     private static String R(String key, Object param) {
         return JNLPRuntime.getMessage(key, new Object[] {param});
@@ -126,6 +131,72 @@ public class CacheUtil {
         }
 
         return null;
+    }
+
+    /**
+     * Clears the cache by deleting all the Netx cache files
+     *
+     * Note: Because of how our caching system works, deleting jars of another javaws
+     * process is using them can be quite disasterous. Hence why Launcher creates lock files
+     * and we check for those by calling {@link #okToClearCache()}
+     */
+    public static void clearCache() {
+
+        if (!okToClearCache()) {
+            System.err.println(R("CCannotClearCache"));
+            return;
+        }
+
+        File cacheDir = new File(JNLPRuntime.getBaseDir() + File.separator + "cache");
+        if (!(cacheDir.isDirectory())) {
+            return;
+        }
+
+        if (JNLPRuntime.isDebug()) {
+            System.err.println("Clearing cache directory: " + cacheDir);
+        }
+        try {
+            FileUtils.recursiveDelete(cacheDir, JNLPRuntime.getBaseDir());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Returns a boolean indicating if it ok to clear the netx application cache at this point
+     * @return true if the cache can be cleared at this time without problems
+     */
+    private static boolean okToClearCache() {
+        File otherJavawsRunning = new File(JNLPRuntime.NETX_RUNNING_FILE);
+        try {
+            if (otherJavawsRunning.isFile()) {
+                FileOutputStream fis = new FileOutputStream(otherJavawsRunning);
+                try {
+                    FileChannel channel = fis.getChannel();
+                    if (channel.tryLock() == null) {
+                        if (JNLPRuntime.isDebug()) {
+                            System.out.println("Other instances of netx are running");
+                        }
+                        return false;
+                    }
+
+                    if (JNLPRuntime.isDebug()) {
+                        System.out.println("No other instances of netx are running");
+                    }
+                    return true;
+
+                } finally {
+                    fis.close();
+                }
+            } else {
+                if (JNLPRuntime.isDebug()) {
+                    System.out.println("No instance file found");
+                }
+                return true;
+            }
+        } catch (IOException e) {
+            return false;
+        }
     }
 
     /**
diff -r f41b0a7fbd70 -r c66cf32a25db netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties	Mon Oct 04 18:13:02 2010 -0400
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties	Wed Oct 13 00:25:56 2010 +0100
@@ -139,6 +139,7 @@ BOViewer    = Shows the trusted certific
 BOViewer    = Shows the trusted certificate viewer.
 BOUmask     = Sets the umask for files created by an application.
 BXnofork    = Do not create another JVM.
+BXclearcache= Clean the JNLP application cache.
 BOHelp      = Print this message and exit.
 
 # Cache
@@ -149,6 +150,7 @@ CChooseCache=Choose a cache directory...
 CChooseCache=Choose a cache directory...
 CChooseCacheInfo=Netx needs a location for storing cache files.
 CChooseCacheDir=Cache directory
+CCannotClearCache=Can not clear cache at this time
 
 # Security
 SFileReadAccess=The application has requested read access to {0}. Do you want to allow this action?
diff -r f41b0a7fbd70 -r c66cf32a25db netx/net/sourceforge/jnlp/runtime/Boot.java
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java	Mon Oct 04 18:13:02 2010 -0400
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java	Wed Oct 13 00:25:56 2010 +0100
@@ -40,6 +40,7 @@ import net.sourceforge.jnlp.ParseExcepti
 import net.sourceforge.jnlp.ParseException;
 import net.sourceforge.jnlp.PropertyDesc;
 import net.sourceforge.jnlp.ResourcesDesc;
+import net.sourceforge.jnlp.cache.CacheUtil;
 import net.sourceforge.jnlp.cache.UpdatePolicy;
 import net.sourceforge.jnlp.security.VariableX509TrustManager;



More information about the distro-pkg-dev mailing list