mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-24 02:22:03 +08:00
Add ftpd as a service. Add rtems-bsd-config.h for app libbsd set up.
This commit is contained in:
parent
c2ec5f188b
commit
90873cc802
@ -107,6 +107,8 @@ def rtems(mm):
|
|||||||
'rtems/rtems-kvm.c',
|
'rtems/rtems-kvm.c',
|
||||||
'rtems/syslog.c',
|
'rtems/syslog.c',
|
||||||
'ftpd/ftpd.c',
|
'ftpd/ftpd.c',
|
||||||
|
'ftpd/ftpd-init.c',
|
||||||
|
'ftpd/ftpd-service.c',
|
||||||
'ftpfs/ftpfs.c',
|
'ftpfs/ftpfs.c',
|
||||||
'mdns/mdns.c',
|
'mdns/mdns.c',
|
||||||
'mdns/mdns-hostname-default.c',
|
'mdns/mdns-hostname-default.c',
|
||||||
|
@ -1013,6 +1013,8 @@ def build(bld):
|
|||||||
'mDNSResponder/mDNSShared/PlatformCommon.c',
|
'mDNSResponder/mDNSShared/PlatformCommon.c',
|
||||||
'mDNSResponder/mDNSShared/dnssd_clientshim.c',
|
'mDNSResponder/mDNSShared/dnssd_clientshim.c',
|
||||||
'mDNSResponder/mDNSShared/mDNSDebug.c',
|
'mDNSResponder/mDNSShared/mDNSDebug.c',
|
||||||
|
'rtemsbsd/ftpd/ftpd-init.c',
|
||||||
|
'rtemsbsd/ftpd/ftpd-service.c',
|
||||||
'rtemsbsd/ftpd/ftpd.c',
|
'rtemsbsd/ftpd/ftpd.c',
|
||||||
'rtemsbsd/ftpfs/ftpfs.c',
|
'rtemsbsd/ftpfs/ftpfs.c',
|
||||||
'rtemsbsd/local/bus_if.c',
|
'rtemsbsd/local/bus_if.c',
|
||||||
|
39
rtemsbsd/ftpd/ftpd-init.c
Normal file
39
rtemsbsd/ftpd/ftpd-init.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* FTP Server Daemon
|
||||||
|
*
|
||||||
|
* Submitted by: Jake Janovetz <janovetz@tempest.ece.uiuc.edu>
|
||||||
|
*
|
||||||
|
* Changed by: Sergei Organov <osv@javad.ru> (OSV)
|
||||||
|
* Arnout Vandecappelle <arnout@mind.be> (AV)
|
||||||
|
* Sebastien Bourdeauducq <sebastien@milkymist.org> (MM)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* ftpd-init.c
|
||||||
|
*************************************************************************
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* This file contains the legacy daemon initialisation.
|
||||||
|
*
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rtems/ftpd.h>
|
||||||
|
|
||||||
|
/* Configuration table */
|
||||||
|
extern struct rtems_ftpd_configuration rtems_ftpd_configuration;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rtems_initialize_ftpd
|
||||||
|
*
|
||||||
|
* Call the FTPD start function.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
rtems_initialize_ftpd(void)
|
||||||
|
{
|
||||||
|
rtems_ftpd_configuration.verbose = true;
|
||||||
|
return rtems_ftpd_start(&rtems_ftpd_configuration);
|
||||||
|
}
|
179
rtemsbsd/ftpd/ftpd-service.c
Normal file
179
rtemsbsd/ftpd/ftpd-service.c
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FTPD service. To use add to rc.conf:
|
||||||
|
*
|
||||||
|
* ftpd_enable="YES"
|
||||||
|
* ftp_options="-p 21 -C 4 -P 100 -I 300 -R / -L -A rw"
|
||||||
|
*
|
||||||
|
* The options defaults are show. The options are:
|
||||||
|
*
|
||||||
|
* -p port : Port.
|
||||||
|
* -C conns : Maximum connections.
|
||||||
|
* -P priority : FTP thread priority (RTEMS Classis API).
|
||||||
|
* -I secs : Idle timeout in seconds.
|
||||||
|
* -R path : Root path.
|
||||||
|
* -L : Logins using /etc/passwd
|
||||||
|
* -A <rw/rd/wr> : Access, rw=read/write, rd=read, wr=write.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define __need_getopt_newlib
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <rtems/ftpd.h>
|
||||||
|
#include <machine/rtems-bsd-rc-conf-services.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
ftpd_service(rtems_bsd_rc_conf* rc_conf)
|
||||||
|
{
|
||||||
|
struct rtems_ftpd_configuration config = {
|
||||||
|
.priority = 100, /* FTPD task priority */
|
||||||
|
.max_hook_filesize = 0, /* Maximum buffersize for hooks */
|
||||||
|
.port = 21, /* Well-known port */
|
||||||
|
.hooks = NULL, /* List of hooks */
|
||||||
|
.root = NULL, /* Root for FTPD or NULL for "/" */
|
||||||
|
.tasks_count = 4, /* Max. connections */
|
||||||
|
.idle = 5 * 60, /* Idle timeout in seconds or 0 for no (infinite) timeout */
|
||||||
|
.access = 0, /* Access: 0 - r/w, 1 - read-only, 2 - write-only,
|
||||||
|
* 3 - browse-only */
|
||||||
|
.login = NULL /* Login */
|
||||||
|
};
|
||||||
|
rtems_bsd_rc_conf_argc_argv* aa;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
aa = rtems_bsd_rc_conf_argc_argv_create();
|
||||||
|
if (aa == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
r = rtems_bsd_rc_conf_find(rc_conf, "ftpd_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, "ftpd_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, "p:C:P:I:R:LA:v", &data);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'p':
|
||||||
|
config.port = strtoul(data.optarg, &end, 10);
|
||||||
|
if (config.port == 0 || *end != '\0') {
|
||||||
|
fprintf(stderr, "error: ftpd: invalid port\n");
|
||||||
|
config.port = 21;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
config.tasks_count = strtoul(data.optarg, &end, 10);
|
||||||
|
if (config.tasks_count == 0 || *end != '\0') {
|
||||||
|
fprintf(stderr, "error: ftpd: invalid port\n");
|
||||||
|
config.tasks_count = 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
config.priority = strtoul(data.optarg, &end, 10);
|
||||||
|
if (config.priority == 0 || *end != '\0') {
|
||||||
|
fprintf(stderr, "error: ftpd: invalid priority\n");
|
||||||
|
config.priority = 100;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
config.idle = strtoul(data.optarg, &end, 10);
|
||||||
|
if (config.tasks_count == 0 || *end != '\0') {
|
||||||
|
fprintf(stderr, "error: ftpd: invalid idle seconds\n");
|
||||||
|
config.idle = 5 * 60;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
config.root = strdup(data.optarg);
|
||||||
|
if (config.root == NULL) {
|
||||||
|
fprintf(stderr, "error: ftpd: no memory for root path\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
config.login = rtems_shell_login_check;
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
if (strcasecmp("rw", data.optarg) == 0)
|
||||||
|
config.access = 0;
|
||||||
|
else if (strcasecmp("rd", data.optarg) == 0)
|
||||||
|
config.access = 1;
|
||||||
|
else if (strcasecmp("wr", data.optarg) == 0)
|
||||||
|
config.access = 2;
|
||||||
|
else
|
||||||
|
fprintf(stderr, "error: ftp: invalid access option\n");
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose = true;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "error: ftp: unknown option: %s\n", data.optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (verbose) {
|
||||||
|
printf("ftpd: port:%lu conns:%lu pri:%lu idle:%lu root:%s login:%s access:%s\n",
|
||||||
|
config.port, config.tasks_count, config.priority, config.idle,
|
||||||
|
config.root == NULL ? "/" : config.root,
|
||||||
|
config.login == NULL ? "no" : "yes",
|
||||||
|
config.access == 0 ? "read/write" : config.access == 1 ? "read" : "write");
|
||||||
|
}
|
||||||
|
sc = rtems_ftpd_start(&config);
|
||||||
|
if (sc != RTEMS_SUCCESSFUL)
|
||||||
|
fprintf(stderr, "error: ftpd: %s\n", rtems_status_text(sc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rc_conf_ftpd_init(void* arg)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
r = rtems_bsd_rc_conf_service_add("ftpd",
|
||||||
|
"after:network;",
|
||||||
|
ftpd_service);
|
||||||
|
if (r < 0)
|
||||||
|
fprintf(stderr, "error: ftpd service add failed: %s\n", strerror(errno));
|
||||||
|
}
|
@ -13,18 +13,18 @@
|
|||||||
* Changed by: Sergei Organov <osv@javad.ru> (OSV)
|
* Changed by: Sergei Organov <osv@javad.ru> (OSV)
|
||||||
* Arnout Vandecappelle <arnout@mind.be> (AV)
|
* Arnout Vandecappelle <arnout@mind.be> (AV)
|
||||||
* Sebastien Bourdeauducq <sebastien@milkymist.org> (MM)
|
* Sebastien Bourdeauducq <sebastien@milkymist.org> (MM)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Changes:
|
* Changes:
|
||||||
*
|
*
|
||||||
* 2010-12-02 Sebastien Bourdeauducq <sebastien@milkymist.org>
|
* 2010-12-02 Sebastien Bourdeauducq <sebastien@milkymist.org>
|
||||||
*
|
*
|
||||||
* * Support spaces in filenames
|
* * Support spaces in filenames
|
||||||
*
|
*
|
||||||
* 2010-04-29 Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
|
* 2010-04-29 Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
|
||||||
*
|
*
|
||||||
* * Added USER/PASS authentication.
|
* * Added USER/PASS authentication.
|
||||||
*
|
*
|
||||||
* 2001-01-31 Sergei Organov <osv@javad.ru>
|
* 2001-01-31 Sergei Organov <osv@javad.ru>
|
||||||
*
|
*
|
||||||
* * Hacks with current dir and root dir removed in favor of new libio
|
* * Hacks with current dir and root dir removed in favor of new libio
|
||||||
@ -244,7 +244,7 @@ enum
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Configuration table */
|
/* Configuration table */
|
||||||
extern struct rtems_ftpd_configuration rtems_ftpd_configuration;
|
static struct rtems_ftpd_configuration* ftpd_config;
|
||||||
|
|
||||||
/* this is not prototyped in strict ansi mode */
|
/* this is not prototyped in strict ansi mode */
|
||||||
FILE *fdopen (int fildes, const char *mode);
|
FILE *fdopen (int fildes, const char *mode);
|
||||||
@ -953,7 +953,7 @@ command_store(FTPD_SessionInfo_t *info, char const *filename)
|
|||||||
wrt = &discard;
|
wrt = &discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!null && rtems_ftpd_configuration.hooks != NULL)
|
if (!null && ftpd_config->hooks != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Search our list of hooks to see if we need to do something special. */
|
/* Search our list of hooks to see if we need to do something special. */
|
||||||
@ -961,7 +961,7 @@ command_store(FTPD_SessionInfo_t *info, char const *filename)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
hook = &rtems_ftpd_configuration.hooks[i++];
|
hook = &ftpd_config->hooks[i++];
|
||||||
while (hook->filename != NULL)
|
while (hook->filename != NULL)
|
||||||
{
|
{
|
||||||
if (!strcmp(hook->filename, filename))
|
if (!strcmp(hook->filename, filename))
|
||||||
@ -969,7 +969,7 @@ command_store(FTPD_SessionInfo_t *info, char const *filename)
|
|||||||
usehook = hook;
|
usehook = hook;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hook = &rtems_ftpd_configuration.hooks[i++];
|
hook = &ftpd_config->hooks[i++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -982,8 +982,8 @@ command_store(FTPD_SessionInfo_t *info, char const *filename)
|
|||||||
* given name.
|
* given name.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *bigBufr;
|
char *bigBufr;
|
||||||
size_t filesize = rtems_ftpd_configuration.max_hook_filesize + 1;
|
size_t filesize = ftpd_config->max_hook_filesize + 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate space for our "file".
|
* Allocate space for our "file".
|
||||||
@ -1766,8 +1766,8 @@ exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
|
|||||||
free(info->pass);
|
free(info->pass);
|
||||||
info->pass = NULL;
|
info->pass = NULL;
|
||||||
info->user = strdup(fname);
|
info->user = strdup(fname);
|
||||||
if (rtems_ftpd_configuration.login &&
|
if (ftpd_config->login &&
|
||||||
!rtems_ftpd_configuration.login(info->user, NULL)) {
|
!ftpd_config->login(info->user, NULL)) {
|
||||||
info->auth = false;
|
info->auth = false;
|
||||||
send_reply(info, 331, "User name okay, need password.");
|
send_reply(info, 331, "User name okay, need password.");
|
||||||
} else {
|
} else {
|
||||||
@ -1784,8 +1784,8 @@ exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
|
|||||||
if (!info->user) {
|
if (!info->user) {
|
||||||
send_reply(info, 332, "Need account to log in");
|
send_reply(info, 332, "Need account to log in");
|
||||||
} else {
|
} else {
|
||||||
if (rtems_ftpd_configuration.login &&
|
if (ftpd_config->login &&
|
||||||
!rtems_ftpd_configuration.login(info->user, info->pass)) {
|
!ftpd_config->login(info->user, info->pass)) {
|
||||||
info->auth = false;
|
info->auth = false;
|
||||||
send_reply(info, 530, "Not logged in.");
|
send_reply(info, 530, "Not logged in.");
|
||||||
} else {
|
} else {
|
||||||
@ -1826,7 +1826,7 @@ exec_command(FTPD_SessionInfo_t *info, char* cmd, char* args)
|
|||||||
else {
|
else {
|
||||||
char *c;
|
char *c;
|
||||||
c = strchr(args, ' ');
|
c = strchr(args, ' ');
|
||||||
if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254)
|
if((c != NULL) && (sscanf(args, "%o", &mask) == 1) && strncpy(fname, c+1, 254)
|
||||||
&& (chmod(fname, (mode_t)mask) == 0))
|
&& (chmod(fname, (mode_t)mask) == 0))
|
||||||
send_reply(info, 257, "CHMOD successful.");
|
send_reply(info, 257, "CHMOD successful.");
|
||||||
else
|
else
|
||||||
@ -2009,7 +2009,7 @@ ftpd_daemon(rtems_task_argument args __attribute__((unused)))
|
|||||||
syslog(LOG_ERR, "ftpd: Error creating socket: %s", serr());
|
syslog(LOG_ERR, "ftpd: Error creating socket: %s", serr());
|
||||||
|
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_port = htons(rtems_ftpd_configuration.port);
|
addr.sin_port = htons(ftpd_config->port);
|
||||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
|
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
|
||||||
|
|
||||||
@ -2064,7 +2064,7 @@ ftpd_daemon(rtems_task_argument args __attribute__((unused)))
|
|||||||
info->idle = ftpd_timeout;
|
info->idle = ftpd_timeout;
|
||||||
info->user = NULL;
|
info->user = NULL;
|
||||||
info->pass = NULL;
|
info->pass = NULL;
|
||||||
if (rtems_ftpd_configuration.login)
|
if (ftpd_config->login)
|
||||||
info->auth = false;
|
info->auth = false;
|
||||||
else
|
else
|
||||||
info->auth = true;
|
info->auth = true;
|
||||||
@ -2088,46 +2088,54 @@ ftpd_daemon(rtems_task_argument args __attribute__((unused)))
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
*
|
* config: constant initial setup.
|
||||||
* Output parameters:
|
* Output parameters:
|
||||||
* returns RTEMS_SUCCESSFUL on successful start of the daemon.
|
* returns RTEMS_SUCCESSFUL on successful start of the daemon.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
rtems_initialize_ftpd(void)
|
rtems_ftpd_start(const struct rtems_ftpd_configuration* config)
|
||||||
{
|
{
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
rtems_id tid;
|
rtems_id tid;
|
||||||
rtems_task_priority priority;
|
rtems_task_priority priority;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (rtems_ftpd_configuration.port == 0)
|
if (ftpd_config != NULL)
|
||||||
|
return RTEMS_RESOURCE_IN_USE;
|
||||||
|
|
||||||
|
ftpd_config = malloc(sizeof(*ftpd_config));
|
||||||
|
if (ftpd_config == NULL)
|
||||||
|
return RTEMS_NO_MEMORY;
|
||||||
|
|
||||||
|
*ftpd_config = *config;
|
||||||
|
|
||||||
|
if (ftpd_config->port == 0)
|
||||||
{
|
{
|
||||||
rtems_ftpd_configuration.port = FTPD_CONTROL_PORT;
|
ftpd_config->port = FTPD_CONTROL_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtems_ftpd_configuration.priority == 0)
|
if (ftpd_config->priority == 0)
|
||||||
{
|
{
|
||||||
rtems_ftpd_configuration.priority = 40;
|
ftpd_config->priority = 40;
|
||||||
}
|
}
|
||||||
priority = rtems_ftpd_configuration.priority;
|
priority = ftpd_config->priority;
|
||||||
|
|
||||||
ftpd_timeout = rtems_ftpd_configuration.idle;
|
ftpd_timeout = ftpd_config->idle;
|
||||||
if (ftpd_timeout < 0)
|
if (ftpd_timeout < 0)
|
||||||
ftpd_timeout = 0;
|
ftpd_timeout = 0;
|
||||||
rtems_ftpd_configuration.idle = ftpd_timeout;
|
ftpd_config->idle = ftpd_timeout;
|
||||||
|
|
||||||
ftpd_access = rtems_ftpd_configuration.access;
|
ftpd_access = ftpd_config->access;
|
||||||
|
|
||||||
ftpd_root = "/";
|
ftpd_root = "/";
|
||||||
if ( rtems_ftpd_configuration.root &&
|
if (ftpd_config->root && ftpd_config->root[0] == '/' )
|
||||||
rtems_ftpd_configuration.root[0] == '/' )
|
ftpd_root = ftpd_config->root;
|
||||||
ftpd_root = rtems_ftpd_configuration.root;
|
|
||||||
|
|
||||||
rtems_ftpd_configuration.root = ftpd_root;
|
ftpd_config->root = ftpd_root;
|
||||||
|
|
||||||
if (rtems_ftpd_configuration.tasks_count <= 0)
|
if (ftpd_config->tasks_count <= 0)
|
||||||
rtems_ftpd_configuration.tasks_count = 1;
|
ftpd_config->tasks_count = 1;
|
||||||
count = rtems_ftpd_configuration.tasks_count;
|
count = ftpd_config->tasks_count;
|
||||||
|
|
||||||
if (!task_pool_init(count, priority))
|
if (!task_pool_init(count, priority))
|
||||||
{
|
{
|
||||||
@ -2157,8 +2165,9 @@ rtems_initialize_ftpd(void)
|
|||||||
return RTEMS_UNSATISFIED;
|
return RTEMS_UNSATISFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
|
if (ftpd_config->verbose)
|
||||||
count, ((count > 1) ? "s" : ""));
|
syslog(LOG_INFO, "ftpd: FTP daemon started (%d session%s max)",
|
||||||
|
count, ((count > 1) ? "s" : ""));
|
||||||
|
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
133
rtemsbsd/include/machine/rtems-bsd-config.h
Normal file
133
rtemsbsd/include/machine/rtems-bsd-config.h
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure the LibBSD software stack.
|
||||||
|
*
|
||||||
|
* Configuration defines:
|
||||||
|
*
|
||||||
|
* RTEMS_BSD_CONFIG_NET_PF_UNIX : Packet Filter.
|
||||||
|
* RTEMS_BSD_CONFIG_NET_IF_LAGG : Link Aggregetion and Failover.
|
||||||
|
* RTEMS_BSD_CONFIG_NET_IF_VLAN : Virtual LAN.
|
||||||
|
* RTEMS_BSD_CONFIG_SERVICE_FTPD : File Transfer Protocol (FTP).
|
||||||
|
* RTEMS_BSD_CONFIG_BSP_CONFIG : Configure default BSP devices.
|
||||||
|
* RTEMS_BSD_CONFIG_INIT : Configure the LibBSD support.
|
||||||
|
*
|
||||||
|
* Rules for adding to this file:
|
||||||
|
* 1. All user visible defines start with 'RTEMS_BSD_CONFIG_'.
|
||||||
|
* 2. Define an implementation define starting with 'RTEMS_BSD_CFGDECL_'.
|
||||||
|
* 3. Only declare anything in the 'RTEMS_BSD_CONFIG_INIT' section.
|
||||||
|
* 4. Do not use '#ifdef ..' or '#ifndef ..'.
|
||||||
|
* 5. All '#endif' statements need a comment showing the '#if ..' logic.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RTEMS_BSD_CONFIG_h
|
||||||
|
#define _RTEMS_BSD_CONFIG_h
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include the Nexus bus.
|
||||||
|
*/
|
||||||
|
#include <machine/rtems-bsd-nexus-bus.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include the SYSINIT support.
|
||||||
|
*/
|
||||||
|
#include <machine/rtems-bsd-sysinit.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include the services.
|
||||||
|
*/
|
||||||
|
#include <machine/rtems-bsd-rc-conf-services.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
//extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BSD Kernel modules.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unix packet filter.
|
||||||
|
* https://www.freebsd.org/doc/handbook/firewalls-pf.html
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_NET_PF_UNIX)
|
||||||
|
#define RTEMS_BSD_CFGDECL_NET_PF_UNIX SYSINIT_NEED_NET_PF_UNIX
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_NET_PF_UNIX */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Link Aggregation and Failover.
|
||||||
|
* https://www.freebsd.org/doc/handbook/network-aggregation.html
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_NET_IF_LAGG)
|
||||||
|
#define RTEMS_BSD_CFGDECL_IF_LAGG SYSINIT_NEED_NET_IF_LAGG
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_NET_IF_LAGG */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Virtual LAN
|
||||||
|
* https://www.freebsd.org/cgi/man.cgi?query=rc.conf then 'network_interfaces'.
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_NET_IF_VLAN)
|
||||||
|
#define RTEMS_BSD_CFGDECL_NET_IF_VLAN SYSINIT_NEED_NET_IF_VLAN
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_NET_IF_VLAN */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FTPD
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_SERVICE_FTPD)
|
||||||
|
#define RTEMS_BSD_CFGDECL_FTPD RTEMS_BSD_RC_CONF_SYSINT(rc_conf_ftpd)
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_SERVICE_FTPD */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure the system.
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_INIT)
|
||||||
|
/*
|
||||||
|
* If a BSP configuration is requested include the Nexus bus BSP configuration.
|
||||||
|
*/
|
||||||
|
#if defined(RTEMS_BSD_CONFIG_BSP_CONFIG)
|
||||||
|
#include <bsp/nexus-devices.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the networking modules and interfaces.
|
||||||
|
*/
|
||||||
|
RTEMS_BSD_CFGDECL_NET_PF_UNIX;
|
||||||
|
RTEMS_BSD_CFGDECL_IF_LAGG;
|
||||||
|
RTEMS_BSD_CFGDECL_NET_IF_VLAN;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the services.
|
||||||
|
*/
|
||||||
|
RTEMS_BSD_CFGDECL_FTPD;
|
||||||
|
#endif /* RTEMS_BSD_CONFIG_INIT */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _RTEMS_BSD_CONFIG_h */
|
@ -154,7 +154,8 @@ 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" */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added services.
|
* Added services.
|
||||||
|
@ -54,6 +54,7 @@ struct rtems_ftpd_configuration
|
|||||||
3 - browse-only */
|
3 - browse-only */
|
||||||
rtems_shell_login_check_t login; /* Login check or 0 to ignore
|
rtems_shell_login_check_t login; /* Login check or 0 to ignore
|
||||||
user/passwd. */
|
user/passwd. */
|
||||||
|
bool verbose; /* Say hello! */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -73,14 +73,19 @@ rtems_task Init(
|
|||||||
assert( 0 );
|
assert( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <machine/rtems-bsd-sysinit.h>
|
/*
|
||||||
|
* Configure LibBSD.
|
||||||
|
*/
|
||||||
|
#define RTEMS_BSD_CONFIG_NET_PF_UNIX
|
||||||
|
#define RTEMS_BSD_CONFIG_NET_IF_LAGG
|
||||||
|
#define RTEMS_BSD_CONFIG_NET_IF_VLAN
|
||||||
|
#define RTEMS_BSD_CONFIG_INIT
|
||||||
|
|
||||||
SYSINIT_NEED_NET_PF_UNIX;
|
#include <machine/rtems-bsd-config.h>
|
||||||
SYSINIT_NEED_NET_IF_LAGG;
|
|
||||||
SYSINIT_NEED_NET_IF_VLAN;
|
|
||||||
|
|
||||||
#include <bsp/nexus-devices.h>
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure RTEMS.
|
||||||
|
*/
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#include <rtems/console.h>
|
#include <rtems/console.h>
|
||||||
#include <rtems/shell.h>
|
#include <rtems/shell.h>
|
||||||
|
|
||||||
|
#define RCCONF02_HAS_SHELL
|
||||||
|
|
||||||
#define TEST_NAME "LIBBSD RC.CONF 2"
|
#define TEST_NAME "LIBBSD RC.CONF 2"
|
||||||
|
|
||||||
#define IFACE_IPV4(iface) \
|
#define IFACE_IPV4(iface) \
|
||||||
@ -70,20 +72,23 @@
|
|||||||
IFACE_VLAN(em0) \
|
IFACE_VLAN(em0) \
|
||||||
IFACE_VLAN(re0)
|
IFACE_VLAN(re0)
|
||||||
|
|
||||||
static const char* rc_conf_text = \
|
static const char* rc_conf_text = \
|
||||||
"#\n" \
|
"#\n" \
|
||||||
"# Tests rc.conf. Add every NIC\n" \
|
"# Tests rc.conf. Add every NIC\n" \
|
||||||
"#\n" \
|
"#\n" \
|
||||||
"hostname=\"rctest\"\n" \
|
"hostname=\"rctest\"\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
"create_args_myvlan=\"vlan 102\"\n" \
|
"create_args_myvlan=\"vlan 102\"\n" \
|
||||||
"create_args_yourvlan=\"vlan 202\"\n" \
|
"create_args_yourvlan=\"vlan 202\"\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
RC_CONF_IFACES \
|
RC_CONF_IFACES \
|
||||||
"\n" \
|
"\n" \
|
||||||
RC_CONF_VLANS \
|
RC_CONF_VLANS \
|
||||||
"\n" \
|
"\n" \
|
||||||
"defaultrouter=\"" NET_CFG_GATEWAY_IP "\"\n" \
|
"defaultrouter=\"" NET_CFG_GATEWAY_IP "\"\n" \
|
||||||
|
"\n" \
|
||||||
|
"ftpd_enable=\"YES\"\n" \
|
||||||
|
"ftpd_options=\"-v -p 21 -C 10 -P 150 -L -I 10 -R /\"\n" \
|
||||||
"n";
|
"n";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -113,6 +118,8 @@ static void
|
|||||||
test_main(void)
|
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,
|
||||||
@ -122,9 +129,16 @@ test_main(void)
|
|||||||
true,
|
true,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
#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>
|
||||||
@ -163,5 +177,9 @@ 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_SERVICE_FTPD
|
||||||
|
|
||||||
#include <rtems/bsd/test/default-init.h>
|
#include <rtems/bsd/test/default-init.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user