unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56866: [Shepherd] inetd connections not correctly counted?
@ 2022-08-01  8:39 Ludovic Courtès
  2022-08-09 21:59 ` Ludovic Courtès
  2023-04-27 13:27 ` Ludovic Courtès
  0 siblings, 2 replies; 4+ messages in thread
From: Ludovic Courtès @ 2022-08-01  8:39 UTC (permalink / raw)
  To: 56866

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

Hi,

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
accumulating¹.

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!

Thanks,
Ludo’.

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


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

diff --git a/tests/inetd.sh b/tests/inetd.sh
index 0301b68..894ce98 100644
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -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)'
+
 initial_fd_count=$(file_descriptor_count)
 
 $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)
+do
+    $herd status
+    test $($herd status | grep '\+' | wc -l) -eq 2
+    ! converse_with_echo_server \
+	"(make-socket-address AF_INET INADDR_LOOPBACK $PORT)"
+done
+
+$herd stop test-inetd-unix
+test $(file_descriptor_count) -lt $initial_fd_count

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-27 18:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01  8:39 bug#56866: [Shepherd] inetd connections not correctly counted? Ludovic Courtès
2022-08-09 21:59 ` Ludovic Courtès
2022-08-13 22:57   ` Joshua Branson via Bug reports for GNU Guix
2023-04-27 13:27 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).