diff --git a/java/net/i2p/router/WindowsUpdatePostProcessor.java b/java/net/i2p/router/WindowsUpdatePostProcessor.java index 11bfea7..8de152b 100644 --- a/java/net/i2p/router/WindowsUpdatePostProcessor.java +++ b/java/net/i2p/router/WindowsUpdatePostProcessor.java @@ -39,6 +39,11 @@ public class WindowsUpdatePostProcessor implements UpdatePostProcessor { String version, File file) throws IOException { _log.info("Got an update to post-process"); + if (type != UpdateType.ROUTER_SIGNED_SU3 && + type != UpdateType.ROUTER_DEV_SU3) { + _log.warn("Unsupported update type " + type); + return; + } if (fileType != SU3File.TYPE_ZIP) { this.positionedFile = moveUpdateInstaller(file); this.version = version; @@ -55,12 +60,6 @@ public class WindowsUpdatePostProcessor implements UpdatePostProcessor { } if (SystemVersion.isWindows()) { - if (type != UpdateType.ROUTER_SIGNED_SU3 && - type != UpdateType.ROUTER_DEV_SU3) { - _log.warn("Unsupported update type " + type); - return; - } - if (fileType != SU3File.TYPE_EXE) { _log.warn("Unsupported file type " + fileType); return; diff --git a/java/net/i2p/router/ZipUpdateProcess.java b/java/net/i2p/router/ZipUpdateProcess.java index 6ed01a7..d9e656a 100644 --- a/java/net/i2p/router/ZipUpdateProcess.java +++ b/java/net/i2p/router/ZipUpdateProcess.java @@ -51,30 +51,11 @@ public class ZipUpdateProcess implements Runnable { return; File workingDir = workDir(); - File logFile = new File(workingDir, "log-" + version + ".txt"); + File zipFile = new File(workingDir, "i2pupdate_portable.zip"); + File destDir = ctx.getConfigDir(); - // check if we can write to the log file. If we can, use the - // ProcessBuilder to run the installer. - // ProcessBuilder pb = new ProcessBuilder( - // file.getAbsolutePath(), "/S", "/D=" + workingDir.getAbsolutePath()); - // Map env = pb.environment(); - // env.put("OLD_I2P_VERSION", version); - // env.remove("RESTART_I2P"); - - int exitCode = ctx.router().scheduledGracefulExitCode(); - // if (exitCode == Router.EXIT_HARD_RESTART || - // exitCode == Router.EXIT_GRACEFUL_RESTART) - // env.put("RESTART_I2P", "true"); - - /*try { - pb.directory(workingDir) - .redirectErrorStream(true) - .redirectOutput(logFile) - .start(); - } catch (IOException ex) { - _log.error( - "Unable to run update-program in background. Update will fail.", ex); - }*/ + String errors = unzip(zipFile.getAbsolutePath(), destDir.getAbsolutePath()); + _log.error(errors); } @Override @@ -86,7 +67,12 @@ public class ZipUpdateProcess implements Runnable { } } - private static void unzip(String zipFilePath, String destDir) { + // copied wholesale from this example: + // https://www.digitalocean.com/community/tutorials/java-unzip-file-example + // It doesn't check for zip-slips, but that's fine because if somebody's able + // to deliver a malicious update then they can just run code anyway so there's + // no point. + private static String unzip(String zipFilePath, String destDir) { File dir = new File(destDir); // create output directory if it doesn't exist if (!dir.exists()) @@ -119,7 +105,8 @@ public class ZipUpdateProcess implements Runnable { zis.close(); fis.close(); } catch (IOException e) { - e.printStackTrace(); + return e.toString(); } + return null; } }