android: Change how initial log handler is registered

Previously, if the two utility functions were called while the VPN
connection was established (i.e. charon was initialized) the logger for
libstrongswan would get reset to the initial log handler.  So certain
log messages would not get logged to the log file after the TUN device
was created (one of the helpers is used to convert IPs there).
This commit is contained in:
Tobias Brunner
2020-06-02 14:07:06 +02:00
parent 070cd12dfb
commit f3695d089b
@@ -620,6 +620,14 @@ static void segv_handler(int signal)
exit(1);
}
/**
* Register this logger as default before we have the bus available
*/
static void __attribute__ ((constructor))register_logger()
{
dbg = dbg_android;
}
/**
* Initialize charon and the libraries via JNI
*/
@@ -630,9 +638,6 @@ JNI_METHOD(CharonVpnService, initializeCharon, jboolean,
struct utsname utsname;
char *logfile, *appdir, *plugins;
/* logging for library during initialization, as we have no bus yet */
dbg = dbg_android;
/* initialize library */
if (!library_init(NULL, "charon"))
{
@@ -750,8 +755,6 @@ JNI_METHOD_P(org_strongswan_android_utils, Utils, isProposalValid, jboolean,
char *str;
bool valid;
dbg = dbg_android;
if (!library_init(NULL, "charon"))
{
library_deinit();
@@ -776,8 +779,6 @@ JNI_METHOD_P(org_strongswan_android_utils, Utils, parseInetAddressBytes, jbyteAr
host_t *host;
char *str;
dbg = dbg_android;
if (!library_init(NULL, "charon"))
{
library_deinit();