PROJECT(fms)\r
\r
OPTION(USE_BUNDLED_SQLITE "Use the bundled SQLite3 library." OFF)\r
-OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8. This requires libiconv." OFF)\r
+IF(APPLE)\r
+ SET(USE_BUNDLED_SQLITE ON)\r
+ENDIF(APPLE)\r
+OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8. This requires libiconv." ON)\r
+OPTION(I_HAVE_READ_THE_README "I have fully read and understood the readme.txt." OFF)\r
\r
SET(FMS_SRC \r
src/base64.cpp\r
+src/bitmapvalidator.cpp\r
src/board.cpp\r
src/boardlist.cpp\r
src/commandthread.cpp\r
SET(FMS_PLATFORM_SRC src/fmsdaemon.cpp)\r
ENDIF(WIN32)\r
\r
+IF(NOT I_HAVE_READ_THE_README)\r
+ MESSAGE(FATAL_ERROR "You must fully read the readme.txt before continuing.")\r
+ENDIF(NOT I_HAVE_READ_THE_README)\r
+\r
ADD_DEFINITIONS(-DTIXML_USE_STL)\r
\r
# was for ZThreads\r
TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY})\r
ELSE(SQLITE3_LIBRARY)\r
IF(NOT USE_BUNDLED_SQLITE)\r
- MESSAGE(STATUS "Could not find system SQLite library. Will compile from included source.")\r
+ MESSAGE(STATUS "Could not find system SQLite3 library. Will compile from included source.")\r
ENDIF(NOT USE_BUNDLED_SQLITE)\r
ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c)\r
TARGET_LINK_LIBRARIES(fms sqlite3)\r
IF(PTHREADS_LIBRARY)\r
TARGET_LINK_LIBRARIES(fms ${PTHREADS_LIBRARY})\r
ELSE(PTHREADS_LIBRARY)\r
- MESSAGE(FATAL ERROR "Could not find pthreads library. You must set the location manually.")\r
+ MESSAGE(FATAL_ERROR "Could not find pthreads library. You must set the location manually.")\r
ENDIF(PTHREADS_LIBRARY)\r
\r
IF(SHTTPD_LIBRARY)\r
TARGET_LINK_LIBRARIES(fms ${ICONV_LIBRARY})\r
ELSE(ICONV_LIBRARY)\r
IF(WIN32)\r
- MESSAGE(FATAL ERROR "Could not find iconv library. You must set the location manually, or turn off charset conversion.")\r
+ MESSAGE(FATAL_ERROR "Could not find iconv library. You must set the location manually, or turn off charset conversion.")\r
ENDIF(WIN32)\r
ENDIF(ICONV_LIBRARY)\r
ENDIF(DO_CHARSET_CONVERSION)\r
--- /dev/null
+#ifndef _bitmapvalidator_\r
+#define _bitmapvalidator_\r
+\r
+#include "documenttypevalidator.h"\r
+\r
+class BitmapValidator:public DocumentTypeValidator\r
+{\r
+public:\r
+ const bool Validate(const std::vector<unsigned char> &data);\r
+};\r
+\r
+#endif // _bitmapvalidator_\r
--- /dev/null
+#ifndef _documenttypevalidator_\r
+#define _documenttypevalidator_\r
+\r
+#include <vector>\r
+\r
+class DocumentTypeValidator\r
+{\r
+public:\r
+ virtual const bool Validate(const std::vector<unsigned char> &data)=0; \r
+};\r
+\r
+#endif // _documenttypevalidator_\r
#include <vector>\r
#include "pthreadwrapper/thread.h"\r
\r
-#define FMS_VERSION "0.2.22"\r
+#define FMS_VERSION "0.2.23"\r
\r
// opens database and creates tables and initial inserts if necessary\r
void SetupDB();\r
conversion. Other required libraries are bundled with FMS.\r
\r
To compile, run these commands from the source directory:\r
-cmake .\r
+cmake -D I_HAVE_READ_THE_README=ON .\r
make\r
\r
If you want to use the bundled SQLite3 library, add a -D USE_BUNDLED_SQLITE=ON\r
-to the cmake command. To do charset conversion to UTF-8 when sending messages,\r
-add a -D DO_CHARSET_CONVERSION=ON.\r
+to the cmake command. Use of the bundled SQLite3 library is on by default when\r
+compiling on a Mac. To turn off charset conversion to UTF-8 when sending\r
+messages, add a -D DO_CHARSET_CONVERSION=OFF. Compiling with charset\r
+conversion turned on is recommended.\r
\r
UPGRADING\r
---------\r
-It is always a good idea to make copies of your current FMS installation before\r
-continuing. First shut down FMS and then replace the binary and templates with\r
-those from the new version. You may keep the same database unless otherwise\r
-noted.\r
+It is always a good idea to make a copy of your current FMS installation before\r
+continuing. First shut down FMS, make a copy of the directory, and then\r
+replace all files except the database with those from the new version. You may\r
+keep the same database unless otherwise noted.\r
\r
INSTALLATION\r
------------\r
--- /dev/null
+#include "../include/bitmapvalidator.h"\r
+#include "../include/freenet/captcha/easybmp/EasyBMP.h"\r
+\r
+#include <sstream>\r
+\r
+const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)\r
+{\r
+ bool validated=false;\r
+ std::ostringstream tempname;\r
+ \r
+ tempname << "validatebmp-" << rand() << ".tmp";\r
+ FILE *outfile=fopen(tempname.str().c_str(),"w+b");\r
+ if(outfile)\r
+ {\r
+ fwrite(&data[0],1,data.size(),outfile);\r
+ fclose(outfile);\r
+ \r
+ BMP temp;\r
+ if(temp.ReadFromFile(tempname.str().c_str()))\r
+ {\r
+ validated=true; \r
+ }\r
+\r
+ unlink(tempname.str().c_str());\r
+ \r
+ }\r
+ \r
+ return validated;\r
+}\r
#include "../../include/freenet/introductionpuzzlexml.h"\r
#include "../../include/option.h"\r
#include "../../include/stringfunctions.h"\r
+#include "../../include/bitmapvalidator.h"\r
+#include "../../include/base64.h"\r
\r
#ifdef XMEM\r
#include <xmem.h>\r
validmessage=false;\r
}\r
\r
+ // we can only validate bitmaps for now\r
+ BitmapValidator val;\r
+ std::vector<unsigned char> puzzledata;\r
+ Base64::Decode(xml.GetPuzzleData(),puzzledata);\r
+ if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false)\r
+ {\r
+ m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData received bad mime type and/or data for "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r
st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);");\r
st.Bind(0,identityid);\r
st.Bind(1,idparts[4]);\r
while(st.RowReturned())\r
{\r
std::string name="";\r
+ std::string namepart="";\r
std::string publickey="";\r
int identityid=0;\r
st.ResultText(0,name);\r
std::vector<std::string> parts;\r
StringFunctions::Split(name,"@",parts);\r
\r
+ // name can have a @ in it - so reattach all parts except the last which is the key\r
+ for(long i=0; i<parts.size()-1; i++)\r
+ {\r
+ if(i!=0)\r
+ {\r
+ namepart+="@";\r
+ }\r
+ namepart+=parts[i];\r
+ }\r
+\r
// find identities with this name\r
SQLite3DB::Statement st2=m_db->Prepare("SELECT IdentityID,PublicKey FROM tblIdentity WHERE Name=?;");\r
- st2.Bind(0,name);\r
+ st2.Bind(0,namepart);\r
st2.Step();\r
while(st2.RowReturned())\r
{\r
// we have the identity - so update the messages table with the identityid\r
st2.ResultInt(0,identityid);\r
\r
- SQLite3DB::Statement st3=m_db->Prepare("UPDATE tblMessage SET IdentityID=? WHERE Name=? AND IdentityID IS NULL;");\r
+ SQLite3DB::Statement st3=m_db->Prepare("UPDATE tblMessage SET IdentityID=? WHERE FromName=? AND IdentityID IS NULL;");\r
st3.Bind(0,identityid);\r
st3.Bind(1,name);\r
st3.Step();\r
SQLite3DB::Statement countst=m_db->Prepare("SELECT COUNT(*) FROM tblMessage WHERE IdentityID=? AND MessageDate>=?;");\r
\r
// build the xml file - we only want to add identities that we recently saw, otherwise we could be inserting a ton of identities\r
- date.Add(0,0,0,-15); // identities seen in last 15 days\r
+ date.Add(0,0,0,-15); // identities seen in last 15 days - the maintenance page lets us delete identities not seen in 20 days, so this gives us a window where the identity won't be deleted and then found in a trust list and readded immediately\r
//SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust, MessageTrustComment, TrustListTrustComment FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;");\r
// we want to order by public key so we can't do identity correllation based on the sequence of identities in the list.\r
SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, tblIdentityTrust.LocalMessageTrust, tblIdentityTrust.LocalTrustListTrust, tblIdentityTrust.MessageTrustComment, tblIdentityTrust.TrustListTrustComment, tblIdentity.IdentityID, tblIdentity.DateAdded FROM tblIdentity INNER JOIN tblIdentityTrust ON tblIdentity.IdentityID=tblIdentityTrust.IdentityID WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=? AND tblIdentityTrust.LocalIdentityID=? ORDER BY PublicKey;");\r