summaryrefslogtreecommitdiff
path: root/src/hostname
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-08-11 03:44:24 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-08-12 13:48:15 +0900
commit0995accdfd8d6c8ab5d237398cfaf58c64246274 (patch)
tree99824dcaf687740479ffab26fa23223e3751ebc4 /src/hostname
parentccdf235464297c2ca4c1dea8733a6bad423084d5 (diff)
downloadsystemd-0995accdfd8d6c8ab5d237398cfaf58c64246274.tar.gz
hostname: introduce gethostname_full() and use it in various gethostname() variants
Diffstat (limited to 'src/hostname')
-rw-r--r--src/hostname/hostnamed.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 36702f2fb0..2557d6d807 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -575,8 +575,7 @@ static int property_get_default_hostname(
}
static void context_determine_hostname_source(Context *c) {
- char hostname[HOST_NAME_MAX + 1] = {};
- _cleanup_free_ char *fallback = NULL;
+ _cleanup_free_ char *hostname = NULL;
int r;
assert(c);
@@ -584,11 +583,13 @@ static void context_determine_hostname_source(Context *c) {
if (c->hostname_source >= 0)
return;
- (void) get_hostname_filtered(hostname);
+ (void) gethostname_full(GET_HOSTNAME_ALLOW_LOCALHOST, &hostname);
if (streq_ptr(hostname, c->data[PROP_STATIC_HOSTNAME]))
c->hostname_source = HOSTNAME_STATIC;
else {
+ _cleanup_free_ char *fallback = NULL;
+
/* If the hostname was not set by us, try to figure out where it came from. If we set it to
* the default hostname, the file will tell us. We compare the string because it is possible
* that the hostname was set by an older version that had a different fallback, in the