|
|
a1c89c5 |
From 4dfc092a7176f74102b6be205f11008e1de59bb3 Mon Sep 17 00:00:00 2001
|
|
|
a1c89c5 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
a1c89c5 |
Date: Thu, 22 Sep 2011 03:29:51 +0200
|
|
|
a1c89c5 |
Subject: [PATCH] service: if StandardInput=socket and StandardOutput=inherit
|
|
|
a1c89c5 |
imply socket for output, don't imply default output
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
This is useful for inetd-style per-connection services, so that they
|
|
|
a1c89c5 |
again can simply specify StandardOutput=socket to connect all three fds
|
|
|
a1c89c5 |
to the socket.
|
|
|
a1c89c5 |
---
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
[ unfuzzed with quilt -- michich ]
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
Index: systemd-26/src/service.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/service.c
|
|
|
a1c89c5 |
+++ systemd-26/src/service.c
|
|
|
a1c89c5 |
@@ -121,8 +121,6 @@ static void service_init(Unit *u) {
|
|
|
a1c89c5 |
s->guess_main_pid = true;
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
exec_context_init(&s->exec_context);
|
|
|
a1c89c5 |
- s->exec_context.std_output = u->meta.manager->default_std_output;
|
|
|
a1c89c5 |
- s->exec_context.std_error = u->meta.manager->default_std_error;
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
RATELIMIT_INIT(s->ratelimit, 10*USEC_PER_SEC, 5);
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
@@ -830,9 +828,10 @@ static int service_load_sysv_path(Servic
|
|
|
a1c89c5 |
s->type = SERVICE_FORKING;
|
|
|
a1c89c5 |
s->remain_after_exit = true;
|
|
|
a1c89c5 |
s->restart = SERVICE_RESTART_NO;
|
|
|
a1c89c5 |
- s->exec_context.std_output =
|
|
|
a1c89c5 |
- (s->meta.manager->sysv_console || s->exec_context.std_input == EXEC_INPUT_TTY)
|
|
|
a1c89c5 |
- ? EXEC_OUTPUT_TTY : s->meta.manager->default_std_output;
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
+ if (s->meta.manager->sysv_console)
|
|
|
a1c89c5 |
+ s->exec_context.std_output = EXEC_OUTPUT_TTY;
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
s->exec_context.kill_mode = KILL_PROCESS;
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
/* We use the long description only if
|
|
|
a1c89c5 |
@@ -1095,6 +1094,24 @@ static int service_add_default_dependenc
|
|
|
a1c89c5 |
return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
|
|
|
a1c89c5 |
}
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
+static void service_fix_output(Service *s) {
|
|
|
a1c89c5 |
+ assert(s);
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
+ /* If nothing has been explicitly configured, patch default
|
|
|
a1c89c5 |
+ * output in. If input is socket/tty we avoid this however,
|
|
|
a1c89c5 |
+ * since in that case we want output to default to the same
|
|
|
a1c89c5 |
+ * place as we read input from. */
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
+ if (s->exec_context.std_error == EXEC_OUTPUT_INHERIT &&
|
|
|
a1c89c5 |
+ s->exec_context.std_output == EXEC_OUTPUT_INHERIT &&
|
|
|
a1c89c5 |
+ s->exec_context.std_input == EXEC_INPUT_NULL)
|
|
|
a1c89c5 |
+ s->exec_context.std_error = s->meta.manager->default_std_error;
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
+ if (s->exec_context.std_output == EXEC_OUTPUT_INHERIT &&
|
|
|
a1c89c5 |
+ s->exec_context.std_input == EXEC_INPUT_NULL)
|
|
|
a1c89c5 |
+ s->exec_context.std_output = s->meta.manager->default_std_output;
|
|
|
a1c89c5 |
+}
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
static int service_load(Unit *u) {
|
|
|
a1c89c5 |
int r;
|
|
|
a1c89c5 |
Service *s = SERVICE(u);
|
|
|
a1c89c5 |
@@ -1151,6 +1168,8 @@ static int service_load(Unit *u) {
|
|
|
a1c89c5 |
if (s->meta.default_dependencies)
|
|
|
a1c89c5 |
if ((r = service_add_default_dependencies(s)) < 0)
|
|
|
a1c89c5 |
return r;
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
+ service_fix_output(s);
|
|
|
a1c89c5 |
}
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
return service_verify(s);
|