[PATCH] telnetd max active sessions

Denys Vlasenko vda.linux at googlemail.com
Wed Nov 28 11:15:53 PST 2007


On Tuesday 27 November 2007 05:30, Roberto A. Foglietta wrote:
> Hi,
>
>  in order to limit the max number of telnetd accpeted sessions apply this
> patch.

Instead of adding this to each networking applet, I propose using
inetd's connection limiting, or use this applet + telnetd in inetd mode:

$ busybox tcpsvd --help
BusyBox v1.8.0.svn (2007-09-26 13:19:27 IST) multi-call binary

Usage: tcpsvd [-hEv] [-c n] [-C n:msg] [-b n] [-u user] [-l name] ip port 
prog...

Creates TCP socket, binds it to ip:port and listens on it
for incoming connections. For each connection it runs prog.

ip              IP to listen on. '0' = all
port            Port to listen on
prog [arg]      Program to run
-l name         Local hostname (else looks up local hostname in DNS)
-u user[:group] Change to user/group after bind
-c n            Handle up to n connections simultaneously
-b n            Allow a backlog of approximately n TCP SYNs
-C n[:msg]      Allow only up to n connections from the same IP
                New connections from this IP address are closed
                immediately. 'msg' is written to the peer before close
-h              Look up peer's hostname
-E              Do not set up environment variables
-v              Verbose


-c is your friend.

Re patch:


 #else /* !FEATURE_TELNETD_STANDALONE */
 
 /* Used in main() only, thus "return 0" actually is exit(0). */
-#define free_session(ts) return 0
+#define free_session(ts) do { n_sess--; return 0; } while(0)
 
 #endif

Not needed - you are exiting anyway.

--
vda


More information about the busybox mailing list