mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-25 06:34:06 +08:00
Add telnetd as service to rc.conf.
This commit is contained in:
parent
fc26479566
commit
65c65bb7a3
@ -148,6 +148,8 @@ def rtems(mm):
|
|||||||
'telnetd/des.c',
|
'telnetd/des.c',
|
||||||
'telnetd/pty.c',
|
'telnetd/pty.c',
|
||||||
'telnetd/telnetd.c',
|
'telnetd/telnetd.c',
|
||||||
|
'telnetd/telnetd-init.c',
|
||||||
|
'telnetd/telnetd-service.c',
|
||||||
'sys/dev/tsec/if_tsec_nexus.c',
|
'sys/dev/tsec/if_tsec_nexus.c',
|
||||||
],
|
],
|
||||||
mm.generator['source']()
|
mm.generator['source']()
|
||||||
|
@ -1115,6 +1115,8 @@ def build(bld):
|
|||||||
'rtemsbsd/telnetd/check_passwd.c',
|
'rtemsbsd/telnetd/check_passwd.c',
|
||||||
'rtemsbsd/telnetd/des.c',
|
'rtemsbsd/telnetd/des.c',
|
||||||
'rtemsbsd/telnetd/pty.c',
|
'rtemsbsd/telnetd/pty.c',
|
||||||
|
'rtemsbsd/telnetd/telnetd-init.c',
|
||||||
|
'rtemsbsd/telnetd/telnetd-service.c',
|
||||||
'rtemsbsd/telnetd/telnetd.c']
|
'rtemsbsd/telnetd/telnetd.c']
|
||||||
if bld.get_env()["RTEMS_ARCH"] == "arm":
|
if bld.get_env()["RTEMS_ARCH"] == "arm":
|
||||||
source += ['freebsd/sys/mips/mips/in_cksum.c']
|
source += ['freebsd/sys/mips/mips/in_cksum.c']
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
* RTEMS_BSD_CONFIG_NET_PF_UNIX : Packet Filter.
|
* RTEMS_BSD_CONFIG_NET_PF_UNIX : Packet Filter.
|
||||||
* RTEMS_BSD_CONFIG_NET_IF_LAGG : Link Aggregetion and Failover.
|
* RTEMS_BSD_CONFIG_NET_IF_LAGG : Link Aggregetion and Failover.
|
||||||
* RTEMS_BSD_CONFIG_NET_IF_VLAN : Virtual LAN.
|
* RTEMS_BSD_CONFIG_NET_IF_VLAN : Virtual LAN.
|
||||||
|
* RTEMS_BSD_CONFIG_SERVICE_TELNETD : Telnet Protocol (TELNET).
|
||||||
|
* RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE : Telnet shell task stack size.
|
||||||
* RTEMS_BSD_CONFIG_SERVICE_FTPD : File Transfer Protocol (FTP).
|
* RTEMS_BSD_CONFIG_SERVICE_FTPD : File Transfer Protocol (FTP).
|
||||||
* RTEMS_BSD_CONFIG_BSP_CONFIG : Configure default BSP devices.
|
* RTEMS_BSD_CONFIG_BSP_CONFIG : Configure default BSP devices.
|
||||||
* RTEMS_BSD_CONFIG_INIT : Configure the LibBSD support.
|
* RTEMS_BSD_CONFIG_INIT : Configure the LibBSD support.
|
||||||
@ -117,6 +119,17 @@ extern "C" {
|
|||||||
#define RTEMS_BSD_CFGDECL_FTPD RTEMS_BSD_RC_CONF_SYSINT(rc_conf_ftpd)
|
#define RTEMS_BSD_CFGDECL_FTPD RTEMS_BSD_RC_CONF_SYSINT(rc_conf_ftpd)
|
||||||
#endif /* RTEMS_BSD_CONFIG_SERVICE_FTPD */
|
#endif /* RTEMS_BSD_CONFIG_SERVICE_FTPD */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Telnetd
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_SERVICE_TELNETD)
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE)
|
||||||
|
#define RTEMS_BSD_CFGDECL_TELNETD_STACK_SIZE \
|
||||||
|
int rtems_telnetd_stack_size = RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE */
|
||||||
|
#define RTEMS_BSD_CFGDECL_TELNETD RTEMS_BSD_RC_CONF_SYSINT(rc_conf_telnetd)
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_SERVICE_TELNETD */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure the system.
|
* Configure the system.
|
||||||
*/
|
*/
|
||||||
@ -145,6 +158,8 @@ extern "C" {
|
|||||||
/*
|
/*
|
||||||
* Create the services.
|
* Create the services.
|
||||||
*/
|
*/
|
||||||
|
RTEMS_BSD_CFGDECL_TELNETD;
|
||||||
|
RTEMS_BSD_CFGDECL_TELNETD_STACK_SIZE;
|
||||||
RTEMS_BSD_CFGDECL_FTPD;
|
RTEMS_BSD_CFGDECL_FTPD;
|
||||||
#endif /* RTEMS_BSD_CONFIG_INIT */
|
#endif /* RTEMS_BSD_CONFIG_INIT */
|
||||||
|
|
||||||
|
@ -154,8 +154,9 @@ extern void rtems_bsd_rc_conf_print_cmd(rtems_bsd_rc_conf* rc_conf,
|
|||||||
/*
|
/*
|
||||||
* Decls for the handlers.
|
* Decls for the handlers.
|
||||||
*/
|
*/
|
||||||
void rc_conf_net_init(void* arg); /* Installed by default. */
|
void rc_conf_net_init(void* arg); /* Installed by default. */
|
||||||
void rc_conf_ftpd_init(void* arg); /* ftpd_enabled="YES" */
|
void rc_conf_telnetd_init(void* arg); /* telnetd_enabled="YES" */
|
||||||
|
void rc_conf_ftpd_init(void* arg); /* ftpd_enabled="YES" */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added services.
|
* Added services.
|
||||||
|
@ -87,6 +87,11 @@ typedef struct {
|
|||||||
bool keep_stdio;
|
bool keep_stdio;
|
||||||
} rtems_telnetd_config_table;
|
} rtems_telnetd_config_table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Start the Telnet subsystem with the provided configuration.
|
||||||
|
*/
|
||||||
|
rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Telnet configuration.
|
* @brief Telnet configuration.
|
||||||
*
|
*
|
||||||
|
33
rtemsbsd/telnetd/telnetd-init.c
Normal file
33
rtemsbsd/telnetd/telnetd-init.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/***********************************************************/
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* The telnet DAEMON
|
||||||
|
*
|
||||||
|
* Author: 17,may 2001
|
||||||
|
*
|
||||||
|
* WORK: fernando.ruiz@ctv.es
|
||||||
|
* HOME: correo@fernando-ruiz.com
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 embedded brains GmbH and others.
|
||||||
|
*
|
||||||
|
* embedded brains GmbH
|
||||||
|
* Obere Lagerstr. 30
|
||||||
|
* D-82178 Puchheim
|
||||||
|
* Germany
|
||||||
|
* <rtems@embedded-brains.de>
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.org/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rtems/telnetd.h>
|
||||||
|
|
||||||
|
rtems_status_code rtems_telnetd_initialize(void)
|
||||||
|
{
|
||||||
|
return rtems_telnetd_start(&rtems_telnetd_config);
|
||||||
|
}
|
184
rtemsbsd/telnetd/telnetd-service.c
Normal file
184
rtemsbsd/telnetd/telnetd-service.c
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Telnet service. To use add to rc.conf:
|
||||||
|
*
|
||||||
|
* telnetd_enable="YES"
|
||||||
|
* telnet_options="-p 21 -s 32768 -P 8 -L"
|
||||||
|
*
|
||||||
|
* The options defaults are show. The options are:
|
||||||
|
*
|
||||||
|
* -C conns : Maximum connections (ptys).
|
||||||
|
* -P priority : Telnet thread priority (RTEMS Classis API).
|
||||||
|
* -L : Login using /etc/passwd
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <rtems/telnetd.h>
|
||||||
|
#include <machine/rtems-bsd-rc-conf-services.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack size. Use RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE.
|
||||||
|
*/
|
||||||
|
extern int rtems_telnetd_stack_size;
|
||||||
|
__weak_reference(_rtems_telnetd_stack_size, rtems_telnetd_stack_size);
|
||||||
|
int _rtems_telnetd_stack_size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Condefs always defines this variable.
|
||||||
|
*/
|
||||||
|
extern int rtems_telnetd_maximum_ptys;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default no login.
|
||||||
|
*/
|
||||||
|
static bool telnet_login;
|
||||||
|
|
||||||
|
static void
|
||||||
|
hydra_telnetd_command(char* device, void* arg)
|
||||||
|
{
|
||||||
|
rtems_shell_login_check_t login = NULL;
|
||||||
|
rtems_shell_env_t shell_env;
|
||||||
|
|
||||||
|
if (telnet_login)
|
||||||
|
login = rtems_shell_login_check;
|
||||||
|
|
||||||
|
rtems_shell_dup_current_env(&shell_env);
|
||||||
|
|
||||||
|
shell_env.devname = device;
|
||||||
|
shell_env.taskname = "TELn";
|
||||||
|
shell_env.exit_shell = false;
|
||||||
|
shell_env.forever = 0;
|
||||||
|
shell_env.echo = 0;
|
||||||
|
shell_env.input = NULL;
|
||||||
|
shell_env.output = NULL;
|
||||||
|
shell_env.output_append = 0;
|
||||||
|
shell_env.wake_on_end = 0;
|
||||||
|
shell_env.login_check = login;
|
||||||
|
|
||||||
|
rtems_shell_main_loop (&shell_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
telnetd_service(rtems_bsd_rc_conf* rc_conf)
|
||||||
|
{
|
||||||
|
rtems_telnetd_config_table config = {
|
||||||
|
.priority = 100, /* Telnet task priority */
|
||||||
|
.stack_size = 32 * 1024, /* Stack size */
|
||||||
|
.command = hydra_telnetd_command, /* The telnetd command, runs the shell. */
|
||||||
|
};
|
||||||
|
rtems_bsd_rc_conf_argc_argv* aa;
|
||||||
|
int conns = 0;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (rtems_telnetd_stack_size != 0)
|
||||||
|
config.stack_size = rtems_telnetd_stack_size;
|
||||||
|
|
||||||
|
aa = rtems_bsd_rc_conf_argc_argv_create();
|
||||||
|
if (aa == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
r = rtems_bsd_rc_conf_find(rc_conf, "telnetd_enable", aa);
|
||||||
|
if (r == 0) {
|
||||||
|
rtems_status_code sc;
|
||||||
|
bool verbose = false;
|
||||||
|
if (aa->argc == 2 && strcasecmp("YES", aa->argv[1]) == 0) {
|
||||||
|
r = rtems_bsd_rc_conf_find(rc_conf, "telnetd_options", aa);
|
||||||
|
if (r == 0) {
|
||||||
|
struct getopt_data data;
|
||||||
|
char* end;
|
||||||
|
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
int c;
|
||||||
|
|
||||||
|
c = getopt_r(aa->argc, aa->argv, "C:P:Lv", &data);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'C':
|
||||||
|
conns = strtoul(data.optarg, &end, 10);
|
||||||
|
if (conns == 0 || *end != '\0') {
|
||||||
|
fprintf(stderr, "error: telnet: invalid connections countt\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rtems_telnetd_maximum_ptys = conns;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
config.priority = strtoul(data.optarg, &end, 10);
|
||||||
|
if (config.priority == 0 || *end != '\0') {
|
||||||
|
fprintf(stderr, "error: telnetd: invalid priority\n");
|
||||||
|
config.priority = 100;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
telnet_login = true;
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose = true;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "error: telnetd: unknown option: %s\n", data.optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (verbose) {
|
||||||
|
printf("telnetd: conns:%lu pri:%lu login:%s\n",
|
||||||
|
rtems_telnetd_maximum_ptys, config.priority,
|
||||||
|
telnet_login == NULL ? "no" : "yes");
|
||||||
|
}
|
||||||
|
sc = rtems_telnetd_start(&config);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
fprintf(stderr, "error: telnetd: %s\n", rtems_status_text(sc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rc_conf_telnetd_init(void* arg)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
r = rtems_bsd_rc_conf_service_add("telnetd",
|
||||||
|
"after:network;before:ftpd;",
|
||||||
|
telnetd_service);
|
||||||
|
if (r < 0)
|
||||||
|
fprintf(stderr, "error: telnetd service add failed: %s\n", strerror(errno));
|
||||||
|
}
|
@ -87,9 +87,16 @@ rtems_id telnetd_dflt_spawn(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
static rtems_id telnetd_task_id = RTEMS_ID_NONE;
|
static rtems_telnetd_config_table* telnetd_config;
|
||||||
|
static rtems_id telnetd_task_id;
|
||||||
|
|
||||||
rtems_id (*telnetd_spawn_task)(
|
/*
|
||||||
|
* chrisj: this variable was global and with no declared interface in a header
|
||||||
|
* file and with no means to set it so I have stopped it being global;
|
||||||
|
* if this breaks any user they will have be to provide a formal
|
||||||
|
* interface to get this change reverted.
|
||||||
|
*/
|
||||||
|
static const rtems_id (*telnetd_spawn_task)(
|
||||||
const char *,
|
const char *,
|
||||||
unsigned,
|
unsigned,
|
||||||
unsigned,
|
unsigned,
|
||||||
@ -207,24 +214,24 @@ rtems_task_telnetd(void *task_argument)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* we don't redirect stdio as this probably
|
/* we don't redirect stdio as this probably
|
||||||
* was started from the console anyways..
|
* was started from the console anyway ..
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
if (rtems_telnetd_config.keep_stdio) {
|
if (telnetd_config->keep_stdio) {
|
||||||
bool start = true;
|
bool start = true;
|
||||||
char device_name [32];
|
char device_name [32];
|
||||||
|
|
||||||
ttyname_r( 1, device_name, sizeof( device_name));
|
ttyname_r( 1, device_name, sizeof( device_name));
|
||||||
if (rtems_telnetd_config.login_check != NULL) {
|
if (telnetd_config->login_check != NULL) {
|
||||||
start = rtems_shell_login_prompt(
|
start = rtems_shell_login_prompt(
|
||||||
stdin,
|
stdin,
|
||||||
stderr,
|
stderr,
|
||||||
device_name,
|
device_name,
|
||||||
rtems_telnetd_config.login_check
|
telnetd_config->login_check
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (start) {
|
if (start) {
|
||||||
rtems_telnetd_config.command( device_name, arg->arg);
|
telnetd_config->command( device_name, arg->arg);
|
||||||
} else {
|
} else {
|
||||||
syslog(
|
syslog(
|
||||||
LOG_AUTHPRIV | LOG_WARNING,
|
LOG_AUTHPRIV | LOG_WARNING,
|
||||||
@ -244,13 +251,13 @@ rtems_task_telnetd(void *task_argument)
|
|||||||
arg = malloc( sizeof(*arg) );
|
arg = malloc( sizeof(*arg) );
|
||||||
|
|
||||||
arg->devname = devname;
|
arg->devname = devname;
|
||||||
arg->arg = rtems_telnetd_config.arg;
|
arg->arg = telnetd_config->arg;
|
||||||
strncpy(arg->peername, peername, sizeof(arg->peername));
|
strncpy(arg->peername, peername, sizeof(arg->peername));
|
||||||
|
|
||||||
telnetd_task_id = telnetd_spawn_task(
|
telnetd_task_id = telnetd_spawn_task(
|
||||||
devname,
|
devname,
|
||||||
rtems_telnetd_config.priority,
|
telnetd_config->priority,
|
||||||
rtems_telnetd_config.stack_size,
|
telnetd_config->stack_size,
|
||||||
spawned_shell,
|
spawned_shell,
|
||||||
arg
|
arg
|
||||||
);
|
);
|
||||||
@ -287,52 +294,65 @@ rtems_task_telnetd(void *task_argument)
|
|||||||
telnetd_task_id = RTEMS_ID_NONE;
|
telnetd_task_id = RTEMS_ID_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_status_code rtems_telnetd_initialize( void)
|
rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config)
|
||||||
{
|
{
|
||||||
if (telnetd_task_id != RTEMS_ID_NONE) {
|
if (telnetd_config != NULL) {
|
||||||
fprintf(stderr, "telnetd already started\n");
|
fprintf(stderr, "telnetd already started\n");
|
||||||
return RTEMS_RESOURCE_IN_USE;
|
return RTEMS_RESOURCE_IN_USE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtems_telnetd_config.command == NULL) {
|
if (config->command == NULL) {
|
||||||
fprintf(stderr, "telnetd setup with invalid command\n");
|
fprintf(stderr, "telnetd setup with invalid command\n");
|
||||||
return RTEMS_IO_ERROR;
|
return RTEMS_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
telnetd_config = calloc(1, sizeof(*telnetd_config));
|
||||||
|
if (telnetd_config == NULL) {
|
||||||
|
fprintf(stderr, "telnetd cannot alloc telnetd config table\n");
|
||||||
|
return RTEMS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( !telnet_pty_initialize() ) {
|
if ( !telnet_pty_initialize() ) {
|
||||||
fprintf(stderr, "telnetd cannot initialize PTY driver\n");
|
fprintf(stderr, "telnetd cannot initialize PTY driver\n");
|
||||||
|
free(telnetd_config);
|
||||||
|
telnetd_config = NULL;
|
||||||
return RTEMS_IO_ERROR;
|
return RTEMS_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*telnetd_config = *config;
|
||||||
|
|
||||||
/* Check priority */
|
/* Check priority */
|
||||||
if (rtems_telnetd_config.priority < 2) {
|
if (telnetd_config->priority < 2) {
|
||||||
rtems_telnetd_config.priority = 100;
|
telnetd_config->priority = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check stack size */
|
/* Check stack size */
|
||||||
if (rtems_telnetd_config.stack_size <= 0) {
|
if (telnetd_config->stack_size <= 0) {
|
||||||
rtems_telnetd_config.stack_size = (size_t)32 * 1024;
|
telnetd_config->stack_size = (size_t)32 * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spawn task */
|
/* Spawn task */
|
||||||
telnetd_task_id = telnetd_spawn_task(
|
telnetd_task_id = telnetd_spawn_task(
|
||||||
"TNTD",
|
"TNTD",
|
||||||
rtems_telnetd_config.priority,
|
telnetd_config->priority,
|
||||||
rtems_telnetd_config.stack_size,
|
telnetd_config->stack_size,
|
||||||
rtems_task_telnetd,
|
rtems_task_telnetd,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
if (telnetd_task_id == RTEMS_ID_NONE) {
|
if (telnetd_task_id == RTEMS_ID_NONE) {
|
||||||
|
free(telnetd_config);
|
||||||
|
telnetd_config = NULL;
|
||||||
return RTEMS_IO_ERROR;
|
return RTEMS_IO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print status */
|
/* Print status */
|
||||||
if (!rtems_telnetd_config.keep_stdio) {
|
if (!telnetd_config->keep_stdio) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
"telnetd started with stacksize = %u and priority = %d\n",
|
"telnetd started with stacksize = %u and priority = %d\n",
|
||||||
(unsigned) rtems_telnetd_config.stack_size,
|
(unsigned) telnetd_config->stack_size,
|
||||||
(unsigned) rtems_telnetd_config.priority
|
(unsigned) telnetd_config->priority
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,17 +406,17 @@ spawned_shell(void *targ)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* call their routine */
|
/* call their routine */
|
||||||
if (rtems_telnetd_config.login_check != NULL) {
|
if (telnetd_config->login_check != NULL) {
|
||||||
start = rtems_shell_login_prompt(
|
start = rtems_shell_login_prompt(
|
||||||
stdin,
|
stdin,
|
||||||
stderr,
|
stderr,
|
||||||
arg->devname,
|
arg->devname,
|
||||||
rtems_telnetd_config.login_check
|
telnetd_config->login_check
|
||||||
);
|
);
|
||||||
login_failed = !start;
|
login_failed = !start;
|
||||||
}
|
}
|
||||||
if (start) {
|
if (start) {
|
||||||
rtems_telnetd_config.command( arg->devname, arg->arg);
|
telnetd_config->command( arg->devname, arg->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
stdin = ostd[0];
|
stdin = ostd[0];
|
||||||
|
@ -69,10 +69,6 @@
|
|||||||
#include <rtems/console.h>
|
#include <rtems/console.h>
|
||||||
#include <rtems/shell.h>
|
#include <rtems/shell.h>
|
||||||
|
|
||||||
#if DEFINE_FOR_TESTING
|
|
||||||
#define RCCONF02_HAS_SHELL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TEST_NAME "LIBBSD RC.CONF 2"
|
#define TEST_NAME "LIBBSD RC.CONF 2"
|
||||||
|
|
||||||
#define IFACE_IPV4(iface) \
|
#define IFACE_IPV4(iface) \
|
||||||
@ -121,6 +117,9 @@ static const char* rc_conf_text = \
|
|||||||
"\n" \
|
"\n" \
|
||||||
"dhcpcd_options=\"-h foobar\"\n" \
|
"dhcpcd_options=\"-h foobar\"\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
|
"telnetd_enable=\"YES\"\n" \
|
||||||
|
"telnetd_options=\"-v -C 10 -P 50 -L\"\n" \
|
||||||
|
"\n" \
|
||||||
"ftpd_enable=\"YES\"\n" \
|
"ftpd_enable=\"YES\"\n" \
|
||||||
"ftpd_options=\"-v -p 21 -C 10 -P 150 -L -I 10 -R /\"\n" \
|
"ftpd_options=\"-v -p 21 -C 10 -P 150 -L -I 10 -R /\"\n" \
|
||||||
"n";
|
"n";
|
||||||
@ -153,7 +152,6 @@ test_main(void)
|
|||||||
{
|
{
|
||||||
test_rc_conf_script();
|
test_rc_conf_script();
|
||||||
|
|
||||||
#if defined(RCCONF02_HAS_SHELL)
|
|
||||||
rtems_shell_init(
|
rtems_shell_init(
|
||||||
"SHLL",
|
"SHLL",
|
||||||
32 * 1024,
|
32 * 1024,
|
||||||
@ -163,19 +161,10 @@ test_main(void)
|
|||||||
true,
|
true,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
#else
|
|
||||||
printf("RCCONF02 sleeping for 10s\n");
|
|
||||||
sleep(10);
|
|
||||||
#endif /* RCCONF02_HAS_SHELL */
|
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Optional shell for testing this test.
|
|
||||||
*/
|
|
||||||
#if defined(RCCONF02_HAS_SHELL)
|
|
||||||
|
|
||||||
#define CONFIGURE_SHELL_COMMANDS_INIT
|
#define CONFIGURE_SHELL_COMMANDS_INIT
|
||||||
|
|
||||||
#include <bsp/irq-info.h>
|
#include <bsp/irq-info.h>
|
||||||
@ -214,9 +203,12 @@ test_main(void)
|
|||||||
#define CONFIGURE_SHELL_COMMAND_SHUTDOWN
|
#define CONFIGURE_SHELL_COMMAND_SHUTDOWN
|
||||||
|
|
||||||
#include <rtems/shellconfig.h>
|
#include <rtems/shellconfig.h>
|
||||||
#endif /* RCCONF02_HAS_SHELL */
|
|
||||||
|
|
||||||
#define RTEMS_BSD_CONFIG_BSP_CONFIG
|
#define RTEMS_BSD_CONFIG_BSP_CONFIG
|
||||||
|
#define RTEMS_BSD_CONFIG_SERVICE_TELNETD
|
||||||
|
#define RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE (16 * 1024)
|
||||||
#define RTEMS_BSD_CONFIG_SERVICE_FTPD
|
#define RTEMS_BSD_CONFIG_SERVICE_FTPD
|
||||||
|
|
||||||
|
#define CONFIGURE_MAXIMUM_DRIVERS 32
|
||||||
|
|
||||||
#include <rtems/bsd/test/default-init.h>
|
#include <rtems/bsd/test/default-init.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user