summaryrefslogtreecommitdiff
path: root/networking/telnetd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-06 18:36:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-06 18:36:50 +0000
commit3538b9a8822421b7c8596a33a917dcf2f99c92b7 (patch)
tree768c23fe79bb81583de7376a4d744632d888d303 /networking/telnetd.c
parent5d725462d44268f9a86030daaa6f6396d32f796c (diff)
downloadbusybox-w32-3538b9a8822421b7c8596a33a917dcf2f99c92b7.tar.gz
busybox-w32-3538b9a8822421b7c8596a33a917dcf2f99c92b7.tar.bz2
busybox-w32-3538b9a8822421b7c8596a33a917dcf2f99c92b7.zip
Implement optional syslog logging using ordinary
bb_xx_msg calls, and convert networking/* to it. The rest of bbox will be converted gradually.
Diffstat (limited to 'networking/telnetd.c')
-rw-r--r--networking/telnetd.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 87f44ce51..890e58466 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -263,7 +263,7 @@ make_new_session(int sockfd)
263 pty = getpty(tty_name); 263 pty = getpty(tty_name);
264 264
265 if (pty < 0) { 265 if (pty < 0) {
266 syslog(LOG_ERR, "All terminals in use!"); 266 bb_error_msg("all terminals in use");
267 return 0; 267 return 0;
268 } 268 }
269 269
@@ -285,7 +285,7 @@ make_new_session(int sockfd)
285 send_iac(ts, WILL, TELOPT_SGA); 285 send_iac(ts, WILL, TELOPT_SGA);
286 286
287 if ((pid = fork()) < 0) { 287 if ((pid = fork()) < 0) {
288 syslog(LOG_ERR, "Could not fork"); 288 bb_perror_msg("fork");
289 } 289 }
290 if (pid == 0) { 290 if (pid == 0) {
291 /* In child, open the child's side of the tty. */ 291 /* In child, open the child's side of the tty. */
@@ -296,10 +296,7 @@ make_new_session(int sockfd)
296 /* make new process group */ 296 /* make new process group */
297 setsid(); 297 setsid();
298 298
299 if (open(tty_name, O_RDWR /*| O_NOCTTY*/) < 0) { 299 xopen(tty_name, O_RDWR /*| O_NOCTTY*/);
300 syslog(LOG_ERR, "Could not open tty");
301 exit(1);
302 }
303 dup(0); 300 dup(0);
304 dup(0); 301 dup(0);
305 302
@@ -323,8 +320,7 @@ make_new_session(int sockfd)
323 execv(loginpath, (char *const *)argv_init); 320 execv(loginpath, (char *const *)argv_init);
324 321
325 /* NOT REACHED */ 322 /* NOT REACHED */
326 syslog(LOG_ERR, "execv error"); 323 bb_perror_msg_and_die("execv");
327 exit(1);
328 } 324 }
329 325
330 ts->shell_pid = pid; 326 ts->shell_pid = pid;
@@ -390,6 +386,14 @@ telnetd_main(int argc, char **argv)
390 loginpath = DEFAULT_SHELL; 386 loginpath = DEFAULT_SHELL;
391#endif 387#endif
392 388
389 /* We use inetd-style operation unconditionally
390 * (no --foreground option), user most likely will
391 * look into syslog for all errors, even early ones.
392 * Direct all output to syslog at once.
393 */
394 openlog(bb_applet_name, 0, LOG_USER);
395 logmode = LOGMODE_SYSLOG;
396
393 for (;;) { 397 for (;;) {
394 c = getopt( argc, argv, options); 398 c = getopt( argc, argv, options);
395 if (c == EOF) break; 399 if (c == EOF) break;
@@ -415,13 +419,11 @@ telnetd_main(int argc, char **argv)
415 } 419 }
416 420
417 if (access(loginpath, X_OK) < 0) { 421 if (access(loginpath, X_OK) < 0) {
418 bb_error_msg_and_die ("'%s' unavailable.", loginpath); 422 bb_error_msg_and_die("'%s' unavailable", loginpath);
419 } 423 }
420 424
421 argv_init[0] = loginpath; 425 argv_init[0] = loginpath;
422 426
423 openlog(bb_applet_name, 0, LOG_USER);
424
425#ifdef CONFIG_FEATURE_TELNETD_INETD 427#ifdef CONFIG_FEATURE_TELNETD_INETD
426 maxfd = 1; 428 maxfd = 1;
427 sessions = make_new_session(); 429 sessions = make_new_session();