]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Change how initial log handler is registered
authorTobias Brunner <tobias@strongswan.org>
Tue, 31 Mar 2020 12:56:38 +0000 (14:56 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 2 Jun 2020 12:07:06 +0000 (14:07 +0200)
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).

src/frontends/android/app/src/main/jni/libandroidbridge/charonservice.c

index 5a3435a11cb522aeeff17b67951382d5aa54de37..d0f1d35ab3b884f1fa582e5cbf1e402dd28b81ad 100644 (file)
@@ -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();