summaryrefslogtreecommitdiffstats
path: root/cpukit/ftpd/ftpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/ftpd/ftpd.c')
-rw-r--r--cpukit/ftpd/ftpd.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/cpukit/ftpd/ftpd.c b/cpukit/ftpd/ftpd.c
index c71a13648c..a925126dee 100644
--- a/cpukit/ftpd/ftpd.c
+++ b/cpukit/ftpd/ftpd.c
@@ -1,3 +1,11 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @brief
+ */
+
/* FIXME: 1. Parse command is a hack. We can do better.
* 2. OSV: hooks support seems to be bad, as it requires storing of
* entire input file in memory. Seems to be better to change it to
@@ -186,6 +194,31 @@
* x5z Filesystem status.
*************************************************************************/
+/*
+ * Copyright (C) 1999 Jake Janovetz <janovetz@tempest.ece.uiuc.edu>
+ *
+ * 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+ */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -543,10 +576,9 @@ send_reply(FTPD_SessionInfo_t *info, int code, const char *text)
* Output parameters:
* returns 1 on success, 0 on failure.
*/
-static int
+static void
set_socket_timeout(int s, int seconds)
{
- int res = 0;
struct timeval tv;
int len = sizeof(tv);
@@ -558,9 +590,6 @@ set_socket_timeout(int s, int seconds)
syslog(LOG_ERR, "ftpd: Can't set send timeout on socket: %s.", serr());
else if(0 != setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, len))
syslog(LOG_ERR, "ftpd: Can't set receive timeout on socket: %s.", serr());
- else
- res = 1;
- return res;
}
/*
@@ -655,8 +684,7 @@ data_socket(FTPD_SessionInfo_t *info)
}
info->data_socket = s;
info->use_default = 1;
- if(s >= 0)
- set_socket_timeout(s, info->idle);
+ set_socket_timeout(s, info->idle);
return s;
}
@@ -1535,8 +1563,8 @@ command_pasv(FTPD_SessionInfo_t *info)
syslog(LOG_ERR, "ftpd: Error binding PASV socket: %s", serr());
else if (0 > listen(s, 1))
syslog(LOG_ERR, "ftpd: Error listening on PASV socket: %s", serr());
- else if (set_socket_timeout(s, info->idle))
{
+ set_socket_timeout(s, info->idle);
if (0 == getsockname(s, (struct sockaddr *)&addr, &addrLen))
{
char buf[FTPD_BUFSIZE];
@@ -1997,12 +2025,11 @@ ftpd_daemon(rtems_task_argument args RTEMS_UNUSED)
ss = accept(s, (struct sockaddr *)&addr, &addrLen);
if (0 > ss)
syslog(LOG_ERR, "ftpd: Error accepting control connection: %s", serr());
- else if(!set_socket_timeout(ss, ftpd_timeout))
- close_socket(ss);
else
{
FTPD_SessionInfo_t *info;
+ set_socket_timeout(ss, ftpd_timeout);
info = task_pool_obtain();
if (NULL == info)
{