From 7ade8982ca1969e251a29589ae918c3b5c595afb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 2 Jun 2020 12:06:22 +0200 Subject: [PATCH] core: remove support for ".include" stanza Six years ago we declared it obsolete and removed it from the docs (c073a0c4a5ffbf6677dd6af02e7c7d59b2b901ab) and added a note about it in NEWS. Two years ago we add warning messages about it, indicating the feature will be removed (41b283d0f1f4abd85d0bbeeb7f71bb30f87cfab9) and mentioned it in NEWS again. Let's now kill it for good. --- NEWS | 5 +++++ man/systemd.unit.xml | 3 --- src/core/load-fragment.c | 2 +- src/fuzz/fuzz-unit-file.c | 2 +- src/shared/conf-parser.c | 31 +------------------------------ src/shared/conf-parser.h | 3 +-- src/shared/install.c | 2 +- 7 files changed, 10 insertions(+), 38 deletions(-) diff --git a/NEWS b/NEWS index b27d38be77..911df9cabb 100644 --- a/NEWS +++ b/NEWS @@ -357,6 +357,11 @@ CHANGES WITH 246 in spe: The optional positional argument to "systemctl reboot" is now being deprecated in favor of this option. + * Support for the .include syntax in unit files has been removed. The + concept has been obsolete for 6 years and we started warning about + its pending removal 2 years ago (also see NEWS file below). It's + finally gone now. + CHANGES WITH 245: * A new tool "systemd-repart" has been added, that operates as an diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index cdd7572add..8c0815488b 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -226,9 +226,6 @@ foo-.service.d/10-override.conf would override service.d/10-override.conf. - - Note that while systemd offers a flexible dependency system between units it is recommended to use this functionality only sparingly and instead rely on techniques such as bus-based or diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 49fdcaff7e..517813986b 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4864,7 +4864,7 @@ int unit_load_fragment(Unit *u) { r = config_parse(u->id, fragment, f, UNIT_VTABLE(u)->sections, config_item_perf_lookup, load_fragment_gperf_lookup, - CONFIG_PARSE_ALLOW_INCLUDE, + 0, u, NULL); if (r == -ENOEXEC) diff --git a/src/fuzz/fuzz-unit-file.c b/src/fuzz/fuzz-unit-file.c index 34f59a4437..c0661433a3 100644 --- a/src/fuzz/fuzz-unit-file.c +++ b/src/fuzz/fuzz-unit-file.c @@ -74,7 +74,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { name, name, f, UNIT_VTABLE(u)->sections, config_item_perf_lookup, load_fragment_gperf_lookup, - CONFIG_PARSE_ALLOW_INCLUDE, + 0, u, NULL); diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 2122657342..0a59f19e2a 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -159,7 +159,7 @@ static int parse_line( char *l, void *userdata) { - char *e, *include; + char *e; assert(filename); assert(line > 0); @@ -173,35 +173,6 @@ static int parse_line( if (*l == '\n') return 0; - include = first_word(l, ".include"); - if (include) { - _cleanup_free_ char *fn = NULL; - - /* .includes are a bad idea, we only support them here - * for historical reasons. They create cyclic include - * problems and make it difficult to detect - * configuration file changes with an easy - * stat(). Better approaches, such as .d/ drop-in - * snippets exist. - * - * Support for them should be eventually removed. */ - - if (!(flags & CONFIG_PARSE_ALLOW_INCLUDE)) { - log_syntax(unit, LOG_ERR, filename, line, 0, ".include not allowed here. Ignoring."); - return 0; - } - - log_syntax(unit, LOG_WARNING, filename, line, 0, - ".include directives are deprecated, and support for them will be removed in a future version of systemd. " - "Please use drop-in files instead."); - - fn = file_in_same_dir(filename, strstrip(include)); - if (!fn) - return -ENOMEM; - - return config_parse(unit, fn, NULL, sections, lookup, table, flags, userdata, NULL); - } - if (!utf8_is_valid(l)) return log_syntax_invalid_utf8(unit, LOG_WARNING, filename, line, l); diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 6c8c1092ea..0eaff0c0e0 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -16,8 +16,7 @@ typedef enum ConfigParseFlags { CONFIG_PARSE_RELAXED = 1 << 0, /* Do not warn about unknown non-extension fields */ - CONFIG_PARSE_ALLOW_INCLUDE = 1 << 1, /* Allow the deprecated .include stanza */ - CONFIG_PARSE_WARN = 1 << 2, /* Emit non-debug messages */ + CONFIG_PARSE_WARN = 1 << 1, /* Emit non-debug messages */ } ConfigParseFlags; /* Argument list for parsers of specific configuration settings. */ diff --git a/src/shared/install.c b/src/shared/install.c index 5dd5d2aa9a..bb2eff7387 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1304,7 +1304,7 @@ static int unit_file_load( "-Target\0" "-Timer\0", config_item_table_lookup, items, - CONFIG_PARSE_ALLOW_INCLUDE, info, + 0, info, NULL); if (r < 0) return log_debug_errno(r, "Failed to parse %s: %m", info->name);