update busybox to v1.2.1
[openwrt-10.03/.git] / package / busybox / patches / 110-telnetd.patch
1 diff -ruN busybox-1.2.0-old/networking/telnetd.c busybox-1.2.0-new/networking/telnetd.c
2 --- busybox-1.2.0-old/networking/telnetd.c      2006-07-01 00:42:02.000000000 +0200
3 +++ busybox-1.2.0-new/networking/telnetd.c      2006-07-31 10:52:30.000000000 +0200
4 @@ -44,6 +44,7 @@
5  #include <arpa/telnet.h>
6  #include <ctype.h>
7  #include <sys/syslog.h>
8 +#include <net/if.h>
9  
10  #include "busybox.h"
11  
12 @@ -391,11 +392,13 @@
13         struct in_addr bind_addr = { .s_addr = 0x0 };
14  #endif /* CONFIG_FEATURE_TELNETD_INETD */
15         int c;
16 +       char *interface_name = NULL;
17 +       struct ifreq interface;
18         static const char options[] =
19  #ifdef CONFIG_FEATURE_TELNETD_INETD
20 -               "f:l:";
21 +               "i:f:l:";
22  #else /* CONFIG_EATURE_TELNETD_INETD */
23 -               "f:l:p:b:";
24 +               "i:f:l:p:b:";
25  #endif /* CONFIG_FEATURE_TELNETD_INETD */
26         int maxlen, w, r;
27  
28 @@ -410,6 +413,9 @@
29                         case 'f':
30                                 issuefile = optarg;
31                                 break;
32 +                       case 'i':
33 +                               interface_name = strdup(optarg);
34 +                               break;
35                         case 'l':
36                                 loginpath = optarg;
37                                 break;
38 @@ -459,6 +465,13 @@
39         sa.sin_addr = bind_addr;
40  #endif
41  
42 +       /* Set it to listen on the specified interface */
43 +       if (interface_name) {
44 +               strncpy(interface.ifr_ifrn.ifrn_name, interface_name, IFNAMSIZ);
45 +               (void)setsockopt(master_fd, SOL_SOCKET,
46 +                               SO_BINDTODEVICE, &interface, sizeof(interface));
47 +       }
48
49         bb_xbind(master_fd, (struct sockaddr *) &sa, sizeof(sa));
50         bb_xlisten(master_fd, 1);
51         bb_xdaemon(0, 0);