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/basic/hostname-util.h | |
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/basic/hostname-util.h')
-rw-r--r-- | src/basic/hostname-util.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/basic/hostname-util.h b/src/basic/hostname-util.h index a7d09c910b..52fd6b0899 100644 --- a/src/basic/hostname-util.h +++ b/src/basic/hostname-util.h @@ -39,4 +39,5 @@ bool is_gateway_hostname(const char *hostname); int sethostname_idempotent(const char *s); -int read_hostname_config(const char *path, char **hostname); +int read_etc_hostname_stream(FILE *f, char **ret); +int read_etc_hostname(const char *path, char **ret); |