summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/include/rtems/telnetd.h23
-rw-r--r--cpukit/telnetd/telnetd.c112
2 files changed, 55 insertions, 80 deletions
diff --git a/cpukit/include/rtems/telnetd.h b/cpukit/include/rtems/telnetd.h
index 2339bad8b6..e662874a81 100644
--- a/cpukit/include/rtems/telnetd.h
+++ b/cpukit/include/rtems/telnetd.h
@@ -59,13 +59,14 @@ typedef struct {
/**
* @brief Task priority.
*
- * If this parameter is equal to zero, then the priority of network task is
- * used or 100 if this priority is less than two.
+ * Use 0 for the default value.
*/
rtems_task_priority priority;
/**
* @brief Task stack size.
+ *
+ * Use 0 for the default value.
*/
size_t stack_size;
@@ -77,12 +78,10 @@ typedef struct {
rtems_shell_login_check_t login_check;
/**
- * @brief Keep standard IO of the caller.
+ * @brief This is an obsolete configuration option.
*
- * Telnet takes over the standard input, output and error associated with
- * task, if this parameter is set to @c true. In this case, it will @b not
- * listen on any sockets. When this parameter is @c false, Telnet will
- * create other tasks for the shell which listen on sockets.
+ * It must be set to false, otherwise rtems_telnetd_start() will do nothing
+ * and returns with a status of RTEMS_NOT_IMPLEMENTED.
*/
bool keep_stdio;
@@ -96,7 +95,15 @@ typedef struct {
} rtems_telnetd_config_table;
/**
- * @brief Start the Telnet subsystem with the provided configuration.
+ * @brief Starts the Telnet server using the provided configuration.
+ *
+ * @retval RTEMS_SUCCESSFUL Successful operation.
+ * @retval RTEMS_INVALID_ADDRESS The command function in the configuration is
+ * @c NULL.
+ * @retval RTEMS_RESOURCE_IN_USE The Telnet server was already started.
+ * @retval RTEMS_NOT_IMPLEMENTED The keep stdio configuration option is true.
+ * @retval RTEMS_UNSATISFIED Not enough resources to start the Telnet server or
+ * task priority in configuration is invalid.
*/
rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table *config);
diff --git a/cpukit/telnetd/telnetd.c b/cpukit/telnetd/telnetd.c
index 650b0f9418..56e48b9d78 100644
--- a/cpukit/telnetd/telnetd.c
+++ b/cpukit/telnetd/telnetd.c
@@ -234,67 +234,43 @@ rtems_task_telnetd(void *task_argument)
* was started from the console anyway ..
*/
do {
- if (ctx->config.keep_stdio) {
- bool start = true;
- char device_name [32];
-
- ttyname_r( 1, device_name, sizeof( device_name));
- if (ctx->config.login_check != NULL) {
- start = rtems_shell_login_prompt(
- stdin,
- stderr,
- device_name,
- ctx->config.login_check
- );
- }
- if (start) {
- ctx->config.command( device_name, ctx->config.arg);
- } else {
- syslog(
- LOG_AUTHPRIV | LOG_WARNING,
- "telnetd: to many wrong passwords entered from %s",
- device_name
- );
- }
- } else {
- arg = grab_a_Connection(ctx, des_socket, &srv, peername,
- sizeof(peername));
-
- if (arg == NULL) {
- /* if something went wrong, sleep for some time */
- sleep(10);
- continue;
- }
+ arg = grab_a_Connection(ctx, des_socket, &srv, peername,
+ sizeof(peername));
- strncpy(arg->peername, peername, sizeof(arg->peername));
-
- task_id = telnetd_spawn_task(
- arg->pty.name,
- ctx->config.priority,
- ctx->config.stack_size,
- spawned_shell,
- arg
- );
- if (task_id == RTEMS_ID_NONE) {
- FILE *dummy;
-
- if ( telnetd_spawn_task != telnetd_dflt_spawn ) {
- fprintf(stderr,"Telnetd: Unable to spawn child task\n");
- }
-
- /* hmm - the pty driver slot can only be
- * released by opening and subsequently
- * closing the PTY - this also closes
- * the underlying socket. So we mock up
- * a stream...
- */
+ if (arg == NULL) {
+ /* if something went wrong, sleep for some time */
+ sleep(10);
+ continue;
+ }
+
+ strncpy(arg->peername, peername, sizeof(arg->peername));
+
+ task_id = telnetd_spawn_task(
+ arg->pty.name,
+ ctx->config.priority,
+ ctx->config.stack_size,
+ spawned_shell,
+ arg
+ );
+ if (task_id == RTEMS_ID_NONE) {
+ FILE *dummy;
- if ( !(dummy=fopen(arg->pty.name,"r+")) )
- perror("Unable to dummy open the pty, losing a slot :-(");
- release_a_Connection(ctx, arg->pty.name, peername, &dummy, 1);
- free(arg);
- sleep(2); /* don't accept connections too fast */
+ if ( telnetd_spawn_task != telnetd_dflt_spawn ) {
+ fprintf(stderr,"Telnetd: Unable to spawn child task\n");
}
+
+ /* hmm - the pty driver slot can only be
+ * released by opening and subsequently
+ * closing the PTY - this also closes
+ * the underlying socket. So we mock up
+ * a stream...
+ */
+
+ if ( !(dummy=fopen(arg->pty.name,"r+")) )
+ perror("Unable to dummy open the pty, losing a slot :-(");
+ release_a_Connection(ctx, arg->pty.name, peername, &dummy, 1);
+ free(arg);
+ sleep(2); /* don't accept connections too fast */
}
} while(1);
@@ -313,12 +289,12 @@ rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config)
rtems_id task_id;
if (config->command == NULL) {
- fprintf(stderr, "telnetd setup with invalid command\n");
- return RTEMS_IO_ERROR;
+ syslog(LOG_DAEMON | LOG_ERR, "telnetd: configuration with invalid command");
+ return RTEMS_INVALID_ADDRESS;
}
if (ctx->config.command != NULL) {
- fprintf(stderr, "telnetd already started\n");
+ syslog(LOG_DAEMON | LOG_ERR, "telnetd: already started");
return RTEMS_RESOURCE_IN_USE;
}
@@ -353,19 +329,11 @@ rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config)
);
if (task_id == RTEMS_ID_NONE) {
ctx->config.command = NULL;
- return RTEMS_IO_ERROR;
- }
-
- /* Print status */
- if (!ctx->config.keep_stdio) {
- fprintf(
- stderr,
- "telnetd started with stacksize = %u and priority = %d\n",
- (unsigned) ctx->config.stack_size,
- (unsigned) ctx->config.priority
- );
+ syslog(LOG_DAEMON | LOG_ERR, "telnetd: cannot create server task");
+ return RTEMS_UNSATISFIED;
}
+ syslog(LOG_DAEMON | LOG_INFO, "telnetd: started successfully");
return RTEMS_SUCCESSFUL;
}