X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Futil.c;h=3d875c72b360d7d1f0e04376c6957c45ed7abd71;hp=4ad3f203d7d3f1b268b1044732cea6dac745e638;hb=7f0d207d2c816e0a8cb2742b0a789911f7c99356;hpb=8f6e22a1cafafb4e78e23c1998f23a997c1b294f diff --git a/src/shared/util.c b/src/shared/util.c index 4ad3f203d..3d875c72b 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,