Author: toad
Date: 2006-06-03 15:25:00 +0000 (Sat, 03 Jun 2006)
New Revision: 9027
Modified:
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/src/freenet/node/updater/NodeUpdater.java
trunk/freenet/src/freenet/node/updater/PrivkeyHasBeenBlownException.java
Log:
778: Fix revocation, and HTMLEncode the revocation message.
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-06-03 15:19:18 UTC (rev
9026)
+++ trunk/freenet/src/freenet/node/Version.java 2006-06-03 15:25:00 UTC (rev
9027)
@@ -18,7 +18,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 777;
+ private static final int buildNumber = 778;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 765;
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdater.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2006-06-03
15:19:18 UTC (rev 9026)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2006-06-03
15:25:00 UTC (rev 9027)
@@ -90,7 +90,6 @@
ctxRevocation = n.makeClient((short)0).getFetcherContext();
ctxRevocation.allowSplitfiles = false;
ctxRevocation.cacheLocalRequests = false;
- ctxRevocation.followRedirects = false;
ctxRevocation.maxArchiveLevels = 1;
// big enough ?
ctxRevocation.maxOutputLength = 4096;
@@ -140,10 +139,9 @@
try{
if(isFetching || (!isRunning) ||
(!isUpdatable())) return;
}catch (PrivkeyHasBeenBlownException e){
- // how to handle it ? a new UserAlert or an
imediate exit?
- Logger.error(this, "The auto-updating Private
key has been blown!");
- System.err.println("The auto-updating Private
key has been blown!");
- node.exit();
+ // Handled in blow().
+ isRunning=false;
+ return;
}
isRunning=false;
@@ -160,8 +158,9 @@
}
cg.start();
isFetching = true;
+ queueFetchRevocation(0);
}catch (Exception e) {
- Logger.error(this, "Error while starting the fetching");
+ Logger.error(this, "Error while starting the fetching:
"+e, e);
}
}
@@ -369,16 +368,21 @@
}else{
// The key has been blown !
// FIXME: maybe we need a bigger warning message.
- try{
-
blow(result.asBucket().getOutputStream().toString());
- Logger.error(this, "The revocation key has been
found on the network : blocking auto-update");
- }catch(IOException e){
- // We stop anyway.
- synchronized(this){
- this.hasBeenBlown = true;
+ String msg = null;
+ try {
+ byte[] buf = result.asByteArray();
+ msg = new String(buf);
+ } catch (Throwable t) {
+ try {
+ Logger.error(this, "Failed to extract
result when key blown: "+t, t);
+ System.err.println("Failed to extract
result when key blown: "+t);
+ t.printStackTrace();
+ msg = "Failed to extract result when
key blown: "+t;
+ } catch (Throwable t1) {
+ msg = "Internal error after retreiving
revocation key";
}
- Logger.error(this, "Unable to set the
revocation flag");
}
+ blow(msg);
}
}
@@ -396,13 +400,14 @@
Logger.normal(this, "Rescheduling new request");
maybeUpdate();
- }else
+ } else
Logger.error(this, "Canceling fetch : "+
e.getMessage());
}else{
synchronized(this) {
if(errorCode == FetchException.DATA_NOT_FOUND){
revocationDNFCounter++;
}
+ if(e.isFatal()) this.blow("Permanent error
fetching revocation (invalid data inserted?): "+e.toString());
// Start it again
if(this.finalCheck) {
if(revocationDNFCounter < 3)
Modified:
trunk/freenet/src/freenet/node/updater/PrivkeyHasBeenBlownException.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/PrivkeyHasBeenBlownException.java
2006-06-03 15:19:18 UTC (rev 9026)
+++ trunk/freenet/src/freenet/node/updater/PrivkeyHasBeenBlownException.java
2006-06-03 15:25:00 UTC (rev 9027)
@@ -1,11 +1,13 @@
package freenet.node.updater;
+import freenet.support.HTMLEncoder;
+
public class PrivkeyHasBeenBlownException extends Exception{
private static final long serialVersionUID = -1;
PrivkeyHasBeenBlownException(String msg) {
super("The project's private key has been blown, meaning that
it has been compromized"+
"and shouldn't be trusted anymore. Please get a new
build by hand and verify CAREFULLY"+
- "its signature and CRC. Here is the revocation
message: "+msg);
+ "its signature and CRC. Here is the revocation
message: "+HTMLEncoder.encode(msg));
}
}