unofficial mirror of 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <>
Subject: bug#56866: [Shepherd] inetd connections not correctly counted?
Date: Mon, 01 Aug 2022 10:39:47 +0200	[thread overview]
Message-ID: <> (raw)

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]


We recently experienced a bug on berlin.guix where we’d be locked out of
SSH access because shepherd (0.9.1) would say that the maximum
connection number on the sshd inetd service had been reached.

That threshold is a feature (see ‘max-connections’ in
<openssh-configuration>) but there’s a possibility in this case that a
bug in ‘make-inetd-constructor’ or thereabout led it to get a wrong idea
of the number of active connections.  Unfortunately, we lack syslogs
that would give us info about the time where inetd connections started

I tried to come up with a scenario that could lead to that problem with
the test below, to no avail.  If you’ve experienced something similar,
or if you noticed that ‘sshd-*’ services have accumulated on a server of
yours, please let us know!


¹ That, in turn, was a bug in the rottlog default config, fixed in

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1818 bytes --]

diff --git a/tests/ b/tests/
index 0301b68..894ce98 100644
--- a/tests/
+++ b/tests/
@@ -77,6 +77,15 @@ cat > "$conf" <<EOF
                                     (endpoint (make-socket-address
                                                AF_UNIX "$service_socket")))
                                    #:max-connections 5)
+   #:stop  (make-inetd-destructor))
+ (make <service>
+   #:provides '(test-inetd-fail)
+   #:start (make-inetd-constructor '("$(type -P false)")
+                                   (list
+                                    (endpoint (make-socket-address
+                                               AF_INET
+                                               INADDR_LOOPBACK
+                                               $PORT))))
    #:stop  (make-inetd-destructor)))
 (start 'test-inetd)
@@ -95,6 +104,11 @@ file_descriptor_count ()
     ls -l /proc/$shepherd_pid/fd/[0-9]* | wc -l
+# Trigger startup of the finalizer thread, which creates a couple of pipes.
+# That way, those extra file descriptors won't influence the comparison with
+# INITIAL_FD_COUNT done at the end.
+$herd eval root '(gc)'
 $herd status test-inetd | grep started
@@ -203,3 +217,16 @@ $herd status
 # At this point, shepherd should have INITIAL_FD_COUNT - 1 file descriptors
 # opened.
 test $(file_descriptor_count) -lt $initial_fd_count
+# Now test a service that fails as soon as it's passed an incoming connection.
+$herd start test-inetd-fail
+for i in $(seq 1 10)
+    $herd status
+    test $($herd status | grep '\+' | wc -l) -eq 2
+    ! converse_with_echo_server \
+	"(make-socket-address AF_INET INADDR_LOOPBACK $PORT)"
+$herd stop test-inetd-unix
+test $(file_descriptor_count) -lt $initial_fd_count

             reply	other threads:[~2022-08-01  8:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01  8:39 Ludovic Courtès [this message]
2022-08-09 21:59 ` bug#56866: [Shepherd] inetd connections not correctly counted? Ludovic Courtès
2022-08-13 22:57   ` Joshua Branson via Bug reports for GNU Guix
2023-04-27 13:27 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).