Package: apt-cacher-ng
Version: 3.6.4-1
X-Debbugs-Cc: aeru...@aerusso.net
Severity: normal
Tags: patch upstream

Dear maintainer,

This is a composite of three bug reports, all closely related to the use of 
unix domain sockets instead of tcp.

1. The tcp listener cannot be disabled, due to an erroneous reapplication of the
default port.  The attached patch should fix this (previously, this variable was
a string describing the port, rather than the actual integer value).

2. When a unix domain socket connection is created, szClientName may be null.
The current behavior is to set that string to "", which prevents it from being
handled correctly by the rest of the infrastructure.  The attached patch sets
the string to the sentinel value "0", which should never be a valid hostname or
ip address.  This may not be ideal, but it does illustrate problem and one 
solution.

3. acngtool cannot properly connect to a unix domain socket. Unix domain socket
connections cannot be reused, as alluded to in the empty 
TUdsFactory::RecycleIdleConnection.
However, the udsconnection::tcpconnect function (which does in fact create a 
unix
domain socket connection), passes a request to get / from the acng server.

This dooms that connection to uselessness, and results in acngtool falling back 
to
the tcp connection code path.  If that is also disabled, the tool hangs for a
very long time.  The attached patch avoids this first / lookup, making the tool
work with unix domain sockets.

Best,
Antonio Russo
commit 3c8d91146b9acfa5ab42e4c2496038185b86f95d
Author: Antonio Russo <aeru...@aerusso.net>
Date:   Mon Dec 26 12:31:48 2022 -0700

    Do not override disabled tcp listener

diff --git a/src/acfg.cc b/src/acfg.cc
index a137ac2..2a64348 100644
--- a/src/acfg.cc
+++ b/src/acfg.cc
@@ -702,9 +702,6 @@ void PostProcConfig()
 {
 	remotedb::GetInstance().PostConfig();
 
-	if(!port) // heh?
-		port=ACNG_DEF_PORT;
-
 	if(connectPermPattern == "~~~")
 	   connectPermPattern="^(bugs\\.debian\\.org|changelogs\\.ubuntu\\.com):443$";
 
diff --git a/src/conserver.cc b/src/conserver.cc
index 6ca6639..afa7d26 100644
--- a/src/conserver.cc
+++ b/src/conserver.cc
@@ -207,6 +207,8 @@ std::string scratchBuf;
 unsigned setup_tcp_listeners(LPCSTR addi, uint16_t port)
 {
 	LOGSTARTFUNCxs(addi, port);
+	if(!port)
+		return 0;
 	USRDBG("Binding on host: " << addi << ", port: " << port);
 
 	auto hints = addrinfo();
commit 080a5aecd9fbc9161e677ffcdbc600580fee5540
Author: Antonio Russo <aeru...@aerusso.net>
Date:   Sat Dec 24 08:32:14 2022 -0700

    Send sentinel client name for unix domain sockets

diff --git a/src/conserver.cc b/src/conserver.cc
index b47a548..6ca6639 100644
--- a/src/conserver.cc
+++ b/src/conserver.cc
@@ -53,7 +53,8 @@ SHARED_PTR<tpool> g_tpool;
 void SetupConAndGo(unique_fd&& man_fd, const char *szClientName, const char *portName)
 {
 	LOGSTARTFUNCs;
-	string sClient(szClientName ? szClientName : "");
+	// szClientName is null exactly when this is a unix domain socket
+	string sClient(szClientName ? szClientName : "0");
 	USRDBG("Client name: " << sClient << ":" << portName);
 	try
 	{
commit 4e71a6542351e688855bc05349c17d2633c5d36c
Author: Antonio Russo <aeru...@aerusso.net>
Date:   Wed Dec 28 11:06:15 2022 -0700

    UDS connections cannot be reused

diff --git a/src/acngtool.cc b/src/acngtool.cc
index 19373ff..14e330f 100644
--- a/src/acngtool.cc
+++ b/src/acngtool.cc
@@ -533,14 +533,6 @@ struct TUdsFactory : public ::acng::IDlConFactory
 					failed = true;
 					return;
 				}
-				// basic identification needed
-				tSS ids;
-				ids << "GET / HTTP/1.0\r\nX-Original-Source: localhost\r\n\r\n";
-				if (!ids.send(m_conFd))
-				{
-					failed = true;
-					return;
-				}
 			}
 		};
 		auto ret = make_shared<udsconnection>();

Reply via email to