aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/usage.h1
-rw-r--r--networking/telnetd.c10
2 files changed, 10 insertions, 1 deletions
diff --git a/include/usage.h b/include/usage.h
index a82230e41..4b27984f3 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -2951,6 +2951,7 @@
2951 "Telnetd listens for incoming TELNET connections on PORT.\n" \ 2951 "Telnetd listens for incoming TELNET connections on PORT.\n" \
2952 "Options:\n" \ 2952 "Options:\n" \
2953 "\t-p PORT\tlisten for connections on PORT (default 23)\n" \ 2953 "\t-p PORT\tlisten for connections on PORT (default 23)\n" \
2954 "\t-b ADDR\tlisten for connections on ADDR (default 0.0.0.0)\n"\
2954 "\t-l LOGIN\texec LOGIN on connect (default /bin/sh)\n" \ 2955 "\t-l LOGIN\texec LOGIN on connect (default /bin/sh)\n" \
2955 "\t-f issue_file\tDisplay issue_file instead of /etc/issue" 2956 "\t-f issue_file\tDisplay issue_file instead of /etc/issue"
2956#endif 2957#endif
diff --git a/networking/telnetd.c b/networking/telnetd.c
index b3d0a1166..d5de8903c 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -33,6 +33,7 @@
33#include <unistd.h> 33#include <unistd.h>
34#include <errno.h> 34#include <errno.h>
35#include <netinet/in.h> 35#include <netinet/in.h>
36#include <arpa/inet.h>
36#include <fcntl.h> 37#include <fcntl.h>
37#include <stdio.h> 38#include <stdio.h>
38#include <signal.h> 39#include <signal.h>
@@ -390,13 +391,14 @@ telnetd_main(int argc, char **argv)
390#ifndef CONFIG_FEATURE_TELNETD_INETD 391#ifndef CONFIG_FEATURE_TELNETD_INETD
391 int on = 1; 392 int on = 1;
392 int portnbr = 23; 393 int portnbr = 23;
394 struct in_addr bind_addr = { .s_addr = 0x0 };
393#endif /* CONFIG_FEATURE_TELNETD_INETD */ 395#endif /* CONFIG_FEATURE_TELNETD_INETD */
394 int c; 396 int c;
395 static const char options[] = 397 static const char options[] =
396#ifdef CONFIG_FEATURE_TELNETD_INETD 398#ifdef CONFIG_FEATURE_TELNETD_INETD
397 "f:l:"; 399 "f:l:";
398#else /* CONFIG_EATURE_TELNETD_INETD */ 400#else /* CONFIG_EATURE_TELNETD_INETD */
399 "f:l:p:"; 401 "f:l:p:b:";
400#endif /* CONFIG_FEATURE_TELNETD_INETD */ 402#endif /* CONFIG_FEATURE_TELNETD_INETD */
401 int maxlen, w, r; 403 int maxlen, w, r;
402 404
@@ -418,6 +420,10 @@ telnetd_main(int argc, char **argv)
418 case 'p': 420 case 'p':
419 portnbr = atoi(optarg); 421 portnbr = atoi(optarg);
420 break; 422 break;
423 case 'b':
424 if (inet_aton(optarg, &bind_addr) == 0)
425 bb_show_usage();
426 break;
421#endif /* CONFIG_FEATURE_TELNETD_INETD */ 427#endif /* CONFIG_FEATURE_TELNETD_INETD */
422 default: 428 default:
423 bb_show_usage(); 429 bb_show_usage();
@@ -452,9 +458,11 @@ telnetd_main(int argc, char **argv)
452#ifdef CONFIG_FEATURE_IPV6 458#ifdef CONFIG_FEATURE_IPV6
453 sa.sin6_family = AF_INET6; 459 sa.sin6_family = AF_INET6;
454 sa.sin6_port = htons(portnbr); 460 sa.sin6_port = htons(portnbr);
461 /* sa.sin6_addr = bind_addr6; */
455#else 462#else
456 sa.sin_family = AF_INET; 463 sa.sin_family = AF_INET;
457 sa.sin_port = htons(portnbr); 464 sa.sin_port = htons(portnbr);
465 sa.sin_addr = bind_addr;
458#endif 466#endif
459 467
460 if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { 468 if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {