teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
Blob Blame History Raw
From 66ff3b83bae08e5c3ddd9f62d2bdfbef2aaf95fb Mon Sep 17 00:00:00 2001
From: Aggelos Avgerinos <evaggelos.avgerinos@gmail.com>
Date: Tue, 9 May 2017 02:09:22 +0300
Subject: [PATCH] execute: Properly log errors considering socket fds (#5910)

Till now if the params->n_fds was 0, systemd was logging that there were
more than one sockets.

Thanks @gregoryp and @VFXcode who did the most work debugging this.
(cherry picked from commit 488ab41cb89828e68162f34fb68241bbda700c05)
---
 src/core/execute.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/core/execute.c b/src/core/execute.c
index d7798387c5..aa655cfae8 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2927,11 +2927,16 @@ int exec_spawn(Unit *unit,
             context->std_output == EXEC_OUTPUT_SOCKET ||
             context->std_error == EXEC_OUTPUT_SOCKET) {
 
-                if (params->n_fds != 1) {
+                if (params->n_fds > 1) {
                         log_unit_error(unit, "Got more than one socket.");
                         return -EINVAL;
                 }
 
+                if (params->n_fds == 0) {
+                        log_unit_error(unit, "Got no socket.");
+                        return -EINVAL;
+                }
+
                 socket_fd = params->fds[0];
         } else {
                 socket_fd = -1;