Commit d844fc24 authored by Max Lv's avatar Max Lv

refine fake proc name

parent a1bdfa5b
...@@ -192,6 +192,7 @@ struct { ...@@ -192,6 +192,7 @@ struct {
#ifdef ANDROID #ifdef ANDROID
int tun_fd; int tun_fd;
int tun_mtu; int tun_mtu;
int fake_proc;
char *pid; char *pid;
char *dnsgw; char *dnsgw;
#else #else
...@@ -391,10 +392,6 @@ int main (int argc, char **argv) ...@@ -391,10 +392,6 @@ int main (int argc, char **argv)
return 1; return 1;
} }
// Fake process name to cheat on Lollipop
strcpy(argv[0], "com.github.shadowsocks");
prctl(PR_SET_NAME, "com.github.shadowsocks");
// open standard streams // open standard streams
open_standard_streams(); open_standard_streams();
...@@ -405,6 +402,13 @@ int main (int argc, char **argv) ...@@ -405,6 +402,13 @@ int main (int argc, char **argv)
goto fail0; goto fail0;
} }
if (options.fake_proc) {
// Fake process name to cheat on Lollipop
strcpy(argv[0], "com.github.shadowsocks");
prctl(PR_SET_NAME, "com.github.shadowsocks");
}
// handle --help and --version // handle --help and --version
if (options.help) { if (options.help) {
print_version(); print_version();
...@@ -664,6 +668,7 @@ void print_help (const char *name) ...@@ -664,6 +668,7 @@ void print_help (const char *name)
" [--loglevel <0-5/none/error/warning/notice/info/debug>]\n" " [--loglevel <0-5/none/error/warning/notice/info/debug>]\n"
" [--channel-loglevel <channel-name> <0-5/none/error/warning/notice/info/debug>] ...\n" " [--channel-loglevel <channel-name> <0-5/none/error/warning/notice/info/debug>] ...\n"
#ifdef ANDROID #ifdef ANDROID
" [--fake-proc]\n"
" [--tunfd <fd>]\n" " [--tunfd <fd>]\n"
" [--tunmtu <mtu>]\n" " [--tunmtu <mtu>]\n"
" [--dnsgw <dns_gateway_address>]\n" " [--dnsgw <dns_gateway_address>]\n"
...@@ -718,6 +723,7 @@ int parse_arguments (int argc, char *argv[]) ...@@ -718,6 +723,7 @@ int parse_arguments (int argc, char *argv[])
#ifdef ANDROID #ifdef ANDROID
options.tun_fd = -1; options.tun_fd = -1;
options.tun_mtu = 1500; options.tun_mtu = 1500;
options.fake_proc = 0;
options.pid = NULL; options.pid = NULL;
#else #else
options.tundev = NULL; options.tundev = NULL;
...@@ -812,6 +818,9 @@ int parse_arguments (int argc, char *argv[]) ...@@ -812,6 +818,9 @@ int parse_arguments (int argc, char *argv[])
i += 2; i += 2;
} }
#ifdef ANDROID #ifdef ANDROID
else if (!strcmp(arg, "--fake-proc")) {
options.fake_proc = 1;
}
else if (!strcmp(arg, "--tunfd")) { else if (!strcmp(arg, "--tunfd")) {
if (1 >= argc - i) { if (1 >= argc - i) {
fprintf(stderr, "%s: requires an argument\n", arg); fprintf(stderr, "%s: requires an argument\n", arg);
......
...@@ -320,6 +320,10 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -320,6 +320,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
else else
cmd += " --dnsgw %s:8153".format(PRIVATE_VLAN.format("1")) cmd += " --dnsgw %s:8153".format(PRIVATE_VLAN.format("1"))
if (Utils.isLollipopOrAbove) {
cmd += " --fake-proc";
}
if (BuildConfig.DEBUG) Log.d(TAG, cmd) if (BuildConfig.DEBUG) Log.d(TAG, cmd)
System.exec(cmd); System.exec(cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment