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.
This commit is contained in:
parent
f9c5f09c8d
commit
fd66e2fe29
22
packages/apt/0012-termux-id.patch
Normal file
22
packages/apt/0012-termux-id.patch
Normal file
@ -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))
|
@ -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<termux_prefix_len; i++) {
|
||||
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
|
||||
+ }
|
||||
+
|
||||
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
|
||||
+ // If checks failed, then we probably running in incompatible environment.
|
||||
+ // In this case warn user and exit with status 1.
|
||||
+ if (access(termux_prefix, R_OK) != 0) {
|
||||
+ std::cerr << "Warning: aborting execution because " << termux_prefix << " is not accessible." << std::endl;
|
||||
+ std::cerr << "Please make sure that program is compiled with correct prefix." << std::endl;
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
CommandLine CmdL;
|
||||
auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
|
||||
|
@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Front-end for the dpkg package manager"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=2.1.14
|
||||
TERMUX_PKG_REVISION=2
|
||||
TERMUX_PKG_SRCURL=http://deb.debian.org/debian/pool/main/a/apt/apt_${TERMUX_PKG_VERSION}.tar.xz
|
||||
TERMUX_PKG_SHA256=cc61d7216ec3c4b901a070fc14887200120464ac3538653ce0c06412bdbc8b49
|
||||
# apt-key requires utilities from coreutils, findutils, gpgv, grep, sed.
|
||||
@ -54,12 +55,6 @@ termux_step_pre_configure() {
|
||||
termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
|
||||
fi
|
||||
|
||||
# Prefix verification patch should be applied only for the
|
||||
# builds with original prefix.
|
||||
if [ "$TERMUX_PREFIX" = "/data/data/com.termux/files/usr" ]; then
|
||||
patch -p1 -i $TERMUX_PKG_BUILDER_DIR/0012-verify-prefix.patch.txt
|
||||
fi
|
||||
|
||||
# Fix i686 builds.
|
||||
CXXFLAGS+=" -Wno-c++11-narrowing"
|
||||
# Fix glob() on Android 7.
|
||||
|
@ -5,7 +5,7 @@ TERMUX_PKG_MAINTAINER="@termux"
|
||||
_MAIN_VERSION=5.1
|
||||
_PATCH_VERSION=0
|
||||
TERMUX_PKG_VERSION=${_MAIN_VERSION}.${_PATCH_VERSION}
|
||||
TERMUX_PKG_REVISION=2
|
||||
TERMUX_PKG_REVISION=3
|
||||
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/bash/bash-${_MAIN_VERSION}.tar.gz
|
||||
TERMUX_PKG_SHA256=cc012bc860406dcf42f64431bcd3d2fa7560c02915a601aba9cd597a39329baa
|
||||
TERMUX_PKG_DEPENDS="libandroid-support, libiconv, ncurses, readline (>= 8.0), termux-tools"
|
||||
@ -49,12 +49,6 @@ termux_step_pre_configure() {
|
||||
patch -p0 -i $PATCHFILE
|
||||
done
|
||||
unset PATCH_CHECKSUMS PATCHFILE PATCH_NUM
|
||||
|
||||
# Prefix verification patch should be applied only for the
|
||||
# builds with original prefix.
|
||||
if [ "$TERMUX_PREFIX" = "/data/data/com.termux/files/usr" ]; then
|
||||
patch -p1 -i $TERMUX_PKG_BUILDER_DIR/verify-prefix.patch.txt
|
||||
fi
|
||||
}
|
||||
|
||||
termux_step_post_make_install() {
|
||||
|
@ -1,33 +0,0 @@
|
||||
Patch to encourage third-parties to compile own packages instead
|
||||
of using hosted by Termux.
|
||||
|
||||
diff -uNr bash-5.0/shell.c bash-5.0.mod/shell.c
|
||||
--- bash-5.0/shell.c 2018-12-06 18:28:21.000000000 +0200
|
||||
+++ bash-5.0.mod/shell.c 2020-09-27 23:27:30.347678058 +0300
|
||||
@@ -384,6 +384,26 @@
|
||||
USE_VAR(saverst);
|
||||
#endif
|
||||
|
||||
+ // 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<termux_prefix_len; i++) {
|
||||
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
|
||||
+ }
|
||||
+
|
||||
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
|
||||
+ // If checks failed, then we probably running in incompatible environment.
|
||||
+ // In this case warn user and exit with status 1.
|
||||
+ if (access(termux_prefix, R_OK) != 0) {
|
||||
+ fprintf(stderr, "Warning: aborting execution because %s is not accessible.\n", termux_prefix);
|
||||
+ fprintf(stderr, "Please make sure that program is compiled with correct prefix.\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
/* Catch early SIGINTs. */
|
||||
code = setjmp_nosigs (top_level);
|
||||
if (code)
|
@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Basic file, shell and text manipulation utilities from t
|
||||
TERMUX_PKG_LICENSE="GPL-3.0"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=8.32
|
||||
TERMUX_PKG_REVISION=6
|
||||
TERMUX_PKG_REVISION=7
|
||||
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/coreutils/coreutils-${TERMUX_PKG_VERSION}.tar.xz
|
||||
TERMUX_PKG_SHA256=4458d8de7849df44ccab15e16b1548b285224dbba5f08fac070c1c0e0bcc4cfa
|
||||
TERMUX_PKG_DEPENDS="libandroid-support, libgmp, libiconv"
|
||||
@ -33,10 +33,4 @@ termux_step_pre_configure() {
|
||||
if $TERMUX_ON_DEVICE_BUILD; then
|
||||
termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
|
||||
fi
|
||||
|
||||
# Prefix verification patch should be applied only for the
|
||||
# builds with original prefix.
|
||||
if [ "$TERMUX_PREFIX" = "/data/data/com.termux/files/usr" ]; then
|
||||
patch -p1 -i $TERMUX_PKG_BUILDER_DIR/verify-prefix.patch.txt
|
||||
fi
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
Patch to encourage third-parties to compile own packages instead
|
||||
of using hosted by Termux.
|
||||
|
||||
diff -uNr coreutils-8.32/src/coreutils.c coreutils-8.32.mod/src/coreutils.c
|
||||
--- coreutils-8.32/src/coreutils.c 2020-01-01 16:13:12.000000000 +0200
|
||||
+++ coreutils-8.32.mod/src/coreutils.c 2020-09-27 23:37:17.025160590 +0300
|
||||
@@ -26,6 +26,8 @@
|
||||
# include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
+#include <unistd.h>
|
||||
+
|
||||
#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<termux_prefix_len; i++) {
|
||||
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
|
||||
+ }
|
||||
+
|
||||
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
|
||||
+ // If checks failed, then we probably running in incompatible environment.
|
||||
+ // In this case warn user and exit with status 1.
|
||||
+ if (access(termux_prefix, R_OK) != 0) {
|
||||
+ fprintf(stderr, "Warning: aborting execution because %s is not accessible.\n", termux_prefix);
|
||||
+ fprintf(stderr, "Please make sure that program is compiled with correct prefix.\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
/* Map external name to internal name. */
|
||||
char ginstall[] = "ginstall";
|
||||
if (STREQ (prog_name, "install"))
|
@ -3,20 +3,12 @@ TERMUX_PKG_DESCRIPTION="Small POSIX-compliant implementation of /bin/sh"
|
||||
TERMUX_PKG_LICENSE="BSD 3-Clause"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=0.5.11.2
|
||||
TERMUX_PKG_REVISION=4
|
||||
TERMUX_PKG_REVISION=5
|
||||
TERMUX_PKG_SRCURL=http://gondor.apana.org.au/~herbert/dash/files/dash-${TERMUX_PKG_VERSION}.tar.gz
|
||||
TERMUX_PKG_SHA256=00fb7d68b7599cc41ab151051c06c01e9500540183d8aa72116cb9c742bd6d5f
|
||||
TERMUX_PKG_ESSENTIAL=true
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--disable-static"
|
||||
|
||||
termux_step_pre_configure() {
|
||||
# Prefix verification patch should be applied only for the
|
||||
# builds with original prefix.
|
||||
if [ "$TERMUX_PREFIX" = "/data/data/com.termux/files/usr" ]; then
|
||||
patch -p1 -i $TERMUX_PKG_BUILDER_DIR/verify-prefix.patch.txt
|
||||
fi
|
||||
}
|
||||
|
||||
termux_step_post_make_install() {
|
||||
# Symlink sh -> dash
|
||||
ln -sfr $TERMUX_PREFIX/bin/{dash,sh}
|
||||
|
@ -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<termux_prefix_len; i++) {
|
||||
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
|
||||
+ }
|
||||
+
|
||||
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
|
||||
+ // If checks failed, then we probably running in incompatible environment.
|
||||
+ // In this case warn user and exit with status 1.
|
||||
+ if (access(termux_prefix, R_OK) != 0) {
|
||||
+ fprintf(stderr, "Warning: aborting execution because %s is not accessible.\n", termux_prefix);
|
||||
+ fprintf(stderr, "Please make sure that program is compiled with correct prefix.\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
#ifdef __GLIBC__
|
||||
dash_errno = __errno_location();
|
||||
#endif
|
@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Debian package management system"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION=1.20.5
|
||||
TERMUX_PKG_REVISION=4
|
||||
TERMUX_PKG_REVISION=5
|
||||
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/debian/pool/main/d/dpkg/dpkg_${TERMUX_PKG_VERSION}.tar.xz
|
||||
TERMUX_PKG_SHA256=f2f23f3197957d89e54b87cf8fc42ab00e1b74f3a32090efe9acd08443f3e0dd
|
||||
# with the extract.c.patch we remove the -p and --warning=no-timestamp tar options so we can use busybox tar
|
||||
@ -74,12 +74,6 @@ share/polkit-1
|
||||
termux_step_pre_configure() {
|
||||
export TAR=tar # To make sure dpkg tries to use "tar" instead of e.g. "gnutar" (which happens when building on OS X)
|
||||
perl -p -i -e "s/TERMUX_ARCH/$TERMUX_ARCH/" $TERMUX_PKG_SRCDIR/configure
|
||||
|
||||
# Prefix verification patch should be applied only for the
|
||||
# builds with original prefix.
|
||||
if [ "$TERMUX_PREFIX" = "/data/data/com.termux/files/usr" ]; then
|
||||
patch -p1 -i $TERMUX_PKG_BUILDER_DIR/verify-prefix.patch.txt
|
||||
fi
|
||||
}
|
||||
|
||||
termux_step_post_massage() {
|
||||
|
@ -1,33 +0,0 @@
|
||||
Patch to encourage third-parties to compile own packages instead
|
||||
of using hosted by Termux.
|
||||
|
||||
diff -uNr dpkg-1.20.5/src/main.c dpkg-1.20.5.mod/src/main.c
|
||||
--- dpkg-1.20.5/src/main.c 2020-06-28 00:07:40.000000000 +0300
|
||||
+++ dpkg-1.20.5.mod/src/main.c 2020-09-28 02:51:27.602517110 +0300
|
||||
@@ -760,6 +760,26 @@
|
||||
int main(int argc, const char *const *argv) {
|
||||
int ret;
|
||||
|
||||
+ // 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<termux_prefix_len; i++) {
|
||||
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
|
||||
+ }
|
||||
+
|
||||
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
|
||||
+ // If checks failed, then we probably running in incompatible environment.
|
||||
+ // In this case warn user and exit with status 1.
|
||||
+ if (access(termux_prefix, R_OK) != 0) {
|
||||
+ fprintf(stderr, "Warning: aborting execution because %s is not accessible.\n", termux_prefix);
|
||||
+ fprintf(stderr, "Please make sure that program is compiled with correct prefix.\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
dpkg_locales_init(PACKAGE);
|
||||
dpkg_program_init("dpkg");
|
||||
set_force_default(FORCE_ALL);
|
Loading…
Reference in New Issue
Block a user