diff options
author | Ingela Anderton Andin <[email protected]> | 2015-08-14 16:01:01 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2015-09-10 09:04:48 +0200 |
commit | cdcc5ae200ffd47bdb8704e20d1a5d50db12808d (patch) | |
tree | d7b08e9f5dbd5ac4672f5cba0e7766da29af3fce /lib/inets/src/tftp/tftp_engine.erl | |
parent | 1cd00d0d139a23b1abc8ec73e9e49031974b2acb (diff) | |
download | otp-cdcc5ae200ffd47bdb8704e20d1a5d50db12808d.tar.gz otp-cdcc5ae200ffd47bdb8704e20d1a5d50db12808d.tar.bz2 otp-cdcc5ae200ffd47bdb8704e20d1a5d50db12808d.zip |
inets: tftpd - Mend broken fd option
Diffstat (limited to 'lib/inets/src/tftp/tftp_engine.erl')
-rw-r--r-- | lib/inets/src/tftp/tftp_engine.erl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/inets/src/tftp/tftp_engine.erl b/lib/inets/src/tftp/tftp_engine.erl index fa44cd61ce..d0510e795b 100644 --- a/lib/inets/src/tftp/tftp_engine.erl +++ b/lib/inets/src/tftp/tftp_engine.erl @@ -128,8 +128,8 @@ daemon_start(Options) when is_list(Options) -> daemon_init(Config) when is_record(Config, config), is_pid(Config#config.parent_pid) -> process_flag(trap_exit, true), - UdpOptions = prepare_daemon_udp(Config), - case catch gen_udp:open(Config#config.udp_port, UdpOptions) of + {Port, UdpOptions} = prepare_daemon_udp(Config), + case catch gen_udp:open(Port, UdpOptions) of {ok, Socket} -> {ok, ActualPort} = inet:port(Socket), proc_lib:init_ack({ok, self()}), @@ -157,7 +157,7 @@ prepare_daemon_udp(#config{udp_port = Port, udp_options = UdpOptions} = Config) case lists:keymember(fd, 1, UdpOptions) of true -> %% Use explicit fd - UdpOptions; + {Port, UdpOptions}; false -> %% Use fd from setuid_socket_wrap, such as -tftpd_69 InitArg = list_to_atom("tftpd_" ++ integer_to_list(Port)), @@ -165,7 +165,7 @@ prepare_daemon_udp(#config{udp_port = Port, udp_options = UdpOptions} = Config) {ok, [[FdStr]] = Badarg} when is_list(FdStr) -> case catch list_to_integer(FdStr) of Fd when is_integer(Fd) -> - [{fd, Fd} | UdpOptions]; + {0, [{fd, Fd} | lists:keydelete(ip, 1, UdpOptions)]}; {'EXIT', _} -> Text = lists:flatten(io_lib:format("Illegal prebound fd ~p: ~p", [InitArg, Badarg])), print_debug_info(Config, daemon, open, ?ERROR(open, undef, Text, "")), @@ -176,7 +176,7 @@ prepare_daemon_udp(#config{udp_port = Port, udp_options = UdpOptions} = Config) print_debug_info(Config, daemon, open, ?ERROR(open, undef, Text, "")), exit({badarg, {prebound_fd, InitArg, Badarg}}); error -> - UdpOptions + {Port, UdpOptions} end end. |