|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From 66ff3b83bae08e5c3ddd9f62d2bdfbef2aaf95fb Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From: Aggelos Avgerinos <evaggelos.avgerinos@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Date: Tue, 9 May 2017 02:09:22 +0300
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Subject: [PATCH] execute: Properly log errors considering socket fds (#5910)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Till now if the params->n_fds was 0, systemd was logging that there were
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
more than one sockets.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Thanks @gregoryp and @VFXcode who did the most work debugging this.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(cherry picked from commit 488ab41cb89828e68162f34fb68241bbda700c05)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/core/execute.c | 7 ++++++-
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/core/execute.c b/src/core/execute.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index d7798387c5..aa655cfae8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/core/execute.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/core/execute.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -2927,11 +2927,16 @@ int exec_spawn(Unit *unit,
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
context->std_output == EXEC_OUTPUT_SOCKET ||
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
context->std_error == EXEC_OUTPUT_SOCKET) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- if (params->n_fds != 1) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ if (params->n_fds > 1) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
log_unit_error(unit, "Got more than one socket.");
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ if (params->n_fds == 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ log_unit_error(unit, "Got no socket.");
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
socket_fd = params->fds[0];
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
socket_fd = -1;
|