diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2021-02-25 11:36:45 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2021-02-25 11:36:45 +0100 |
| commit | d92aa7f298fe84d4cf686c5ad64b73438e00d377 (patch) | |
| tree | 2f1f4c7b48cff9e63b0d0e3669bada3d9aeda72e /shared/systemd/src/basic/hostname-util.h | |
| parent | a82e048a943092315a32d745c99e0f5635e29134 (diff) | |
| parent | 3a56bce6c0ea7ba0fe269520547740783b342e0d (diff) | |
Merge branch 'upstream/latest' of https://salsa.debian.org/utopia-team/network-manager into upstream/latest
Diffstat (limited to 'shared/systemd/src/basic/hostname-util.h')
| -rw-r--r-- | shared/systemd/src/basic/hostname-util.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/shared/systemd/src/basic/hostname-util.h b/shared/systemd/src/basic/hostname-util.h index cafd6f02..6cff9c1d 100644 --- a/shared/systemd/src/basic/hostname-util.h +++ b/shared/systemd/src/basic/hostname-util.h @@ -1,29 +1,29 @@ -/* SPDX-License-Identifier: LGPL-2.1+ */ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once #include <stdbool.h> #include <stdio.h> #include "macro.h" - -bool hostname_is_set(void); +#include "strv.h" char* gethostname_malloc(void); char* gethostname_short_malloc(void); int gethostname_strict(char **ret); bool valid_ldh_char(char c) _const_; -bool hostname_is_valid(const char *s, bool allow_trailing_dot) _pure_; -char* hostname_cleanup(char *s); - -#define machine_name_is_valid(s) hostname_is_valid(s, false) -bool is_localhost(const char *hostname); -bool is_gateway_hostname(const char *hostname); +typedef enum ValidHostnameFlags { + VALID_HOSTNAME_TRAILING_DOT = 1 << 0, /* Accept trailing dot on multi-label names */ + VALID_HOSTNAME_DOT_HOST = 1 << 1, /* Accept ".host" as valid hostname */ +} ValidHostnameFlags; -int sethostname_idempotent(const char *s); +bool hostname_is_valid(const char *s, ValidHostnameFlags flags) _pure_; +char* hostname_cleanup(char *s); -int shorten_overlong(const char *s, char **ret); +bool is_localhost(const char *hostname); -int read_etc_hostname_stream(FILE *f, char **ret); -int read_etc_hostname(const char *path, char **ret); +static inline bool is_gateway_hostname(const char *hostname) { + /* This tries to identify the valid syntaxes for the our synthetic "gateway" host. */ + return STRCASE_IN_SET(hostname, "_gateway", "_gateway."); +} |