mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-10 00:58:20 +03:00
Merge pull request #15812 from poettering/deprecate-stdout-syslog
Get rid of StandardOutput=syslog
This commit is contained in:
commit
f5b04551b8
@ -70,10 +70,9 @@
|
||||
|
||||
<para>These prefixes are intended to be used in conjunction with stderr-based logging (or stdout-based
|
||||
logging) as implemented by systemd. If a systemd service definition file is configured with
|
||||
<varname>StandardError=journal</varname>, <varname>StandardError=syslog</varname> or
|
||||
<varname>StandardError=kmsg</varname> (and similar with <varname>StandardOutput=</varname>), these
|
||||
prefixes can be used to encode a log level in lines printed. This is similar to the kernel
|
||||
<function>printk()</function>-style logging. See
|
||||
<varname>StandardError=journal</varname> or <varname>StandardError=kmsg</varname> (and similar with
|
||||
<varname>StandardOutput=</varname>), these prefixes can be used to encode a log level in lines
|
||||
printed. This is similar to the kernel <function>printk()</function>-style logging. See
|
||||
<citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry> for more
|
||||
information.</para>
|
||||
|
||||
|
@ -66,9 +66,9 @@
|
||||
will also gain an automatic <varname>After=</varname> dependency on
|
||||
<citerefentry><refentrytitle>systemd-tmpfiles-setup.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para></listitem>
|
||||
|
||||
<listitem><para>Units whose standard output or error output is connected to <option>journal</option>,
|
||||
<option>syslog</option> or <option>kmsg</option> (or their combinations with console output, see below)
|
||||
automatically acquire dependencies of type <varname>After=</varname> on
|
||||
<listitem><para>Units whose standard output or error output is connected to <option>journal</option> or
|
||||
<option>kmsg</option> (or their combinations with console output, see below) automatically acquire
|
||||
dependencies of type <varname>After=</varname> on
|
||||
<filename>systemd-journald.socket</filename>.</para></listitem>
|
||||
|
||||
<listitem><para>Units using <varname>LogNamespace=</varname> will automatically gain ordering and
|
||||
|
@ -219,17 +219,10 @@ static bool is_terminal_input(ExecInput i) {
|
||||
static bool is_terminal_output(ExecOutput o) {
|
||||
return IN_SET(o,
|
||||
EXEC_OUTPUT_TTY,
|
||||
EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_KMSG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_JOURNAL_AND_CONSOLE);
|
||||
}
|
||||
|
||||
static bool is_syslog_output(ExecOutput o) {
|
||||
return IN_SET(o,
|
||||
EXEC_OUTPUT_SYSLOG,
|
||||
EXEC_OUTPUT_SYSLOG_AND_CONSOLE);
|
||||
}
|
||||
|
||||
static bool is_kmsg_output(ExecOutput o) {
|
||||
return IN_SET(o,
|
||||
EXEC_OUTPUT_KMSG,
|
||||
@ -361,7 +354,7 @@ static int connect_logger_as(
|
||||
params->flags & EXEC_PASS_LOG_UNIT ? unit->id : "",
|
||||
context->syslog_priority,
|
||||
!!context->syslog_level_prefix,
|
||||
is_syslog_output(output),
|
||||
false,
|
||||
is_kmsg_output(output),
|
||||
is_terminal_output(output)) < 0)
|
||||
return -errno;
|
||||
@ -664,8 +657,6 @@ static int setup_output(
|
||||
/* We don't reset the terminal if this is just about output */
|
||||
return open_terminal_as(exec_context_tty_path(context), O_WRONLY, fileno);
|
||||
|
||||
case EXEC_OUTPUT_SYSLOG:
|
||||
case EXEC_OUTPUT_SYSLOG_AND_CONSOLE:
|
||||
case EXEC_OUTPUT_KMSG:
|
||||
case EXEC_OUTPUT_KMSG_AND_CONSOLE:
|
||||
case EXEC_OUTPUT_JOURNAL:
|
||||
@ -4736,17 +4727,13 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
|
||||
prefix, yes_no(c->tty_vt_disallocate));
|
||||
|
||||
if (IN_SET(c->std_output,
|
||||
EXEC_OUTPUT_SYSLOG,
|
||||
EXEC_OUTPUT_KMSG,
|
||||
EXEC_OUTPUT_JOURNAL,
|
||||
EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_KMSG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_JOURNAL_AND_CONSOLE) ||
|
||||
IN_SET(c->std_error,
|
||||
EXEC_OUTPUT_SYSLOG,
|
||||
EXEC_OUTPUT_KMSG,
|
||||
EXEC_OUTPUT_JOURNAL,
|
||||
EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_KMSG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_JOURNAL_AND_CONSOLE)) {
|
||||
|
||||
@ -5764,8 +5751,6 @@ static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = {
|
||||
[EXEC_OUTPUT_INHERIT] = "inherit",
|
||||
[EXEC_OUTPUT_NULL] = "null",
|
||||
[EXEC_OUTPUT_TTY] = "tty",
|
||||
[EXEC_OUTPUT_SYSLOG] = "syslog",
|
||||
[EXEC_OUTPUT_SYSLOG_AND_CONSOLE] = "syslog+console",
|
||||
[EXEC_OUTPUT_KMSG] = "kmsg",
|
||||
[EXEC_OUTPUT_KMSG_AND_CONSOLE] = "kmsg+console",
|
||||
[EXEC_OUTPUT_JOURNAL] = "journal",
|
||||
|
@ -52,8 +52,6 @@ typedef enum ExecOutput {
|
||||
EXEC_OUTPUT_INHERIT,
|
||||
EXEC_OUTPUT_NULL,
|
||||
EXEC_OUTPUT_TTY,
|
||||
EXEC_OUTPUT_SYSLOG,
|
||||
EXEC_OUTPUT_SYSLOG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_KMSG,
|
||||
EXEC_OUTPUT_KMSG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_JOURNAL,
|
||||
|
@ -1099,6 +1099,7 @@ int config_parse_exec_output(
|
||||
const char *n;
|
||||
ExecContext *c = data;
|
||||
const Unit *u = userdata;
|
||||
bool obsolete = false;
|
||||
ExecOutput eo;
|
||||
int r;
|
||||
|
||||
@ -1123,6 +1124,14 @@ int config_parse_exec_output(
|
||||
|
||||
eo = EXEC_OUTPUT_NAMED_FD;
|
||||
|
||||
} else if (streq(rvalue, "syslog")) {
|
||||
eo = EXEC_OUTPUT_JOURNAL;
|
||||
obsolete = true;
|
||||
|
||||
} else if (streq(rvalue, "syslog+console")) {
|
||||
eo = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
|
||||
obsolete = true;
|
||||
|
||||
} else if ((n = startswith(rvalue, "file:"))) {
|
||||
|
||||
r = unit_full_printf(u, n, &resolved);
|
||||
@ -1154,6 +1163,11 @@ int config_parse_exec_output(
|
||||
}
|
||||
}
|
||||
|
||||
if (obsolete)
|
||||
log_syntax(unit, LOG_NOTICE, filename, line, 0,
|
||||
"Standard output type %s is obsolete, automatically updating to %s. Please update your unit file, and consider removing the setting altogether.",
|
||||
rvalue, exec_output_to_string(eo));
|
||||
|
||||
if (streq(lvalue, "StandardOutput")) {
|
||||
if (eo == EXEC_OUTPUT_NAMED_FD)
|
||||
free_and_replace(c->stdio_fdname[STDOUT_FILENO], resolved);
|
||||
@ -5051,22 +5065,36 @@ int config_parse_output_restricted(
|
||||
void *userdata) {
|
||||
|
||||
ExecOutput t, *eo = data;
|
||||
bool obsolete = false;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
t = exec_output_from_string(rvalue);
|
||||
if (t < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse output type, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
if (streq(rvalue, "syslog")) {
|
||||
t = EXEC_OUTPUT_JOURNAL;
|
||||
obsolete = true;
|
||||
} else if (streq(rvalue, "syslog+console")) {
|
||||
t = EXEC_OUTPUT_JOURNAL_AND_CONSOLE;
|
||||
obsolete = true;
|
||||
} else {
|
||||
t = exec_output_from_string(rvalue);
|
||||
if (t < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse output type, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (IN_SET(t, EXEC_OUTPUT_SOCKET, EXEC_OUTPUT_NAMED_FD, EXEC_OUTPUT_FILE, EXEC_OUTPUT_FILE_APPEND)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Standard output types socket, fd:, file:, append: are not supported as defaults, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (IN_SET(t, EXEC_OUTPUT_SOCKET, EXEC_OUTPUT_NAMED_FD, EXEC_OUTPUT_FILE, EXEC_OUTPUT_FILE_APPEND)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Standard output types socket, fd:, file:, append: are not supported as defaults, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (obsolete)
|
||||
log_syntax(unit, LOG_NOTICE, filename, line, 0,
|
||||
"Standard output type %s is obsolete, automatically updating to %s. Please update your configuration.",
|
||||
rvalue, exec_output_to_string(t));
|
||||
|
||||
*eo = t;
|
||||
return 0;
|
||||
|
@ -1123,12 +1123,10 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
|
||||
|
||||
if (!IN_SET(c->std_output,
|
||||
EXEC_OUTPUT_JOURNAL, EXEC_OUTPUT_JOURNAL_AND_CONSOLE,
|
||||
EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_SYSLOG, EXEC_OUTPUT_SYSLOG_AND_CONSOLE) &&
|
||||
EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE) &&
|
||||
!IN_SET(c->std_error,
|
||||
EXEC_OUTPUT_JOURNAL, EXEC_OUTPUT_JOURNAL_AND_CONSOLE,
|
||||
EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE,
|
||||
EXEC_OUTPUT_SYSLOG, EXEC_OUTPUT_SYSLOG_AND_CONSOLE) &&
|
||||
EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE) &&
|
||||
!c->log_namespace)
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user