@@ -388,16 +388,18 @@ query_node_props(Nodes) when Nodes =/= [] ->
388388 _ ->
389389 VMArgs1
390390 end ,
391- VMArgs3 = maybe_add_tls_arguments (VMArgs2 ),
391+ VMArgs3 = maybe_add_proto_dist_arguments (VMArgs2 ),
392+ VMArgs4 = maybe_add_inetrc_arguments (VMArgs3 ),
393+ VMArgs5 = maybe_add_tls_arguments (VMArgs4 ),
392394 PeerStartArg = case Context of
393395 #{nodename_type := longnames } ->
394396 #{name => PeerName ,
395397 host => Suffix ,
396398 longnames => true ,
397- args => VMArgs3 };
399+ args => VMArgs5 };
398400 _ ->
399401 #{name => PeerName ,
400- args => VMArgs3 }
402+ args => VMArgs5 }
401403 end ,
402404 ? LOG_DEBUG (" Peer discovery: peer node arguments: ~tp " ,
403405 [PeerStartArg ]),
@@ -423,27 +425,45 @@ query_node_props(Nodes) when Nodes =/= [] ->
423425query_node_props ([]) ->
424426 [].
425427
426- maybe_add_tls_arguments ( VMArgs0 ) ->
428+ maybe_add_proto_dist_arguments ( VMArgs ) ->
427429 case init :get_argument (proto_dist ) of
428- {ok , [[" inet_tls" ]]} ->
429- add_tls_arguments (inet_tls , VMArgs0 );
430- {ok , [[" inet6_tls" ]]} ->
431- add_tls_arguments (inet6_tls , VMArgs0 );
430+ {ok , [[Val ]]} ->
431+ % % Note:
432+ % %
433+ % % We can't use list_to_existing_atom/1 because
434+ % % the atom doesn't actually already exist.
435+ % %
436+ % % See net_kernel.erl / protocol_childspecs/1
437+ Mod = list_to_atom (Val ++ " _dist" ),
438+ ModDir = filename :dirname (code :which (Mod )),
439+ [" -proto_dist" , Val , " -pa" , ModDir | VMArgs ];
432440 _ ->
433- VMArgs0
441+ VMArgs
434442 end .
435443
436- add_tls_arguments (InetDistModule , VMArgs0 ) ->
437- VMArgs1 = case InetDistModule of
438- inet_tls ->
439- ProtoDistArg = [" -proto_dist" , " inet_tls" | VMArgs0 ],
440- [" -pa" , filename :dirname (code :which (inet_tls_dist ))
441- | ProtoDistArg ];
442- inet6_tls ->
443- ProtoDistArg = [" -proto_dist" , " inet6_tls" | VMArgs0 ],
444- [" -pa" , filename :dirname (code :which (inet6_tls_dist ))
445- | ProtoDistArg ]
446- end ,
444+ maybe_add_inetrc_arguments (VMArgs ) ->
445+ % % If an inetrc file is configured, we need to use it for the temporary
446+ % % hidden node too.
447+ case application :get_env (kernel , inetrc ) of
448+ {ok , Val } when is_list (Val ) ->
449+ maybe_add_inetrc_arguments1 (VMArgs , Val );
450+ undefined ->
451+ case os :getenv (" ERL_INETRC" ) of
452+ Val when is_list (Val ) ->
453+ maybe_add_inetrc_arguments1 (VMArgs , Val );
454+ false ->
455+ VMArgs
456+ end
457+ end .
458+
459+ maybe_add_inetrc_arguments1 (VMArgs , Val ) ->
460+ % % The filename argument must be passed as a quoted string so that the
461+ % % command line is correctly parsed as an Erlang string by the temporary
462+ % % hidden node.
463+ ValString = rabbit_misc :format (" ~0p " , [Val ]),
464+ [" -kernel" , " inetrc" , ValString | VMArgs ].
465+
466+ maybe_add_tls_arguments (VMArgs ) ->
447467 % % In the next case, RabbitMQ has been configured with additional Erlang VM
448468 % % arguments such as this:
449469 % %
@@ -494,14 +514,14 @@ add_tls_arguments(InetDistModule, VMArgs0) ->
494514 % % "/usr/local/lib/erlang/lib/ssl-11.0.3/ebin",
495515 % % "-proto_dist","inet_tls","-boot",
496516 % % "no_dot_erlang","-hidden"],
497- VMArgs2 = case init :get_argument (ssl_dist_opt ) of
517+ VMArgs1 = case init :get_argument (ssl_dist_opt ) of
498518 {ok , SslDistOpts0 } ->
499519 SslDistOpts1 = [[" -ssl_dist_opt" | SslDistOpt ]
500520 || SslDistOpt <- SslDistOpts0 ],
501521 SslDistOpts2 = lists :concat (SslDistOpts1 ),
502- SslDistOpts2 ++ VMArgs1 ;
522+ SslDistOpts2 ++ VMArgs ;
503523 _ ->
504- VMArgs1
524+ VMArgs
505525 end ,
506526 % % In the next case, RabbitMQ has been configured with additional Erlang VM
507527 % % arguments such as this:
@@ -511,13 +531,13 @@ add_tls_arguments(InetDistModule, VMArgs0) ->
511531 % %
512532 % % This code adds the `ssl_dist_optfile' argument to the peer node's
513533 % % argument list.
514- VMArgs3 = case init :get_argument (ssl_dist_optfile ) of
534+ VMArgs2 = case init :get_argument (ssl_dist_optfile ) of
515535 {ok , [[SslDistOptfileArg ]]} ->
516- [" -ssl_dist_optfile" , SslDistOptfileArg | VMArgs2 ];
536+ [" -ssl_dist_optfile" , SslDistOptfileArg | VMArgs1 ];
517537 _ ->
518- VMArgs2
538+ VMArgs1
519539 end ,
520- VMArgs3 .
540+ VMArgs2 .
521541
522542do_query_node_props (Nodes ) when Nodes =/= [] ->
523543 % % Make sure all log messages are forwarded from this temporary hidden
0 commit comments