--- busybox.org/networking/telnetd.c 2014-08-11 17:52:07.905502746 +0530 +++ busybox/networking/telnetd.c 2014-08-12 19:08:56.450238947 +0530 @@ -254,11 +254,13 @@ #if !ENABLE_FEATURE_TELNETD_STANDALONE enum { sock = 0 }; #endif - const char *login_argv[2]; + const char *login_argv[4]; + char *hostname1 = NULL; struct termios termbuf; int fd, pid; char tty_name[GETPTY_BUFSIZE]; struct tsession *ts = xzalloc(sizeof(struct tsession) + BUFSIZE * 2); + len_and_sockaddr *lsa1=NULL; /*ts->buf1 = (char *)(ts + 1);*/ /*ts->buf2 = ts->buf1 + BUFSIZE;*/ @@ -338,6 +340,13 @@ /* Restore default signal handling ASAP */ bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL); + /*Get the hostname*/ + lsa1 = get_peer_lsa(sock); + if (lsa1) { + /*convert it into string pattern */ + hostname1 = xmalloc_sockaddr2dotted_noport(&lsa1->u.sa); + free(lsa1); + } pid = getpid(); @@ -384,7 +393,10 @@ /* Exec shell / login / whatever */ login_argv[0] = G.loginpath; - login_argv[1] = NULL; + login_argv[1] = "-h"; + /*Allow both IPv4 and IPv6 Address*/ + login_argv[2] = hostname1; + login_argv[3] = NULL; /* exec busybox applet (if PREFER_APPLETS=y), if that fails, * exec external program. * NB: sock is either 0 or has CLOEXEC set on it.