@@ -388,16 +388,18 @@ query_node_props(Nodes) when Nodes =/= [] ->
388
388
_ ->
389
389
VMArgs1
390
390
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 ),
392
394
PeerStartArg = case Context of
393
395
#{nodename_type := longnames } ->
394
396
#{name => PeerName ,
395
397
host => Suffix ,
396
398
longnames => true ,
397
- args => VMArgs3 };
399
+ args => VMArgs5 };
398
400
_ ->
399
401
#{name => PeerName ,
400
- args => VMArgs3 }
402
+ args => VMArgs5 }
401
403
end ,
402
404
? LOG_DEBUG (" Peer discovery: peer node arguments: ~tp " ,
403
405
[PeerStartArg ]),
@@ -423,27 +425,45 @@ query_node_props(Nodes) when Nodes =/= [] ->
423
425
query_node_props ([]) ->
424
426
[].
425
427
426
- maybe_add_tls_arguments ( VMArgs0 ) ->
428
+ maybe_add_proto_dist_arguments ( VMArgs ) ->
427
429
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 ];
432
440
_ ->
433
- VMArgs0
441
+ VMArgs
434
442
end .
435
443
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 ) ->
447
467
% % In the next case, RabbitMQ has been configured with additional Erlang VM
448
468
% % arguments such as this:
449
469
% %
@@ -494,14 +514,14 @@ add_tls_arguments(InetDistModule, VMArgs0) ->
494
514
% % "/usr/local/lib/erlang/lib/ssl-11.0.3/ebin",
495
515
% % "-proto_dist","inet_tls","-boot",
496
516
% % "no_dot_erlang","-hidden"],
497
- VMArgs2 = case init :get_argument (ssl_dist_opt ) of
517
+ VMArgs1 = case init :get_argument (ssl_dist_opt ) of
498
518
{ok , SslDistOpts0 } ->
499
519
SslDistOpts1 = [[" -ssl_dist_opt" | SslDistOpt ]
500
520
|| SslDistOpt <- SslDistOpts0 ],
501
521
SslDistOpts2 = lists :concat (SslDistOpts1 ),
502
- SslDistOpts2 ++ VMArgs1 ;
522
+ SslDistOpts2 ++ VMArgs ;
503
523
_ ->
504
- VMArgs1
524
+ VMArgs
505
525
end ,
506
526
% % In the next case, RabbitMQ has been configured with additional Erlang VM
507
527
% % arguments such as this:
@@ -511,13 +531,13 @@ add_tls_arguments(InetDistModule, VMArgs0) ->
511
531
% %
512
532
% % This code adds the `ssl_dist_optfile' argument to the peer node's
513
533
% % argument list.
514
- VMArgs3 = case init :get_argument (ssl_dist_optfile ) of
534
+ VMArgs2 = case init :get_argument (ssl_dist_optfile ) of
515
535
{ok , [[SslDistOptfileArg ]]} ->
516
- [" -ssl_dist_optfile" , SslDistOptfileArg | VMArgs2 ];
536
+ [" -ssl_dist_optfile" , SslDistOptfileArg | VMArgs1 ];
517
537
_ ->
518
- VMArgs2
538
+ VMArgs1
519
539
end ,
520
- VMArgs3 .
540
+ VMArgs2 .
521
541
522
542
do_query_node_props (Nodes ) when Nodes =/= [] ->
523
543
% % Make sure all log messages are forwarded from this temporary hidden
0 commit comments