From 35835c2d09db825d3d6c1662690dae0722d589c2 Mon Sep 17 00:00:00 2001 From: termux-pacman-bot Date: Sat, 20 Jan 2024 14:37:02 +0000 Subject: [PATCH] chore(main/apt): drop user agent patch Why remove the patch: https://github.com/termux/termux-exec/pull/24 These changes in termux-exec would cause apt to send invalid installation prefix in user agent. This patch is not actual for now and can be removed anyway. *** Background why the patch was added earlier: Its only purpose to generate HTTP user agent string specific for environment. This lets us to distinguish on server side whether user download packages using official Termux app or derivative checking the installation prefix path and disallow downloads made by non-Termux projects to reduce egress traffic when needed. --- packages/apt/0012-termux-id.patch | 57 ------------------------------- packages/apt/build.sh | 1 + 2 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 packages/apt/0012-termux-id.patch diff --git a/packages/apt/0012-termux-id.patch b/packages/apt/0012-termux-id.patch deleted file mode 100644 index cd69d2cf37..0000000000 --- a/packages/apt/0012-termux-id.patch +++ /dev/null @@ -1,57 +0,0 @@ -diff -uNr apt-2.1.18/methods/http.cc apt-2.1.18.mod/methods/http.cc ---- apt-2.1.18/methods/http.cc 2021-01-13 18:37:30.000000000 +0200 -+++ apt-2.1.18.mod/methods/http.cc 2021-02-03 22:06:04.242782879 +0200 -@@ -341,7 +341,26 @@ - 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"; -+ // Determine the actual installation prefix to send as part of user-agent string. -+ // Mirrors can use this information to distinguish legit Termux installations from -+ // third parties using Termux repositories. -+ char binPath[PATH_MAX] = {0}; -+ ssize_t binPathLen = readlink("/proc/self/exe", binPath, sizeof(binPath)-1); -+ if (binPathLen != -1) { -+ binPath[binPathLen] = '\0'; -+ -+ char *aptMethodsSub = strstr(binPath, "/lib/apt/methods"); -+ if (aptMethodsSub) { -+ // Cut /lib/apt/methods.. from prefix, if possible. -+ aptMethodsSub[0] = '\0'; -+ } -+ } else { -+ // Use hardcoded as fallback. -+ // Mostly useless as will help to detect only binary-patched apt. -+ strncpy(binPath, "@TERMUX_PREFIX@", PATH_MAX - 1); -+ } -+ -+ Req << "User-Agent: Debian APT-HTTP/1.3 (" PACKAGE_VERSION ") Termux (@TERMUX_APP_PACKAGE@; install-prefix:" << binPath <<")" << "\r\n"; - - Req << "\r\n"; - -@@ -954,8 +973,23 @@ - Req << "Authorization: Basic " - << Base64Encode(Uri.User + ":" + Uri.Password) << "\r\n"; - -- Req << "User-Agent: " << ConfigFind("User-Agent", -- "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")"); -+ char binPath[PATH_MAX] = {0}; -+ ssize_t binPathLen = readlink("/proc/self/exe", binPath, sizeof(binPath)-1); -+ if (binPathLen != -1) { -+ binPath[binPathLen] = '\0'; -+ -+ char *aptMethodsSub = strstr(binPath, "/lib/apt/methods"); -+ if (aptMethodsSub) { -+ // Cut /lib/apt/methods.. from prefix, if possible. -+ aptMethodsSub[0] = '\0'; -+ } -+ } else { -+ // Use hardcoded as fallback. -+ // Mostly useless as will help to detect only binary-patched apt. -+ strncpy(binPath, "@TERMUX_PREFIX@", PATH_MAX - 1); -+ } -+ -+ Req << "User-Agent: Debian APT-HTTP/1.3 (" PACKAGE_VERSION ") Termux (@TERMUX_APP_PACKAGE@; install-prefix:" << binPath << ")"; - - #ifdef HAVE_SYSTEMD - if (ConfigFindB("User-Agent-Non-Interactive", false)) diff --git a/packages/apt/build.sh b/packages/apt/build.sh index 79c6180822..fc2c3fe35d 100644 --- a/packages/apt/build.sh +++ b/packages/apt/build.sh @@ -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.7.7" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://deb.debian.org/debian/pool/main/a/apt/apt_${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=d3b3f3b7014f6e561b86c059b89040d0c742cbabc576593c6efaa0dd7b24de77 # apt-key requires utilities from coreutils, findutils, gpgv, grep, sed.