diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-10-27 16:22:38 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-11-17 11:13:44 +0100 |
commit | 5db9818772757bd6ad431a17cecc38320211c72b (patch) | |
tree | b488987a69aaecf501a49680b6eaeb87f19b071b /src | |
parent | 666d787787b7f7168478b73865adb7928b50cb88 (diff) | |
download | systemd-5db9818772757bd6ad431a17cecc38320211c72b.tar.gz systemd-5db9818772757bd6ad431a17cecc38320211c72b.tar.bz2 systemd-5db9818772757bd6ad431a17cecc38320211c72b.zip |
core: don't allow DefaultStandardOutput= be set to socket/fd:/file:
These three settings only make sense within the context of actual unit
files, hence filter this out when applied to the per-manager default,
and generate a log message about it.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/load-fragment.c | 2 | ||||
-rw-r--r-- | src/core/load-fragment.h | 1 | ||||
-rw-r--r-- | src/core/main.c | 38 |
3 files changed, 36 insertions, 5 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 37f0229de3..b4405b5e21 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -832,8 +832,6 @@ int config_parse_socket_bindtodevice( return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_output, exec_output, ExecOutput, "Failed to parse output literal specifier"); - int config_parse_exec_input( const char *unit, const char *filename, diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h index bba1259ceb..481bab7cbd 100644 --- a/src/core/load-fragment.h +++ b/src/core/load-fragment.h @@ -46,7 +46,6 @@ int config_parse_service_type(const char *unit, const char *filename, unsigned l int config_parse_service_restart(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_socket_bindtodevice(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_exec_output(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); -int config_parse_output(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_exec_input(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_exec_input_text(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_exec_input_data(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/core/main.c b/src/core/main.c index 96cac1cd9e..1dd417749d 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -571,6 +571,40 @@ static int config_parse_show_status( return 0; } +static int config_parse_output_restricted( + const char* unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + ExecOutput t, *eo = data; + + 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 (IN_SET(t, EXEC_OUTPUT_SOCKET, EXEC_OUTPUT_NAMED_FD, EXEC_OUTPUT_FILE)) { + log_syntax(unit, LOG_ERR, filename, line, 0, "Standard output types socket, fd:, file: are not supported as defaults, ignoring: %s", rvalue); + return 0; + } + + *eo = t; + return 0; +} + static int config_parse_crash_chvt( const char* unit, const char *filename, @@ -722,8 +756,8 @@ static int parse_config_file(void) { #endif { "Manager", "TimerSlackNSec", config_parse_nsec, 0, &arg_timer_slack_nsec }, { "Manager", "DefaultTimerAccuracySec", config_parse_sec, 0, &arg_default_timer_accuracy_usec }, - { "Manager", "DefaultStandardOutput", config_parse_output, 0, &arg_default_std_output }, - { "Manager", "DefaultStandardError", config_parse_output, 0, &arg_default_std_error }, + { "Manager", "DefaultStandardOutput", config_parse_output_restricted,0, &arg_default_std_output }, + { "Manager", "DefaultStandardError", config_parse_output_restricted,0, &arg_default_std_error }, { "Manager", "DefaultTimeoutStartSec", config_parse_sec, 0, &arg_default_timeout_start_usec }, { "Manager", "DefaultTimeoutStopSec", config_parse_sec, 0, &arg_default_timeout_stop_usec }, { "Manager", "DefaultRestartSec", config_parse_sec, 0, &arg_default_restart_usec }, |