util: make machine_name_is_valid() a macro and move it to hostname-util.h
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.
This commit is contained in:
parent
b59abc4d1e
commit
25300b5a1f
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -32,13 +32,14 @@
|
|||
#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,
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "replace-var.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
#include "hostname-util.h"
|
||||
|
||||
#define JOURNAL_FILES_MAX 7168
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue