summaryrefslogtreecommitdiffstats
path: root/methods
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 10:17:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 10:17:12 +0000
commit8d4164a78d30384f11a229b87b2c46510a449d2a (patch)
tree1170b32128c5f8ff11d7bdc480bc54204749f8cf /methods
parentAdding debian version 2.7.13. (diff)
downloadapt-8d4164a78d30384f11a229b87b2c46510a449d2a.tar.xz
apt-8d4164a78d30384f11a229b87b2c46510a449d2a.zip
Merging upstream version 2.7.14.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'methods')
-rw-r--r--methods/CMakeLists.txt10
-rw-r--r--methods/connect.cc7
-rw-r--r--methods/http.cc15
3 files changed, 26 insertions, 6 deletions
diff --git a/methods/CMakeLists.txt b/methods/CMakeLists.txt
index a5a3602..a94cb41 100644
--- a/methods/CMakeLists.txt
+++ b/methods/CMakeLists.txt
@@ -15,13 +15,15 @@ add_executable(ftp ftp.cc $<TARGET_OBJECTS:connectlib>)
add_executable(rred rred.cc)
add_executable(rsh rsh.cc)
-target_compile_definitions(connectlib PRIVATE ${GNUTLS_DEFINITIONS})
-target_include_directories(connectlib PRIVATE ${GNUTLS_INCLUDE_DIR})
+if (HAVE_GNUTLS)
+ target_compile_definitions(connectlib PRIVATE ${GNUTLS_DEFINITIONS})
+ target_include_directories(connectlib PRIVATE ${GNUTLS_INCLUDE_DIR})
+endif()
target_include_directories(http PRIVATE $<$<BOOL:${SYSTEMD_FOUND}>:${SYSTEMD_INCLUDE_DIRS}>)
# Additional libraries to link against for networked stuff
-target_link_libraries(http ${GNUTLS_LIBRARIES} $<$<BOOL:${SYSTEMD_FOUND}>:${SYSTEMD_LIBRARIES}>)
-target_link_libraries(ftp ${GNUTLS_LIBRARIES})
+target_link_libraries(http $<$<BOOL:${GNUTLS_FOUND}>:${GNUTLS_LIBRARIES}> $<$<BOOL:${SYSTEMD_FOUND}>:${SYSTEMD_LIBRARIES}>)
+target_link_libraries(ftp $<$<BOOL:${GNUTLS_FOUND}>:${GNUTLS_LIBRARIES}>)
target_link_libraries(rred apt-private)
diff --git a/methods/connect.cc b/methods/connect.cc
index 110f2fc..f3e199d 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -19,8 +19,10 @@
#include <apt-pkg/srvrec.h>
#include <apt-pkg/strutl.h>
+#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#endif
#include <cerrno>
#include <cstdio>
@@ -798,7 +800,8 @@ ResultState UnwrapSocks(std::string Host, int Port, URI Proxy, std::unique_ptr<M
return ResultState::SUCCESSFUL;
}
- /*}}}*/
+
+#ifdef HAVE_GNUTLS /*}}}*/
// UnwrapTLS - Handle TLS connections /*{{{*/
// ---------------------------------------------------------------------
/* Performs a TLS handshake on the socket */
@@ -1050,4 +1053,4 @@ ResultState UnwrapTLS(std::string const &Host, std::unique_ptr<MethodFd> &Fd,
return ResultState::SUCCESSFUL;
}
- /*}}}*/
+#endif /*}}}*/
diff --git a/methods/http.cc b/methods/http.cc
index 9b45506..0c4d822 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -429,7 +429,9 @@ ResultState HttpServerState::Open()
Out.Reset();
Persistent = true;
+#ifdef HAVE_GNUTLS
bool tls = (ServerName.Access == "https" || APT::String::Endswith(ServerName.Access, "+https"));
+#endif
// Determine the proxy setting
// Used to run AutoDetectProxy(ServerName) here, but we now send a Proxy
@@ -454,6 +456,7 @@ ResultState HttpServerState::Open()
{
char *result = getenv("http_proxy");
Proxy = result ? result : "";
+#ifdef HAVE_GNUTLS
if (tls == true)
{
char *result = getenv("https_proxy");
@@ -462,6 +465,7 @@ ResultState HttpServerState::Open()
Proxy = result;
}
}
+#endif
}
}
@@ -475,8 +479,13 @@ ResultState HttpServerState::Open()
if (Proxy.empty() == false)
Owner->AddProxyAuth(Proxy, ServerName);
+#ifdef HAVE_GNUTLS
auto const DefaultService = tls ? "https" : "http";
auto const DefaultPort = tls ? 443 : 80;
+#else
+ auto const DefaultService = "http";
+ auto const DefaultPort = 80;
+#endif
if (Proxy.Access == "socks5h")
{
auto result = Connect(Proxy.Host, Proxy.Port, "socks", 1080, ServerFd, TimeOut, Owner);
@@ -510,12 +519,15 @@ ResultState HttpServerState::Open()
Port = Proxy.Port;
Host = Proxy.Host;
+#ifdef HAVE_GNUTLS
if (Proxy.Access == "https" && Port == 0)
Port = 443;
+#endif
}
auto result = Connect(Host, Port, DefaultService, DefaultPort, ServerFd, TimeOut, Owner);
if (result != ResultState::SUCCESSFUL)
return result;
+#ifdef HAVE_GNUTLS
if (Host == Proxy.Host && Proxy.Access == "https")
{
aptConfigWrapperForMethods ProxyConf{std::vector<std::string>{"http", "https"}};
@@ -530,10 +542,13 @@ ResultState HttpServerState::Open()
if (result != ResultState::SUCCESSFUL)
return result;
}
+#endif
}
+#ifdef HAVE_GNUTLS
if (tls)
return UnwrapTLS(ServerName.Host, ServerFd, TimeOut, Owner, Owner);
+#endif
return ResultState::SUCCESSFUL;
}