Browse Source

Kick-out all Enigmail 2.0 leftovers. Bump API version to 0.17.0 and version name to "(40) Eisenach-Ost".

JSON-123
Roker 3 years ago
parent
commit
2793593cb2
7 changed files with 17 additions and 299 deletions
  1. +13
    -15
      server/ev_server.cc
  2. +0
    -52
      server/gpg_environment.cc
  3. +0
    -16
      server/gpg_environment.hh
  4. +0
    -187
      server/hotfixer.cc
  5. +0
    -15
      server/hotfixer.hh
  6. +0
    -12
      server/main.cc
  7. +4
    -2
      server/server_version.cc

+ 13
- 15
server/ev_server.cc View File

@ -8,7 +8,6 @@
#include "pep-types.hh"
#include "json_rpc.hh"
#include "pep-utils.hh"
#include "gpg_environment.hh"
#include "logger.hh"
#include "server_version.hh"
@ -16,8 +15,11 @@
#include <pEp/blacklist.h>
#include <pEp/key_reset.h>
#include <pEp/openpgp_compat.h>
#include <pEp/message_api.h> // for get_binary_path()
#include <pEp/mime.h>
// libpEpAdapter:
#include <pEp/status_to_string.hh>
#include <pEp/slurp.hh>
#include <boost/filesystem.hpp>
@ -54,22 +56,18 @@ std::string version_as_a_string()
return ss.str();
}
#ifdef ENIGMAIL_2_0_COMPAT
// wrapper for Enigmail 2.0 to provide the old Engine's API before JSON-92 / ENGINE-423
PEP_STATUS MIME_decrypt_message_20(PEP_SESSION session, const char* src, size_t src_len, char** plaintext,
stringlist_t** keylist, PEP_rating* rating, PEP_decrypt_flags_t* flags)
std::string getBinaryPath()
{
*flags = 0;
char* modified_src = nullptr;
PEP_STATUS status = MIME_decrypt_message(session, src, src_len, plaintext, keylist, rating, flags, &modified_src);
pEp_free(modified_src);
return status;
const char* gpg_path = nullptr;
const auto status = get_binary_path( PEP_crypt_OpenPGP, &gpg_path);
if(status == PEP_STATUS_OK && gpg_path)
{
return std::string(gpg_path);
}
throw std::runtime_error("getBinaryPath returns error: " + ::pEp::status_to_string(status) );
}
#endif // ENIGMAIL_2_0_COMPAT
using In_Pep_Session = In<PEP_SESSION, ParamFlag::NoInput>;
@ -161,7 +159,7 @@ const FunctionMap functions = {
FP( "Other", new Separator ),
FP( "serverVersion", new Func<ServerVersion>( &server_version ) ),
FP( "version", new Func<std::string>( &version_as_a_string ) ),
FP( "getGpgEnvironment", new Func<GpgEnvironment>( &getGpgEnvironment ) ),
FP( "getBinaryPath", new Func<std::string>( &getBinaryPath ) ),
FP( "shutdown", new Func<void, In<JsonAdapter*,ParamFlag::NoInput>>( &JsonAdapter::shutdown_now ) ),
};


+ 0
- 52
server/gpg_environment.cc View File

@ -1,52 +0,0 @@
#include "gpg_environment.hh"
#include "function_map.hh"
#include <cstdlib>
#include <pEp/message_api.h> // for get_binary_path()
GpgEnvironment getGpgEnvironment()
{
GpgEnvironment ge{};
const char* gpg_path = nullptr;
const auto status = get_binary_path( PEP_crypt_OpenPGP, &gpg_path);
if(status == PEP_STATUS_OK && gpg_path)
{
ge.gnupg_path = std::string(gpg_path);
}
const char* home = std::getenv("GNUPGHOME");
if(home)
{
ge.gnupg_home = std::string(home);
}
const char* ai = std::getenv("GPG_AGENT_INFO");
if(ai)
{
ge.gpg_agent_info = std::string(ai);
}
return ge;
}
template<>
Out<GpgEnvironment>::~Out()
{
}
template<>
js::Value to_json<GpgEnvironment>(const GpgEnvironment& ge)
{
js::Object obj;
obj.emplace_back("gnupg_path", (ge.gnupg_path ? ge.gnupg_path.get() : js::Value{}) );
obj.emplace_back("gnupg_home", (ge.gnupg_home ? ge.gnupg_home.get() : js::Value{}) );
obj.emplace_back("gpg_agent_info", (ge.gpg_agent_info ? ge.gpg_agent_info.get() : js::Value{}) );
return obj;
}
template<>
js::Value Type2String<GpgEnvironment>::get() { return "GpgEnvironment"; }

+ 0
- 16
server/gpg_environment.hh View File

@ -1,16 +0,0 @@
#ifndef JSON_GPG_ENVIRONMENT_HH
#define JSON_GPG_ENVIRONMENT_HH
#include <boost/optional.hpp>
#include <string>
struct GpgEnvironment
{
boost::optional<std::string> gnupg_path; // filled by pEpEngine's gnu_gpg_path()
boost::optional<std::string> gnupg_home; // filled by getenv("GNUPGHOME")
boost::optional<std::string> gpg_agent_info; // filled by getenv("GPG_AGENT_INFO")
};
GpgEnvironment getGpgEnvironment();
#endif

+ 0
- 187
server/hotfixer.cc View File

@ -1,187 +0,0 @@
#include "hotfixer.hh"
#include "logger.hh"
#ifdef __APPLE__
// disable boost::process because b0rken on MacOS since boost version 1.69
#else
#include <boost/process.hpp>
namespace bp = boost::process;
#endif
#include <boost/filesystem.hpp>
#ifdef _WIN32
# ifndef HOTFIX_SENTINEL_FILE
# define HOTFIX_SENTINEL_FILE "json-hotfix-1.dat"
# endif
# define HOTFIX_BINARY "pep-hotfix.exe"
#else
# ifndef HOTFIX_SENTINEL_FILE
# define HOTFIX_SENTINEL_FILE "json-hotfix-1.dat"
# endif
# define HOTFIX_BINARY "pep-hotfix"
#endif
#define IS_ERROR_LOGGED(e) ( is_error_logged((e), "hotfixer.cc", __LINE__) )
namespace fs = boost::filesystem;
namespace sys = boost::system;
namespace pEp
{
namespace utility
{
fs::path get_pep_dir()
{
const char *env_pephome = getenv("PEPHOME");
#ifndef _WIN32
const char *env_usrhome = getenv("HOME");
const char *env_pepsub = ".pEp";
#else
const char *env_usrhome = getenv("APPDATA");
const char *env_pepsub = "pEp";
#endif
fs::path pephome;
if (env_pephome)
pephome = fs::path(env_pephome);
else
{
if (!env_usrhome || !env_pepsub)
return fs::path(); // .empty() == true
fs::path p1 = env_usrhome;
fs::path p2 = env_pepsub;
pephome = p1 / p2;
}
if(!fs::create_directory(pephome))
if (!fs::exists(pephome))
return fs::path();
return pephome;
}
int is_error_logged(sys::error_code& sec, const char* const src, const int line)
{
int ret = 0;
if ((ret = sec.value()))
{
Logger l("hotfix");
l.error("%s error (%d): %s (%s:%d)", sec.category().name(), ret, sec.message().c_str(), src, line);
sec.clear();
return ret;
}
return 0;
}
int is_error_logged(std::error_code& ec, const char* const src, const int line)
{
int ret = 0;
if ((ret = ec.value()))
{
Logger l("hotfix");
l.error("%s error (%d): %s (%s:%d)", ec.category().name(), ret, ec.message().c_str(), src, line);
ec.clear();
return ret;
}
return 0;
}
fs::path get_adapter_share_dir(sys::error_code& sec)
{
return fs::path(".");
}
fs::path get_adapter_bin_dir(sys::error_code& sec)
{
fs::path p = "../../bin";
return p;
}
bool hotfix_call_required()
{
sys::error_code sec;
int ret;
Logger L("hotfix");
fs::path pepdir = get_adapter_share_dir(sec);
if ((ret = IS_ERROR_LOGGED(sec)))
return ret;
if (fs::exists(pepdir / HOTFIX_SENTINEL_FILE), sec)
return false;
L.info("hotfix required to run");
return true;
}
int hotfix_call_execute()
{
// problems on Mac OS and boost::process version 1.69, so we disable this hotfix functionality here. :-P
#ifdef __APPLE__
return 0;
#else
std::error_code ec;
sys::error_code sec;
int ret;
Logger L("hotfix");
fs::path sent_path = get_adapter_share_dir(sec);
if ((ret = IS_ERROR_LOGGED(ec)))
return ret;
sent_path /= HOTFIX_SENTINEL_FILE;
fs::path hotfix_bin = get_adapter_bin_dir(sec);
if ((ret = IS_ERROR_LOGGED(ec)))
return ret;
hotfix_bin /= HOTFIX_BINARY;
if (!(fs::exists(hotfix_bin, sec)))
{
IS_ERROR_LOGGED(sec);
L.debug("file: '%s'", hotfix_bin.c_str());
L.info("error locating hotfix binary, ignoring.");
return 0;
}
bp::ipstream is; // reading spipe-stream
std::string line;
bp::child c(hotfix_bin, bp::std_out > is, ec);
if ((ret = IS_ERROR_LOGGED(ec)))
return ret;
while (c.running(ec) && std::getline(is, line) && !line.empty())
L.info(line);
if ((ret = IS_ERROR_LOGGED(ec)))
{
c.wait(ec);
return ret;
}
c.wait(ec);
if ((ret = IS_ERROR_LOGGED(ec)))
return ret;
if ((ret = c.exit_code()))
{
L.error("hotfix returned exit code %d, exiting...", ret);
return ret;
}
fs::ofstream sent_file(sent_path);
sent_file << "# HOTFIX SENTINEL FILE, DO NOT REMOVE" << std::endl;
sent_file.close();
L.debug("sentinel file created: '%s'", sent_path.c_str());
return 0;
#endif // ! __APPLE__
}
}
}

+ 0
- 15
server/hotfixer.hh View File

@ -1,15 +0,0 @@
#ifndef HOT_FIXER_HH
#define HOT_FIXER_HH
namespace pEp
{
namespace utility
{
bool hotfix_call_required();
int hotfix_call_execute();
}
}
#endif

+ 0
- 12
server/main.cc View File

@ -5,7 +5,6 @@
#include "daemonize.hh"
#include "logger.hh"
#include "nulllogger.hh"
#include "hotfixer.hh"
#include <thread>
#include <fstream>
@ -105,17 +104,6 @@ try
Logger L("main");
L.info("main logger started");
int hotfix_ret = 0;
#ifdef _WIN32
if ((STATUS_HANDLE == 0) && pEp::utility::hotfix_call_required())
#else
if (pEp::utility::hotfix_call_required())
#endif
{
if ((hotfix_ret = pEp::utility::hotfix_call_execute()) != 0)
return hotfix_ret;
}
if(add_sharks)
{
ev_server::addSharks();


+ 4
- 2
server/server_version.cc View File

@ -68,7 +68,8 @@ static const std::string VersionName =
// Renumbering due to political decisions - the planned exits 31..39 through the Sauerland will never be build. :-(
// So we got a new exit with the same number:
"(39) Eisenach"; // JSON-118: fix to_json() for KeySync callbacks to avoid crashes. Add attachment support in interactive.js \o/
// "(39) Eisenach"; // JSON-118: fix to_json() for KeySync callbacks to avoid crashes. Add attachment support in interactive.js \o/
"(40) Eisenach-Ost"; // remove all Enigmail leftovers. Bump API version to 0.17.0
} // end of anonymous namespace
////////////////////////////////////////////////////////////////////////////
@ -92,7 +93,8 @@ const ServerVersion& server_version()
//static const ServerVersion sv(0,15,4); // JSON-117: add trust_own_key()
//static const ServerVersion sv(0,15,5); // JSON-119: add get_key_rating_for_user()
//static const ServerVersion sv(0,16,0); // Kick-out Enigmail 2.0 compat, remove MIME_*() methods, deliverHandshakeResult() changes parameter types
static const ServerVersion sv(0,16,1); // JSON-120: add support for key_reset_identity(), key_reset_user(), and key_reset_all_own_keys()
//static const ServerVersion sv(0,16,1); // JSON-120: add support for key_reset_identity(), key_reset_user(), and key_reset_all_own_keys()
static const ServerVersion sv(0,17,0); // kick out getGpgEnvironment(). It was Enigmail-only (JSON-18) and breaks architecture. Kick-out hotfixer un-feature.
return sv;
}


Loading…
Cancel
Save