diff --git a/CHANGES-4.3.md b/CHANGES-4.3.md index e8c4804b3..61ce7c232 100644 --- a/CHANGES-4.3.md +++ b/CHANGES-4.3.md @@ -31,7 +31,7 @@ File format: * Improved resilience against autocluster partitioning during cluster startup. [#7876] [ekka-158](https://github.com/emqx/ekka/pull/158) -* Fix Added regularity (`^[0-9A-Za-z_\-]+$`) check for node names +* Add regular expression check ^[0-9A-Za-z_\-]+$ for node name [#7979] ## v4.3.14 diff --git a/bin/emqx b/bin/emqx index bcb7622a0..a3843ec7e 100755 --- a/bin/emqx +++ b/bin/emqx @@ -488,6 +488,10 @@ fi NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')" NAME="$(echo "$NAME_ARG" | awk '{print $2}')" NODENAME="$(echo "$NAME" | awk -F'@' '{print $1}')" +if ! (echo "$NODENAME" | grep -q '^[0-9A-Za-z_\-]\+$'); then + echo "Invalid node name, should be of format '^[0-9A-Za-z_-]+$'." + exit 1 +fi export ESCRIPT_NAME="$NODENAME" PIPE_DIR="${PIPE_DIR:-/$RUNNER_DATA_DIR/${WHOAMI}_erl_pipes/$NAME/}" diff --git a/priv/emqx.schema b/priv/emqx.schema index 5a352993a..4d7b1beda 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -206,21 +206,6 @@ end}. {override_env, "NODE_NAME"} ]}. -%% Node name regular expression from net_kernel:valid_name_head/1. -%% Be same with otp. -{translation, "vm_args.-name", -fun(Conf) -> - NodeName = cuttlefish:conf_get("node.name", Conf), - {Head, _Host} = lists:splitwith(fun(C) -> C =/= $@ end, NodeName), - {ok, MP} = re:compile("^[0-9A-Za-z_\\-]+$", [unicode]), - case re:run(Head, MP) of - {match, _} -> - NodeName; - nomatch -> - cuttlefish:invalid("Bad node name, expect ^[0-9A-Za-z_\\-]+$") - end -end}. - %% @doc Specify SSL Options in the file if using SSL for erlang distribution {mapping, "node.ssl_dist_optfile", "vm_args.-ssl_dist_optfile", [ {datatype, string},