wg-quick: android: allow package to be overridden
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
c61c5a03ee
commit
f621f36800
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -24,8 +25,11 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#ifndef WG_PACKAGE_NAME
|
||||||
|
#define WG_PACKAGE_NAME "com.wireguard.android"
|
||||||
|
#endif
|
||||||
#ifndef WG_CONFIG_SEARCH_PATHS
|
#ifndef WG_CONFIG_SEARCH_PATHS
|
||||||
#define WG_CONFIG_SEARCH_PATHS "/data/misc/wireguard /data/data/com.wireguard.android/files"
|
#define WG_CONFIG_SEARCH_PATHS "/data/misc/wireguard /data/data/" WG_PACKAGE_NAME "/files"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _printf_(x, y) __attribute__((format(printf, x, y)))
|
#define _printf_(x, y) __attribute__((format(printf, x, y)))
|
||||||
|
@ -34,7 +38,7 @@
|
||||||
|
|
||||||
static bool is_exiting = false;
|
static bool is_exiting = false;
|
||||||
|
|
||||||
/* TODO: remove this once the NDK supports it. */
|
#if defined(__ANDROID_API__) && __ANDROID_API__ < 24
|
||||||
static char *strchrnul(const char *s, int c)
|
static char *strchrnul(const char *s, int c)
|
||||||
{
|
{
|
||||||
char *x = strchr(s, c);
|
char *x = strchr(s, c);
|
||||||
|
@ -42,6 +46,7 @@ static char *strchrnul(const char *s, int c)
|
||||||
return (char *)s + strlen(s);
|
return (char *)s + strlen(s);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void *xmalloc(size_t size)
|
static void *xmalloc(size_t size)
|
||||||
{
|
{
|
||||||
|
@ -598,8 +603,8 @@ static void broadcast_change(void)
|
||||||
{
|
{
|
||||||
const char *pkg = getenv("CALLING_PACKAGE");
|
const char *pkg = getenv("CALLING_PACKAGE");
|
||||||
|
|
||||||
if (!pkg || strcmp(pkg, "com.wireguard.android"))
|
if (!pkg || strcmp(pkg, WG_PACKAGE_NAME))
|
||||||
cmd("am broadcast -a com.wireguard.android.action.REFRESH_TUNNEL_STATES com.wireguard.android");
|
cmd("am broadcast -a com.wireguard.android.action.REFRESH_TUNNEL_STATES " WG_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_search_paths(FILE *file, const char *prefix)
|
static void print_search_paths(FILE *file, const char *prefix)
|
||||||
|
|
Loading…
Reference in New Issue