import java.util.*;
import java.text.*;
+// FIXME: check for binaries (razor, clamassassin, etc) and complain if not present
+
//
// - better matching syntax:
// - src-ip
case "mail.drop": return METHOD;
case "mail.razor": return getSub("mail.razor");
case "mail.razor.check": return METHOD;
+ case "mail.clamav": return getSub("mail.clamav");
+ case "mail.clamav.check": return METHOD;
case "mail.procmail": /* FEATURE */ return null;
case "mail.vacation": /* FEATURE */ return null;
case "mail.dcc": return getSub("mail.dcc");
} catch (IOException e) { throw new JSExn(e.toString()); }
case "mail.whitelist": return JSReflection.wrap(org.ibex.mail.SMTP.whitelist);
case "mail.my.mailbox":
- Mailbox root = FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT, true);
- return root.slash("user", true).slash("megacz", true);
+ MailTree root = FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT, true);
+ return (JS)root.slash("user", true).slash("megacz", true);
case "mail.list": return METHOD;
//#end
return super.get(name);
Log.warn("dbug", b.getClass().getName());
Message m = (Message)b;
final Process p = Runtime.getRuntime().exec(JSU.toString(a));
- new Thread() {
+ Main.threadPool.start(new Runnable() {
public void run() {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
Log.warn("shell", s);
} catch (Exception e) { e.printStackTrace(); }
}
- }.start();
+ });
OutputStream os = p.getOutputStream();
Stream stream = new Stream(os);
((Message)args[0]).getStream().transcribe(new Stream(p.getOutputStream()), true);
return JSU.N(p.waitFor());
}
+ if (name.equals("mail.clamav.check")) {
+ // FIXME: this is returning "is-virus-laden" when clamdscan is unhappy -- BAD!
+ // should use error code: 0=clean, 1=virus, 2=malfunction
+ Process p = Runtime.getRuntime().exec("clamdscan - --stdout --quiet");
+ ((Message)args[0]).getStream().transcribe(new Stream(p.getOutputStream()), true);
+ int result = p.waitFor();
+ if (result==0) return JSU.N(0);
+ StringBuffer ret = new StringBuffer();
+ new Stream(p.getInputStream()).transcribe(ret);
+ return JSU.S(ret.toString());
+ }
if (name.equals("mail.dcc.check")) {
Process p = Runtime.getRuntime().exec(new String[] { "dccproc", "-H" });
((Message)args[0]).getStream().transcribe(new Stream(p.getOutputStream()), true);
StringBuffer ret = new StringBuffer();
new Stream(p.getInputStream()).transcribe(ret);
p.waitFor();
- return JSU.S(ret.toString());
+ String result = ret.toString();
+ Log.warn("dcc", ((Message)args[0]).summary() + ":\n " + result);
+ int body = 0;
+ int fuz1 = 0;
+ int fuz2 = 0;
+ int i_body = result.indexOf("Body=");
+ int i_fuz1 = result.indexOf("Fuz1=");
+ int i_fuz2 = result.indexOf("Fuz2=");
+ if (i_body != -1) try {
+ String s = result.substring(i_body+5);
+ if (s.indexOf(' ') != -1) s = s.substring(0, s.indexOf(' '));
+ if (s.indexOf('\n') != -1) s = s.substring(0, s.indexOf('\n'));
+ body = s.trim().equals("many") ? 999 : Integer.parseInt(s.trim());
+ } catch (Exception e) { Log.error("", e); }
+ if (i_fuz1 != -1) try {
+ String s = result.substring(i_fuz1+5);
+ if (s.indexOf(' ') != -1) s = s.substring(0, s.indexOf(' '));
+ if (s.indexOf('\n') != -1) s = s.substring(0, s.indexOf('\n'));
+ fuz1 = s.trim().equals("many") ? 999 : Integer.parseInt(s.trim());
+ } catch (Exception e) { Log.error("", e); }
+ if (i_fuz2 != -1) try {
+ String s = result.substring(i_fuz2+5);
+ if (s.indexOf(' ') != -1) s = s.substring(0, s.indexOf(' '));
+ if (s.indexOf('\n') != -1) s = s.substring(0, s.indexOf('\n'));
+ fuz2 = s.trim().equals("many") ? 999 : Integer.parseInt(s.trim());
+ } catch (Exception e) { Log.error("", e); }
+ JSArray jsa = new JSArray();
+ jsa.put(JSU.N(0), JSU.N(body));
+ jsa.put(JSU.N(1), JSU.N(fuz1));
+ jsa.put(JSU.N(2), JSU.N(fuz2));
+ return jsa;
}
if (name.equals("mail.drop")) {
return args.length==0 ? new Drop() : new Drop(JSU.toString(args[0]));