From 4101c1accbab07629648cd260d30d704f60e894b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:50:28 +0100 Subject: [PATCH 1/7] locale-util: add unicode bullet to special glyphs --- src/basic/locale-util.c | 2 ++ src/basic/locale-util.h | 1 + src/test/test-locale-util.c | 1 + 3 files changed, 4 insertions(+) diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 7e479d605a7..b2ef66392e1 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -365,6 +365,7 @@ const char *special_glyph(SpecialGlyph code) { [TREE_SPACE] = " ", [TRIANGULAR_BULLET] = ">", [BLACK_CIRCLE] = "*", + [BULLET] = "*", [ARROW] = "->", [MDASH] = "-", [ELLIPSIS] = "...", @@ -381,6 +382,7 @@ const char *special_glyph(SpecialGlyph code) { [TREE_SPACE] = " ", /* */ [TRIANGULAR_BULLET] = "\342\200\243", /* ‣ */ [BLACK_CIRCLE] = "\342\227\217", /* ● */ + [BULLET] = "\342\200\242", /* • */ [ARROW] = "\342\206\222", /* → */ [MDASH] = "\342\200\223", /* – */ [ELLIPSIS] = "\342\200\246", /* … */ diff --git a/src/basic/locale-util.h b/src/basic/locale-util.h index ea624e99082..2aa2bef8c5c 100644 --- a/src/basic/locale-util.h +++ b/src/basic/locale-util.h @@ -45,6 +45,7 @@ typedef enum { TREE_SPACE, TRIANGULAR_BULLET, BLACK_CIRCLE, + BULLET, ARROW, MDASH, ELLIPSIS, diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c index 6d0f24eeea2..a1d4307eb51 100644 --- a/src/test/test-locale-util.c +++ b/src/test/test-locale-util.c @@ -77,6 +77,7 @@ static void dump_special_glyphs(void) { dump_glyph(TREE_SPACE); dump_glyph(TRIANGULAR_BULLET); dump_glyph(BLACK_CIRCLE); + dump_glyph(BULLET); dump_glyph(ARROW); dump_glyph(MDASH); dump_glyph(ELLIPSIS); From 1b9706b1cb30783f8ac768e9aa8609bb0dfd24de Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:39:28 +0100 Subject: [PATCH 2/7] systemctl: suffix unit file settings with = in our output We do this in our man pages and log messages, and hence also in this explanatory text. --- src/systemctl/systemctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index d573f8f17a3..87836d611f5 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6297,9 +6297,9 @@ static int enable_unit(int argc, char *argv[], void *userdata) { } if (carries_install_info == 0 && !ignore_carries_install_info) - log_warning("The unit files have no installation config (WantedBy, RequiredBy, Also, Alias\n" - "settings in the [Install] section, and DefaultInstance for template units).\n" - "This means they are not meant to be enabled using systemctl.\n" + log_warning("The unit files have no installation config (WantedBy=, RequiredBy=, Also=,\n" + "Alias= settings in the [Install] section, and DefaultInstance= for template\n" + "units). This means they are not meant to be enabled using systemctl.\n" "Possible reasons for having this kind of units are:\n" "1) A unit may be statically enabled by being symlinked from another unit's\n" " .wants/ or .requires/ directory.\n" From 46efc9780d3f955294cf1807e7e2f7f32c180bfd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:40:19 +0100 Subject: [PATCH 3/7] systemctl: downgrade log message to LOG_NOTICE This log message is not problematic at all, it is merely explanatory, hence LOG_WARN is too high for this. --- src/systemctl/systemctl.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 87836d611f5..5d4b3170dd2 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6297,18 +6297,18 @@ static int enable_unit(int argc, char *argv[], void *userdata) { } if (carries_install_info == 0 && !ignore_carries_install_info) - log_warning("The unit files have no installation config (WantedBy=, RequiredBy=, Also=,\n" - "Alias= settings in the [Install] section, and DefaultInstance= for template\n" - "units). This means they are not meant to be enabled using systemctl.\n" - "Possible reasons for having this kind of units are:\n" - "1) A unit may be statically enabled by being symlinked from another unit's\n" - " .wants/ or .requires/ directory.\n" - "2) A unit's purpose may be to act as a helper for some other unit which has\n" - " a requirement dependency on it.\n" - "3) A unit may be started when needed via activation (socket, path, timer,\n" - " D-Bus, udev, scripted systemctl call, ...).\n" - "4) In case of template units, the unit is meant to be enabled with some\n" - " instance name specified."); + log_notice("The unit files have no installation config (WantedBy=, RequiredBy=, Also=,\n" + "Alias= settings in the [Install] section, and DefaultInstance= for template\n" + "units). This means they are not meant to be enabled using systemctl.\n" + "Possible reasons for having this kind of units are:\n" + "1) A unit may be statically enabled by being symlinked from another unit's\n" + " .wants/ or .requires/ directory.\n" + "2) A unit's purpose may be to act as a helper for some other unit which has\n" + " a requirement dependency on it.\n" + "3) A unit may be started when needed via activation (socket, path, timer,\n" + " D-Bus, udev, scripted systemctl call, ...).\n" + "4) In case of template units, the unit is meant to be enabled with some\n" + " instance name specified."); if (arg_now && STR_IN_SET(argv[0], "enable", "disable", "mask")) { sd_bus *bus; From 18c93ee3ed798367de8b080c001118908bcdab62 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:52:04 +0100 Subject: [PATCH 4/7] systemctl: bullet lists FTW! There's no reason to number these items, let's make this a bit nicer by using proper bullets. --- src/systemctl/systemctl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 5d4b3170dd2..9098ff6dd70 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6301,14 +6301,15 @@ static int enable_unit(int argc, char *argv[], void *userdata) { "Alias= settings in the [Install] section, and DefaultInstance= for template\n" "units). This means they are not meant to be enabled using systemctl.\n" "Possible reasons for having this kind of units are:\n" - "1) A unit may be statically enabled by being symlinked from another unit's\n" - " .wants/ or .requires/ directory.\n" - "2) A unit's purpose may be to act as a helper for some other unit which has\n" - " a requirement dependency on it.\n" - "3) A unit may be started when needed via activation (socket, path, timer,\n" - " D-Bus, udev, scripted systemctl call, ...).\n" - "4) In case of template units, the unit is meant to be enabled with some\n" - " instance name specified."); + "%1$s A unit may be statically enabled by being symlinked from another unit's\n" + " .wants/ or .requires/ directory.\n" + "%1$s A unit's purpose may be to act as a helper for some other unit which has\n" + " a requirement dependency on it.\n" + "%1$s A unit may be started when needed via activation (socket, path, timer,\n" + " D-Bus, udev, scripted systemctl call, ...).\n" + "%1$s In case of template units, the unit is meant to be enabled with some\n" + " instance name specified.", + special_glyph(BULLET)); if (arg_now && STR_IN_SET(argv[0], "enable", "disable", "mask")) { sd_bus *bus; From ac9bbabbc57454cadd0e65675cb138087d5c94f2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:52:54 +0100 Subject: [PATCH 5/7] systemctl: separate out paragraphs in long message with empty line --- src/systemctl/systemctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 9098ff6dd70..38545e8f5eb 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6299,7 +6299,7 @@ static int enable_unit(int argc, char *argv[], void *userdata) { if (carries_install_info == 0 && !ignore_carries_install_info) log_notice("The unit files have no installation config (WantedBy=, RequiredBy=, Also=,\n" "Alias= settings in the [Install] section, and DefaultInstance= for template\n" - "units). This means they are not meant to be enabled using systemctl.\n" + "units). This means they are not meant to be enabled using systemctl.\n \n" "Possible reasons for having this kind of units are:\n" "%1$s A unit may be statically enabled by being symlinked from another unit's\n" " .wants/ or .requires/ directory.\n" From d23aeead14eda5a70d599dcc37bcd4b2ebea7579 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:39:20 +0100 Subject: [PATCH 6/7] install: use structured initializers --- src/shared/install.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shared/install.c b/src/shared/install.c index 97c48afe5d8..735e1f5b0e0 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1048,11 +1048,14 @@ static int install_info_add( if (r < 0) return r; - i = new0(UnitFileInstallInfo, 1); + i = new(UnitFileInstallInfo, 1); if (!i) return -ENOMEM; - i->type = _UNIT_FILE_TYPE_INVALID; - i->auxiliary = auxiliary; + + *i = (UnitFileInstallInfo) { + .type = _UNIT_FILE_TYPE_INVALID, + .auxiliary = auxiliary, + }; i->name = strdup(name); if (!i->name) { From e4086ae0b323cb17eacd7ed60ff5782f87baa4f2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Nov 2018 13:50:37 +0100 Subject: [PATCH 7/7] install: when enabling a template unit without DefaultInstance= nor specified instance don't do anything Previously, we'd link the unit file into /etc in this case, but that should only be done if the unit file is not in the search path anyway, and this is already done implicitly anyway for all enabled unit files, hence no reason to duplicate this here. Fixes: #10253 --- src/shared/install.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/install.c b/src/shared/install.c index 735e1f5b0e0..28e07a23a55 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1752,12 +1752,16 @@ static int install_info_symlink_wants( if (strv_isempty(list)) return 0; - if (unit_name_is_valid(i->name, UNIT_NAME_TEMPLATE) && i->default_instance) { + if (unit_name_is_valid(i->name, UNIT_NAME_TEMPLATE)) { UnitFileInstallInfo instance = { .type = _UNIT_FILE_TYPE_INVALID, }; _cleanup_free_ char *path = NULL; + /* If this is a template, and we have no instance, don't do anything */ + if (!i->default_instance) + return 1; + r = unit_name_replace_instance(i->name, i->default_instance, &buf); if (r < 0) return r;