From: SomeDude Date: Mon, 23 Jun 2008 17:25:00 +0000 (+0200) Subject: version 0.2.23 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9b22dd53fe62e312c1647310b7ec43aa127090af;p=fms.git version 0.2.23 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index cfb7d40..f5dd453 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,15 @@ ENDIF(COMMAND CMAKE_POLICY) PROJECT(fms) OPTION(USE_BUNDLED_SQLITE "Use the bundled SQLite3 library." OFF) -OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8. This requires libiconv." OFF) +IF(APPLE) + SET(USE_BUNDLED_SQLITE ON) +ENDIF(APPLE) +OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8. This requires libiconv." ON) +OPTION(I_HAVE_READ_THE_README "I have fully read and understood the readme.txt." OFF) SET(FMS_SRC src/base64.cpp +src/bitmapvalidator.cpp src/board.cpp src/boardlist.cpp src/commandthread.cpp @@ -105,6 +110,10 @@ ELSE(WIN32) SET(FMS_PLATFORM_SRC src/fmsdaemon.cpp) ENDIF(WIN32) +IF(NOT I_HAVE_READ_THE_README) + MESSAGE(FATAL_ERROR "You must fully read the readme.txt before continuing.") +ENDIF(NOT I_HAVE_READ_THE_README) + ADD_DEFINITIONS(-DTIXML_USE_STL) # was for ZThreads @@ -153,7 +162,7 @@ IF(SQLITE3_LIBRARY) TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY}) ELSE(SQLITE3_LIBRARY) IF(NOT USE_BUNDLED_SQLITE) - MESSAGE(STATUS "Could not find system SQLite library. Will compile from included source.") + MESSAGE(STATUS "Could not find system SQLite3 library. Will compile from included source.") ENDIF(NOT USE_BUNDLED_SQLITE) ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c) TARGET_LINK_LIBRARIES(fms sqlite3) @@ -172,7 +181,7 @@ ENDIF(TINYXML_LIBRARY) IF(PTHREADS_LIBRARY) TARGET_LINK_LIBRARIES(fms ${PTHREADS_LIBRARY}) ELSE(PTHREADS_LIBRARY) - MESSAGE(FATAL ERROR "Could not find pthreads library. You must set the location manually.") + MESSAGE(FATAL_ERROR "Could not find pthreads library. You must set the location manually.") ENDIF(PTHREADS_LIBRARY) IF(SHTTPD_LIBRARY) @@ -197,7 +206,7 @@ IF(DO_CHARSET_CONVERSION) TARGET_LINK_LIBRARIES(fms ${ICONV_LIBRARY}) ELSE(ICONV_LIBRARY) IF(WIN32) - MESSAGE(FATAL ERROR "Could not find iconv library. You must set the location manually, or turn off charset conversion.") + MESSAGE(FATAL_ERROR "Could not find iconv library. You must set the location manually, or turn off charset conversion.") ENDIF(WIN32) ENDIF(ICONV_LIBRARY) ENDIF(DO_CHARSET_CONVERSION) diff --git a/include/bitmapvalidator.h b/include/bitmapvalidator.h new file mode 100644 index 0000000..0a1ee65 --- /dev/null +++ b/include/bitmapvalidator.h @@ -0,0 +1,12 @@ +#ifndef _bitmapvalidator_ +#define _bitmapvalidator_ + +#include "documenttypevalidator.h" + +class BitmapValidator:public DocumentTypeValidator +{ +public: + const bool Validate(const std::vector &data); +}; + +#endif // _bitmapvalidator_ diff --git a/include/documenttypevalidator.h b/include/documenttypevalidator.h new file mode 100644 index 0000000..8c99dd5 --- /dev/null +++ b/include/documenttypevalidator.h @@ -0,0 +1,12 @@ +#ifndef _documenttypevalidator_ +#define _documenttypevalidator_ + +#include + +class DocumentTypeValidator +{ +public: + virtual const bool Validate(const std::vector &data)=0; +}; + +#endif // _documenttypevalidator_ diff --git a/include/global.h b/include/global.h index 529ef3b..fa9f487 100644 --- a/include/global.h +++ b/include/global.h @@ -5,7 +5,7 @@ #include #include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.2.22" +#define FMS_VERSION "0.2.23" // opens database and creates tables and initial inserts if necessary void SetupDB(); diff --git a/readme.txt b/readme.txt index 420fdf1..038bb56 100644 --- a/readme.txt +++ b/readme.txt @@ -4,19 +4,21 @@ Compiling FMS requires CMake, pthreads and iconv if you want to do charset conversion. Other required libraries are bundled with FMS. To compile, run these commands from the source directory: -cmake . +cmake -D I_HAVE_READ_THE_README=ON . make If you want to use the bundled SQLite3 library, add a -D USE_BUNDLED_SQLITE=ON -to the cmake command. To do charset conversion to UTF-8 when sending messages, -add a -D DO_CHARSET_CONVERSION=ON. +to the cmake command. Use of the bundled SQLite3 library is on by default when +compiling on a Mac. To turn off charset conversion to UTF-8 when sending +messages, add a -D DO_CHARSET_CONVERSION=OFF. Compiling with charset +conversion turned on is recommended. UPGRADING --------- -It is always a good idea to make copies of your current FMS installation before -continuing. First shut down FMS and then replace the binary and templates with -those from the new version. You may keep the same database unless otherwise -noted. +It is always a good idea to make a copy of your current FMS installation before +continuing. First shut down FMS, make a copy of the directory, and then +replace all files except the database with those from the new version. You may +keep the same database unless otherwise noted. INSTALLATION ------------ diff --git a/src/bitmapvalidator.cpp b/src/bitmapvalidator.cpp new file mode 100644 index 0000000..68482c1 --- /dev/null +++ b/src/bitmapvalidator.cpp @@ -0,0 +1,29 @@ +#include "../include/bitmapvalidator.h" +#include "../include/freenet/captcha/easybmp/EasyBMP.h" + +#include + +const bool BitmapValidator::Validate(const std::vector &data) +{ + bool validated=false; + std::ostringstream tempname; + + tempname << "validatebmp-" << rand() << ".tmp"; + FILE *outfile=fopen(tempname.str().c_str(),"w+b"); + if(outfile) + { + fwrite(&data[0],1,data.size(),outfile); + fclose(outfile); + + BMP temp; + if(temp.ReadFromFile(tempname.str().c_str())) + { + validated=true; + } + + unlink(tempname.str().c_str()); + + } + + return validated; +} diff --git a/src/freenet/introductionpuzzlerequester.cpp b/src/freenet/introductionpuzzlerequester.cpp index 39ffb36..70b3102 100644 --- a/src/freenet/introductionpuzzlerequester.cpp +++ b/src/freenet/introductionpuzzlerequester.cpp @@ -2,6 +2,8 @@ #include "../../include/freenet/introductionpuzzlexml.h" #include "../../include/option.h" #include "../../include/stringfunctions.h" +#include "../../include/bitmapvalidator.h" +#include "../../include/base64.h" #ifdef XMEM #include @@ -104,6 +106,16 @@ const bool IntroductionPuzzleRequester::HandleAllData(FCPMessage &message) validmessage=false; } + // we can only validate bitmaps for now + BitmapValidator val; + std::vector puzzledata; + Base64::Decode(xml.GetPuzzleData(),puzzledata); + if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false) + { + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IntroductionPuzzleRequester::HandleAllData received bad mime type and/or data for "+message["Identifier"]); + validmessage=false; + } + st=m_db->Prepare("INSERT INTO tblIntroductionPuzzleRequests(IdentityID,Day,RequestIndex,Found,UUID,Type,MimeType,PuzzleData) VALUES(?,?,?,?,?,?,?,?);"); st.Bind(0,identityid); st.Bind(1,idparts[4]); diff --git a/src/freenet/periodicdbmaintenance.cpp b/src/freenet/periodicdbmaintenance.cpp index caf14ab..f199fd2 100644 --- a/src/freenet/periodicdbmaintenance.cpp +++ b/src/freenet/periodicdbmaintenance.cpp @@ -189,6 +189,7 @@ void PeriodicDBMaintenance::Do1DayMaintenance() while(st.RowReturned()) { std::string name=""; + std::string namepart=""; std::string publickey=""; int identityid=0; st.ResultText(0,name); @@ -196,9 +197,19 @@ void PeriodicDBMaintenance::Do1DayMaintenance() std::vector parts; StringFunctions::Split(name,"@",parts); + // name can have a @ in it - so reattach all parts except the last which is the key + for(long i=0; iPrepare("SELECT IdentityID,PublicKey FROM tblIdentity WHERE Name=?;"); - st2.Bind(0,name); + st2.Bind(0,namepart); st2.Step(); while(st2.RowReturned()) { @@ -211,7 +222,7 @@ void PeriodicDBMaintenance::Do1DayMaintenance() // we have the identity - so update the messages table with the identityid st2.ResultInt(0,identityid); - SQLite3DB::Statement st3=m_db->Prepare("UPDATE tblMessage SET IdentityID=? WHERE Name=? AND IdentityID IS NULL;"); + SQLite3DB::Statement st3=m_db->Prepare("UPDATE tblMessage SET IdentityID=? WHERE FromName=? AND IdentityID IS NULL;"); st3.Bind(0,identityid); st3.Bind(1,name); st3.Step(); diff --git a/src/freenet/trustlistinserter.cpp b/src/freenet/trustlistinserter.cpp index ee67e6b..a858de1 100644 --- a/src/freenet/trustlistinserter.cpp +++ b/src/freenet/trustlistinserter.cpp @@ -162,7 +162,7 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin SQLite3DB::Statement countst=m_db->Prepare("SELECT COUNT(*) FROM tblMessage WHERE IdentityID=? AND MessageDate>=?;"); // build the xml file - we only want to add identities that we recently saw, otherwise we could be inserting a ton of identities - date.Add(0,0,0,-15); // identities seen in last 15 days + 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 //SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust, MessageTrustComment, TrustListTrustComment FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;"); // we want to order by public key so we can't do identity correllation based on the sequence of identities in the list. 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;");