nuttx-apps/netutils/telnetd
Ricard Rosson 01ff92f794 netutils/telnetd: survive transient connection errors instead of exiting
Any single failed connection killed the whole daemon:

- A peer that resets before the accept completes (a port scanner, or a
  simple "nc -z" probe) surfaces as an accept4() error such as
  ECONNABORTED, which took the errout path and closed the listener.
- The per-connection error paths after a successful accept (setsockopt,
  opening /dev/telnet, SIOCTELNET, opening the session device, spawning
  the session) likewise exited the daemon instead of dropping the one
  connection.

Either way, one bad or aborted connection and the telnet console is
dead until reboot - a trivial remote way to take out the NuttX console
on any reachable network.  Verified on hardware: one "nc -zv" probe
permanently killed the listener.

Treat these as per-connection failures: drop the connection and keep
accepting.  Genuinely unrecoverable accept4() errors (EBADF, ENOTSOCK,
EINVAL, EOPNOTSUPP - a bad listen socket) still exit loudly, and a
short pause on repeated transient failures avoids busy-spinning while
an interface is down.  Daemon setup errors (socket/bind/listen) exit
as before.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ricard Rosson <ricard@groundbits.com>
2026-07-23 19:00:43 +01:00
..
CMakeLists.txt netutils: migrate the license to ASF 2024-12-21 13:53:10 +08:00
Kconfig netutils: Support telnetd in the kernel mode 2022-11-07 15:24:08 +09:00
Make.defs netutils: migrate the license to ASF 2024-12-21 13:53:10 +08:00
Makefile netutils: migrate the license to ASF 2024-12-21 13:53:10 +08:00
telnetd_daemon.c netutils/telnetd: survive transient connection errors instead of exiting 2026-07-23 19:00:43 +01:00