aboutsummaryrefslogtreecommitdiff
path: root/networking/telnetd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-25 10:35:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-25 10:35:11 +0000
commit88308fec804a0e1df644c3ef99d339a2e653c0f3 (patch)
tree7bccb0e4091c6b431da8714f0df6974c29e097b1 /networking/telnetd.c
parent56258b688cc4fb2a5cfacb4e7a17fe51e158c101 (diff)
downloadbusybox-w32-88308fec804a0e1df644c3ef99d339a2e653c0f3.tar.gz
busybox-w32-88308fec804a0e1df644c3ef99d339a2e653c0f3.tar.bz2
busybox-w32-88308fec804a0e1df644c3ef99d339a2e653c0f3.zip
test: suppress gcc warning
telnetd: do not use suferfluous static variable.
Diffstat (limited to 'networking/telnetd.c')
-rw-r--r--networking/telnetd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 21b704a46..9246f7052 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -21,7 +21,6 @@
21 * Set process group corrections, initial busybox port 21 * Set process group corrections, initial busybox port
22 */ 22 */
23 23
24/*#define DEBUG 1 */
25#define DEBUG 0 24#define DEBUG 0
26 25
27#include "libbb.h" 26#include "libbb.h"
@@ -34,8 +33,6 @@
34#include <sys/syslog.h> 33#include <sys/syslog.h>
35 34
36 35
37#define BUFSIZE 4000
38
39#if ENABLE_LOGIN 36#if ENABLE_LOGIN
40static const char *loginpath = "/bin/login"; 37static const char *loginpath = "/bin/login";
41#else 38#else
@@ -44,10 +41,6 @@ static const char *loginpath = DEFAULT_SHELL;
44 41
45static const char *issuefile = "/etc/issue.net"; 42static const char *issuefile = "/etc/issue.net";
46 43
47/* shell name and arguments */
48
49static const char *argv_init[2];
50
51/* structure that describes a session */ 44/* structure that describes a session */
52 45
53struct tsession { 46struct tsession {
@@ -60,6 +53,10 @@ struct tsession {
60 int rdidx2, wridx2, size2; 53 int rdidx2, wridx2, size2;
61}; 54};
62 55
56/* Two buffers are directly after tsession in malloced memory.
57 * Make whole thing fit in 4k */
58enum { BUFSIZE = (4*1024 - sizeof(struct tsession)) / 2 };
59
63/* 60/*
64 This is how the buffers are used. The arrows indicate the movement 61 This is how the buffers are used. The arrows indicate the movement
65 of data. 62 of data.
@@ -231,6 +228,7 @@ make_new_session(
231 USE_FEATURE_TELNETD_STANDALONE(int sock_r, int sock_w) 228 USE_FEATURE_TELNETD_STANDALONE(int sock_r, int sock_w)
232 SKIP_FEATURE_TELNETD_STANDALONE(void) 229 SKIP_FEATURE_TELNETD_STANDALONE(void)
233) { 230) {
231 const char *login_argv[2];
234 struct termios termbuf; 232 struct termios termbuf;
235 int fd, pid; 233 int fd, pid;
236 char tty_name[32]; 234 char tty_name[32];
@@ -283,7 +281,7 @@ make_new_session(
283 281
284 /* child */ 282 /* child */
285 283
286 /* make new process group */ 284 /* make new session and process group */
287 setsid(); 285 setsid();
288 286
289 /* open the child's side of the tty. */ 287 /* open the child's side of the tty. */
@@ -294,7 +292,7 @@ make_new_session(
294 dup2(fd, 1); 292 dup2(fd, 1);
295 dup2(fd, 2); 293 dup2(fd, 2);
296 while (fd > 2) close(fd--); 294 while (fd > 2) close(fd--);
297 tcsetpgrp(0, getpid()); /* comment? */ 295 tcsetpgrp(0, getpid()); /* switch this tty's process group to us */
298 296
299 /* The pseudo-terminal allocated to the client is configured to operate in 297 /* The pseudo-terminal allocated to the client is configured to operate in
300 * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */ 298 * cooked mode, and with XTABS CRMOD enabled (see tty(4)). */
@@ -308,9 +306,12 @@ make_new_session(
308 306
309 print_login_issue(issuefile, NULL); 307 print_login_issue(issuefile, NULL);
310 308
311 /* exec shell, with correct argv and env */ 309 /* exec shell / login /whatever */
312 execv(loginpath, (char *const *)argv_init); 310 login_argv[0] = loginpath;
313 bb_perror_msg_and_die("execv"); 311 login_argv[1] = NULL;
312 execv(loginpath, (char **)login_argv);
313 /* Hmmm... this gets sent to the client thru fd#2! Is it ok?? */
314 bb_perror_msg_and_die("execv %s", loginpath);
314} 315}
315 316
316#if ENABLE_FEATURE_TELNETD_STANDALONE 317#if ENABLE_FEATURE_TELNETD_STANDALONE
@@ -405,7 +406,6 @@ int telnetd_main(int argc, char **argv)
405 406
406 /* Used to check access(loginpath, X_OK) here. Pointless. 407 /* Used to check access(loginpath, X_OK) here. Pointless.
407 * exec will do this for us for free later. */ 408 * exec will do this for us for free later. */
408 argv_init[0] = loginpath;
409 409
410#if ENABLE_FEATURE_TELNETD_STANDALONE 410#if ENABLE_FEATURE_TELNETD_STANDALONE
411 if (IS_INETD) { 411 if (IS_INETD) {