From a258456f25aea8a5d9a98b4caa053848cc900c00 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 4 Oct 2022 22:02:33 +0100 Subject: [PATCH] check return value of bind is common to forget to run this as root, in which case we would like to see the permission denied error when it tries to open port 69 --- pkgs/tufted/tftp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/tufted/tftp.lua b/pkgs/tufted/tftp.lua index 0bbe45bf..5fa66a30 100644 --- a/pkgs/tufted/tftp.lua +++ b/pkgs/tufted/tftp.lua @@ -339,7 +339,8 @@ function tftp:listen(rrq_generator_callback, wrq_generator_callback, hosts, port local logfile = logfile or io.stderr --listen on all given addresses, default to localhost if not given for i, address in pairs((type(hosts) == 'table' and hosts) or (hosts ~= nil and{hosts}) or {'127.0.0.1'}) do - socket:bind(address, port) + local ok, err = socket:bind(address, port) + if not ok then error(err .. " binding to " .. address .. ":" .. port) end end --[[The main event loop does two things: