connectd: teach dev_report_fds about Tor fds
What changed, and why it matters
This is a small developer-only fix that stops an internal file-descriptor reporting tool from incorrectly flagging a Tor socket as 'unowned.' It only affects a diagnostic function used in testing and does not change how user funds, network connections, or cryptography are handled.
No security action required; treat as a normal test/diagnostic fix.
Security signals we found
No security-relevant behavior change
Fixes a false-positive diagnostic assertion in developer mode only
Does not alter Tor service creation, socket permissions, or lifecycle
No input validation, memory handling, or cryptographic changes
Evidence from the diff
The commit adds a global tor_service_fd variable and teaches dev_report_fds() in connectd to recognize it. Previously, when Tor static onion services were enabled, the diagnostic dev_report_fds routine logged a BROKEN message because it did not know about the intentionally kept-open Tor control socket. The patch simply labels that fd and continues, eliminating a false-positive test failure.
Changed components
connectd/dev_report_fds diagnostic routineconnectd/tor_autoservice.cconnectd/tor_autoservice.hInspect captured patch +9 / −0
diff --git a/connectd/connectd.c b/connectd/connectd.c
index 14713911..14dbb36b 100644
--- a/connectd/connectd.c
+++ b/connectd/connectd.c
@@ -2255,6 +2255,10 @@ static void dev_report_fds(struct daemon *daemon, const u8 *msg)
status_info("dev_report_fds: %i -> gossip_store", fd);
continue;
}
+ if (fd == tor_service_fd) {
+ status_info("dev_report_fds: %i -> tor service fd", fd);
+ continue;
+ }
c = io_have_fd(fd, &listener);
if (!c) {
/* We consider a single CHR as expected */
diff --git a/connectd/tor_autoservice.c b/connectd/tor_autoservice.c
index fef93a80..cc867995 100644
--- a/connectd/tor_autoservice.c
+++ b/connectd/tor_autoservice.c
@@ -12,6 +12,7 @@
#include <netdb.h>
#include <unistd.h>
+int tor_service_fd = -1;
static void *buf_resize(struct membuf *mb, void *buf, size_t len)
{
@@ -331,5 +332,6 @@ struct wireaddr *tor_fixed_service(const tal_t *ctx,
* read_partial to keep it open until LN drops
* DO NOT CLOSE FD TO KEEP ADDRESS ALIVE AS WE DO NOT DETACH WITH STATIC ADDRESS
*/
+ tor_service_fd = fd;
return onion;
}
diff --git a/connectd/tor_autoservice.h b/connectd/tor_autoservice.h
index dce91a63..950c6a97 100644
--- a/connectd/tor_autoservice.h
+++ b/connectd/tor_autoservice.h
@@ -18,4 +18,7 @@ struct wireaddr *tor_fixed_service(const tal_t *ctx,
const struct wireaddr *bind,
const u8 index);
+/* For dev_report_fds */
+extern int tor_service_fd;
+
#endif /* LIGHTNING_CONNECTD_TOR_AUTOSERVICE_H */
Why this scored 14/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.