From 9fe20c3234d5e1944b1458e8c7ed6a61b86fafe2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 Apr 2022 18:09:18 +0200 Subject: [PATCH] specifier: use %q for pretty hostname %R is already used in service manager specifier expansion (cgroup root), hence use a different char, that was so far not used. Follow-up for: 6ceb0a4094908dd213a78b9f6d0c59a684831ab0 --- NEWS | 2 +- man/standard-specifiers.xml | 10 +++++----- man/systemd.unit.xml | 2 +- src/shared/specifier.h | 3 ++- src/test/test-specifier.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index c01bcdab45e..330d46d1d12 100644 --- a/NEWS +++ b/NEWS @@ -239,7 +239,7 @@ CHANGES WITH 251: normalized unit file path, which is particularly useful for symlinked unit files. - The new %R specifier resolves to the pretty hostname + The new %q specifier resolves to the pretty hostname (i.e. PRETTY_HOSTNAME= from /etc/machine-info). The new %d specifier resolves to the credentials directory of a diff --git a/man/standard-specifiers.xml b/man/standard-specifiers.xml index abbd47f7782..e7314b9c4a3 100644 --- a/man/standard-specifiers.xml +++ b/man/standard-specifiers.xml @@ -34,11 +34,6 @@ Short host name The hostname of the running system, truncated at the first dot to remove any domain component. - - %R - Pretty host name - The pretty hostname of the running system, as read from the PRETTY_HOSTNAME= field of /etc/machine-info. If not set, resolves to the short hostname. See machine-info5 for more information. - %m Machine ID @@ -54,6 +49,11 @@ Operating system ID The operating system identifier of the running system, as read from the ID= field of /etc/os-release. See os-release5 for more information. + + %q + Pretty host name + The pretty hostname of the running system, as read from the PRETTY_HOSTNAME= field of /etc/machine-info. If not set, resolves to the short hostname. See machine-info5 for more information. + %T Directory for temporary files diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 7a611dc93f7..cd033ac52e1 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -2097,7 +2097,7 @@ Note that this setting is not influenced by the Us - %R + %q Pretty host name The pretty hostname of the running system at the point in time the unit configuration is loaded, as read from the PRETTY_HOSTNAME= field of /etc/machine-info. If not set, resolves to the short hostname. See machine-info5 for more information. diff --git a/src/shared/specifier.h b/src/shared/specifier.h index 78b10f84671..ea37e3cef6f 100644 --- a/src/shared/specifier.h +++ b/src/shared/specifier.h @@ -51,6 +51,7 @@ int specifier_var_tmp_dir(char specifier, const void *data, const char *root, co * %B: the OS build ID, according to /etc/os-release * %H: the hostname of the running system * %l: the short hostname of the running system + * %q: the 'pretty' hostname as per /etc/machine-info * %m: the machine ID of the running system * %M: the OS image ID, according to /etc/os-release * %o: the OS ID according to /etc/os-release @@ -76,7 +77,7 @@ int specifier_var_tmp_dir(char specifier, const void *data, const char *root, co { 'B', specifier_os_build_id, NULL }, \ { 'H', specifier_host_name, NULL }, \ { 'l', specifier_short_host_name, NULL }, \ - { 'R', specifier_pretty_host_name,NULL }, \ + { 'q', specifier_pretty_host_name,NULL }, \ { 'm', specifier_machine_id, NULL }, \ { 'M', specifier_os_image_id, NULL }, \ { 'o', specifier_os_id, NULL }, \ diff --git a/src/test/test-specifier.c b/src/test/test-specifier.c index 49b4f5a2a33..516502032a7 100644 --- a/src/test/test-specifier.c +++ b/src/test/test-specifier.c @@ -74,7 +74,7 @@ TEST(specifier_printf) { assert_se(streq(w, "xxx a=AAAA b=BBBB e= yyy")); free(w); - r = specifier_printf("machine=%m, boot=%b, host=%H, pretty=%R, version=%v, arch=%a, empty=%e", SIZE_MAX, table, NULL, NULL, &w); + r = specifier_printf("machine=%m, boot=%b, host=%H, pretty=%q, version=%v, arch=%a, empty=%e", SIZE_MAX, table, NULL, NULL, &w); assert_se(r >= 0); assert_se(w); puts(w); -- 2.47.3