termux-packages/packages/apt/0003-no-srv-records.patch
Leonid Pliushch c061024982
apt: update patches
***

This commit contains further changes to user agent string in addition
to introduced in fd66e2fe29.

Now it will send installation prefix obtained by /proc/self/exe. It
should resist patching `apt` with sed or in other way. Reminding that
installation prefix provided in user agent http header is intended for
distinguishing Termux from derivatives.

Here are sample lines from my mirror logs showing usage of Termux repo
by third-party projects:
```
162.158.103.43 - - [21/Jan/2021:09:46:43 +0200] "GET /dists/stable/Release HTTP/1.1" 304 0 "-" "Termux-PKG/1.0 mirror-checker (termux-tools 0.104) Termux (pl.sviete.dom; install-prefix:/data/data/pl.sviete.dom/files/usr)"
162.158.210.8 - - [20/Jan/2021:06:24:54 +0200] "GET /dists/stable/InRelease HTTP/1.1" 404 146 "-" "Debian APT-HTTP/1.3 (2.1.15) Termux (vn.vhn.vsc; install-prefix:/data/data/vn.vhn.vsc/files/usr)"
162.158.210.142 - - [20/Jan/2021:06:24:54 +0200] "GET /dists/stable/Release.gpg HTTP/1.1" 304 0 "-" "Debian APT-HTTP/1.3 (2.1.15) Termux (vn.vhn.vsc; install-prefix:/data/data/vn.vhn.vsc/files/usr)"
```

***

CloudFlare firewall for termux.org and termux-mirror.ml hosts would be
adjusted to block all requests which do not have install-prefix set or
if the latter doesn't match one of the Termux.
2021-02-03 22:33:22 +02:00

102 lines
3.3 KiB
Diff

diff -uNr apt-2.1.18/apt-pkg/contrib/srvrec.cc apt-2.1.18.mod/apt-pkg/contrib/srvrec.cc
--- apt-2.1.18/apt-pkg/contrib/srvrec.cc 2021-01-13 18:37:30.000000000 +0200
+++ apt-2.1.18.mod/apt-pkg/contrib/srvrec.cc 2021-02-03 21:38:17.382553856 +0200
@@ -6,6 +6,7 @@
##################################################################### */
/*}}}*/
+#ifndef __ANDROID__
#include <config.h>
#include <netdb.h>
@@ -202,3 +203,4 @@
return selected;
}
+#endif
diff -uNr apt-2.1.18/apt-pkg/contrib/srvrec.h apt-2.1.18.mod/apt-pkg/contrib/srvrec.h
--- apt-2.1.18/apt-pkg/contrib/srvrec.h 2021-01-13 18:37:30.000000000 +0200
+++ apt-2.1.18.mod/apt-pkg/contrib/srvrec.h 2021-02-03 21:38:17.386553898 +0200
@@ -8,6 +8,7 @@
/*}}}*/
#ifndef SRVREC_H
#define SRVREC_H
+#ifndef __ANDROID__
#include <string>
#include <vector>
@@ -54,3 +55,4 @@
APT_PUBLIC SrvRec PopFromSrvRecs(std::vector<SrvRec> &Recs);
#endif
+#endif
diff -uNr apt-2.1.18/cmdline/apt-helper.cc apt-2.1.18.mod/cmdline/apt-helper.cc
--- apt-2.1.18/cmdline/apt-helper.cc 2021-01-13 18:37:30.000000000 +0200
+++ apt-2.1.18.mod/cmdline/apt-helper.cc 2021-02-03 21:38:17.386553898 +0200
@@ -106,6 +106,7 @@
return true;
}
+#ifndef __ANDROID__
/*}}}*/
static bool DoSrvLookup(CommandLine &CmdL) /*{{{*/
{
@@ -134,6 +135,7 @@
return true;
}
/*}}}*/
+#endif
static const APT::Configuration::Compressor *FindCompressor(std::vector<APT::Configuration::Compressor> const &compressors, std::string const &name) /*{{{*/
{
APT::Configuration::Compressor const * compressor = NULL;
@@ -311,7 +313,9 @@
{
return {
{"download-file", &DoDownloadFile, _("download the given uri to the target-path")},
+#ifndef __ANDROID__
{"srv-lookup", &DoSrvLookup, _("lookup a SRV record (e.g. _http._tcp.ftp.debian.org)")},
+#endif
{"cat-file", &DoCatFile, _("concatenate files, with automatic decompression")},
{"auto-detect-proxy", &DoAutoDetectProxy, _("detect proxy using apt.conf")},
{"wait-online", &DoWaitOnline, _("wait for system to be online")},
diff -uNr apt-2.1.18/methods/connect.cc apt-2.1.18.mod/methods/connect.cc
--- apt-2.1.18/methods/connect.cc 2021-01-13 18:37:30.000000000 +0200
+++ apt-2.1.18.mod/methods/connect.cc 2021-02-03 21:41:48.220687372 +0200
@@ -49,7 +49,9 @@
static struct addrinfo *LastHostAddr = 0;
static struct addrinfo *LastUsed = 0;
+#ifndef __ANDROID__
static std::vector<SrvRec> SrvRecords;
+#endif
// Set of IP/hostnames that we timed out before or couldn't resolve
static std::set<std::string> bad_addr;
@@ -486,6 +488,10 @@
// Used by getaddrinfo(); prefer port if given, else fallback to service
std::string ServiceNameOrPort = Port != 0 ? std::to_string(Port) : Service;
+ size_t stackSize = 0;
+
+#ifndef __ANDROID__
+
if(LastHost != Host || LastService != ServiceNameOrPort)
{
SrvRecords.clear();
@@ -503,7 +509,6 @@
}
}
- size_t stackSize = 0;
// try to connect in the priority order of the srv records
std::string initialHost{std::move(Host)};
auto const initialPort = Port;
@@ -525,6 +530,7 @@
}
Host = std::move(initialHost);
Port = initialPort;
+#endif
// we have no (good) SrvRecords for this host, connect right away
_error->PushToStack();