Changeset b771cb4 in rtems


Ignore:
Timestamp:
Apr 30, 2018, 8:11:37 AM (12 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b80b34c3
Parents:
32b5b23
git-author:
Sebastian Huber <sebastian.huber@…> (04/30/18 08:11:37)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/02/18 07:56:49)
Message:

ftpd: Always build FTP daemon

Add support for libbsd initialization.

Update #3419.

Location:
cpukit
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ftpd/Makefile.am

    r32b5b23 rb771cb4  
    11include $(top_srcdir)/automake/compile.am
    22
    3 if LIBNETWORKING
    43project_lib_LIBRARIES = libftpd.a
    54
     
    87TMPINSTALL_FILES = $(PROJECT_LIB)/libftpd.a
    98
    10 libftpd_a_SOURCES = ftpd.c ftpd.h
    11 endif
     9libftpd_a_SOURCES = ftpd.c ftpd-init.c
    1210
    1311include $(top_srcdir)/automake/local.am
  • cpukit/ftpd/ftpd.c

    r32b5b23 rb771cb4  
    203203
    204204#include <rtems.h>
    205 #include <rtems/rtems_bsdnet.h>
    206205#include <rtems/error.h>
    207206#include <rtems/ftpd.h>
     
    244243
    245244/* Configuration table */
    246 extern struct rtems_ftpd_configuration rtems_ftpd_configuration;
     245static struct rtems_ftpd_configuration *ftpd_config;
    247246
    248247/* this is not prototyped in strict ansi mode */
     
    935934  }
    936935
    937   if (!null && rtems_ftpd_configuration.hooks != NULL)
     936  if (!null && ftpd_config->hooks != NULL)
    938937  {
    939938
     
    943942
    944943    i = 0;
    945     hook = &rtems_ftpd_configuration.hooks[i++];
     944    hook = &ftpd_config->hooks[i++];
    946945    while (hook->filename != NULL)
    947946    {
     
    951950        break;
    952951      }
    953       hook = &rtems_ftpd_configuration.hooks[i++];
     952      hook = &ftpd_config->hooks[i++];
    954953    }
    955954  }
     
    964963     */
    965964
    966     char                *bigBufr;
    967     size_t filesize = rtems_ftpd_configuration.max_hook_filesize + 1;
     965    char   *bigBufr;
     966    size_t  filesize = ftpd_config->max_hook_filesize + 1;
    968967
    969968    /*
     
    17481747    info->pass = NULL;
    17491748    info->user = strdup(fname);
    1750     if (rtems_ftpd_configuration.login &&
    1751       !rtems_ftpd_configuration.login(info->user, NULL)) {
     1749    if (ftpd_config->login &&
     1750      !ftpd_config->login(info->user, NULL)) {
    17521751      info->auth = false;
    17531752      send_reply(info, 331, "User name okay, need password.");
     
    17661765      send_reply(info, 332, "Need account to log in");
    17671766    } else {
    1768       if (rtems_ftpd_configuration.login &&
    1769         !rtems_ftpd_configuration.login(info->user, info->pass)) {
     1767      if (ftpd_config->login &&
     1768        !ftpd_config->login(info->user, info->pass)) {
    17701769        info->auth = false;
    17711770        send_reply(info, 530, "Not logged in.");
     
    19911990
    19921991  addr.sin_family      = AF_INET;
    1993   addr.sin_port        = htons(rtems_ftpd_configuration.port);
     1992  addr.sin_port        = htons(ftpd_config->port);
    19941993  addr.sin_addr.s_addr = htonl(INADDR_ANY);
    19951994  memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
     
    20462045            info->user = NULL;
    20472046            info->pass = NULL;
    2048             if (rtems_ftpd_configuration.login)
     2047            if (ftpd_config->login)
    20492048              info->auth = false;
    20502049            else
     
    20702069 *
    20712070 * Input parameters:
    2072  *
     2071 *    config: constant initial setup.
    20732072 * Output parameters:
    20742073 *    returns RTEMS_SUCCESSFUL on successful start of the daemon.
    20752074 */
    20762075int
    2077 rtems_initialize_ftpd(void)
     2076rtems_ftpd_start(const struct rtems_ftpd_configuration* config)
    20782077{
    20792078  rtems_status_code   sc;
     
    20822081  int count;
    20832082
    2084   if (rtems_ftpd_configuration.port == 0)
    2085   {
    2086     rtems_ftpd_configuration.port = FTPD_CONTROL_PORT;
    2087   }
    2088 
    2089   if (rtems_ftpd_configuration.priority == 0)
    2090   {
    2091     rtems_ftpd_configuration.priority = 40;
    2092   }
    2093   priority = rtems_ftpd_configuration.priority;
    2094 
    2095   ftpd_timeout = rtems_ftpd_configuration.idle;
     2083  if (ftpd_config != NULL)
     2084    return RTEMS_RESOURCE_IN_USE;
     2085
     2086  ftpd_config = malloc(sizeof(*ftpd_config));
     2087  if (ftpd_config == NULL)
     2088    return RTEMS_NO_MEMORY;
     2089
     2090  *ftpd_config = *config;
     2091
     2092  if (ftpd_config->port == 0)
     2093  {
     2094    ftpd_config->port = FTPD_CONTROL_PORT;
     2095  }
     2096
     2097  if (ftpd_config->priority == 0)
     2098  {
     2099    ftpd_config->priority = 40;
     2100  }
     2101  priority = ftpd_config->priority;
     2102
     2103  ftpd_timeout = ftpd_config->idle;
    20962104  if (ftpd_timeout < 0)
    20972105    ftpd_timeout = 0;
    2098   rtems_ftpd_configuration.idle = ftpd_timeout;
    2099 
    2100   ftpd_access = rtems_ftpd_configuration.access;
     2106  ftpd_config->idle = ftpd_timeout;
     2107
     2108  ftpd_access = ftpd_config->access;
    21012109
    21022110  ftpd_root = "/";
    2103   if ( rtems_ftpd_configuration.root &&
    2104        rtems_ftpd_configuration.root[0] == '/' )
    2105     ftpd_root = rtems_ftpd_configuration.root;
    2106 
    2107   rtems_ftpd_configuration.root = ftpd_root;
    2108 
    2109   if (rtems_ftpd_configuration.tasks_count <= 0)
    2110     rtems_ftpd_configuration.tasks_count = 1;
    2111   count = rtems_ftpd_configuration.tasks_count;
     2111  if (ftpd_config->root && ftpd_config->root[0] == '/' )
     2112    ftpd_root = ftpd_config->root;
     2113
     2114  ftpd_config->root = ftpd_root;
     2115
     2116  if (ftpd_config->tasks_count <= 0)
     2117    ftpd_config->tasks_count = 1;
     2118  count = ftpd_config->tasks_count;
    21122119
    21132120  if (!task_pool_init(count, priority))
     
    21392146  }
    21402147
    2141   syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
    2142     count, ((count > 1) ? "s" : ""));
     2148  if (ftpd_config->verbose)
     2149    syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
     2150           count, ((count > 1) ? "s" : ""));
    21432151
    21442152  return RTEMS_SUCCESSFUL;
  • cpukit/include/rtems/ftpd.h

    r32b5b23 rb771cb4  
    66#define _RTEMS_FTPD_H
    77
    8 #include <rtems/rtems/tasks.h>
     8#include <rtems.h>
    99
    1010#ifdef __cplusplus
     
    5555   rtems_shell_login_check_t login;            /* Login check or 0 to ignore
    5656                                                  user/passwd. */
     57   bool                    verbose;            /* Say hello! */
    5758};
    5859
     
    6667#define ERROR           5       /* permanent negative completion */
    6768
     69int rtems_ftpd_start(const struct rtems_ftpd_configuration *config);
     70
     71extern struct rtems_ftpd_configuration rtems_ftpd_configuration;
     72
    6873int rtems_initialize_ftpd(void);
    6974
Note: See TracChangeset for help on using the changeset viewer.