chiark / gitweb /
sd-bus: support connecting to remote hosts, directly into containers
[elogind.git] / src / shared / util.c
index 4ad3f203d7d3f1b268b1044732cea6dac745e638..3d875c72b360d7d1f0e04376c6957c45ed7abd71 100644 (file)
@@ -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,