diff options
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 4ad3f203d7..3d875c72b3 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -3975,6 +3975,21 @@ char* hostname_cleanup(char *s, bool lowercase) { return s; } +bool machine_name_is_valid(const char *s) { + + if (!hostname_is_valid(s)) + return false; + + /* Machine names should be useful hostnames, but also be + * useful in unit names, hence we enforce a stricter length + * limitation. */ + + if (strlen(s) > 64) + return false; + + return true; +} + int pipe_eof(int fd) { struct pollfd pollfd = { .fd = fd, |