2005-09-17 jrandom

* Added the natively compiled jbigi and patched java service wrapper for
      OS X.  Thanks Bill Dorsey for letting me use your machine!
    * Don't build i2p.exe or i2pinstall.exe when run on OS X machines, as we
      don't bundle the binutils necessary (and there'd be a naming conflict
      if we did).
    * Added 'single user' functionality to syndie - if the single user
      checkbox on the admin page is checked, all users are allowed to control
      the instance and sync up with remote syndie nodes.
    * Temporarily disable the x-i2p-gzip in i2ptunnel until it is more closely
      debugged.
This commit is contained in:
jrandom
2005-09-17 07:31:48 +00:00
committed by zzz
parent 177e0ae6a3
commit d6c3ffde87
18 changed files with 216 additions and 17 deletions

View File

@ -371,7 +371,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
if (line.length() == 0) { if (line.length() == 0) {
String ok = getTunnel().getContext().getProperty("i2ptunnel.gzip"); String ok = getTunnel().getContext().getProperty("i2ptunnel.gzip");
boolean gzip = true; boolean gzip = false;
if (ok != null) if (ok != null)
gzip = Boolean.valueOf(ok).booleanValue(); gzip = Boolean.valueOf(ok).booleanValue();
if (gzip) if (gzip)

View File

@ -240,11 +240,22 @@ public class BlogManager {
File cfg = getConfigFile(); File cfg = getConfigFile();
return (cfg.exists()); return (cfg.exists());
} }
/**
* If true, this syndie instance is meant for just one local user, so we don't need
* to password protect registration, remote.jsp, or admin.jsp
*
*/
public boolean isSingleUser() {
String isSingle = _context.getProperty("syndie.singleUser");
return ( (isSingle != null) && (Boolean.valueOf(isSingle).booleanValue()) );
}
public String getDefaultProxyHost() { return _context.getProperty("syndie.defaultProxyHost", ""); } public String getDefaultProxyHost() { return _context.getProperty("syndie.defaultProxyHost", ""); }
public String getDefaultProxyPort() { return _context.getProperty("syndie.defaultProxyPort", ""); } public String getDefaultProxyPort() { return _context.getProperty("syndie.defaultProxyPort", ""); }
public boolean authorizeAdmin(String pass) { public boolean authorizeAdmin(String pass) {
if (isSingleUser()) return true;
String admin = getAdminPasswordHash(); String admin = getAdminPasswordHash();
if ( (admin == null) || (admin.trim().length() <= 0) ) if ( (admin == null) || (admin.trim().length() <= 0) )
return false; return false;
@ -252,15 +263,20 @@ public class BlogManager {
return (hash.equals(admin)); return (hash.equals(admin));
} }
public boolean authorizeRemote(String pass) { public boolean authorizeRemote(String pass) {
if (isSingleUser()) return true;
String rem = getRemotePasswordHash(); String rem = getRemotePasswordHash();
if ( (rem == null) || (rem.trim().length() <= 0) ) if ( (rem == null) || (rem.trim().length() <= 0) )
return false; return false;
String hash = Base64.encode(_context.sha().calculateHash(DataHelper.getUTF8(pass.trim())).getData()); String hash = Base64.encode(_context.sha().calculateHash(DataHelper.getUTF8(pass.trim())).getData());
return (hash.equals(rem)); return (hash.equals(rem));
} }
public boolean authorizeRemote(User user) {
if (isSingleUser()) return true;
return (!user.getAuthenticated() || !user.getAllowAccessRemote());
}
public void configure(String registrationPassword, String remotePassword, String adminPass, String defaultSelector, public void configure(String registrationPassword, String remotePassword, String adminPass, String defaultSelector,
String defaultProxyHost, int defaultProxyPort, Properties opts) { String defaultProxyHost, int defaultProxyPort, boolean isSingleUser, Properties opts) {
File cfg = getConfigFile(); File cfg = getConfigFile();
Writer out = null; Writer out = null;
try { try {
@ -277,6 +293,7 @@ public class BlogManager {
out.write("syndie.defaultProxyHost="+defaultProxyHost.trim() + "\n"); out.write("syndie.defaultProxyHost="+defaultProxyHost.trim() + "\n");
if (defaultProxyPort > 0) if (defaultProxyPort > 0)
out.write("syndie.defaultProxyPort="+defaultProxyPort + "\n"); out.write("syndie.defaultProxyPort="+defaultProxyPort + "\n");
out.write("syndie.singleUser=" + isSingleUser + "\n");
if (opts != null) { if (opts != null) {
for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) { for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next(); String key = (String)iter.next();
@ -327,7 +344,7 @@ public class BlogManager {
public String register(User user, String login, String password, String registrationPassword, String blogName, String blogDescription, String contactURL) { public String register(User user, String login, String password, String registrationPassword, String blogName, String blogDescription, String contactURL) {
System.err.println("Register [" + login + "] pass [" + password + "] name [" + blogName + "] descr [" + blogDescription + "] contact [" + contactURL + "] regPass [" + registrationPassword + "]"); System.err.println("Register [" + login + "] pass [" + password + "] name [" + blogName + "] descr [" + blogDescription + "] contact [" + contactURL + "] regPass [" + registrationPassword + "]");
String hashedRegistrationPassword = getRegistrationPasswordHash(); String hashedRegistrationPassword = getRegistrationPasswordHash();
if (hashedRegistrationPassword != null) { if ( (hashedRegistrationPassword != null) && (!isSingleUser()) ) {
try { try {
if (!hashedRegistrationPassword.equals(Base64.encode(_context.sha().calculateHash(registrationPassword.getBytes("UTF-8")).getData()))) if (!hashedRegistrationPassword.equals(Base64.encode(_context.sha().calculateHash(registrationPassword.getBytes("UTF-8")).getData())))
return "<span class=\"b_regMsgErr\">Invalid registration password</span>"; return "<span class=\"b_regMsgErr\">Invalid registration password</span>";

View File

@ -351,7 +351,7 @@ public class HTMLRenderer extends EventReceiverImpl {
_bodyBuffer.append(getSpan("blogArchive")).append(" Archives: "); _bodyBuffer.append(getSpan("blogArchive")).append(" Archives: ");
for (int i = 0; i < locations.size(); i++) { for (int i = 0; i < locations.size(); i++) {
SafeURL surl = (SafeURL)locations.get(i); SafeURL surl = (SafeURL)locations.get(i);
if (_user.getAuthenticated() && _user.getAllowAccessRemote()) if (_user.getAuthenticated() && BlogManager.instance().authorizeRemote(_user) )
_bodyBuffer.append("<a ").append(getClass("blogArchiveView")).append(" href=\"").append(getArchiveURL(blog, surl)).append("\">").append(sanitizeString(surl.toString())).append("</a> "); _bodyBuffer.append("<a ").append(getClass("blogArchiveView")).append(" href=\"").append(getArchiveURL(blog, surl)).append("\">").append(sanitizeString(surl.toString())).append("</a> ");
else else
_bodyBuffer.append(getSpan("blogArchiveURL")).append(sanitizeString(surl.toString())).append("</span> "); _bodyBuffer.append(getSpan("blogArchiveURL")).append(sanitizeString(surl.toString())).append("</span> ");

View File

@ -97,7 +97,7 @@ public class PostBean {
_filenames, localStreams, _fileTypes); _filenames, localStreams, _fileTypes);
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Posted the entry " + uri.toString() + " (archive = " + _archive + ")"); _log.debug("Posted the entry " + uri.toString() + " (archive = " + _archive + ")");
if ( (uri != null) && (_user.getAllowAccessRemote()) ) { if ( (uri != null) && BlogManager.instance().authorizeRemote(_user) ) {
PetName pn = _user.getPetNameDB().get(_archive); PetName pn = _user.getPetNameDB().get(_archive);
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Archive to petname? " + pn + " (protocol: " + (pn != null ? pn.getProtocol() : "") + ")"); _log.debug("Archive to petname? " + pn + " (protocol: " + (pn != null ? pn.getProtocol() : "") + ")");

View File

@ -25,11 +25,18 @@ if (!user.getAuthenticated()) {
String proxyHost = request.getParameter("proxyhost"); String proxyHost = request.getParameter("proxyhost");
String proxyPort = request.getParameter("proxyport"); String proxyPort = request.getParameter("proxyport");
String selector = request.getParameter("selector"); String selector = request.getParameter("selector");
boolean isSingleUser = BlogManager.instance().isSingleUser();
String singleSet = request.getParameter("singleuser");
if (singleSet != null)
isSingleUser = true;
else
isSingleUser = false;
if (configured) { if (configured) {
if ( (adminPass != null) && (BlogManager.instance().authorizeAdmin(adminPass)) ) { if (BlogManager.instance().authorizeAdmin(adminPass)) {
int port = -1; int port = -1;
try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; } try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; }
BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, null); BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, isSingleUser, null);
%><span class="b_adminMsgOk">Configuration updated</span><% %><span class="b_adminMsgOk">Configuration updated</span><%
} else { } else {
%><span class="b_adminMsgErr">Invalid admin password. If you lost it, please update your syndie.config.</span><% %><span class="b_adminMsgErr">Invalid admin password. If you lost it, please update your syndie.config.</span><%
@ -37,11 +44,15 @@ if (!user.getAuthenticated()) {
} else { } else {
int port = -1; int port = -1;
try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; } try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; }
BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, null); BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, isSingleUser, null);
%><span class="b_adminMsgOk">Configuration saved</span><% %><span class="b_adminMsgOk">Configuration saved</span><%
} }
} else { } else {
%><form action="admin.jsp" method="POST"> %><form action="admin.jsp" method="POST">
<em class="b_adminField">Single user?</em> <input type="checkbox" class="b_adminField" name="singleuser" <%=BlogManager.instance().isSingleUser() ? " checked=\"true\" " : ""%> /><br />
<span class="b_adminDescr">If this is checked, the registration, admin, and remote passwords are unnecessary - anyone
can register and administer Syndie, as well as use any remote functionality. This should not be checked if untrusted
parties can access this web interface.</span><br />
<em class="b_adminField">Registration password:</em> <input class="b_adminField" type="text" name="regpass" size="10" /><br /> <em class="b_adminField">Registration password:</em> <input class="b_adminField" type="text" name="regpass" size="10" /><br />
<span class="b_adminDescr">Users must specify this password on the registration form to proceed. If this is <span class="b_adminDescr">Users must specify this password on the registration form to proceed. If this is
blank, anyone can register.</span><br /> blank, anyone can register.</span><br />

View File

@ -97,7 +97,7 @@ if (!user.getAuthenticated()) {
post.renderPreview(out); post.renderPreview(out);
%><hr /><span class="b_postConfirm"><form action="post.jsp" method="POST"> %><hr /><span class="b_postConfirm"><form action="post.jsp" method="POST">
Please confirm that the above is ok<% if (user.getAllowAccessRemote()) { %>, and select what additional archives you Please confirm that the above is ok<% if (BlogManager.instance().authorizeRemote(user)) { %>, and select what additional archives you
want the post transmitted to. Otherwise, just hit your browser's back arrow and want the post transmitted to. Otherwise, just hit your browser's back arrow and
make changes. make changes.
<select class="b_postConfirm" name="archive"> <select class="b_postConfirm" name="archive">

View File

@ -16,7 +16,7 @@ request.setCharacterEncoding("UTF-8");
<jsp:include page="_topnav.jsp" /> <jsp:include page="_topnav.jsp" />
<td valign="top" align="left" rowspan="2" class="b_rightnav"><jsp:include page="_rightnav.jsp" /></td></tr> <td valign="top" align="left" rowspan="2" class="b_rightnav"><jsp:include page="_rightnav.jsp" /></td></tr>
<tr class="b_content"><td valign="top" align="left" colspan="3" class="b_content"><% <tr class="b_content"><td valign="top" align="left" colspan="3" class="b_content"><%
if (!user.getAuthenticated() || !user.getAllowAccessRemote()) { if (!BlogManager.instance().authorizeRemote(user)) {
%><span class="b_remoteMsgErr">Sorry, you are not allowed to access remote archives from here. Perhaps you should install Syndie yourself?</span><% %><span class="b_remoteMsgErr">Sorry, you are not allowed to access remote archives from here. Perhaps you should install Syndie yourself?</span><%
} else { %><form action="remote.jsp" method="POST"><span class="b_remoteChooser"><span class="b_remoteChooserField">Import from:</span> } else { %><form action="remote.jsp" method="POST"><span class="b_remoteChooser"><span class="b_remoteChooserField">Import from:</span>
<select class="b_remoteChooserNet" name="schema"> <select class="b_remoteChooserNet" name="schema">

View File

@ -46,6 +46,12 @@
<copy file="apps/jetty/jettylib/javax.servlet.jar" todir="build/" /> <copy file="apps/jetty/jettylib/javax.servlet.jar" todir="build/" />
</target> </target>
<target name="buildexe"> <target name="buildexe">
<condition property="osx">
<os family="mac" />
</condition>
<ant target="doBuildEXE" />
</target>
<target name="doBuildEXE" unless="osx">
<jar destfile="./build/launchi2p.jar"> <jar destfile="./build/launchi2p.jar">
<manifest> <manifest>
<attribute name="Main-Class" value="net.i2p.router.RouterLaunch" /> <attribute name="Main-Class" value="net.i2p.router.RouterLaunch" />
@ -115,8 +121,8 @@
</target> </target>
<target name="clean" depends="pkgclean" > <target name="clean" depends="pkgclean" >
<delete dir="./build" /> <delete dir="./build" />
<delete file="i2pinstall.exe" /> <delete file="i2pinstall.exe" failonerror="false" quiet="true" />
<delete file="i2p.exe" /> <delete file="i2p.exe" failonerror="false" quiet="true" />
</target> </target>
<target name="distclean" depends="clean"> <target name="distclean" depends="clean">
<ant dir="core/java/" target="distclean" /> <ant dir="core/java/" target="distclean" />
@ -199,7 +205,7 @@
<copy file="build/routerconsole.jar" todir="pkg-temp/lib/" /> <copy file="build/routerconsole.jar" todir="pkg-temp/lib/" />
<copy file="build/sam.jar" todir="pkg-temp/lib/" /> <copy file="build/sam.jar" todir="pkg-temp/lib/" />
<copy file="build/systray.jar" todir="pkg-temp/lib" /> <copy file="build/systray.jar" todir="pkg-temp/lib" />
<copy file="i2p.exe" todir="pkg-temp/" /> <copy file="i2p.exe" todir="pkg-temp/" failonerror="false" />
<copy file="installer/resources/runplain.sh" todir="pkg-temp/" /> <copy file="installer/resources/runplain.sh" todir="pkg-temp/" />
<copy file="apps/systray/java/lib/systray4j.jar" todir="pkg-temp/lib" /> <copy file="apps/systray/java/lib/systray4j.jar" todir="pkg-temp/lib" />
<copy file="apps/systray/java/lib/systray4j.dll" todir="pkg-temp/lib" /> <copy file="apps/systray/java/lib/systray4j.dll" todir="pkg-temp/lib" />
@ -289,7 +295,7 @@
<copy file="build/sam.jar" todir="pkg-temp/lib/" /> <copy file="build/sam.jar" todir="pkg-temp/lib/" />
<copy file="build/router.jar" todir="pkg-temp/lib/" /> <copy file="build/router.jar" todir="pkg-temp/lib/" />
<copy file="build/routerconsole.jar" todir="pkg-temp/lib/" /> <copy file="build/routerconsole.jar" todir="pkg-temp/lib/" />
<copy file="i2p.exe" todir="pkg-temp/" /> <copy file="i2p.exe" todir="pkg-temp/" failonerror="false" />
<copy file="installer/resources/runplain.sh" todir="pkg-temp/" /> <copy file="installer/resources/runplain.sh" todir="pkg-temp/" />
<!-- for the i2p 0.5 release, push jetty 5.2.1 --> <!-- for the i2p 0.5 release, push jetty 5.2.1 -->
@ -341,6 +347,12 @@
<ant target="installerexe" /> <ant target="installerexe" />
</target> </target>
<target name="installerexe"> <target name="installerexe">
<condition property="osx">
<os family="mac" />
</condition>
<ant target="doInstallerEXE" />
</target>
<target name="doInstallerEXE">
<!-- now the installer exe --> <!-- now the installer exe -->
<taskdef name="launch4j" <taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask" classname="net.sf.launch4j.ant.Launch4jTask"

View File

@ -1,4 +1,16 @@
$Id: history.txt,v 1.252 2005/09/16 13:28:27 jrandom Exp $ $Id: history.txt,v 1.253 2005/09/16 16:24:43 jrandom Exp $
2005-09-17 jrandom
* Added the natively compiled jbigi and patched java service wrapper for
OS X. Thanks Bill Dorsey for letting me use your machine!
* Don't build i2p.exe or i2pinstall.exe when run on OS X machines, as we
don't bundle the binutils necessary (and there'd be a naming conflict
if we did).
* Added 'single user' functionality to syndie - if the single user
checkbox on the admin page is checked, all users are allowed to control
the instance and sync up with remote syndie nodes.
* Temporarily disable the x-i2p-gzip in i2ptunnel until it is more closely
debugged.
2005-09-16 jrandom 2005-09-16 jrandom
* Reject unroutable IPs in SSU like we do for the TCP transport (unless * Reject unroutable IPs in SSU like we do for the TCP transport (unless

View File

@ -1,4 +1,7 @@
jbigi.jar was built by jrandom on Aug 21, 2004 with the jbigi and jcpuid jbigi.jar was built by jrandom on Aug 21, 2004 with the jbigi and jcpuid
native libraries compiled on linux, winXP (w/ MinGW), and freebsd (4.8). native libraries compiled on linux, winXP (w/ MinGW), and freebsd (4.8).
The GMP code in jbigi is from GMP-4.1.3 (http://www.swox.com/gmp/), and The GMP code in jbigi is from GMP-4.1.3 (http://www.swox.com/gmp/), and
was optimized for a variety of CPU architectures. was optimized for a variety of CPU architectures.
On Sep 16, 2005, libjbigi-osx-none.jnilib was added to jbigi.jar after
being compiled by jrandom on osx/ppc with GMP-4.1.4.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
The wrapper in here is built with an osx patch, backported from
the 3.1.2 per
http://sourceforge.net/tracker/index.php?func=detail&
aid=1262323&
group_id=39428&
atid=425187

View File

@ -0,0 +1,78 @@
--- wrapper_3.1.1_src/src/c/wrapper.c Fri Jul 16 10:29:10 2004
+++ wrapper_3.1.1_src_modified/src/c/wrapper.c Fri Sep 16 14:55:23 2005
@@ -312,7 +312,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+
+#ifdef MACOSX
+#include <sys/time.h>
+#else
#include <sys/timeb.h>
+#endif
+
#include <sys/stat.h>
#include "wrapperinfo.h"
#include "wrapper.h"
@@ -760,16 +766,28 @@
int len;
int pos;
int err;
+
+ #ifdef MACOSX
+ struct timeval timeBuffer;
+ #else
struct timeb timeBuffer;
+ #endif
+
long startTime;
int startTimeMillis;
long now;
int nowMillis;
long durr;
+#ifdef MACOSX
+ gettimeofday(&timeBuffer, NULL);
+ startTime = now = timeBuffer.tv_sec;
+ startTimeMillis = nowMillis = timeBuffer.tv_usec / 1000;
+#else
ftime( &timeBuffer );
startTime = now = timeBuffer.time;
startTimeMillis = nowMillis = timeBuffer.millitm;
+#endif
/*
log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, "now=%ld, nowMillis=%d", now, nowMillis);
@@ -900,9 +918,15 @@
}
/* Get the time again */
+#ifdef MACOSX
+ gettimeofday(&timeBuffer, NULL);
+ now = timeBuffer.tv_sec;
+ nowMillis = timeBuffer.tv_usec / 1000;
+#else
ftime( &timeBuffer );
now = timeBuffer.time;
nowMillis = timeBuffer.millitm;
+#endif
}
/*
log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, "done durr=%ld", durr);
@@ -2250,10 +2274,15 @@
* Calculates a tick count using the system time.
*/
DWORD wrapperGetSystemTicks() {
+#ifdef MACOSX
+ struct timeval timeBuffer;
+ gettimeofday(&timeBuffer, NULL);
+ return (timeBuffer.tv_sec * 1000 + timeBuffer.tv_usec/1000) / WRAPPER_TICK_MS;
+#else
struct timeb timeBuffer;
-
ftime( &timeBuffer );
return (timeBuffer.time * 1000 + timeBuffer.millitm) / WRAPPER_TICK_MS;
+#endif
}
/**

View File

@ -0,0 +1,60 @@
--- wrapper_3.1.1_src/src/c/wrapper_unix.c Fri Jul 16 10:29:10 2004
+++ wrapper_3.1.1_src_modified/src/c/wrapper_unix.c Fri Sep 16 14:45:48 2005
@@ -309,7 +309,13 @@
#include <limits.h>
#include <pthread.h>
#include <pwd.h>
+
+#ifdef MACOSX
+#include <sys/time.h>
+#else
#include <sys/timeb.h>
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -1056,7 +1062,11 @@
ssize_t bytesRead;
char readBuf [1025];
int readBufPos, childOutputBufferPos;
+#ifdef MACOSX
+ struct timeval timeBuffer;
+#else
struct timeb timeBuffer;
+#endif
long startTime;
int startTimeMillis;
long now;
@@ -1064,9 +1074,15 @@
long durr;
if (jvmOut != -1) {
+#ifdef MACOSX
+ gettimeofday(&timeBuffer, NULL);
+ startTime = now = timeBuffer.tv_sec;
+ startTimeMillis = nowMillis = timeBuffer.tv_usec / 1000;
+#else
ftime( &timeBuffer );
startTime = now = timeBuffer.time;
startTimeMillis = nowMillis = timeBuffer.millitm;
+#endif
/*
log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, "now=%ld, nowMillis=%d", now, nowMillis);
@@ -1159,9 +1175,15 @@
}
/* Get the time again */
+#ifdef MACOSX
+ gettimeofday(&timeBuffer, NULL);
+ now = timeBuffer.tv_sec;
+ nowMillis = timeBuffer.tv_usec / 1000;
+#else
ftime( &timeBuffer );
now = timeBuffer.time;
nowMillis = timeBuffer.millitm;
+#endif
}
}

View File

@ -19,7 +19,7 @@ fi
chmod 744 ./i2prouter chmod 744 ./i2prouter
# chmod 744 ./install_i2p_service_unix # chmod 744 ./install_i2p_service_unix
chmod 744 ./osid chmod 744 ./osid
chmod 744 ./startRouter.sh chmod 744 ./runplain.sh
# chmod 744 ./uninstall_i2p_service_unix # chmod 744 ./uninstall_i2p_service_unix
ERROR_MSG="Cannot determine operating system type. From the subdirectory in lib/wrapper matching your operating system, please move i2psvc to your base I2P directory, and move the remaining two files to the lib directory." ERROR_MSG="Cannot determine operating system type. From the subdirectory in lib/wrapper matching your operating system, please move i2psvc to your base I2P directory, and move the remaining two files to the lib directory."