diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-11-14 19:51:06 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-11-20 16:43:15 +0100 |
commit | f35cb39ed6fa8ad48bd3125c30bca7f310ef5788 (patch) | |
tree | fd507f1e37bc864b7b7e338cf139b1dacb1e5eb8 /src/hostname | |
parent | 9990ea0e59373c02b6bd64a5a4c860d2579f77db (diff) | |
download | systemd-f35cb39ed6fa8ad48bd3125c30bca7f310ef5788.tar.gz |
hostname-util: rework read_hostname_config() a bit
First of all, let's rename it to read_etc_hostname(), to make clearer
what kind of configuration it actually reads: the file format defined in
/etc/hostname and nothing else.
Secondly: let's port this to use read_line(), i.e. the new way to read
lines from a file in a safe, bounded way.
Thirdly: let's strip leading/trailing whitespace from what we are
reading. Given that we are already pretty lenient what we read (comments
and empty lines), let's be permissive regarding whitespace too.
Fourthly: let's actually validate the hostname when reading it. So far
we tried to make it valid, but that's not always possible (for example,
we can't make an empty hostname valid, ever).
Diffstat (limited to 'src/hostname')
-rw-r--r-- | src/hostname/hostnamed.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index a9d5d49bdd..5feaa60c99 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -96,7 +96,7 @@ static int context_read_data(Context *c) { if (!c->data[PROP_HOSTNAME]) return -ENOMEM; - r = read_hostname_config("/etc/hostname", &c->data[PROP_STATIC_HOSTNAME]); + r = read_etc_hostname(NULL, &c->data[PROP_STATIC_HOSTNAME]); if (r < 0 && r != -ENOENT) return r; |