diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-03-10 16:15:54 +0100 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-03-10 19:03:22 +0100 |
commit | 6ceb0a4094908dd213a78b9f6d0c59a684831ab0 (patch) | |
tree | 4e1d6720898bf86ccb1f39a97b7f1ccca5a5c5a6 /src/shared/specifier.c | |
parent | core: be a bit more defensive when resolving specifiers (diff) | |
download | systemd-6ceb0a4094908dd213a78b9f6d0c59a684831ab0.tar.xz systemd-6ceb0a4094908dd213a78b9f6d0c59a684831ab0.zip |
core: introduce %R specifier for pretty hostname
Resolves: #20054
Diffstat (limited to 'src/shared/specifier.c')
-rw-r--r-- | src/shared/specifier.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/specifier.c b/src/shared/specifier.c index 8c5a4fa831..a02012407b 100644 --- a/src/shared/specifier.c +++ b/src/shared/specifier.c @@ -223,6 +223,21 @@ int specifier_short_host_name(char specifier, const void *data, const char *root return 0; } +int specifier_pretty_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) { + char *n = NULL; + + assert(ret); + + if (get_pretty_hostname(&n) < 0) { + n = gethostname_short_malloc(); + if (!n) + return -ENOMEM; + } + + *ret = n; + return 0; +} + int specifier_kernel_release(char specifier, const void *data, const char *root, const void *userdata, char **ret) { struct utsname uts; char *n; |