fix: check node name, regular expression (good idea from stone)
This commit is contained in:
parent
cdb1c149e7
commit
1adb33a6a0
|
@ -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
|
||||
|
||||
|
|
4
bin/emqx
4
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/}"
|
||||
|
|
|
@ -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},
|
||||
|
|
Loading…
Reference in New Issue