aboutsummaryrefslogtreecommitdiff
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-3538b9a8822421b7c8596a33a917dcf2f99c92b7.tar.gz
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)
pty = getpty(tty_name);
if (pty < 0) {
- syslog(LOG_ERR, "All terminals in use!");
+ bb_error_msg("all terminals in use");
return 0;
}
@@ -285,7 +285,7 @@ make_new_session(int sockfd)
send_iac(ts, WILL, TELOPT_SGA);
if ((pid = fork()) < 0) {
- syslog(LOG_ERR, "Could not fork");
+ bb_perror_msg("fork");
}
if (pid == 0) {
/* In child, open the child's side of the tty. */
@@ -296,10 +296,7 @@ make_new_session(int sockfd)
/* make new process group */
setsid();
- if (open(tty_name, O_RDWR /*| O_NOCTTY*/) < 0) {
- syslog(LOG_ERR, "Could not open tty");
- exit(1);
- }
+ xopen(tty_name, O_RDWR /*| O_NOCTTY*/);
dup(0);
dup(0);
@@ -323,8 +320,7 @@ make_new_session(int sockfd)
execv(loginpath, (char *const *)argv_init);
/* NOT REACHED */
- syslog(LOG_ERR, "execv error");
- exit(1);
+ bb_perror_msg_and_die("execv");
}
ts->shell_pid = pid;
@@ -390,6 +386,14 @@ telnetd_main(int argc, char **argv)
loginpath = DEFAULT_SHELL;
#endif
+ /* We use inetd-style operation unconditionally
+ * (no --foreground option), user most likely will
+ * look into syslog for all errors, even early ones.
+ * Direct all output to syslog at once.
+ */
+ openlog(bb_applet_name, 0, LOG_USER);
+ logmode = LOGMODE_SYSLOG;
+
for (;;) {
c = getopt( argc, argv, options);
if (c == EOF) break;
@@ -415,13 +419,11 @@ telnetd_main(int argc, char **argv)
}
if (access(loginpath, X_OK) < 0) {
- bb_error_msg_and_die ("'%s' unavailable.", loginpath);
+ bb_error_msg_and_die("'%s' unavailable", loginpath);
}
argv_init[0] = loginpath;
- openlog(bb_applet_name, 0, LOG_USER);
-
#ifdef CONFIG_FEATURE_TELNETD_INETD
maxfd = 1;
sessions = make_new_session();