From fd66e2fe2920cdcf39006643c1341ae27f3029d9 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 24 Dec 2020 16:42:32 +0200 Subject: [PATCH] get rid of verify-prefix.patch.txt Switching to a more "soft" solution which will be focused on apt only. Apt will now send an application package name (com.termux) and prefix (/data/data/com.termux/files/usr) as part of user-agent string. That will allow to distinguish real Termux users from parties which download our packages and binary-patching them for the custom prefix. Note that this will disable user's possibility to set custom User-Agent for apt. --- packages/apt/0012-termux-id.patch | 22 ++++++++++++ packages/apt/0012-verify-prefix.patch.txt | 30 ---------------- packages/apt/build.sh | 7 +--- packages/bash/build.sh | 8 +---- packages/bash/verify-prefix.patch.txt | 33 ----------------- packages/coreutils/build.sh | 8 +---- packages/coreutils/verify-prefix.patch.txt | 42 ---------------------- packages/dash/build.sh | 10 +----- packages/dash/verify-prefix.patch.txt | 33 ----------------- packages/dpkg/build.sh | 8 +---- packages/dpkg/verify-prefix.patch.txt | 33 ----------------- 11 files changed, 27 insertions(+), 207 deletions(-) create mode 100644 packages/apt/0012-termux-id.patch delete mode 100644 packages/apt/0012-verify-prefix.patch.txt delete mode 100644 packages/bash/verify-prefix.patch.txt delete mode 100644 packages/coreutils/verify-prefix.patch.txt delete mode 100644 packages/dash/verify-prefix.patch.txt delete mode 100644 packages/dpkg/verify-prefix.patch.txt diff --git a/packages/apt/0012-termux-id.patch b/packages/apt/0012-termux-id.patch new file mode 100644 index 0000000000..f9718de017 --- /dev/null +++ b/packages/apt/0012-termux-id.patch @@ -0,0 +1,22 @@ +diff -uNr apt-2.1.14/methods/http.cc apt-2.1.14.mod/methods/http.cc +--- apt-2.1.14/methods/http.cc 2020-12-15 15:07:36.000000000 +0200 ++++ apt-2.1.14.mod/methods/http.cc 2020-12-24 16:23:15.722168489 +0200 +@@ -341,7 +341,7 @@ + Req << "Proxy-Authorization: Basic " + << Base64Encode(Proxy.User + ":" + Proxy.Password) << "\r\n"; + +- Req << "User-Agent: " << Owner->ConfigFind("User-Agent", "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") << "\r\n"; ++ Req << "User-Agent: Debian APT-HTTP/1.3 (" PACKAGE_VERSION ") Termux (@TERMUX_APP_PACKAGE@; install-prefix:@TERMUX_PREFIX@)" << "\r\n"; + + Req << "\r\n"; + +@@ -955,8 +955,7 @@ + Req << "Authorization: Basic " + << Base64Encode(Uri.User + ":" + Uri.Password) << "\r\n"; + +- Req << "User-Agent: " << ConfigFind("User-Agent", +- "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")"); ++ Req << "User-Agent: Debian APT-HTTP/1.3 (" PACKAGE_VERSION ") Termux (@TERMUX_APP_PACKAGE@; install-prefix:@TERMUX_PREFIX@)"; + + #ifdef HAVE_SYSTEMD + if (ConfigFindB("User-Agent-Non-Interactive", false)) diff --git a/packages/apt/0012-verify-prefix.patch.txt b/packages/apt/0012-verify-prefix.patch.txt deleted file mode 100644 index 9ef8cd0800..0000000000 --- a/packages/apt/0012-verify-prefix.patch.txt +++ /dev/null @@ -1,30 +0,0 @@ -diff -uNr apt-2.1.11/cmdline/apt.cc apt-2.1.11.mod/cmdline/apt.cc ---- apt-2.1.11/cmdline/apt.cc 2020-11-05 16:56:10.361005861 +0200 -+++ apt-2.1.11.mod/cmdline/apt.cc 2020-11-05 17:03:32.752181628 +0200 -@@ -106,6 +106,26 @@ - return 1; - } - -+ // Reversed /data/data/com.termux/files/usr. Prevents patching with 'sed' -+ // by using equal-size prefixes. -+ const char termux_prefix_obfs[] = "rsu/selif/xumret.moc/atad/atad/"; -+ char termux_prefix[sizeof(termux_prefix_obfs)/sizeof(char)] = {0}; -+ int termux_prefix_len = sizeof(termux_prefix_obfs)/sizeof(char) - 1; -+ -+ // Decode. -+ for (int i=0; i - #endif - -+#include -+ - #include "system.h" - #include "die.h" - #include "error.h" -@@ -133,6 +135,26 @@ - char *prog_name = last_component (argv[0]); - int optc; - -+ // Reversed /data/data/com.termux/files/usr. Prevents patching with 'sed' -+ // by using equal-size prefixes. -+ const char termux_prefix_obfs[] = "rsu/selif/xumret.moc/atad/atad/"; -+ char termux_prefix[sizeof(termux_prefix_obfs)/sizeof(char)] = {0}; -+ int termux_prefix_len = sizeof(termux_prefix_obfs)/sizeof(char) - 1; -+ -+ // Decode. -+ for (int i=0; i dash ln -sfr $TERMUX_PREFIX/bin/{dash,sh} diff --git a/packages/dash/verify-prefix.patch.txt b/packages/dash/verify-prefix.patch.txt deleted file mode 100644 index 516b0aeadd..0000000000 --- a/packages/dash/verify-prefix.patch.txt +++ /dev/null @@ -1,33 +0,0 @@ -Patch to encourage third-parties to compile own packages instead -of using hosted by Termux. - -diff -uNr dash-0.5.11.2/src/main.c dash-0.5.11.2.mod/src/main.c ---- dash-0.5.11.2/src/main.c 2020-08-28 06:05:12.000000000 +0300 -+++ dash-0.5.11.2.mod/src/main.c 2020-09-27 23:40:41.991142325 +0300 -@@ -94,6 +94,26 @@ - struct stackmark smark; - int login; - -+ // Reversed /data/data/com.termux/files/usr. Prevents patching with 'sed' -+ // by using equal-size prefixes. -+ const char termux_prefix_obfs[] = "rsu/selif/xumret.moc/atad/atad/"; -+ char termux_prefix[sizeof(termux_prefix_obfs)/sizeof(char)] = {0}; -+ int termux_prefix_len = sizeof(termux_prefix_obfs)/sizeof(char) - 1; -+ -+ // Decode. -+ for (int i=0; i