Anonymous avatar Anonymous committed f102920

mtpd: Get L2TP secret from keystore.

Comments (0)

Files changed (2)

 LOCAL_SRC_FILES := mtpd.c l2tp.c pptp.c
 LOCAL_SHARED_LIBRARIES := libcutils libcrypto
-LOCAL_CFLAGS := -DANDROID_CHANGES -Iexternal/openssl/include
+LOCAL_C_INCLUDES := external/openssl/include frameworks/base/cmds/keystore
 #include <android/log.h>
 #include <cutils/sockets.h>
+#include "keystore_get.h"
 #include "mtpd.h"
     log_print(DEBUG, "Received %d arguments", i - 1);
+    /* L2TP secret is the only thing stored in keystore. We do the query here
+     * so other files are clean and free from android specific code. */
+    if (i > 4 && !strcmp("l2tp", args[1]) && args[4][0]) {
+        char *value = keystore_get(args[4], NULL);
+        if (!value) {
+            log_print(FATAL, "Cannot get L2TP secret from keystore");
+            exit(SYSTEM_ERROR);
+        }
+        free(args[4]);
+        args[4] = value;
+    }
     *argc = i;
     *argv = args;
     return control;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.