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