e95757ee4ed80ec034ed730c285836cf9bd8ce06
[openwrt/svn-archive/archive.git] / obsolete-buildroot / sources / busybox-openwrt-110-telnetd.patch
1 diff -urN busybox-1.00-pre8/networking/telnetd.c busybox-1.00-pre8-openwrt/networking/telnetd.c
2 --- busybox-1.00-pre8/networking/telnetd.c 2004-02-22 03:45:57.000000000 -0600
3 +++ busybox-1.00-pre8-openwrt/networking/telnetd.c 2004-03-05 01:32:57.000000000 -0600
4 @@ -44,6 +44,8 @@
5 #include <arpa/telnet.h>
6 #include <ctype.h>
7 #include <sys/syslog.h>
8 +#include <net/if.h>
9 +
10
11 #include "busybox.h"
12
13 @@ -384,11 +386,13 @@
14 int portnbr = 23;
15 #endif /* CONFIG_FEATURE_TELNETD_INETD */
16 int c;
17 + char *interface_name = NULL;
18 + struct ifreq interface;
19 static const char options[] =
20 #ifdef CONFIG_FEATURE_TELNETD_INETD
21 - "f:l:";
22 -#else /* CONFIG_EATURE_TELNETD_INETD */
23 - "f:l:p:";
24 + "i:f:l:";
25 +#else /* CONFIG_FEATURE_TELNETD_INETD */
26 + "i:f:l:p:";
27 #endif /* CONFIG_FEATURE_TELNETD_INETD */
28 int maxlen, w, r;
29
30 @@ -403,6 +407,9 @@
31 case 'f':
32 issuefile = strdup (optarg);
33 break;
34 + case 'i':
35 + interface_name = strdup(optarg);
36 + break;
37 case 'l':
38 loginpath = strdup (optarg);
39 break;
40 @@ -442,6 +449,13 @@
41 sa.sin_family = AF_INET;
42 sa.sin_port = htons(portnbr);
43
44 + /* Set it to listen on the specified interface */
45 + if (interface_name) {
46 + strncpy(interface.ifr_ifrn.ifrn_name, interface_name, IFNAMSIZ);
47 + (void)setsockopt(master_fd, SOL_SOCKET,
48 + SO_BINDTODEVICE, &interface, sizeof(interface));
49 + }
50 +
51 if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
52 bb_perror_msg_and_die("bind");
53 }