Changeset 90873cc in rtems-libbsd


Ignore:
Timestamp:
06/28/16 03:32:01 (7 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
Children:
4a2b844
Parents:
c2ec5f1
Message:

Add ftpd as a service. Add rtems-bsd-config.h for app libbsd set up.

Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • libbsd.py

    rc2ec5f1 r90873cc  
    108108            'rtems/syslog.c',
    109109            'ftpd/ftpd.c',
     110            'ftpd/ftpd-init.c',
     111            'ftpd/ftpd-service.c',
    110112            'ftpfs/ftpfs.c',
    111113            'mdns/mdns.c',
  • libbsd_waf.py

    rc2ec5f1 r90873cc  
    10141014              'mDNSResponder/mDNSShared/dnssd_clientshim.c',
    10151015              'mDNSResponder/mDNSShared/mDNSDebug.c',
     1016              'rtemsbsd/ftpd/ftpd-init.c',
     1017              'rtemsbsd/ftpd/ftpd-service.c',
    10161018              'rtemsbsd/ftpd/ftpd.c',
    10171019              'rtemsbsd/ftpfs/ftpfs.c',
  • rtemsbsd/ftpd/ftpd.c

    rc2ec5f1 r90873cc  
    1414 *                Arnout Vandecappelle <arnout@mind.be> (AV)
    1515 *                Sebastien Bourdeauducq <sebastien@milkymist.org> (MM)
    16  *               
     16 *
    1717 *
    1818 *  Changes:
     
    2121 *
    2222 *      * Support spaces in filenames
    23  * 
     23 *
    2424 *    2010-04-29        Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
    25  * 
     25 *
    2626 *      * Added USER/PASS authentication.
    27  * 
     27 *
    2828 *    2001-01-31        Sergei Organov <osv@javad.ru>
    2929 *
     
    245245
    246246/* Configuration table */
    247 extern struct rtems_ftpd_configuration rtems_ftpd_configuration;
     247static struct rtems_ftpd_configuration* ftpd_config;
    248248
    249249/* this is not prototyped in strict ansi mode */
     
    954954  }
    955955
    956   if (!null && rtems_ftpd_configuration.hooks != NULL)
     956  if (!null && ftpd_config->hooks != NULL)
    957957  {
    958958
     
    962962
    963963    i = 0;
    964     hook = &rtems_ftpd_configuration.hooks[i++];
     964    hook = &ftpd_config->hooks[i++];
    965965    while (hook->filename != NULL)
    966966    {
     
    970970        break;
    971971      }
    972       hook = &rtems_ftpd_configuration.hooks[i++];
     972      hook = &ftpd_config->hooks[i++];
    973973    }
    974974  }
     
    983983     */
    984984
    985     char                *bigBufr;
    986     size_t filesize = rtems_ftpd_configuration.max_hook_filesize + 1;
     985    char   *bigBufr;
     986    size_t  filesize = ftpd_config->max_hook_filesize + 1;
    987987
    988988    /*
     
    17671767    info->pass = NULL;
    17681768    info->user = strdup(fname);
    1769     if (rtems_ftpd_configuration.login &&
    1770       !rtems_ftpd_configuration.login(info->user, NULL)) {
     1769    if (ftpd_config->login &&
     1770      !ftpd_config->login(info->user, NULL)) {
    17711771      info->auth = false;
    17721772      send_reply(info, 331, "User name okay, need password.");
     
    17851785      send_reply(info, 332, "Need account to log in");
    17861786    } else {
    1787       if (rtems_ftpd_configuration.login &&
    1788         !rtems_ftpd_configuration.login(info->user, info->pass)) {
     1787      if (ftpd_config->login &&
     1788        !ftpd_config->login(info->user, info->pass)) {
    17891789        info->auth = false;
    17901790        send_reply(info, 530, "Not logged in.");
     
    18271827        char *c;
    18281828        c = strchr(args, ' ');
    1829         if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254) 
     1829        if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254)
    18301830          && (chmod(fname, (mode_t)mask) == 0))
    18311831          send_reply(info, 257, "CHMOD successful.");
     
    20102010
    20112011  addr.sin_family      = AF_INET;
    2012   addr.sin_port        = htons(rtems_ftpd_configuration.port);
     2012  addr.sin_port        = htons(ftpd_config->port);
    20132013  addr.sin_addr.s_addr = htonl(INADDR_ANY);
    20142014  memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
     
    20652065            info->user = NULL;
    20662066            info->pass = NULL;
    2067             if (rtems_ftpd_configuration.login)
     2067            if (ftpd_config->login)
    20682068              info->auth = false;
    20692069            else
     
    20892089 *
    20902090 * Input parameters:
    2091  *
     2091 *    config: constant initial setup.
    20922092 * Output parameters:
    20932093 *    returns RTEMS_SUCCESSFUL on successful start of the daemon.
    20942094 */
    20952095int
    2096 rtems_initialize_ftpd(void)
     2096rtems_ftpd_start(const struct rtems_ftpd_configuration* config)
    20972097{
    20982098  rtems_status_code   sc;
     
    21012101  int count;
    21022102
    2103   if (rtems_ftpd_configuration.port == 0)
    2104   {
    2105     rtems_ftpd_configuration.port = FTPD_CONTROL_PORT;
    2106   }
    2107 
    2108   if (rtems_ftpd_configuration.priority == 0)
    2109   {
    2110     rtems_ftpd_configuration.priority = 40;
    2111   }
    2112   priority = rtems_ftpd_configuration.priority;
    2113 
    2114   ftpd_timeout = rtems_ftpd_configuration.idle;
     2103  if (ftpd_config != NULL)
     2104    return RTEMS_RESOURCE_IN_USE;
     2105
     2106  ftpd_config = malloc(sizeof(*ftpd_config));
     2107  if (ftpd_config == NULL)
     2108    return RTEMS_NO_MEMORY;
     2109
     2110  *ftpd_config = *config;
     2111
     2112  if (ftpd_config->port == 0)
     2113  {
     2114    ftpd_config->port = FTPD_CONTROL_PORT;
     2115  }
     2116
     2117  if (ftpd_config->priority == 0)
     2118  {
     2119    ftpd_config->priority = 40;
     2120  }
     2121  priority = ftpd_config->priority;
     2122
     2123  ftpd_timeout = ftpd_config->idle;
    21152124  if (ftpd_timeout < 0)
    21162125    ftpd_timeout = 0;
    2117   rtems_ftpd_configuration.idle = ftpd_timeout;
    2118 
    2119   ftpd_access = rtems_ftpd_configuration.access;
     2126  ftpd_config->idle = ftpd_timeout;
     2127
     2128  ftpd_access = ftpd_config->access;
    21202129
    21212130  ftpd_root = "/";
    2122   if ( rtems_ftpd_configuration.root &&
    2123        rtems_ftpd_configuration.root[0] == '/' )
    2124     ftpd_root = rtems_ftpd_configuration.root;
    2125 
    2126   rtems_ftpd_configuration.root = ftpd_root;
    2127 
    2128   if (rtems_ftpd_configuration.tasks_count <= 0)
    2129     rtems_ftpd_configuration.tasks_count = 1;
    2130   count = rtems_ftpd_configuration.tasks_count;
     2131  if (ftpd_config->root && ftpd_config->root[0] == '/' )
     2132    ftpd_root = ftpd_config->root;
     2133
     2134  ftpd_config->root = ftpd_root;
     2135
     2136  if (ftpd_config->tasks_count <= 0)
     2137    ftpd_config->tasks_count = 1;
     2138  count = ftpd_config->tasks_count;
    21312139
    21322140  if (!task_pool_init(count, priority))
     
    21582166  }
    21592167
    2160   syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
    2161     count, ((count > 1) ? "s" : ""));
     2168  if (ftpd_config->verbose)
     2169    syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
     2170           count, ((count > 1) ? "s" : ""));
    21622171
    21632172  return RTEMS_SUCCESSFUL;
  • rtemsbsd/include/machine/rtems-bsd-rc-conf-services.h

    rc2ec5f1 r90873cc  
    155155 * Decls for the handlers.
    156156 */
    157 void rc_conf_net_init(void* arg);   /* Installed by default. */
     157void rc_conf_net_init(void* arg);    /* Installed by default. */
     158void rc_conf_ftpd_init(void* arg);   /* ftpd_enabled="YES" */
    158159
    159160/*
  • rtemsbsd/include/rtems/ftpd.h

    rc2ec5f1 r90873cc  
    5555   rtems_shell_login_check_t login;            /* Login check or 0 to ignore
    5656                                                  user/passwd. */
     57   bool                      verbose;          /* Say hello! */
    5758};
    5859
  • testsuite/include/rtems/bsd/test/default-init.h

    rc2ec5f1 r90873cc  
    7474}
    7575
    76 #include <machine/rtems-bsd-sysinit.h>
     76/*
     77 * Configure LibBSD.
     78 */
     79#define RTEMS_BSD_CONFIG_NET_PF_UNIX
     80#define RTEMS_BSD_CONFIG_NET_IF_LAGG
     81#define RTEMS_BSD_CONFIG_NET_IF_VLAN
     82#define RTEMS_BSD_CONFIG_INIT
    7783
    78 SYSINIT_NEED_NET_PF_UNIX;
    79 SYSINIT_NEED_NET_IF_LAGG;
    80 SYSINIT_NEED_NET_IF_VLAN;
     84#include <machine/rtems-bsd-config.h>
    8185
    82 #include <bsp/nexus-devices.h>
    83 
     86/*
     87 * Configure RTEMS.
     88 */
    8489#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    8590#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
  • testsuite/rcconf02/test_main.c

    rc2ec5f1 r90873cc  
    4545#include <rtems/shell.h>
    4646
     47#define RCCONF02_HAS_SHELL
     48
    4749#define TEST_NAME "LIBBSD RC.CONF 2"
    4850
     
    7173  IFACE_VLAN(re0)
    7274
    73 static const char* rc_conf_text =              \
    74   "#\n"                                        \
    75   "# Tests rc.conf. Add every NIC\n"           \
    76   "#\n"                                        \
    77   "hostname=\"rctest\"\n"                      \
    78   "\n"                                         \
    79   "create_args_myvlan=\"vlan 102\"\n"          \
    80   "create_args_yourvlan=\"vlan 202\"\n"        \
    81   "\n"                                         \
    82   RC_CONF_IFACES                               \
    83   "\n"                                         \
    84   RC_CONF_VLANS                                \
    85   "\n"                                         \
    86   "defaultrouter=\"" NET_CFG_GATEWAY_IP "\"\n" \
     75static const char* rc_conf_text =                       \
     76  "#\n"                                                 \
     77  "# Tests rc.conf. Add every NIC\n"                    \
     78  "#\n"                                                 \
     79  "hostname=\"rctest\"\n"                               \
     80  "\n"                                                  \
     81  "create_args_myvlan=\"vlan 102\"\n"                   \
     82  "create_args_yourvlan=\"vlan 202\"\n"                 \
     83  "\n"                                                  \
     84  RC_CONF_IFACES                                        \
     85  "\n"                                                  \
     86  RC_CONF_VLANS                                         \
     87  "\n"                                                  \
     88  "defaultrouter=\"" NET_CFG_GATEWAY_IP "\"\n"          \
     89  "\n"                                                  \
     90  "ftpd_enable=\"YES\"\n"                               \
     91  "ftpd_options=\"-v -p 21 -C 10 -P 150 -L -I 10 -R /\"\n" \
    8792  "n";
    8893
     
    114119{
    115120  test_rc_conf_script();
     121
     122#if defined(RCCONF02_HAS_SHELL)
    116123  rtems_shell_init(
    117124    "SHLL",
     
    123130    NULL
    124131    );
     132#endif /* RCCONF02_HAS_SHELL */
     133
    125134  exit(0);
    126135}
     136
     137/*
     138 * Optional shell for testing this test.
     139 */
     140#if defined(RCCONF02_HAS_SHELL)
    127141
    128142#define CONFIGURE_SHELL_COMMANDS_INIT
     
    164178
    165179#include <rtems/shellconfig.h>
     180#endif /* RCCONF02_HAS_SHELL */
     181
     182#define RTEMS_BSD_CONFIG_BSP_CONFIG
     183#define RTEMS_BSD_CONFIG_SERVICE_FTPD
    166184
    167185#include <rtems/bsd/test/default-init.h>
Note: See TracChangeset for help on using the changeset viewer.