Changeset b80b34c3 in rtems


Ignore:
Timestamp:
Apr 30, 2018, 8:54:50 AM (12 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
8d52a0e2
Parents:
b771cb4
git-author:
Sebastian Huber <sebastian.huber@…> (04/30/18 08:54:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/02/18 07:57:32)
Message:

telnetd: Always build telnet daemon

Add support for libbsd initialization.

Update #3419.

Location:
cpukit
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/telnetd.h

    rb771cb4 rb80b34c3  
    8989
    9090/**
     91 * @brief Start the Telnet subsystem with the provided configuration.
     92 */
     93rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table *config);
     94
     95/**
    9196 * @brief Telnet configuration.
    9297 *
  • cpukit/telnetd/Makefile.am

    rb771cb4 rb80b34c3  
    11include $(top_srcdir)/automake/compile.am
    22
    3 if LIBNETWORKING
    43if LIBSHELL
    54project_lib_LIBRARIES = libtelnetd.a
     
    98TMPINSTALL_FILES = $(PROJECT_LIB)/libtelnetd.a
    109
    11 libtelnetd_a_SOURCES = check_passwd.c des.c pty.c telnetd.c
     10libtelnetd_a_SOURCES = check_passwd.c des.c pty.c telnetd.c telnetd-init.c
    1211libtelnetd_a_CPPFLAGS = $(AM_CPPFLAGS)
    1312endif
    14 endif
    15 
    1613
    1714include $(top_srcdir)/automake/local.am
  • cpukit/telnetd/telnetd.c

    rb771cb4 rb80b34c3  
    5858#include <rtems/userenv.h>
    5959#include <rtems/error.h>
     60
     61#ifdef RTEMS_NETWORKING
    6062#include <rtems/rtems_bsdnet.h>
     63#endif
    6164
    6265#define PARANOIA
     
    8891
    8992/***********************************************************/
    90 static rtems_id telnetd_task_id = RTEMS_ID_NONE;
    91 
    92 rtems_id (*telnetd_spawn_task)(
     93static rtems_telnetd_config_table *telnetd_config;
     94static rtems_id                    telnetd_task_id;
     95
     96/*
     97 * chrisj: this variable was global and with no declared interface in a header
     98 *         file and with no means to set it so I have stopped it being global;
     99 *         if this breaks any user they will have be to provide a formal
     100 *         interface to get this change reverted.
     101 */
     102static const rtems_id (*telnetd_spawn_task)(
    93103  const char *,
    94104  unsigned,
     
    208218
    209219  /* we don't redirect stdio as this probably
    210    * was started from the console anyways..
     220   * was started from the console anyway ..
    211221   */
    212222  do {
    213     if (rtems_telnetd_config.keep_stdio) {
     223    if (telnetd_config->keep_stdio) {
    214224      bool start = true;
    215225      char device_name [32];
    216226
    217227      ttyname_r( 1, device_name, sizeof( device_name));
    218       if (rtems_telnetd_config.login_check != NULL) {
     228      if (telnetd_config->login_check != NULL) {
    219229        start = rtems_shell_login_prompt(
    220230          stdin,
    221231          stderr,
    222232          device_name,
    223           rtems_telnetd_config.login_check
     233          telnetd_config->login_check
    224234        );
    225235      }
    226236      if (start) {
    227         rtems_telnetd_config.command( device_name, arg->arg);
     237        telnetd_config->command( device_name, arg->arg);
    228238      } else {
    229239        syslog(
     
    245255
    246256      arg->devname = devname;
    247       arg->arg = rtems_telnetd_config.arg;
     257      arg->arg = telnetd_config->arg;
    248258      strncpy(arg->peername, peername, sizeof(arg->peername));
    249259
    250260      telnetd_task_id = telnetd_spawn_task(
    251261        devname,
    252         rtems_telnetd_config.priority,
    253         rtems_telnetd_config.stack_size,
     262        telnetd_config->priority,
     263        telnetd_config->stack_size,
    254264        spawned_shell,
    255265        arg
     
    288298}
    289299
    290 rtems_status_code rtems_telnetd_initialize( void)
    291 {
    292   if (telnetd_task_id != RTEMS_ID_NONE) {
     300rtems_status_code rtems_telnetd_start(const rtems_telnetd_config_table* config)
     301{
     302  if (telnetd_config != NULL) {
    293303    fprintf(stderr, "telnetd already started\n");
    294304    return RTEMS_RESOURCE_IN_USE;
    295305  }
    296306
    297   if (rtems_telnetd_config.command == NULL) {
     307  if (config->command == NULL) {
    298308    fprintf(stderr, "telnetd setup with invalid command\n");
    299309    return RTEMS_IO_ERROR;
    300310  }
    301311
     312  telnetd_config = calloc(1, sizeof(*telnetd_config));
     313  if (telnetd_config == NULL) {
     314    fprintf(stderr, "telnetd cannot alloc telnetd config table\n");
     315    return RTEMS_NO_MEMORY;
     316  }
     317
     318
    302319  if ( !telnet_pty_initialize() ) {
    303320    fprintf(stderr, "telnetd cannot initialize PTY driver\n");
     321    free(telnetd_config);
     322    telnetd_config = NULL;
    304323    return RTEMS_IO_ERROR;
    305324  }
    306325
     326  *telnetd_config = *config;
     327
    307328  /* Check priority */
    308   if (rtems_telnetd_config.priority <= 0) {
    309     rtems_telnetd_config.priority = rtems_bsdnet_config.network_task_priority;
    310   }
    311   if (rtems_telnetd_config.priority < 2) {
    312     rtems_telnetd_config.priority = 100;
     329#ifdef RTEMS_NETWORKING
     330  if (telnetd_config->priority <= 0) {
     331    telnetd_config->priority = rtems_bsdnet_config.network_task_priority;
     332  }
     333#endif
     334  if (telnetd_config->priority < 2) {
     335    telnetd_config->priority = 100;
    313336  }
    314337
    315338  /* Check stack size */
    316   if (rtems_telnetd_config.stack_size <= 0) {
    317     rtems_telnetd_config.stack_size = (size_t)32 * 1024;
     339  if (telnetd_config->stack_size <= 0) {
     340    telnetd_config->stack_size = (size_t)32 * 1024;
    318341  }
    319342
     
    321344  telnetd_task_id = telnetd_spawn_task(
    322345    "TNTD",
    323     rtems_telnetd_config.priority,
    324     rtems_telnetd_config.stack_size,
     346    telnetd_config->priority,
     347    telnetd_config->stack_size,
    325348    rtems_task_telnetd,
    326349    0
    327350  );
    328351  if (telnetd_task_id == RTEMS_ID_NONE) {
     352    free(telnetd_config);
     353    telnetd_config = NULL;
    329354    return RTEMS_IO_ERROR;
    330355  }
    331356
    332357  /* Print status */
    333   if (!rtems_telnetd_config.keep_stdio) {
     358  if (!telnetd_config->keep_stdio) {
    334359    fprintf(
    335360      stderr,
    336361      "telnetd started with stacksize = %u and priority = %d\n",
    337       (unsigned) rtems_telnetd_config.stack_size,
    338       (unsigned) rtems_telnetd_config.priority
     362      (unsigned) telnetd_config->stack_size,
     363      (unsigned) telnetd_config->priority
    339364    );
    340365  }
     
    390415
    391416  /* call their routine */
    392   if (rtems_telnetd_config.login_check != NULL) {
     417  if (telnetd_config->login_check != NULL) {
    393418    start = rtems_shell_login_prompt(
    394419      stdin,
    395420      stderr,
    396421      arg->devname,
    397       rtems_telnetd_config.login_check
     422      telnetd_config->login_check
    398423    );
    399424    login_failed = !start;
    400425  }
    401426  if (start) {
    402     rtems_telnetd_config.command( arg->devname, arg->arg);
     427    telnetd_config->command( arg->devname, arg->arg);
    403428  }
    404429
Note: See TracChangeset for help on using the changeset viewer.