From 99f8fd894be14226a64f1889657edf863edf8afb Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 16 Aug 2004 00:01:20 +0000 Subject: [PATCH] moved to better jinetd setup darcs-hash:20040816000120-5007d-f4656e5627097b60a073c7316e81a438cceba006.gz --- src/org/ibex/jinetd/Loader.java | 14 ++++++++-- src/org/ibex/jinetd/Main.java | 53 ++++++++++++++++++++++++++++++++++++++ src/org/ibex/jinetd/Port.java | 4 +-- src/org/ibex/jinetd/Root.java | 5 ++-- src/org/ibex/jinetd/Watched.java | 14 ++++++---- www/index.html | 10 ++++--- 6 files changed, 85 insertions(+), 15 deletions(-) diff --git a/src/org/ibex/jinetd/Loader.java b/src/org/ibex/jinetd/Loader.java index b166df6..96093bd 100644 --- a/src/org/ibex/jinetd/Loader.java +++ b/src/org/ibex/jinetd/Loader.java @@ -11,10 +11,14 @@ public class Loader extends Watcher { ClassLoader parentClassLoader = null; static final ClassLoader mycl = Loader.class.getClassLoader(); + + protected ThreadGroup tg = new ThreadGroup(getAbsolutePath()); + public Loader(String path) { super(path); } //public Loader(String path, ClassLoader pcl) { super(path); this.parentClassLoader = pcl; } private TreeClassLoader classloader = null; + public synchronized void scan() throws IOException { super.scan(); } public synchronized ClassLoader getClassLoader() { ClassLoader classloader = this.classloader; if (classloader == null) { @@ -28,7 +32,6 @@ public class Loader extends Watcher { if (us.endsWith(".jar")) us = "file:"+us; else us = "file:"+us+"/"; urls[i] = new URL(us); - Log.warn("[classpath]", urls[i].toString()); } } catch (MalformedURLException e) { Log.error(this, e); @@ -52,6 +55,7 @@ public class Loader extends Watcher { } } + public String getClassPath() { String classpath = System.getProperty("java.class.path"); String [] l = new File(Root.root + "/LIB/").list(); @@ -122,7 +126,7 @@ public class Loader extends Watcher { String[] all = new String[args.size()]; args.copyInto(all); Log.info(this, "invoking javac for " + srcdir.getAbsolutePath()); - final Process javac = Runtime.getRuntime().exec(all); + final Process javac = Runtime.getRuntime().exec(all, new String[] { "PATH=/bin:/usr/bin" }); final BufferedReader out = new BufferedReader(new InputStreamReader(javac.getInputStream())); final BufferedReader err = new BufferedReader(new InputStreamReader(javac.getErrorStream())); new Thread() { public void run() { @@ -147,6 +151,12 @@ public class Loader extends Watcher { public void changed(Watched w) { if (w.path.indexOf("BIN") != -1) return; if (classloader != null) { + Log.info(this, "killing all threads for: " + w.path); + Log.info(this, " thread count before kill: " + tg.activeCount()); + tg.interrupt(); + try { Thread.sleep(1000); } catch (Exception e) { } + Log.info(this, " thread count after kill: " + tg.activeCount()); + tg = new ThreadGroup(getAbsolutePath()); Log.info(this, "scheduling classes for reload due to change in: " + w.path); classloader = null; } diff --git a/src/org/ibex/jinetd/Main.java b/src/org/ibex/jinetd/Main.java index a8ae366..c2cb324 100644 --- a/src/org/ibex/jinetd/Main.java +++ b/src/org/ibex/jinetd/Main.java @@ -1,10 +1,63 @@ package org.ibex.jinetd; import org.ibex.util.*; import java.io.*; +import java.net.*; import java.util.*; +import java.util.zip.*; public class Main { + public static String ROOT; + public static String LOGFILE; + public static PrintStream LOGSTREAM; + + private static void configureRoot() throws Exception { + ROOT = System.getProperty("jinetd.root", null); + if (ROOT == null) { + ROOT = autoDetectRoot(); + System.setProperty("jinetd.root", ROOT); + } + } + + private static void configureLogging() throws Exception { + LOGFILE = System.getProperty("jinetd.logfile", ROOT + File.separatorChar+"log.txt"); + LOGSTREAM = new PrintStream(new FileOutputStream(LOGFILE, true)); + System.setErr(LOGSTREAM); + System.setOut(LOGSTREAM); + } + + private static String autoDetectRoot() throws Exception { + if (!(Main.class.getClassLoader() instanceof URLClassLoader)) + throw new Error("unable to detect jinetd.root because my ClassLoader is not an instanceof URLClassLoader"); + URL[] urls = ((URLClassLoader)Main.class.getClassLoader()).getURLs(); + for(int i=0; i Isn't HTTP all that matters? There are now Java servers for almost every network protocol: HTTP, -SMTP, IMAP, POP3, NNTP, DNS, SSH, CIFS/SMB, and plenty of others. -Using servers written in buffer-overflow-free languages is the most -important step towards maintaining network security and stopping -worms. +SMTP, IMAP, POP3, NNTP, DNS, SSH, TELNET, CIFS/SMB, +and plenty of others. Using servers written in buffer-overflow-free +languages is the most important step towards maintaining network +security and stopping worms.

Huh?

-- 1.7.10.4