]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util: make machine_name_is_valid() a macro and move it to hostname-util.h
authorLennart Poettering <lennart@poettering.net>
Sun, 23 Aug 2015 12:30:52 +0000 (14:30 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 24 Aug 2015 20:46:45 +0000 (22:46 +0200)
As it turns out machine_name_is_valid() does the exact same thing as
hostname_is_valid() these days, as it just invoked that and checked the
name length was < 64. However, hostname_is_valid() checks the length
against HOST_NAME_MAX anyway (which is 64 on Linux), hence any
additional check is redundant.

We hence replace machine_name_is_valid() by a macro that simply maps it
to hostname_is_valid() but sets the allow_trailing_dot parameter to
false. We also move this this call to hostname-util.h, to the same place
as the hostname_is_valid() declaration.

19 files changed:
src/basic/hostname-util.h
src/basic/util.c
src/basic/util.h
src/import/export.c
src/import/import-raw.c
src/import/import-tar.c
src/import/import.c
src/import/importd.c
src/import/pull-raw.c
src/import/pull-tar.c
src/import/pull.c
src/journal/sd-journal.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-login/sd-login.c
src/machine/machinectl.c
src/machine/machined-dbus.c
src/machine/machined.c
src/nss-mymachines/nss-mymachines.c
src/shared/logs-show.c

index 7c50260d73c64b6060dcad8dff661b6f4bfde64f..d4f5bfe45ec41ebdc357caff073309d0812426bd 100644 (file)
@@ -32,6 +32,8 @@ char* gethostname_malloc(void);
 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);
 
index 9571f0ab122b1c62977997fa2d7400b8b0b6224a..deff68073c14301371dd287748ffda7311589c98 100644 (file)
@@ -3006,21 +3006,6 @@ char* strshorten(char *s, size_t l) {
         return s;
 }
 
-bool machine_name_is_valid(const char *s) {
-
-        if (!hostname_is_valid(s, false))
-                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,
index 8f21d56ed8ebc494bcd0b2e0bb1efe44f9baa63d..1ead7b5419b3fda7971003cc4a217122550a6f76 100644 (file)
@@ -394,8 +394,6 @@ bool nulstr_contains(const char*nulstr, const char *needle);
 
 bool plymouth_running(void);
 
-bool machine_name_is_valid(const char *s) _pure_;
-
 char* strshorten(char *s, size_t l);
 
 int symlink_idempotent(const char *from, const char *to);
index ec7dbe210a9ea3246d5466821399457c9b6ad16a..b88d71fec63e7a1c1a00a0c23f6768282436b391 100644 (file)
@@ -24,6 +24,7 @@
 #include "sd-event.h"
 #include "event-util.h"
 #include "signal-util.h"
+#include "hostname-util.h"
 #include "verbs.h"
 #include "build.h"
 #include "machine-image.h"
index 43cd413042d993c4f5f2e4076692077831f073c2..a27e81bbd4ce6451ab4a2918bf3615597cc14cc7 100644 (file)
@@ -26,6 +26,7 @@
 #include "util.h"
 #include "path-util.h"
 #include "btrfs-util.h"
+#include "hostname-util.h"
 #include "copy.h"
 #include "mkdir.h"
 #include "rm-rf.h"
index 2bf0b0680c4cef9ae4e81d63fa2facd142f2db80..7ffe83cc336a4aebb92196a8b5c14c7adb3abe87 100644 (file)
@@ -26,6 +26,7 @@
 #include "util.h"
 #include "path-util.h"
 #include "btrfs-util.h"
+#include "hostname-util.h"
 #include "copy.h"
 #include "mkdir.h"
 #include "rm-rf.h"
index b7772390e943c47ae72469f8448fd25f2f031c4c..929a840298a90e8d61a4b2830fdfd02d09f882ae 100644 (file)
@@ -26,6 +26,7 @@
 #include "verbs.h"
 #include "build.h"
 #include "signal-util.h"
+#include "hostname-util.h"
 #include "machine-image.h"
 #include "import-util.h"
 #include "import-tar.h"
index dd314f5b0024ee139ee231d305034ade8186b482..8b508eaeec857372aa8376d2809eb2a6721bee67 100644 (file)
@@ -35,6 +35,7 @@
 #include "import-util.h"
 #include "process-util.h"
 #include "signal-util.h"
+#include "hostname-util.h"
 
 typedef struct Transfer Transfer;
 typedef struct Manager Manager;
index 5bfaf012c08d3bed8d38be765f2d383e4584e6c4..d0e0faa2614df43beaaafde02d33a502d7c5c951 100644 (file)
@@ -33,6 +33,7 @@
 #include "mkdir.h"
 #include "rm-rf.h"
 #include "path-util.h"
+#include "hostname-util.h"
 #include "import-util.h"
 #include "import-common.h"
 #include "curl-util.h"
index 71b8908a5886d6250e7d4b82b3833902ce47d501..d38a2158c44a0221cc8e8e13505ff7f1893635e4 100644 (file)
 #include "mkdir.h"
 #include "rm-rf.h"
 #include "path-util.h"
+#include "process-util.h"
+#include "hostname-util.h"
 #include "import-util.h"
 #include "import-common.h"
 #include "curl-util.h"
 #include "pull-job.h"
 #include "pull-common.h"
 #include "pull-tar.h"
-#include "process-util.h"
 
 typedef enum TarProgress {
         TAR_DOWNLOADING,
index ca7be6be85b02832ec584bf71d843e9f73cead15..e13cd6af971eca1050cd37574b884ae305c0f597 100644 (file)
@@ -26,6 +26,7 @@
 #include "verbs.h"
 #include "build.h"
 #include "signal-util.h"
+#include "hostname-util.h"
 #include "machine-image.h"
 #include "import-util.h"
 #include "pull-tar.h"
index bfd1901e163dc4482cd6cbe4fadee1fb5f5acac7..13fa9b52fc49cf59e6f2a61cd715da0b8ce4713b 100644 (file)
@@ -43,6 +43,7 @@
 #include "replace-var.h"
 #include "fileio.h"
 #include "formats-util.h"
+#include "hostname-util.h"
 
 #define JOURNAL_FILES_MAX 7168
 
index db4f21e9ff2e2ddcb949313560f2c94cf2fd3859..31cdcb4e5b44af3835e009846ae41528be774466 100644 (file)
@@ -33,6 +33,7 @@
 #include "missing.h"
 #include "def.h"
 #include "cgroup-util.h"
+#include "hostname-util.h"
 #include "bus-label.h"
 
 #include "sd-bus.h"
index 9bbf8974ddb8804bcfe352b5369fefc545883c6a..5f290573cb3930dc387e67918b951e68e1b63466 100644 (file)
@@ -32,6 +32,7 @@
 #include "fileio.h"
 #include "login-util.h"
 #include "formats-util.h"
+#include "hostname-util.h"
 #include "sd-login.h"
 
 _public_ int sd_pid_get_session(pid_t pid, char **session) {
index 8e7550844413723ca354d0f1d4b0d83de7c0910a..72b9a619d2d7860782f2269c3f7b2936de5e92d3 100644 (file)
@@ -56,6 +56,7 @@
 #include "terminal-util.h"
 #include "signal-util.h"
 #include "env-util.h"
+#include "hostname-util.h"
 
 static char **arg_property = NULL;
 static bool arg_all = false;
index 93514986f32ad3c97c16ad29dc1cf5d5aaafdc5e..03625ba4cdb4157df27763751dbd554ea4b6896d 100644 (file)
@@ -33,6 +33,7 @@
 #include "btrfs-util.h"
 #include "formats-util.h"
 #include "process-util.h"
+#include "hostname-util.h"
 #include "machine-image.h"
 #include "machine-pool.h"
 #include "image-dbus.h"
index c8ad157326549f3004cc197f88552d6104ac1277..109bab76c5159669400e95b8ad87704b7a90123a 100644 (file)
@@ -30,6 +30,7 @@
 #include "label.h"
 #include "formats-util.h"
 #include "signal-util.h"
+#include "hostname-util.h"
 #include "machine-image.h"
 #include "machined.h"
 
index cdec83d074064c82c7117250c25d0f744e78582f..5758ea1569080c97f94922136ffc2b7e1f23e379 100644 (file)
@@ -30,6 +30,7 @@
 #include "bus-util.h"
 #include "bus-common-errors.h"
 #include "in-addr-util.h"
+#include "hostname-util.h"
 
 NSS_GETHOSTBYNAME_PROTOTYPES(mymachines);
 NSS_GETPW_PROTOTYPES(mymachines);
index 60144ab8a6775b2f02d275baf2b66428093ed8cd..9a5ffb7a6ca670f2245156e88f6ac2495a61ccca 100644 (file)
@@ -34,6 +34,7 @@
 #include "formats-util.h"
 #include "process-util.h"
 #include "terminal-util.h"
+#include "hostname-util.h"
 
 /* up to three lines (each up to 100 characters),
    or 300 characters, whichever is less */