]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/socket: refuse MaxConnection=0 for Accept=no sockets too
authorMike Yuan <me@yhndnzj.com>
Sun, 25 Aug 2024 21:30:47 +0000 (23:30 +0200)
committerMike Yuan <me@yhndnzj.com>
Mon, 26 Aug 2024 12:52:25 +0000 (14:52 +0200)
This makes no sense at all, and we already refuse such setting
for Accept=yes sockets. I see no reason not to extend this to
Accept=no ones.

src/core/socket.c

index 3c866cee935029915a0516f991244817b1b0910f..88c92876a14e0ade07dc8e3c086b0165d1cbfb81 100644 (file)
@@ -410,12 +410,12 @@ static int socket_verify(Socket *s) {
         if (!s->ports)
                 return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.");
 
+        if (s->max_connections <= 0)
+                return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "MaxConnection= setting too small. Refusing.");
+
         if (s->accept && have_non_accept_socket(s))
                 return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit configured for accepting sockets, but sockets are non-accepting. Refusing.");
 
-        if (s->accept && s->max_connections <= 0)
-                return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "MaxConnection= setting too small. Refusing.");
-
         if (s->accept && UNIT_ISSET(s->service))
                 return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Explicit service configuration for accepting socket units not supported. Refusing.");