mirror of
https://github.com/kingk85/uFTP.git
synced 2025-07-25 13:16:12 +03:00
merging with TLS branch
This commit is contained in:
@ -1,67 +0,0 @@
|
||||
#Linux Generic
|
||||
CC=gcc
|
||||
|
||||
OUTPATH=./build/
|
||||
SOURCE_MODULES_PATH=./library/
|
||||
|
||||
#FOR DEBUG PURPOSE
|
||||
#CFLAGS=-c -Wall -I. -g -O0
|
||||
CFLAGS=-c -Wall -I.
|
||||
OPTIMIZATION=-O3
|
||||
HEADERS=-I
|
||||
LIBPATH=./build/modules/
|
||||
BUILDFILES=start uFTP end
|
||||
|
||||
#DEFINITIONS=
|
||||
|
||||
#TO ENABLE THE LARGE FILE SUPPORT UNCOMMENT THE NEXT LINE
|
||||
DEFINITIONS=-D_LARGEFILE64_SOURCE
|
||||
|
||||
all: $(BUILDFILES)
|
||||
|
||||
start:
|
||||
@echo Compiler: $(CC)
|
||||
@echo Output Directory: $(OUTPATH)
|
||||
@echo CGI FILES: $(BUILDFILES)
|
||||
@rm -rf $(LIBPATH)*.o $(OUTPATH)uFTP
|
||||
@echo "Clean ok"
|
||||
|
||||
end:
|
||||
@echo Build process end
|
||||
|
||||
uFTP: uFTP.c fileManagement.o configRead.o logFunctions.o ftpCommandElaborate.o ftpData.o ftpServer.o daemon.o signals.o connection.o
|
||||
@$(CC) $(DEFINITIONS) uFTP.c $(LIBPATH)dynamicVectors.o $(LIBPATH)fileManagement.o $(LIBPATH)configRead.o $(LIBPATH)logFunctions.o $(LIBPATH)ftpCommandElaborate.o $(LIBPATH)ftpData.o $(LIBPATH)ftpServer.o $(LIBPATH)daemon.o $(LIBPATH)signals.o $(LIBPATH)connection.o -o $(OUTPATH)uFTP -lpthread
|
||||
|
||||
daemon.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)daemon.c -o $(LIBPATH)daemon.o
|
||||
|
||||
dynamicVectors.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)dynamicVectors.c -o $(LIBPATH)dynamicVectors.o
|
||||
|
||||
configRead.o: dynamicVectors.o fileManagement.o
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)configRead.c -o $(LIBPATH)configRead.o
|
||||
|
||||
fileManagement.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)fileManagement.c -o $(LIBPATH)fileManagement.o
|
||||
|
||||
signals.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)signals.c -o $(LIBPATH)signals.o
|
||||
|
||||
connection.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)connection.c -o $(LIBPATH)connection.o
|
||||
|
||||
logFunctions.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)logFunctions.c -o $(LIBPATH)logFunctions.o
|
||||
|
||||
ftpCommandElaborate.o:
|
||||
@$(CC) $(CFLAGS) ftpCommandElaborate.c -o $(LIBPATH)ftpCommandElaborate.o
|
||||
|
||||
ftpData.o:
|
||||
@$(CC) $(CFLAGS) ftpData.c -o $(LIBPATH)ftpData.o
|
||||
|
||||
ftpServer.o:
|
||||
@$(CC) $(CFLAGS) ftpServer.c -o $(LIBPATH)ftpServer.o
|
||||
|
||||
clean:
|
||||
@rm -rf $(LIBPATH)*.o $(OUTPATH)uFTP
|
||||
@echo "Clean ok"
|
170
Makefile
170
Makefile
@ -1,128 +1,78 @@
|
||||
#
|
||||
# There exist several targets which are by default empty and which can be
|
||||
# used for execution of your targets. These targets are usually executed
|
||||
# before and after some main targets. They are:
|
||||
#
|
||||
# .build-pre: called before 'build' target
|
||||
# .build-post: called after 'build' target
|
||||
# .clean-pre: called before 'clean' target
|
||||
# .clean-post: called after 'clean' target
|
||||
# .clobber-pre: called before 'clobber' target
|
||||
# .clobber-post: called after 'clobber' target
|
||||
# .all-pre: called before 'all' target
|
||||
# .all-post: called after 'all' target
|
||||
# .help-pre: called before 'help' target
|
||||
# .help-post: called after 'help' target
|
||||
#
|
||||
# Targets beginning with '.' are not intended to be called on their own.
|
||||
#
|
||||
# Main targets can be executed directly, and they are:
|
||||
#
|
||||
# build build a specific configuration
|
||||
# clean remove built files from a configuration
|
||||
# clobber remove all built files
|
||||
# all build all configurations
|
||||
# help print help mesage
|
||||
#
|
||||
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
|
||||
# .help-impl are implemented in nbproject/makefile-impl.mk.
|
||||
#
|
||||
# Available make variables:
|
||||
#
|
||||
# CND_BASEDIR base directory for relative paths
|
||||
# CND_DISTDIR default top distribution directory (build artifacts)
|
||||
# CND_BUILDDIR default top build directory (object files, ...)
|
||||
# CONF name of current configuration
|
||||
# CND_PLATFORM_${CONF} platform name (current configuration)
|
||||
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
|
||||
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
|
||||
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
|
||||
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
|
||||
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
|
||||
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
|
||||
#
|
||||
# NOCDDL
|
||||
#Linux Generic
|
||||
CC=gcc
|
||||
|
||||
OUTPATH=./build/
|
||||
SOURCE_MODULES_PATH=./library/
|
||||
|
||||
#FOR DEBUG PURPOSE
|
||||
CFLAGSTEMP=-c -Wall -I. -g -O0
|
||||
#CFLAGSTEMP=-c -Wall -I.
|
||||
OPTIMIZATION=-O3
|
||||
HEADERS=-I
|
||||
LIBPATH=./build/modules/
|
||||
BUILDFILES=start uFTP end
|
||||
LIBS=-lpthread
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
CCADMIN=CCadmin
|
||||
#ENABLE_LARGE_FILE_SUPPORT=
|
||||
#TO ENABLE THE LARGE FILE SUPPORT UNCOMMENT THE NEXT LINE
|
||||
ENABLE_LARGE_FILE_SUPPORT=-D LARGE_FILE_SUPPORT_ENABLED -D _LARGEFILE64_SOURCE
|
||||
|
||||
#ENABLE_OPENSSL_SUPPORT=
|
||||
#TO ENABLE OPENSSL SUPPORT UNCOMMENT NEXT 2 LINES
|
||||
ENABLE_OPENSSL_SUPPORT=-D OPENSSL_ENABLED
|
||||
LIBS=-lpthread -lssl -lcrypto
|
||||
|
||||
# build
|
||||
build: .build-post
|
||||
CFLAGS=$(CFLAGSTEMP) $(ENABLE_LARGE_FILE_SUPPORT) $(ENABLE_OPENSSL_SUPPORT)
|
||||
|
||||
.build-pre:
|
||||
# Add your pre 'build' code here...
|
||||
all: $(BUILDFILES)
|
||||
|
||||
.build-post: .build-impl
|
||||
# Add your post 'build' code here...
|
||||
start:
|
||||
@echo Compiler: $(CC)
|
||||
@echo Output Directory: $(OUTPATH)
|
||||
@echo CGI FILES: $(BUILDFILES)
|
||||
@rm -rf $(LIBPATH)*.o $(OUTPATH)uFTP
|
||||
@echo "Clean ok"
|
||||
|
||||
end:
|
||||
@echo Build process end
|
||||
|
||||
# clean
|
||||
clean: .clean-post
|
||||
uFTP: uFTP.c fileManagement.o configRead.o logFunctions.o ftpCommandElaborate.o ftpData.o ftpServer.o daemon.o signals.o connection.o openSsl.o
|
||||
@$(CC) $(ENABLE_LARGE_FILE_SUPPORT) $(ENABLE_OPENSSL_SUPPORT) uFTP.c $(LIBPATH)dynamicVectors.o $(LIBPATH)fileManagement.o $(LIBPATH)configRead.o $(LIBPATH)logFunctions.o $(LIBPATH)ftpCommandElaborate.o $(LIBPATH)ftpData.o $(LIBPATH)ftpServer.o $(LIBPATH)daemon.o $(LIBPATH)signals.o $(LIBPATH)connection.o $(LIBPATH)openSsl.o -o $(OUTPATH)uFTP $(LIBS)
|
||||
|
||||
.clean-pre:
|
||||
# Add your pre 'clean' code here...
|
||||
daemon.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)daemon.c -o $(LIBPATH)daemon.o
|
||||
|
||||
.clean-post: .clean-impl
|
||||
# Add your post 'clean' code here...
|
||||
dynamicVectors.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)dynamicVectors.c -o $(LIBPATH)dynamicVectors.o
|
||||
|
||||
openSsl.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)openSsl.c -o $(LIBPATH)openSsl.o
|
||||
|
||||
configRead.o: dynamicVectors.o fileManagement.o
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)configRead.c -o $(LIBPATH)configRead.o
|
||||
|
||||
# clobber
|
||||
clobber: .clobber-post
|
||||
fileManagement.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)fileManagement.c -o $(LIBPATH)fileManagement.o
|
||||
|
||||
.clobber-pre:
|
||||
# Add your pre 'clobber' code here...
|
||||
signals.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)signals.c -o $(LIBPATH)signals.o
|
||||
|
||||
connection.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)connection.c -o $(LIBPATH)connection.o
|
||||
|
||||
.clobber-post: .clobber-impl
|
||||
# Add your post 'clobber' code here...
|
||||
logFunctions.o:
|
||||
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)logFunctions.c -o $(LIBPATH)logFunctions.o
|
||||
|
||||
ftpCommandElaborate.o:
|
||||
@$(CC) $(CFLAGS) ftpCommandElaborate.c -o $(LIBPATH)ftpCommandElaborate.o
|
||||
|
||||
# all
|
||||
all: .all-post
|
||||
ftpData.o:
|
||||
@$(CC) $(CFLAGS) ftpData.c -o $(LIBPATH)ftpData.o
|
||||
|
||||
.all-pre:
|
||||
# Add your pre 'all' code here...
|
||||
ftpServer.o: openSsl.o
|
||||
@$(CC) $(CFLAGS) ftpServer.c -o $(LIBPATH)ftpServer.o
|
||||
|
||||
.all-post: .all-impl
|
||||
# Add your post 'all' code here...
|
||||
|
||||
|
||||
# build tests
|
||||
build-tests: .build-tests-post
|
||||
|
||||
.build-tests-pre:
|
||||
# Add your pre 'build-tests' code here...
|
||||
|
||||
.build-tests-post: .build-tests-impl
|
||||
# Add your post 'build-tests' code here...
|
||||
|
||||
|
||||
# run tests
|
||||
test: .test-post
|
||||
|
||||
.test-pre: build-tests
|
||||
# Add your pre 'test' code here...
|
||||
|
||||
.test-post: .test-impl
|
||||
# Add your post 'test' code here...
|
||||
|
||||
|
||||
# help
|
||||
help: .help-post
|
||||
|
||||
.help-pre:
|
||||
# Add your pre 'help' code here...
|
||||
|
||||
.help-post: .help-impl
|
||||
# Add your post 'help' code here...
|
||||
|
||||
|
||||
|
||||
# include project implementation makefile
|
||||
include nbproject/Makefile-impl.mk
|
||||
|
||||
# include project make variables
|
||||
include nbproject/Makefile-variables.mk
|
||||
clean:
|
||||
@rm -rf $(LIBPATH)*.o $(OUTPATH)uFTP
|
||||
@echo "Clean ok"
|
||||
|
128
MakefileNetBeans
Normal file
128
MakefileNetBeans
Normal file
@ -0,0 +1,128 @@
|
||||
#
|
||||
# There exist several targets which are by default empty and which can be
|
||||
# used for execution of your targets. These targets are usually executed
|
||||
# before and after some main targets. They are:
|
||||
#
|
||||
# .build-pre: called before 'build' target
|
||||
# .build-post: called after 'build' target
|
||||
# .clean-pre: called before 'clean' target
|
||||
# .clean-post: called after 'clean' target
|
||||
# .clobber-pre: called before 'clobber' target
|
||||
# .clobber-post: called after 'clobber' target
|
||||
# .all-pre: called before 'all' target
|
||||
# .all-post: called after 'all' target
|
||||
# .help-pre: called before 'help' target
|
||||
# .help-post: called after 'help' target
|
||||
#
|
||||
# Targets beginning with '.' are not intended to be called on their own.
|
||||
#
|
||||
# Main targets can be executed directly, and they are:
|
||||
#
|
||||
# build build a specific configuration
|
||||
# clean remove built files from a configuration
|
||||
# clobber remove all built files
|
||||
# all build all configurations
|
||||
# help print help mesage
|
||||
#
|
||||
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
|
||||
# .help-impl are implemented in nbproject/makefile-impl.mk.
|
||||
#
|
||||
# Available make variables:
|
||||
#
|
||||
# CND_BASEDIR base directory for relative paths
|
||||
# CND_DISTDIR default top distribution directory (build artifacts)
|
||||
# CND_BUILDDIR default top build directory (object files, ...)
|
||||
# CONF name of current configuration
|
||||
# CND_PLATFORM_${CONF} platform name (current configuration)
|
||||
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
|
||||
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
|
||||
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
|
||||
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
|
||||
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
|
||||
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
CCADMIN=CCadmin
|
||||
|
||||
|
||||
# build
|
||||
build: .build-post
|
||||
|
||||
.build-pre:
|
||||
# Add your pre 'build' code here...
|
||||
|
||||
.build-post: .build-impl
|
||||
# Add your post 'build' code here...
|
||||
|
||||
|
||||
# clean
|
||||
clean: .clean-post
|
||||
|
||||
.clean-pre:
|
||||
# Add your pre 'clean' code here...
|
||||
|
||||
.clean-post: .clean-impl
|
||||
# Add your post 'clean' code here...
|
||||
|
||||
|
||||
# clobber
|
||||
clobber: .clobber-post
|
||||
|
||||
.clobber-pre:
|
||||
# Add your pre 'clobber' code here...
|
||||
|
||||
.clobber-post: .clobber-impl
|
||||
# Add your post 'clobber' code here...
|
||||
|
||||
|
||||
# all
|
||||
all: .all-post
|
||||
|
||||
.all-pre:
|
||||
# Add your pre 'all' code here...
|
||||
|
||||
.all-post: .all-impl
|
||||
# Add your post 'all' code here...
|
||||
|
||||
|
||||
# build tests
|
||||
build-tests: .build-tests-post
|
||||
|
||||
.build-tests-pre:
|
||||
# Add your pre 'build-tests' code here...
|
||||
|
||||
.build-tests-post: .build-tests-impl
|
||||
# Add your post 'build-tests' code here...
|
||||
|
||||
|
||||
# run tests
|
||||
test: .test-post
|
||||
|
||||
.test-pre: build-tests
|
||||
# Add your pre 'test' code here...
|
||||
|
||||
.test-post: .test-impl
|
||||
# Add your post 'test' code here...
|
||||
|
||||
|
||||
# help
|
||||
help: .help-post
|
||||
|
||||
.help-pre:
|
||||
# Add your pre 'help' code here...
|
||||
|
||||
.help-post: .help-impl
|
||||
# Add your post 'help' code here...
|
||||
|
||||
|
||||
|
||||
# include project implementation makefile
|
||||
include nbproject/Makefile-impl.mk
|
||||
|
||||
# include project make variables
|
||||
include nbproject/Makefile-variables.mk
|
133
README.md
133
README.md
@ -1,3 +1,132 @@
|
||||
# uFTP
|
||||
This project is a very easy to configure and light FTP server designed for servers, embedded arm devices and every other common usage.
|
||||
About uFTP
|
||||
|
||||
uFTP is a light FTP server designed for servers and embedded arm devices, is provided under MIT license terms.
|
||||
Visit the official project website to obtain more information: http://www.uftpserver.com/
|
||||
|
||||
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org)
|
||||
|
||||
The MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
OpenSSL License
|
||||
---------------
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. 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.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
Original SSLeay License
|
||||
-----------------------
|
||||
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
Binary file not shown.
@ -1,29 +0,0 @@
|
||||
build/Debug/GNU-Linux/ftpCommandElaborate.o: ftpCommandElaborate.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h ftpData.h library/dynamicVectors.h ftpServer.h \
|
||||
library/logFunctions.h library/fileManagement.h library/configRead.h \
|
||||
library/dynamicVectors.h library/../ftpData.h ftpCommandsElaborate.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpData.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpServer.h:
|
||||
|
||||
library/logFunctions.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
Binary file not shown.
@ -1,27 +0,0 @@
|
||||
build/Debug/GNU-Linux/ftpData.o: ftpData.c library/dynamicVectors.h \
|
||||
library/fileManagement.h library/dynamicVectors.h ftpServer.h \
|
||||
ftpCommandsElaborate.h ftpData.h library/dynamicVectors.h \
|
||||
library/configRead.h library/dynamicVectors.h library/../ftpData.h \
|
||||
library/fileManagement.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpServer.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
||||
|
||||
ftpData.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/fileManagement.h:
|
Binary file not shown.
@ -1,33 +0,0 @@
|
||||
build/Debug/GNU-Linux/ftpServer.o: ftpServer.c library/dynamicVectors.h \
|
||||
library/fileManagement.h library/dynamicVectors.h ftpServer.h ftpData.h \
|
||||
library/dynamicVectors.h ftpCommandsElaborate.h library/fileManagement.h \
|
||||
library/logFunctions.h library/configRead.h library/dynamicVectors.h \
|
||||
library/../ftpData.h library/signals.h library/connection.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpServer.h:
|
||||
|
||||
ftpData.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/logFunctions.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/signals.h:
|
||||
|
||||
library/connection.h:
|
Binary file not shown.
@ -1,23 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/configRead.o: library/configRead.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/configRead.h library/dynamicVectors.h \
|
||||
library/../ftpData.h library/../library/dynamicVectors.h \
|
||||
library/fileManagement.h library/daemon.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/../library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/daemon.h:
|
Binary file not shown.
@ -1,16 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/connection.o: library/connection.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/../ftpData.h \
|
||||
library/../library/dynamicVectors.h library/connection.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/../library/dynamicVectors.h:
|
||||
|
||||
library/connection.h:
|
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/daemon.o: library/daemon.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/fileManagement.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/dynamicVectors.o: library/dynamicVectors.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/dynamicVectors.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/dynamicVectors.h:
|
Binary file not shown.
@ -1,14 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/fileManagement.o: library/fileManagement.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/logFunctions.o: library/logFunctions.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/logFunctions.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/logFunctions.h:
|
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
build/Debug/GNU-Linux/library/signals.o: library/signals.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/../ftpServer.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpServer.h:
|
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
build/Debug/GNU-Linux/uFTP.o: uFTP.c library/dynamicVectors.h \
|
||||
library/fileManagement.h library/dynamicVectors.h ftpServer.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpServer.h:
|
Binary file not shown.
@ -1,22 +0,0 @@
|
||||
build/Release/GNU-Linux/ftpCommandElaborate.o: ftpCommandElaborate.c \
|
||||
ftpData.h library/dynamicVectors.h ftpServer.h library/logFunctions.h \
|
||||
library/fileManagement.h library/dynamicVectors.h library/configRead.h \
|
||||
library/../ftpData.h ftpCommandsElaborate.h
|
||||
|
||||
ftpData.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpServer.h:
|
||||
|
||||
library/logFunctions.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
Binary file not shown.
@ -1,20 +0,0 @@
|
||||
build/Release/GNU-Linux/ftpData.o: ftpData.c ftpServer.h \
|
||||
ftpCommandsElaborate.h ftpData.h library/dynamicVectors.h \
|
||||
library/configRead.h library/dynamicVectors.h library/../ftpData.h \
|
||||
library/fileManagement.h
|
||||
|
||||
ftpServer.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
||||
|
||||
ftpData.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/fileManagement.h:
|
Binary file not shown.
@ -1,26 +0,0 @@
|
||||
build/Release/GNU-Linux/ftpServer.o: ftpServer.c ftpServer.h ftpData.h \
|
||||
library/dynamicVectors.h ftpCommandsElaborate.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/logFunctions.h library/configRead.h \
|
||||
library/../ftpData.h library/signals.h library/connection.h
|
||||
|
||||
ftpServer.h:
|
||||
|
||||
ftpData.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/logFunctions.h:
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/signals.h:
|
||||
|
||||
library/connection.h:
|
Binary file not shown.
@ -1,16 +0,0 @@
|
||||
build/Release/GNU-Linux/library/configRead.o: library/configRead.c \
|
||||
library/configRead.h library/dynamicVectors.h library/../ftpData.h \
|
||||
library/../library/dynamicVectors.h library/fileManagement.h \
|
||||
library/daemon.h
|
||||
|
||||
library/configRead.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/../library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/daemon.h:
|
Binary file not shown.
@ -1,9 +0,0 @@
|
||||
build/Release/GNU-Linux/library/connection.o: library/connection.c \
|
||||
library/../ftpData.h library/../library/dynamicVectors.h \
|
||||
library/connection.h
|
||||
|
||||
library/../ftpData.h:
|
||||
|
||||
library/../library/dynamicVectors.h:
|
||||
|
||||
library/connection.h:
|
Binary file not shown.
@ -1,6 +0,0 @@
|
||||
build/Release/GNU-Linux/library/daemon.o: library/daemon.c \
|
||||
library/fileManagement.h library/dynamicVectors.h
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
build/Release/GNU-Linux/library/dynamicVectors.o: \
|
||||
library/dynamicVectors.c library/dynamicVectors.h
|
||||
|
||||
library/dynamicVectors.h:
|
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
build/Release/GNU-Linux/library/fileManagement.o: \
|
||||
library/fileManagement.c library/fileManagement.h \
|
||||
library/dynamicVectors.h
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
build/Release/GNU-Linux/library/logFunctions.o: library/logFunctions.c \
|
||||
library/logFunctions.h
|
||||
|
||||
library/logFunctions.h:
|
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
build/Release/GNU-Linux/library/signals.o: library/signals.c \
|
||||
library/../ftpServer.h
|
||||
|
||||
library/../ftpServer.h:
|
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
build/Release/GNU-Linux/uFTP.o: uFTP.c ftpServer.h
|
||||
|
||||
ftpServer.h:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/modules/openSsl.o
Normal file
BIN
build/modules/openSsl.o
Normal file
Binary file not shown.
Binary file not shown.
31
cert.pem
Normal file
31
cert.pem
Normal file
@ -0,0 +1,31 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFYDCCA0igAwIBAgIJAKwUkwIPWR4KMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQwHhcNMTgxMTI0MTE0NjQyWhcNMTkxMTI0MTE0NjQyWjBF
|
||||
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
|
||||
CgKCAgEAxtffV5tVrEF9pXAVaDmA2ObGchVThV+8P78W0bJFOBNqDlIrmDtSgNdA
|
||||
/MUOndLGgit2VeQo35w5YCxHpX8aR/hm3LNwK7MOy8Vq0xtafasSzdZAuv1Qfq8Q
|
||||
yVNOc4lZXOHURAmULooj4tM5a0jbQjGhB85FWyhlZDMLM+d4/1C17C6HOS9jpFgy
|
||||
oCPADsUmqHDJ4gKn6ly8lW5ulDtDwjIXFJSFq+NqQ7DnZburpxVxbJzy2vdySatx
|
||||
EbfVoQNUyInJWQ5sxlIk4uFmfeixmponX+IWfv6bQ2x4oH93o0av1wb4/bJj8C92
|
||||
wmxO2a6sH8gQjOR7jDoXBuRAu8ghPzEXRDMfmWUcdHIQDymgWOb63JPF+9MLZK/Q
|
||||
8WB1xGYdZ98qvvVmOmTqTeuAzGhQDMfxA4OSeLmdD//aI/6ciGqxUrGNJVf6jyNt
|
||||
u72bCd/R553/STp+X9CIGRlBKlHL523YBkVEo6UFGtCqfMIQOtIS/frgfq48UpYI
|
||||
CyVBkPv6bvHkJjGJYswLs//saEnfv4bunMAgzkn/GXVMxMMnEQXwHNtTqinLkFlt
|
||||
sEc8kr9KHUx/T+QIZrqzDJmS7HLWuneMyBstSvY4XP83TjiuzVm5R7UtqmEOwx5k
|
||||
dVFH7/2x03Hm+GsC59xPDnb77l2h64FaLnizvgn01JMSE7+jHeMCAwEAAaNTMFEw
|
||||
HQYDVR0OBBYEFL06WcF7b8AhRJPEr8XimqQwzs12MB8GA1UdIwQYMBaAFL06WcF7
|
||||
b8AhRJPEr8XimqQwzs12MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
|
||||
ggIBAC7r1tZTPiQSB0i7pJfoRlYM+CTUymUZnBZi2MSE89+VTvuXIS7aDD7l78qa
|
||||
SjBU3KwNuRYhcmHUUOf/kh3cXQFKwpr6gAz3gzKIOOqcnt0KYRGgcrEHTnw4ONy4
|
||||
YxC/rqmi9qk7MF4ahX8S1rusHrf2XonUJlsRoKqWzIz6+VlDuQOlLbgkKOr041YI
|
||||
OflCbZTgds0w+lAV5pQ5T8DzldIRRdj50Us2t8It8F25yG4chTebtlSX6bHO79f6
|
||||
xYeUCmciZaRTJAX/FAxeSlWmL0ygBOQs0c6u7gV+QHgmmxKhHcQSWVDnBBcpa1fK
|
||||
yZG6fH7va0IFlyeCPmqYFxziGwUJjkjGdBj3ub/tasaiTYzvd58mG58a+FCzeQLZ
|
||||
ijbA3a7FBgPQxyF2Ijn5UNEAmeZRDzqRVH9D/vbZHKSyMuUK8NR/BbxOEIprn4sY
|
||||
SrS97WxlT/wjStG/wnc+GgDui7mJ1yikzxp4UcEsXp6fLMhqBfi6jNFOiD0UwLGN
|
||||
fbmdM71sSwZqviXxLi3/+2nNTT29XkYOhtCcMSOMFa39g5KNlSs0vcRqQsdYtXlu
|
||||
FnvV/27fjJazvpHzC7f6HL4VSOsOC55qsbgLP1OGXgpgJVJnOlfHl4gadsI9wU1w
|
||||
jBoIHCZr/BJVC9GdZkzs3T05TNRjiX1OCE73b5VaUaWqcIKg
|
||||
-----END CERTIFICATE-----
|
BIN
dist/Debug/GNU-Linux/uftp
vendored
BIN
dist/Debug/GNU-Linux/uftp
vendored
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -37,7 +37,8 @@
|
||||
#define FTP_CHMODE_COMMAND_RETURN_CODE_NO_FILE 2
|
||||
#define FTP_CHMODE_COMMAND_RETURN_CODE_NO_PERMISSIONS 3
|
||||
#define FTP_CHMODE_COMMAND_RETURN_NAME_TOO_LONG 4
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include "ftpData.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -46,39 +47,42 @@ extern "C" {
|
||||
|
||||
|
||||
/* Elaborate the User login command */
|
||||
int parseCommandUser(clientDataType *theClientData);
|
||||
int parseCommandSite(clientDataType *theClientData);
|
||||
int parseCommandUser(ftpDataType * data, int socketId);
|
||||
int parseCommandSite(ftpDataType * data, int socketId);
|
||||
int parseCommandPass(ftpDataType * data, int socketId);
|
||||
int parseCommandAuth(clientDataType *theClientData);
|
||||
int parseCommandPwd(clientDataType *theClientData);
|
||||
int parseCommandSyst(clientDataType *theClientData);
|
||||
int parseCommandFeat(clientDataType *theClientData);
|
||||
int parseCommandStruF(clientDataType *theClientData);
|
||||
int parseCommandTypeI(clientDataType *theClientData);
|
||||
int parseCommandModeS(clientDataType *theClientData);
|
||||
int parseCommandTypeA(clientDataType *theClientData);
|
||||
int parseCommandAuth(ftpDataType * data, int socketId);
|
||||
int parseCommandPwd(ftpDataType * data, int socketId);
|
||||
int parseCommandSyst(ftpDataType * data, int socketId);
|
||||
int parseCommandFeat(ftpDataType * data, int socketId);
|
||||
int parseCommandProt(ftpDataType * data, int socketId);
|
||||
int parseCommandCcc(ftpDataType * data, int socketId);
|
||||
int parseCommandPbsz(ftpDataType * data, int socketId);
|
||||
int parseCommandStruF(ftpDataType * data, int socketId);
|
||||
int parseCommandTypeI(ftpDataType * data, int socketId);
|
||||
int parseCommandModeS(ftpDataType * data, int socketId);
|
||||
int parseCommandTypeA(ftpDataType * data, int socketId);
|
||||
int parseCommandAbor(ftpDataType * data, int socketId);
|
||||
int parseCommandPasv(ftpDataType * data, int socketId);
|
||||
int parseCommandPort(ftpDataType * data, int socketId);
|
||||
int parseCommandList(ftpDataType * data, int socketId);
|
||||
int parseCommandNlst(ftpDataType * data, int socketId);
|
||||
int parseCommandRetr(ftpDataType * data, int socketId);
|
||||
int parseCommandMkd(clientDataType *theClientData);
|
||||
int parseCommandNoop(clientDataType *theClientData);
|
||||
int notLoggedInMessage(clientDataType *theClientData);
|
||||
int parseCommandRmd(clientDataType *theClientData);
|
||||
int parseCommandMkd(ftpDataType * data, int socketId);
|
||||
int parseCommandNoop(ftpDataType * data, int socketId);
|
||||
int notLoggedInMessage(ftpDataType * data, int socketId);
|
||||
int parseCommandRmd(ftpDataType * data, int socketId);
|
||||
int parseCommandQuit(ftpDataType * data, int socketId);
|
||||
int parseCommandSize(clientDataType *theClientData);
|
||||
int parseCommandSize(ftpDataType * data, int socketId);
|
||||
int parseCommandStor(ftpDataType * data, int socketId);
|
||||
int parseCommandCwd(clientDataType *theClientData);
|
||||
int parseCommandRest(clientDataType *theClientData);
|
||||
int parseCommandCdup(clientDataType *theClientData);
|
||||
int parseCommandDele(clientDataType *theClientData);
|
||||
int parseCommandOpts(clientDataType *theClientData);
|
||||
int parseCommandRnfr(clientDataType *theClientData);
|
||||
int parseCommandRnto(clientDataType *theClientData);
|
||||
int parseCommandCwd(ftpDataType * data, int socketId);
|
||||
int parseCommandRest(ftpDataType * data, int socketId);
|
||||
int parseCommandCdup(ftpDataType * data, int socketId);
|
||||
int parseCommandDele(ftpDataType * data, int socketId);
|
||||
int parseCommandOpts(ftpDataType * data, int socketId);
|
||||
int parseCommandRnfr(ftpDataType * data, int socketId);
|
||||
int parseCommandRnto(ftpDataType * data, int socketId);
|
||||
|
||||
long long int writeRetrFile(char * theFilename, int thePasvSocketConnection, long long int startFrom, FILE *retrFP);
|
||||
long long int writeRetrFile(ftpDataType * data, int theSocketId, long long int startFrom, FILE *retrFP);
|
||||
char *getFtpCommandArg(char * theCommand, char *theCommandString, int skipArgs);
|
||||
int getFtpCommandArgWithOptions(char * theCommand, char *theCommandString, ftpCommandDataType *ftpCommand);
|
||||
int setPermissions(char * permissionsCommand, char * basePath, ownerShip_DataType ownerShip);
|
||||
|
254
ftpData.c
254
ftpData.c
@ -36,6 +36,7 @@
|
||||
#include "ftpData.h"
|
||||
#include "library/configRead.h"
|
||||
#include "library/fileManagement.h"
|
||||
#include "library/connection.h"
|
||||
|
||||
void cleanDynamicStringDataType(dynamicStringDataType *dynamicString, int init)
|
||||
{
|
||||
@ -90,6 +91,7 @@ void setDynamicStringDataType(dynamicStringDataType *dynamicString, char *theStr
|
||||
|
||||
int getSafePath(dynamicStringDataType *safePath, char *theDirectoryName, loginDataType *loginData)
|
||||
{
|
||||
#define STRING_SIZE 4096
|
||||
int theLen, i;
|
||||
char * theDirectoryNamePointer;
|
||||
theDirectoryNamePointer = theDirectoryName;
|
||||
@ -123,9 +125,9 @@ int getSafePath(dynamicStringDataType *safePath, char *theDirectoryName, loginDa
|
||||
}
|
||||
|
||||
//Check for /../
|
||||
char theDirectoryToCheck[2048];
|
||||
char theDirectoryToCheck[STRING_SIZE];
|
||||
int theDirectoryToCheckIndex = 0;
|
||||
memset(theDirectoryToCheck, 0, 2048);
|
||||
memset(theDirectoryToCheck, 0, STRING_SIZE);
|
||||
|
||||
for (i = 0; i< theLen; i++)
|
||||
{
|
||||
@ -139,11 +141,11 @@ int getSafePath(dynamicStringDataType *safePath, char *theDirectoryName, loginDa
|
||||
}
|
||||
|
||||
theDirectoryToCheckIndex = 0;
|
||||
memset(theDirectoryToCheck, 0, 2048);
|
||||
memset(theDirectoryToCheck, 0, STRING_SIZE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (theDirectoryToCheckIndex<2048)
|
||||
if (theDirectoryToCheckIndex<STRING_SIZE)
|
||||
{
|
||||
theDirectoryToCheck[theDirectoryToCheckIndex++] = theDirectoryName[i];
|
||||
}
|
||||
@ -215,18 +217,18 @@ void setRandomicPort(ftpDataType *data, int socketPosition)
|
||||
|
||||
|
||||
data->clients[socketPosition].workerData.connectionPort = randomicPort;
|
||||
printf("data->clients[%d].workerData.connectionPort = %d", socketPosition, data->clients[socketPosition].workerData.connectionPort);
|
||||
//printf("data->clients[%d].workerData.connectionPort = %d", socketPosition, data->clients[socketPosition].workerData.connectionPort);
|
||||
}
|
||||
|
||||
int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, int commandType)
|
||||
int writeListDataInfoToSocket(ftpDataType *ftpData, int clientId, int *filesNumber, int commandType)
|
||||
{
|
||||
int i, x, returnCode;
|
||||
int fileAndFoldersCount = 0;
|
||||
char **fileList = NULL;
|
||||
FILE_GetDirectoryInodeList(thePath, &fileList, &fileAndFoldersCount, 0);
|
||||
FILE_GetDirectoryInodeList(ftpData->clients[clientId].listPath.text, &fileList, &fileAndFoldersCount, 0);
|
||||
*filesNumber = fileAndFoldersCount;
|
||||
|
||||
returnCode = dprintf(theSocket, "total %d\r\n", fileAndFoldersCount);
|
||||
returnCode = socketWorkerPrintf(ftpData, clientId, "sds", "total ", fileAndFoldersCount ,"\r\n");
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
return -1;
|
||||
@ -241,14 +243,10 @@ int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, i
|
||||
data.fileNameWithPath = NULL;
|
||||
data.finalStringPath = NULL;
|
||||
data.linkPath = NULL;
|
||||
|
||||
|
||||
data.isFile = 0;
|
||||
data.isDirectory = 0;
|
||||
|
||||
|
||||
|
||||
//printf("\nPROCESSING: %s", fileList[i]);
|
||||
//fflush(0);
|
||||
|
||||
if (FILE_IsDirectory(fileList[i]) == 1)
|
||||
{
|
||||
@ -315,21 +313,37 @@ int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, i
|
||||
{
|
||||
case COMMAND_TYPE_LIST:
|
||||
{
|
||||
returnCode = socketWorkerPrintf(ftpData, clientId, "ssdssssslsssss",
|
||||
data.inodePermissionString == NULL? "Unknown" : data.inodePermissionString
|
||||
," "
|
||||
,data.numberOfSubDirectories
|
||||
," "
|
||||
,data.owner == NULL? "Unknown" : data.owner
|
||||
," "
|
||||
,data.groupOwner == NULL? "Unknown" : data.groupOwner
|
||||
," "
|
||||
,data.fileSize
|
||||
," "
|
||||
,data.lastModifiedDataString == NULL? "Unknown" : data.lastModifiedDataString
|
||||
," "
|
||||
,data.finalStringPath == NULL? "Unknown" : data.finalStringPath
|
||||
,"\r\n");
|
||||
/*
|
||||
returnCode = dprintf(theSocket, "%s %d %s %s %lld %s %s\r\n",
|
||||
data.inodePermissionString == NULL? "Uknown" : data.inodePermissionString
|
||||
data.inodePermissionString == NULL? "Unknown" : data.inodePermissionString
|
||||
,data.numberOfSubDirectories
|
||||
,data.owner == NULL? "Uknown" : data.owner
|
||||
,data.groupOwner == NULL? "Uknown" : data.groupOwner
|
||||
,data.owner == NULL? "Unknown" : data.owner
|
||||
,data.groupOwner == NULL? "Unknown" : data.groupOwner
|
||||
,data.fileSize
|
||||
,data.lastModifiedDataString == NULL? "Uknown" : data.lastModifiedDataString
|
||||
,data.finalStringPath == NULL? "Uknown" : data.finalStringPath);
|
||||
|
||||
,data.lastModifiedDataString == NULL? "Unknown" : data.lastModifiedDataString
|
||||
,data.finalStringPath == NULL? "Unknown" : data.finalStringPath);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
|
||||
case COMMAND_TYPE_NLST:
|
||||
{
|
||||
returnCode = dprintf(theSocket, "%s\r\n",data.fileNameNoPath);
|
||||
returnCode = socketWorkerPrintf(ftpData, clientId, "ss", data.fileNameNoPath, "\r\n");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -339,7 +353,6 @@ int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, i
|
||||
printf("\nWarning switch default in function writeListDataInfoToSocket (%d)", commandType);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -370,10 +383,12 @@ int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, i
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fileList != NULL)
|
||||
free (fileList);
|
||||
|
||||
|
||||
if (fileList != NULL)
|
||||
{
|
||||
free (fileList);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -390,7 +405,10 @@ int searchInLoginFailsVector(void * loginFailsVector, void *element)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup_openssl()
|
||||
{
|
||||
EVP_cleanup();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -539,114 +557,150 @@ void deleteListDataInfoVector(void *TheElementToDelete)
|
||||
}
|
||||
}
|
||||
|
||||
void resetWorkerData(workerDataType *workerData, int isInitialization)
|
||||
void resetWorkerData(ftpDataType *data, int clientId, int isInitialization)
|
||||
{
|
||||
workerData->connectionPort = 0;
|
||||
workerData->passiveModeOn = 0;
|
||||
workerData->socketIsConnected = 0;
|
||||
workerData->commandIndex = 0;
|
||||
workerData->passiveListeningSocket = 0;
|
||||
workerData->socketConnection = 0;
|
||||
workerData->bufferIndex = 0;
|
||||
workerData->commandReceived = 0;
|
||||
workerData->retrRestartAtByte = 0;
|
||||
workerData->threadIsAlive = 0;
|
||||
workerData->activeModeOn = 0;
|
||||
workerData->passiveModeOn = 0;
|
||||
workerData->activeIpAddressIndex = 0;
|
||||
|
||||
memset(workerData->buffer, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
memset(workerData->activeIpAddress, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
memset(workerData->theCommandReceived, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
data->clients[clientId].workerData.connectionPort = 0;
|
||||
data->clients[clientId].workerData.passiveModeOn = 0;
|
||||
data->clients[clientId].workerData.socketIsConnected = 0;
|
||||
data->clients[clientId].workerData.commandIndex = 0;
|
||||
data->clients[clientId].workerData.passiveListeningSocket = 0;
|
||||
data->clients[clientId].workerData.socketConnection = 0;
|
||||
data->clients[clientId].workerData.bufferIndex = 0;
|
||||
data->clients[clientId].workerData.commandReceived = 0;
|
||||
data->clients[clientId].workerData.retrRestartAtByte = 0;
|
||||
data->clients[clientId].workerData.threadIsAlive = 0;
|
||||
data->clients[clientId].workerData.activeModeOn = 0;
|
||||
data->clients[clientId].workerData.passiveModeOn = 0;
|
||||
data->clients[clientId].workerData.activeIpAddressIndex = 0;
|
||||
|
||||
cleanDynamicStringDataType(&workerData->ftpCommand.commandArgs, isInitialization);
|
||||
cleanDynamicStringDataType(&workerData->ftpCommand.commandOps, isInitialization);
|
||||
memset(data->clients[clientId].workerData.buffer, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
memset(data->clients[clientId].workerData.activeIpAddress, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
memset(data->clients[clientId].workerData.theCommandReceived, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
|
||||
cleanDynamicStringDataType(&data->clients[clientId].workerData.ftpCommand.commandArgs, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].workerData.ftpCommand.commandOps, isInitialization);
|
||||
|
||||
/* wait main for action */
|
||||
if (isInitialization != 1)
|
||||
{
|
||||
pthread_mutex_destroy(&workerData->conditionMutex);
|
||||
pthread_cond_destroy(&workerData->conditionVariable);
|
||||
pthread_mutex_destroy(&data->clients[clientId].workerData.conditionMutex);
|
||||
pthread_cond_destroy(&data->clients[clientId].workerData.conditionVariable);
|
||||
|
||||
if (workerData->theStorFile != NULL)
|
||||
if (data->clients[clientId].workerData.theStorFile != NULL)
|
||||
{
|
||||
fclose(workerData->theStorFile);
|
||||
workerData->theStorFile = NULL;
|
||||
fclose(data->clients[clientId].workerData.theStorFile);
|
||||
data->clients[clientId].workerData.theStorFile = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL_free(data->clients[clientId].workerData.serverSsl);
|
||||
SSL_free(data->clients[clientId].workerData.clientSsl);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
DYNV_VectorGeneric_Init(&workerData->directoryInfo);
|
||||
workerData->theStorFile = NULL;
|
||||
DYNV_VectorGeneric_Init(&data->clients[clientId].workerData.directoryInfo);
|
||||
data->clients[clientId].workerData.theStorFile = NULL;
|
||||
data->clients[clientId].workerData.threadHasBeenCreated = 0;
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&data->clients[clientId].workerData.conditionMutex, NULL) != 0)
|
||||
{
|
||||
printf("\ndata->clients[clientId].workerData.conditionMutex init failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
if (pthread_cond_init(&data->clients[clientId].workerData.conditionVariable, NULL) != 0)
|
||||
{
|
||||
printf("\ndata->clients[clientId].workerData.conditionVariable init failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
pthread_mutex_init(&workerData->conditionMutex, NULL);
|
||||
pthread_cond_init(&workerData->conditionVariable, NULL);
|
||||
|
||||
//Clear the dynamic vector structure
|
||||
int theSize = workerData->directoryInfo.Size;
|
||||
int theSize = data->clients[clientId].workerData.directoryInfo.Size;
|
||||
char ** lastToDestroy = NULL;
|
||||
if (theSize > 0)
|
||||
{
|
||||
lastToDestroy = ((ftpListDataType *)workerData->directoryInfo.Data[0])->fileList;
|
||||
workerData->directoryInfo.Destroy(&workerData->directoryInfo, deleteListDataInfoVector);
|
||||
lastToDestroy = ((ftpListDataType *)data->clients[clientId].workerData.directoryInfo.Data[0])->fileList;
|
||||
data->clients[clientId].workerData.directoryInfo.Destroy(&data->clients[clientId].workerData.directoryInfo, deleteListDataInfoVector);
|
||||
free(lastToDestroy);
|
||||
}
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
data->clients[clientId].workerData.serverSsl = SSL_new(data->serverCtx);
|
||||
data->clients[clientId].workerData.clientSsl = SSL_new(data->clientCtx);
|
||||
#endif
|
||||
}
|
||||
|
||||
void resetClientData(clientDataType *clientData, int isInitialization)
|
||||
void resetClientData(ftpDataType *data, int clientId, int isInitialization)
|
||||
{
|
||||
if (isInitialization != 0)
|
||||
|
||||
if (isInitialization != 1)
|
||||
{
|
||||
if (clientData->workerData.threadIsAlive == 1)
|
||||
{
|
||||
void *pReturn;
|
||||
pthread_cancel(clientData->workerData.workerThread);
|
||||
pthread_join(clientData->workerData.workerThread, &pReturn);
|
||||
}
|
||||
else
|
||||
{
|
||||
void *pReturn;
|
||||
pthread_join(clientData->workerData.workerThread, &pReturn);
|
||||
}
|
||||
void *pReturn;
|
||||
if (data->clients[clientId].workerData.threadIsAlive == 1)
|
||||
pthread_cancel(data->clients[clientId].workerData.workerThread);
|
||||
|
||||
pthread_mutex_destroy(&data->clients[clientId].writeMutex);
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL_free(data->clients[clientId].ssl);
|
||||
//SSL_free(data->clients[clientId].workerData.ssl);
|
||||
#endif
|
||||
}
|
||||
|
||||
clientData->socketDescriptor = -1;
|
||||
clientData->socketCommandReceived = 0;
|
||||
clientData->socketIsConnected = 0;
|
||||
clientData->bufferIndex = 0;
|
||||
clientData->commandIndex = 0;
|
||||
clientData->closeTheClient = 0;
|
||||
clientData->sockaddr_in_size = sizeof(struct sockaddr_in);
|
||||
clientData->sockaddr_in_server_size = sizeof(struct sockaddr_in);
|
||||
if (pthread_mutex_init(&data->clients[clientId].writeMutex, NULL) != 0)
|
||||
{
|
||||
printf("\nclientData->writeMutex init failed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
data->clients[clientId].tlsIsNegotiating = 0;
|
||||
data->clients[clientId].tlsIsEnabled = 0;
|
||||
data->clients[clientId].dataChannelIsTls = 0;
|
||||
data->clients[clientId].socketDescriptor = -1;
|
||||
data->clients[clientId].socketCommandReceived = 0;
|
||||
data->clients[clientId].socketIsConnected = 0;
|
||||
data->clients[clientId].bufferIndex = 0;
|
||||
data->clients[clientId].commandIndex = 0;
|
||||
data->clients[clientId].closeTheClient = 0;
|
||||
data->clients[clientId].sockaddr_in_size = sizeof(struct sockaddr_in);
|
||||
data->clients[clientId].sockaddr_in_server_size = sizeof(struct sockaddr_in);
|
||||
|
||||
clientData->serverIpAddressInteger[0] = 0;
|
||||
clientData->serverIpAddressInteger[1] = 0;
|
||||
clientData->serverIpAddressInteger[2] = 0;
|
||||
clientData->serverIpAddressInteger[3] = 0;
|
||||
data->clients[clientId].serverIpAddressInteger[0] = 0;
|
||||
data->clients[clientId].serverIpAddressInteger[1] = 0;
|
||||
data->clients[clientId].serverIpAddressInteger[2] = 0;
|
||||
data->clients[clientId].serverIpAddressInteger[3] = 0;
|
||||
|
||||
|
||||
memset(&clientData->client_sockaddr_in, 0, clientData->sockaddr_in_size);
|
||||
memset(&clientData->server_sockaddr_in, 0, clientData->sockaddr_in_server_size);
|
||||
memset(clientData->clientIpAddress, 0, INET_ADDRSTRLEN);
|
||||
memset(clientData->buffer, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
memset(clientData->theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE);
|
||||
cleanLoginData(&clientData->login, isInitialization);
|
||||
memset(&data->clients[clientId].client_sockaddr_in, 0, data->clients[clientId].sockaddr_in_size);
|
||||
memset(&data->clients[clientId].server_sockaddr_in, 0, data->clients[clientId].sockaddr_in_server_size);
|
||||
memset(data->clients[clientId].clientIpAddress, 0, INET_ADDRSTRLEN);
|
||||
memset(data->clients[clientId].buffer, 0, CLIENT_BUFFER_STRING_SIZE);
|
||||
memset(data->clients[clientId].theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE);
|
||||
cleanLoginData(&data->clients[clientId].login, isInitialization);
|
||||
|
||||
//Rename from and to data init
|
||||
cleanDynamicStringDataType(&clientData->renameFromFile, isInitialization);
|
||||
cleanDynamicStringDataType(&clientData->renameToFile, isInitialization);
|
||||
cleanDynamicStringDataType(&clientData->fileToStor, isInitialization);
|
||||
cleanDynamicStringDataType(&clientData->fileToRetr, isInitialization);
|
||||
cleanDynamicStringDataType(&clientData->listPath, isInitialization);
|
||||
cleanDynamicStringDataType(&clientData->nlistPath, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].renameFromFile, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].renameToFile, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].fileToStor, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].fileToRetr, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].listPath, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].nlistPath, isInitialization);
|
||||
|
||||
cleanDynamicStringDataType(&clientData->ftpCommand.commandArgs, isInitialization);
|
||||
cleanDynamicStringDataType(&clientData->ftpCommand.commandOps, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].ftpCommand.commandArgs, isInitialization);
|
||||
cleanDynamicStringDataType(&data->clients[clientId].ftpCommand.commandOps, isInitialization);
|
||||
|
||||
clientData->connectionTimeStamp = 0;
|
||||
clientData->lastActivityTimeStamp = 0;
|
||||
data->clients[clientId].connectionTimeStamp = 0;
|
||||
data->clients[clientId].tlsNegotiatingTimeStart = 0;
|
||||
data->clients[clientId].lastActivityTimeStamp = 0;
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
//data->clients[clientId].workerData.ssl = SSL_new(data->ctx);
|
||||
data->clients[clientId].ssl = SSL_new(data->serverCtx);
|
||||
#endif
|
||||
}
|
||||
|
||||
int compareStringCaseInsensitive(char * stringIn, char * stringRef, int stringLenght)
|
||||
|
41
ftpData.h
41
ftpData.h
@ -27,11 +27,14 @@
|
||||
#define FTPDATA_H
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include "library/dynamicVectors.h"
|
||||
|
||||
|
||||
#define CLIENT_COMMAND_STRING_SIZE 2048
|
||||
#define CLIENT_BUFFER_STRING_SIZE 2048
|
||||
#define CLIENT_COMMAND_STRING_SIZE 4096
|
||||
#define CLIENT_BUFFER_STRING_SIZE 4096
|
||||
#define MAXIMUM_INODE_NAME 4096
|
||||
|
||||
#define LIST_DATA_TYPE_MODIFIED_DATA_STR_SIZE 1024
|
||||
|
||||
@ -50,7 +53,6 @@ struct parameter
|
||||
char* value;
|
||||
} typedef parameter_DataType;
|
||||
|
||||
|
||||
struct ownerShip
|
||||
{
|
||||
int ownerShipSet;
|
||||
@ -80,10 +82,11 @@ struct ftpParameters
|
||||
int singleInstanceModeOn;
|
||||
DYNV_VectorGenericDataType usersVector;
|
||||
int maximumIdleInactivity;
|
||||
|
||||
int maximumConnectionsPerIp;
|
||||
int maximumUserAndPassowrdLoginTries;
|
||||
|
||||
|
||||
char certificatePath[MAXIMUM_INODE_NAME];
|
||||
char privateCertificatePath[MAXIMUM_INODE_NAME];
|
||||
} typedef ftpParameters_DataType;
|
||||
|
||||
struct dynamicStringData
|
||||
@ -116,7 +119,13 @@ struct ipData
|
||||
|
||||
struct workerData
|
||||
{
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL *serverSsl;
|
||||
SSL *clientSsl;
|
||||
#endif
|
||||
|
||||
int threadIsAlive;
|
||||
int threadHasBeenCreated;
|
||||
int connectionPort;
|
||||
int passiveModeOn;
|
||||
int activeModeOn;
|
||||
@ -147,6 +156,16 @@ struct workerData
|
||||
|
||||
struct clientData
|
||||
{
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL *ssl;
|
||||
#endif
|
||||
|
||||
int tlsIsEnabled;
|
||||
int tlsIsNegotiating;
|
||||
unsigned long long int tlsNegotiatingTimeStart;
|
||||
int dataChannelIsTls;
|
||||
pthread_mutex_t writeMutex;
|
||||
|
||||
int clientProgressiveNumber;
|
||||
int socketDescriptor;
|
||||
int socketIsConnected;
|
||||
@ -202,6 +221,11 @@ struct ConnectionParameters
|
||||
|
||||
struct ftpData
|
||||
{
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL_CTX *serverCtx;
|
||||
SSL_CTX *clientCtx;
|
||||
#endif
|
||||
|
||||
int connectedClients;
|
||||
char welcomeMessage[1024];
|
||||
ConnectionData_DataType connectionData;
|
||||
@ -237,14 +261,15 @@ int getSafePath(dynamicStringDataType *safePath, char *theDirectoryName, loginDa
|
||||
void appendToDynamicStringDataType(dynamicStringDataType *dynamicString, char *theString, int stringLen);
|
||||
void setRandomicPort(ftpDataType *data, int socketPosition);
|
||||
void getListDataInfo(char * thePath, DYNV_VectorGenericDataType *directoryInfo);
|
||||
int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, int commandType);
|
||||
int writeListDataInfoToSocket(ftpDataType *data, int clientId, int *filesNumber, int commandType);
|
||||
int searchInLoginFailsVector(void *loginFailsVector, void *element);
|
||||
void deleteLoginFailsData(void *element);
|
||||
void deleteListDataInfoVector(void *TheElementToDelete);
|
||||
void resetWorkerData(workerDataType *pasvData, int isInitialization);
|
||||
void resetClientData(clientDataType *clientData, int isInitialization);
|
||||
void resetWorkerData(ftpDataType *data, int clientId, int isInitialization);
|
||||
void resetClientData(ftpDataType *data, int clientId, int isInitialization);
|
||||
int compareStringCaseInsensitive(char *stringIn, char* stringRef, int stringLenght);
|
||||
int isCharInString(char *theString, int stringLen, char theChar);
|
||||
void destroyConfigurationVectorElement(void * data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
335
ftpServer.c
335
ftpServer.c
@ -22,13 +22,10 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -39,15 +36,15 @@
|
||||
#include <errno.h>
|
||||
|
||||
/* FTP LIBS */
|
||||
#include "ftpServer.h"
|
||||
#include "ftpData.h"
|
||||
#include "ftpCommandsElaborate.h"
|
||||
|
||||
#include "library/fileManagement.h"
|
||||
#include "library/logFunctions.h"
|
||||
#include "library/configRead.h"
|
||||
#include "library/signals.h"
|
||||
#include "library/openSsl.h"
|
||||
#include "library/connection.h"
|
||||
#include "ftpServer.h"
|
||||
#include "ftpData.h"
|
||||
#include "ftpCommandsElaborate.h"
|
||||
|
||||
ftpDataType ftpData;
|
||||
|
||||
@ -55,13 +52,66 @@ static int processCommand(int processingElement);
|
||||
|
||||
void workerCleanup(void *socketId)
|
||||
{
|
||||
int theSocketId = *(int *)socketId;
|
||||
//printf("\nClosing pasv socket (%d) ok!", theSocketId);
|
||||
int theSocketId = *(int *)socketId;
|
||||
int returnCode = 0;
|
||||
|
||||
printf("\nWorker %d cleanup", theSocketId);
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
if (ftpData.clients[theSocketId].dataChannelIsTls == 1)
|
||||
{
|
||||
if(ftpData.clients[theSocketId].workerData.passiveModeOn == 1)
|
||||
{
|
||||
printf("\nSSL worker Shutdown 1");
|
||||
returnCode = SSL_shutdown(ftpData.clients[theSocketId].workerData.serverSsl);
|
||||
printf("\nnSSL worker Shutdown 1 return code : %d", returnCode);
|
||||
|
||||
if (returnCode < 0)
|
||||
{
|
||||
printf("SSL_shutdown failed return code %d", returnCode);
|
||||
}
|
||||
else if (returnCode == 0)
|
||||
{
|
||||
printf("\nSSL worker Shutdown 2");
|
||||
returnCode = SSL_shutdown(ftpData.clients[theSocketId].workerData.serverSsl);
|
||||
printf("\nnSSL worker Shutdown 2 return code : %d", returnCode);
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
printf("SSL_shutdown (2nd time) failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ftpData.clients[theSocketId].workerData.activeModeOn == 1)
|
||||
{
|
||||
printf("\nSSL worker Shutdown 1");
|
||||
returnCode = SSL_shutdown(ftpData.clients[theSocketId].workerData.clientSsl);
|
||||
printf(" return code : %d", returnCode);
|
||||
|
||||
if (returnCode < 0)
|
||||
{
|
||||
printf("SSL_shutdown failed return code %d", returnCode);
|
||||
}
|
||||
else if (returnCode == 0)
|
||||
{
|
||||
returnCode = SSL_shutdown(ftpData.clients[theSocketId].workerData.clientSsl);
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
printf("SSL_shutdown (2nd time) failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
shutdown(ftpData.clients[theSocketId].workerData.socketConnection, SHUT_RDWR);
|
||||
shutdown(ftpData.clients[theSocketId].workerData.passiveListeningSocket, SHUT_RDWR);
|
||||
close(ftpData.clients[theSocketId].workerData.socketConnection);
|
||||
close(ftpData.clients[theSocketId].workerData.passiveListeningSocket);
|
||||
resetWorkerData(&ftpData.clients[theSocketId].workerData, 0);
|
||||
resetWorkerData(&ftpData, theSocketId, 0);
|
||||
printf("\nWorker cleaned!");
|
||||
}
|
||||
|
||||
void *connectionWorkerHandle(void * socketId)
|
||||
@ -69,8 +119,11 @@ void *connectionWorkerHandle(void * socketId)
|
||||
int theSocketId = *(int *)socketId;
|
||||
pthread_cleanup_push(workerCleanup, (void *) &theSocketId);
|
||||
ftpData.clients[theSocketId].workerData.threadIsAlive = 1;
|
||||
ftpData.clients[theSocketId].workerData.threadHasBeenCreated = 1;
|
||||
int returnCode;
|
||||
|
||||
printf("\nWORKER CREATED!");
|
||||
|
||||
//Passive data connection mode
|
||||
if (ftpData.clients[theSocketId].workerData.passiveModeOn == 1)
|
||||
{
|
||||
@ -84,9 +137,10 @@ void *connectionWorkerHandle(void * socketId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
tries--;
|
||||
}
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.passiveListeningSocket == -1)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -96,8 +150,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.socketIsConnected == 0)
|
||||
{
|
||||
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n", ftpData.clients[theSocketId].serverIpAddressInteger[0], ftpData.clients[theSocketId].serverIpAddressInteger[1], ftpData.clients[theSocketId].serverIpAddressInteger[2], ftpData.clients[theSocketId].serverIpAddressInteger[3], (ftpData.clients[theSocketId].workerData.connectionPort / 256), (ftpData.clients[theSocketId].workerData.connectionPort % 256));
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "sdsdsdsdsdsds", "227 Entering Passive Mode (", ftpData.clients[theSocketId].serverIpAddressInteger[0], ",", ftpData.clients[theSocketId].serverIpAddressInteger[1], ",", ftpData.clients[theSocketId].serverIpAddressInteger[2], ",", ftpData.clients[theSocketId].serverIpAddressInteger[3], ",", (ftpData.clients[theSocketId].workerData.connectionPort / 256), ",", (ftpData.clients[theSocketId].workerData.connectionPort % 256), ")\r\n");
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -109,6 +162,32 @@ void *connectionWorkerHandle(void * socketId)
|
||||
if ((ftpData.clients[theSocketId].workerData.socketConnection = accept(ftpData.clients[theSocketId].workerData.passiveListeningSocket, 0, 0))!=-1)
|
||||
{
|
||||
ftpData.clients[theSocketId].workerData.socketIsConnected = 1;
|
||||
#ifdef OPENSSL_ENABLED
|
||||
if (ftpData.clients[theSocketId].dataChannelIsTls == 1)
|
||||
{
|
||||
|
||||
returnCode = SSL_set_fd(ftpData.clients[theSocketId].workerData.serverSsl, ftpData.clients[theSocketId].workerData.socketConnection);
|
||||
|
||||
if (returnCode == 0)
|
||||
{
|
||||
printf("\nSSL ERRORS ON WORKER SSL_set_fd");
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
}
|
||||
|
||||
returnCode = SSL_accept(ftpData.clients[theSocketId].workerData.serverSsl);
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
printf("\nSSL ERRORS ON WORKER");
|
||||
ERR_print_errors_fp(stderr);
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nSSL ACCEPTED ON WORKER");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,6 +201,30 @@ void *connectionWorkerHandle(void * socketId)
|
||||
{
|
||||
ftpData.clients[theSocketId].workerData.socketConnection = createActiveSocket(ftpData.clients[theSocketId].workerData.connectionPort, ftpData.clients[theSocketId].workerData.activeIpAddress);
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
if (ftpData.clients[theSocketId].dataChannelIsTls == 1)
|
||||
{
|
||||
returnCode = SSL_set_fd(ftpData.clients[theSocketId].workerData.clientSsl, ftpData.clients[theSocketId].workerData.socketConnection);
|
||||
|
||||
if (returnCode == 0)
|
||||
{
|
||||
printf("\nSSL ERRORS ON WORKER SSL_set_fd");
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
}
|
||||
//SSL_set_connect_state(ftpData.clients[theSocketId].workerData.clientSsl);
|
||||
returnCode = SSL_connect(ftpData.clients[theSocketId].workerData.clientSsl);
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
printf("\nSSL ERRORS ON WORKER %d error code: %d", returnCode, SSL_get_error(ftpData.clients[theSocketId].workerData.clientSsl, returnCode));
|
||||
ERR_print_errors_fp(stderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nSSL ACCEPTED ON WORKER");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.socketConnection < 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -129,7 +232,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "200 connection accepted\r\n");
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "s", "200 connection accepted\r\n");
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
@ -141,6 +244,9 @@ void *connectionWorkerHandle(void * socketId)
|
||||
ftpData.clients[theSocketId].workerData.socketIsConnected = 1;
|
||||
}
|
||||
|
||||
|
||||
printf("\nftpData.clients[theSocketId].workerData.socketIsConnected = %d", ftpData.clients[theSocketId].workerData.socketIsConnected);
|
||||
|
||||
//Endless loop ftp process
|
||||
while (1)
|
||||
{
|
||||
@ -148,6 +254,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.socketIsConnected > 0)
|
||||
{
|
||||
printf("\nWorker %d is waiting for commands!", theSocketId);
|
||||
//Conditional lock on thread actions
|
||||
pthread_mutex_lock(&ftpData.clients[theSocketId].workerData.conditionMutex);
|
||||
while (ftpData.clients[theSocketId].workerData.commandReceived == 0)
|
||||
@ -156,23 +263,26 @@ void *connectionWorkerHandle(void * socketId)
|
||||
}
|
||||
pthread_mutex_unlock(&ftpData.clients[theSocketId].workerData.conditionMutex);
|
||||
|
||||
printf("\nWorker %d unlocked", theSocketId);
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.commandReceived == 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[theSocketId].workerData.theCommandReceived, "STOR", strlen("STOR")) == 1 &&
|
||||
ftpData.clients[theSocketId].fileToStor.textLen > 0)
|
||||
{
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
#ifdef LARGE_FILE_SUPPORT_ENABLED
|
||||
//#warning LARGE FILE SUPPORT IS ENABLED!
|
||||
ftpData.clients[theSocketId].workerData.theStorFile = fopen64(ftpData.clients[theSocketId].fileToStor.text, "wb");
|
||||
#endif
|
||||
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#ifndef LARGE_FILE_SUPPORT_ENABLED
|
||||
#warning LARGE FILE SUPPORT IS NOT ENABLED!
|
||||
ftpData.clients[theSocketId].workerData.theStorFile = fopen(ftpData.clients[theSocketId].fileToStor.text, "wb");
|
||||
#endif
|
||||
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.theStorFile == NULL)
|
||||
{
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "553 Unable to write the file\r\n");
|
||||
{
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "s", "553 Unable to write the file\r\n");
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
@ -184,7 +294,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
break;
|
||||
}
|
||||
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "150 Accepted data connection\r\n");
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "s", "150 Accepted data connection\r\n");
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
@ -195,8 +305,26 @@ void *connectionWorkerHandle(void * socketId)
|
||||
|
||||
while(1)
|
||||
{
|
||||
ftpData.clients[theSocketId].workerData.bufferIndex = read(ftpData.clients[theSocketId].workerData.socketConnection, ftpData.clients[theSocketId].workerData.buffer, CLIENT_BUFFER_STRING_SIZE);
|
||||
|
||||
|
||||
if (ftpData.clients[theSocketId].dataChannelIsTls != 1)
|
||||
{
|
||||
ftpData.clients[theSocketId].workerData.bufferIndex = read(ftpData.clients[theSocketId].workerData.socketConnection, ftpData.clients[theSocketId].workerData.buffer, CLIENT_BUFFER_STRING_SIZE);
|
||||
}
|
||||
else if (ftpData.clients[theSocketId].dataChannelIsTls == 1)
|
||||
{
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
if (ftpData.clients[theSocketId].workerData.passiveModeOn == 1)
|
||||
ftpData.clients[theSocketId].workerData.bufferIndex = SSL_read(ftpData.clients[theSocketId].workerData.serverSsl, ftpData.clients[theSocketId].workerData.buffer, CLIENT_BUFFER_STRING_SIZE);
|
||||
else if(ftpData.clients[theSocketId].workerData.activeModeOn == 1)
|
||||
ftpData.clients[theSocketId].workerData.bufferIndex = SSL_read(ftpData.clients[theSocketId].workerData.clientSsl, ftpData.clients[theSocketId].workerData.buffer, CLIENT_BUFFER_STRING_SIZE);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nError state");
|
||||
}
|
||||
|
||||
if (ftpData.clients[theSocketId].workerData.bufferIndex == 0)
|
||||
{
|
||||
break;
|
||||
@ -213,14 +341,13 @@ void *connectionWorkerHandle(void * socketId)
|
||||
}
|
||||
fclose(ftpData.clients[theSocketId].workerData.theStorFile);
|
||||
ftpData.clients[theSocketId].workerData.theStorFile = NULL;
|
||||
|
||||
|
||||
|
||||
if (ftpData.clients[theSocketId].login.ownerShip.ownerShipSet == 1)
|
||||
{
|
||||
FILE_doChownFromUidGid(ftpData.clients[theSocketId].fileToStor.text, ftpData.clients[theSocketId].login.ownerShip.uid, ftpData.clients[theSocketId].login.ownerShip.gid);
|
||||
}
|
||||
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "226 file stor ok\r\n");
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "s", "226 file stor ok\r\n");
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -242,7 +369,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
else if (compareStringCaseInsensitive(ftpData.clients[theSocketId].workerData.theCommandReceived, "NLST", strlen("NLST")) == 1)
|
||||
theCommandType = COMMAND_TYPE_NLST;
|
||||
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "150 Accepted data connection\r\n");
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "s", "150 Accepted data connection\r\n");
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -250,7 +377,8 @@ void *connectionWorkerHandle(void * socketId)
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
returnCode = writeListDataInfoToSocket(ftpData.clients[theSocketId].listPath.text, ftpData.clients[theSocketId].workerData.socketConnection, &theFiles, theCommandType);
|
||||
//returnCode = writeListDataInfoToSocket(ftpData.clients[theSocketId].listPath.text, ftpData.clients[theSocketId].workerData.socketConnection, &theFiles, theCommandType);
|
||||
returnCode = writeListDataInfoToSocket(&ftpData, theSocketId, &theFiles, theCommandType);
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -258,7 +386,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
returnCode = dprintf(ftpData.clients[theSocketId].socketDescriptor, "226 %d matches total\r\n", theFiles);
|
||||
returnCode = socketPrintf(&ftpData, theSocketId, "sds", "226 ", theFiles, " matches total\r\n");
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -272,8 +400,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
compareStringCaseInsensitive(ftpData.clients[theSocketId].workerData.theCommandReceived, "RETR", strlen("RETR")) == 1)
|
||||
{
|
||||
long long int writenSize = 0, writeReturn = 0;
|
||||
|
||||
writeReturn = dprintf(ftpData.clients[theSocketId].socketDescriptor, "150 Accepted data connection\r\n");
|
||||
writeReturn = socketPrintf(&ftpData, theSocketId, "s", "150 Accepted data connection\r\n");
|
||||
if (writeReturn <= 0)
|
||||
{
|
||||
ftpData.clients[theSocketId].closeTheClient = 1;
|
||||
@ -282,12 +409,12 @@ void *connectionWorkerHandle(void * socketId)
|
||||
}
|
||||
|
||||
|
||||
writenSize = writeRetrFile(ftpData.clients[theSocketId].fileToRetr.text, ftpData.clients[theSocketId].workerData.socketConnection, ftpData.clients[theSocketId].workerData.retrRestartAtByte, ftpData.clients[theSocketId].workerData.theStorFile);
|
||||
writenSize = writeRetrFile(&ftpData, theSocketId, ftpData.clients[theSocketId].workerData.retrRestartAtByte, ftpData.clients[theSocketId].workerData.theStorFile);
|
||||
ftpData.clients[theSocketId].workerData.retrRestartAtByte = 0;
|
||||
|
||||
if (writenSize == -1)
|
||||
{
|
||||
writeReturn = dprintf(ftpData.clients[theSocketId].socketDescriptor, "550 unable to open the file for reading\r\n");
|
||||
writeReturn = socketPrintf(&ftpData, theSocketId, "s", "550 unable to open the file for reading\r\n");
|
||||
|
||||
if (writeReturn <= 0)
|
||||
{
|
||||
@ -298,7 +425,7 @@ void *connectionWorkerHandle(void * socketId)
|
||||
break;
|
||||
}
|
||||
|
||||
writeReturn = dprintf(ftpData.clients[theSocketId].socketDescriptor, "226-File successfully transferred\r\n226 done\r\n");
|
||||
writeReturn = socketPrintf(&ftpData, theSocketId, "s", "226-File successfully transferred\r\n226 done\r\n");
|
||||
|
||||
if (writeReturn <= 0)
|
||||
{
|
||||
@ -325,11 +452,11 @@ void *connectionWorkerHandle(void * socketId)
|
||||
|
||||
void runFtpServer(void)
|
||||
{
|
||||
|
||||
printf("\nHello uFTP server v%s starting..\n", UFTP_SERVER_VERSION);
|
||||
|
||||
|
||||
/* Needed for Select*/
|
||||
static int processingSock = 0, returnCode = 0;
|
||||
static int processingSock = 0,
|
||||
returnCode = 0;
|
||||
|
||||
/* Handle signals */
|
||||
signalHandlerInstall();
|
||||
@ -352,6 +479,7 @@ void runFtpServer(void)
|
||||
|
||||
/* the maximum socket fd is now the main socket descriptor */
|
||||
ftpData.connectionData.maxSocketFD = ftpData.connectionData.theMainSocket+1;
|
||||
|
||||
|
||||
//Endless loop ftp process
|
||||
while (1)
|
||||
@ -359,9 +487,7 @@ void runFtpServer(void)
|
||||
/* waits for socket activity, if no activity then checks for client socket timeouts */
|
||||
if (selectWait(&ftpData) == 0)
|
||||
{
|
||||
|
||||
checkClientConnectionTimeout(&ftpData);
|
||||
|
||||
flushLoginWrongTriesData(&ftpData);
|
||||
}
|
||||
|
||||
@ -380,7 +506,7 @@ void runFtpServer(void)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* no data to check client is not connected, continue to check other clients */
|
||||
if (isClientConnected(&ftpData, processingSock) == 0)
|
||||
{
|
||||
@ -391,8 +517,50 @@ void runFtpServer(void)
|
||||
if (FD_ISSET(ftpData.clients[processingSock].socketDescriptor, &ftpData.connectionData.rset) ||
|
||||
FD_ISSET(ftpData.clients[processingSock].socketDescriptor, &ftpData.connectionData.eset))
|
||||
{
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
if (ftpData.clients[processingSock].tlsIsNegotiating == 1)
|
||||
{
|
||||
returnCode = SSL_accept(ftpData.clients[processingSock].ssl);
|
||||
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
printf("\nSSL NOT YET ACCEPTED: %d", returnCode);
|
||||
ftpData.clients[processingSock].tlsIsEnabled = 0;
|
||||
ftpData.clients[processingSock].tlsIsNegotiating = 1;
|
||||
|
||||
if ( ((int)time(NULL) - ftpData.clients[processingSock].tlsNegotiatingTimeStart) > TLS_NEGOTIATING_TIMEOUT )
|
||||
{
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
printf("\nTLS timeout closing the client time:%lld, start time: %lld..", (int)time(NULL), ftpData.clients[processingSock].tlsNegotiatingTimeStart);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nSSL ACCEPTED");
|
||||
ftpData.clients[processingSock].tlsIsEnabled = 1;
|
||||
ftpData.clients[processingSock].tlsIsNegotiating = 0;
|
||||
}
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ftpData.clients[processingSock].tlsIsEnabled == 1)
|
||||
{
|
||||
#ifdef OPENSSL_ENABLED
|
||||
ftpData.clients[processingSock].bufferIndex = SSL_read(ftpData.clients[processingSock].ssl, ftpData.clients[processingSock].buffer, CLIENT_BUFFER_STRING_SIZE);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpData.clients[processingSock].bufferIndex = read(ftpData.clients[processingSock].socketDescriptor, ftpData.clients[processingSock].buffer, CLIENT_BUFFER_STRING_SIZE);
|
||||
}
|
||||
|
||||
//The client is not connected anymore
|
||||
if ((ftpData.clients[processingSock].bufferIndex = read(ftpData.clients[processingSock].socketDescriptor, ftpData.clients[processingSock].buffer, CLIENT_BUFFER_STRING_SIZE)) == 0)
|
||||
if ((ftpData.clients[processingSock].bufferIndex) == 0)
|
||||
{
|
||||
fdRemove(&ftpData, processingSock);
|
||||
closeSocket(&ftpData, processingSock);
|
||||
@ -403,7 +571,7 @@ void runFtpServer(void)
|
||||
//Debug print errors
|
||||
if (ftpData.clients[processingSock].bufferIndex < 0)
|
||||
{
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
//ftpData.clients[processingSock].closeTheClient = 1;
|
||||
printf("\n1 Errno = %d", errno);
|
||||
perror("1 Error: ");
|
||||
continue;
|
||||
@ -426,15 +594,16 @@ void runFtpServer(void)
|
||||
if (ftpData.clients[processingSock].buffer[i] == '\n')
|
||||
{
|
||||
ftpData.clients[processingSock].socketCommandReceived = 1;
|
||||
printf("\n Processing the command: %s", ftpData.clients[processingSock].theCommandReceived);
|
||||
commandProcessStatus = processCommand(processingSock);
|
||||
//Echo unrecognized commands
|
||||
if (commandProcessStatus == FTP_COMMAND_NOT_RECONIZED)
|
||||
{
|
||||
int returnCode = 0;
|
||||
returnCode = dprintf(ftpData.clients[processingSock].socketDescriptor, "500 Unknown command\r\n");
|
||||
returnCode = socketPrintf(&ftpData, processingSock, "s", "500 Unknown command\r\n");
|
||||
if (returnCode < 0)
|
||||
{
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
}
|
||||
printf("\n COMMAND NOT SUPPORTED ********* %s", ftpData.clients[processingSock].buffer);
|
||||
}
|
||||
@ -446,7 +615,7 @@ void runFtpServer(void)
|
||||
else if (commandProcessStatus == FTP_COMMAND_PROCESSED_WRITE_ERROR)
|
||||
{
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
printf("\n Write error, closing the client!");
|
||||
printf("\n Write error WARNING!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -456,7 +625,7 @@ void runFtpServer(void)
|
||||
int returnCode;
|
||||
ftpData.clients[processingSock].commandIndex = 0;
|
||||
memset(ftpData.clients[processingSock].theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE);
|
||||
returnCode = dprintf(ftpData.clients[processingSock].socketDescriptor, "500 Unknown command\r\n");
|
||||
returnCode = socketPrintf(&ftpData, processingSock, "s", "500 Unknown command\r\n");
|
||||
if (returnCode <= 0)
|
||||
ftpData.clients[processingSock].closeTheClient = 1;
|
||||
|
||||
@ -481,8 +650,8 @@ void runFtpServer(void)
|
||||
static int processCommand(int processingElement)
|
||||
{
|
||||
int toReturn = 0;
|
||||
printTimeStamp();
|
||||
printf ("Command received from (%d): %s", processingElement, ftpData.clients[processingElement].theCommandReceived);
|
||||
//printTimeStamp();
|
||||
//printf ("Command received from (%d): %s", processingElement, ftpData.clients[processingElement].theCommandReceived);
|
||||
|
||||
cleanDynamicStringDataType(&ftpData.clients[processingElement].ftpCommand.commandArgs, 0);
|
||||
cleanDynamicStringDataType(&ftpData.clients[processingElement].ftpCommand.commandOps, 0);
|
||||
@ -491,9 +660,12 @@ static int processCommand(int processingElement)
|
||||
(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "USER", strlen("USER")) != 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PASS", strlen("PASS")) != 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "QUIT", strlen("QUIT")) != 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PBSZ", strlen("PBSZ")) != 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PROT", strlen("PROT")) != 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "CCC", strlen("CCC")) != 1 &&
|
||||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "AUTH", strlen("AUTH")) != 1))
|
||||
{
|
||||
toReturn = notLoggedInMessage(&ftpData.clients[processingElement]);
|
||||
toReturn = notLoggedInMessage(&ftpData, processingElement);
|
||||
ftpData.clients[processingElement].commandIndex = 0;
|
||||
memset(ftpData.clients[processingElement].theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE);
|
||||
return 1;
|
||||
@ -503,7 +675,7 @@ static int processCommand(int processingElement)
|
||||
if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "USER", strlen("USER")) == 1)
|
||||
{
|
||||
printf("\nUSER COMMAND RECEIVED");
|
||||
toReturn = parseCommandUser(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandUser(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PASS", strlen("PASS")) == 1)
|
||||
{
|
||||
@ -513,47 +685,62 @@ static int processCommand(int processingElement)
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "SITE", strlen("SITE")) == 1)
|
||||
{
|
||||
printf("\nSITE COMMAND RECEIVED");
|
||||
toReturn = parseCommandSite(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandSite(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "AUTH", strlen("AUTH")) == 1)
|
||||
{
|
||||
printf("\nAUTH COMMAND RECEIVED");
|
||||
toReturn = parseCommandAuth(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandAuth(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PROT", strlen("PROT")) == 1)
|
||||
{
|
||||
printf("\nPROT COMMAND RECEIVED");
|
||||
toReturn = parseCommandProt(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PBSZ", strlen("PBSZ")) == 1)
|
||||
{
|
||||
printf("\nPBSZ COMMAND RECEIVED");
|
||||
toReturn = parseCommandPbsz(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "CCC", strlen("CCC")) == 1)
|
||||
{
|
||||
printf("\nCCC COMMAND RECEIVED");
|
||||
toReturn = parseCommandCcc(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PWD", strlen("PWD")) == 1)
|
||||
{
|
||||
printf("\nPWD COMMAND RECEIVED");
|
||||
toReturn = parseCommandPwd(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandPwd(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "SYST", strlen("SYST")) == 1)
|
||||
{
|
||||
printf("\nSYST COMMAND RECEIVED");
|
||||
toReturn = parseCommandSyst(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandSyst(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "FEAT", strlen("FEAT")) == 1)
|
||||
{
|
||||
printf("\nFEAT COMMAND RECEIVED");
|
||||
toReturn = parseCommandFeat(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandFeat(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "TYPE I", strlen("TYPE I")) == 1)
|
||||
{
|
||||
printf("\nTYPE I COMMAND RECEIVED");
|
||||
toReturn = parseCommandTypeI(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandTypeI(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "STRU F", strlen("STRU F")) == 1)
|
||||
{
|
||||
printf("\nTYPE I COMMAND RECEIVED");
|
||||
toReturn = parseCommandStruF(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandStruF(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "MODE S", strlen("MODE S")) == 1)
|
||||
{
|
||||
printf("\nMODE S COMMAND RECEIVED");
|
||||
toReturn = parseCommandModeS(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandModeS(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "TYPE A", strlen("TYPE A")) == 1)
|
||||
{
|
||||
printf("\nTYPE A COMMAND RECEIVED");
|
||||
toReturn = parseCommandTypeI(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandTypeI(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PASV", strlen("PASV")) == 1)
|
||||
{
|
||||
@ -573,17 +760,17 @@ static int processCommand(int processingElement)
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "CWD", strlen("CWD")) == 1)
|
||||
{
|
||||
printf("\nCWD COMMAND RECEIVED");
|
||||
toReturn = parseCommandCwd(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandCwd(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "CDUP", strlen("CDUP")) == 1)
|
||||
{
|
||||
printf("\nCDUP COMMAND RECEIVED");
|
||||
toReturn = parseCommandCdup(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandCdup(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "REST", strlen("REST")) == 1)
|
||||
{
|
||||
printf("\nREST COMMAND RECEIVED");
|
||||
toReturn = parseCommandRest(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandRest(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "RETR", strlen("RETR")) == 1)
|
||||
{
|
||||
@ -598,7 +785,7 @@ static int processCommand(int processingElement)
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "MKD", strlen("MKD")) == 1)
|
||||
{
|
||||
printf("\nMKD command received");
|
||||
toReturn = parseCommandMkd(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandMkd(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "ABOR", strlen("ABOR")) == 1)
|
||||
{
|
||||
@ -608,12 +795,12 @@ static int processCommand(int processingElement)
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "DELE", strlen("DELE")) == 1)
|
||||
{
|
||||
printf("\nDELE command received");
|
||||
toReturn = parseCommandDele(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandDele(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "OPTS", strlen("OPTS")) == 1)
|
||||
{
|
||||
printf("\nOPTS command received");
|
||||
toReturn = parseCommandOpts(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandOpts(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "MTDM", strlen("MTDM")) == 1)
|
||||
{
|
||||
@ -638,23 +825,23 @@ static int processCommand(int processingElement)
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "RMD", strlen("RMD")) == 1)
|
||||
{
|
||||
printf("\nRMD command received");
|
||||
toReturn = parseCommandRmd(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandRmd(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "RNFR", strlen("RNFR")) == 1)
|
||||
{
|
||||
printf("\nRNFR command received");
|
||||
toReturn = parseCommandRnfr(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandRnfr(&ftpData, processingElement);
|
||||
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "RNTO", strlen("RNTO")) == 1)
|
||||
{
|
||||
printf("\nRNTO command received");
|
||||
toReturn = parseCommandRnto(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandRnto(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "SIZE", strlen("SIZE")) == 1)
|
||||
{
|
||||
printf("\nSIZE command received");
|
||||
toReturn = parseCommandSize(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandSize(&ftpData, processingElement);
|
||||
}
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "APPE", strlen("APPE")) == 1)
|
||||
{
|
||||
@ -664,7 +851,7 @@ static int processCommand(int processingElement)
|
||||
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "NOOP", strlen("NOOP")) == 1)
|
||||
{
|
||||
printf("\nNOOP command received");
|
||||
toReturn = parseCommandNoop(&ftpData.clients[processingElement]);
|
||||
toReturn = parseCommandNoop(&ftpData, processingElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -675,3 +862,13 @@ static int processCommand(int processingElement)
|
||||
memset(ftpData.clients[processingElement].theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void deallocateMemory(void)
|
||||
{
|
||||
printf("\n Deallocating the memory.. ");
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
SSL_CTX_free(ftpData.serverCtx);
|
||||
cleanupOpenssl();
|
||||
#endif
|
||||
}
|
||||
|
@ -27,12 +27,14 @@
|
||||
#define FTPSERVER_H
|
||||
|
||||
#define MAX_FTP_CLIENTS 10
|
||||
#define UFTP_SERVER_VERSION "1.0.1 beta"
|
||||
#define UFTP_SERVER_VERSION "2.0.0 beta"
|
||||
|
||||
|
||||
void runFtpServer(void);
|
||||
void *connectionWorkerHandle(void * socketId);
|
||||
void workerCleanup(void *socketId);
|
||||
void signal_callback_handler(int signum);
|
||||
void deallocateMemory(void);
|
||||
|
||||
#endif /* FTPSERVER_H */
|
||||
|
||||
|
51
key.pem
Normal file
51
key.pem
Normal file
@ -0,0 +1,51 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
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
|
||||
-----END RSA PRIVATE KEY-----
|
54
key.pem.cfr
Normal file
54
key.pem.cfr
Normal file
@ -0,0 +1,54 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
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
|
||||
K2EdyPkehQ1J4kxpT5WkMQ==
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
@ -30,6 +30,7 @@
|
||||
#include "configRead.h"
|
||||
#include "../ftpData.h"
|
||||
#include "dynamicVectors.h"
|
||||
#include "openSsl.h"
|
||||
#include "fileManagement.h"
|
||||
#include "daemon.h"
|
||||
|
||||
@ -40,6 +41,12 @@ static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_Ve
|
||||
static int searchParameter(char *name, DYNV_VectorGenericDataType *parametersVector);
|
||||
static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *parametersVector);
|
||||
|
||||
void destroyConfigurationVectorElement(void * data)
|
||||
{
|
||||
free( ((parameter_DataType *) data)->value);
|
||||
free( ((parameter_DataType *) data)->name);
|
||||
}
|
||||
|
||||
/* Public Functions */
|
||||
int searchUser(char *name, DYNV_VectorGenericDataType *usersVector)
|
||||
{
|
||||
@ -66,20 +73,12 @@ void configurationRead(ftpParameters_DataType *ftpParameters)
|
||||
if (FILE_IsFile(LOCAL_CONFIGURATION_FILENAME) == 1)
|
||||
{
|
||||
printf("\nReading configuration from \n -> %s \n", LOCAL_CONFIGURATION_FILENAME);
|
||||
|
||||
returnCode = readConfigurationFile(LOCAL_CONFIGURATION_FILENAME, &configParameters);
|
||||
|
||||
printf("\nDONE\n");
|
||||
|
||||
}
|
||||
else if (FILE_IsFile(DEFAULT_CONFIGURATION_FILENAME) == 1)
|
||||
{
|
||||
printf("\nReading configuration from \n -> %s\n", DEFAULT_CONFIGURATION_FILENAME);
|
||||
|
||||
returnCode = readConfigurationFile(DEFAULT_CONFIGURATION_FILENAME, &configParameters);
|
||||
|
||||
printf("\nDONE\n");
|
||||
|
||||
}
|
||||
|
||||
if (returnCode == 1)
|
||||
@ -92,6 +91,9 @@ void configurationRead(ftpParameters_DataType *ftpParameters)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
DYNV_VectorGeneric_Destroy(&configParameters, destroyConfigurationVectorElement);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,10 +119,18 @@ void applyConfiguration(ftpParameters_DataType *ftpParameters)
|
||||
|
||||
void initFtpData(ftpDataType *ftpData)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
/* Intializes random number generator */
|
||||
srand(time(NULL));
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
initOpenssl();
|
||||
ftpData->serverCtx = createServerContext();
|
||||
ftpData->clientCtx = createClientContext();
|
||||
configureContext(ftpData->serverCtx, ftpData->ftpParameters.certificatePath, ftpData->ftpParameters.privateCertificatePath);
|
||||
configureClientContext(ftpData->clientCtx, ftpData->ftpParameters.certificatePath, ftpData->ftpParameters.privateCertificatePath);
|
||||
#endif
|
||||
|
||||
ftpData->connectedClients = 0;
|
||||
ftpData->clients = (clientDataType *) calloc( sizeof(clientDataType), ftpData->ftpParameters.maxClients);
|
||||
|
||||
@ -137,8 +147,8 @@ void initFtpData(ftpDataType *ftpData)
|
||||
//Client data reset to zero
|
||||
for (i = 0; i < ftpData->ftpParameters.maxClients; i++)
|
||||
{
|
||||
resetWorkerData(&ftpData->clients[i].workerData, 1);
|
||||
resetClientData(&ftpData->clients[i], 1);
|
||||
resetWorkerData(ftpData, i, 1);
|
||||
resetClientData(ftpData, i, 1);
|
||||
ftpData->clients[i].clientProgressiveNumber = i;
|
||||
}
|
||||
|
||||
@ -481,6 +491,31 @@ static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_Ve
|
||||
printf("\nFTP_SERVER_IP parameter not found in the configuration file, listening on all available networks");
|
||||
}
|
||||
|
||||
|
||||
searchIndex = searchParameter("CERTIFICATE_PATH", parametersVector);
|
||||
if (searchIndex != -1)
|
||||
{
|
||||
strcpy(ftpParameters->certificatePath, ((parameter_DataType *) parametersVector->Data[searchIndex])->value);
|
||||
printf("\nCERTIFICATE_PATH: %s", ftpParameters->certificatePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(ftpParameters->certificatePath, "cert.pem");
|
||||
printf("\nCERTIFICATE_PATH parameter not found in the configuration file, using the default value: %s", ftpParameters->certificatePath);
|
||||
}
|
||||
|
||||
searchIndex = searchParameter("PRIVATE_CERTIFICATE_PATH", parametersVector);
|
||||
if (searchIndex != -1)
|
||||
{
|
||||
strcpy(ftpParameters->privateCertificatePath, ((parameter_DataType *) parametersVector->Data[searchIndex])->value);
|
||||
printf("\nPRIVATE_CERTIFICATE_PATH: %s", ftpParameters->certificatePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(ftpParameters->privateCertificatePath, "key.pem");
|
||||
printf("\nPRIVATE_CERTIFICATE_PATH parameter not found in the configuration file, using the default value: %s", ftpParameters->privateCertificatePath);
|
||||
}
|
||||
|
||||
/* USER SETTINGS */
|
||||
userIndex = 0;
|
||||
memset(userX, 0, PARAMETER_SIZE_LIMIT);
|
||||
@ -492,14 +527,14 @@ static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_Ve
|
||||
DYNV_VectorGeneric_Init(&ftpParameters->usersVector);
|
||||
while(1)
|
||||
{
|
||||
int searchUserIndex, searchPasswordIndex, searchHomeIndex, searchUserOwnerIndex, searchGroupOwnerIndex;
|
||||
int searchUserIndex, searchPasswordIndex, searchHomeIndex, searchUserOwnerIndex, searchGroupOwnerIndex, returnCode;
|
||||
usersParameters_DataType userData;
|
||||
|
||||
sprintf(userX, "USER_%d", userIndex);
|
||||
sprintf(passwordX, "PASSWORD_%d", userIndex);
|
||||
sprintf(homeX, "HOME_%d", userIndex);
|
||||
sprintf(groupOwnerX, "GROUP_NAME_OWNER_%d", userIndex);
|
||||
sprintf(userOwnerX, "USER_NAME_OWNER_%d", userIndex);
|
||||
returnCode = snprintf(userX, PARAMETER_SIZE_LIMIT, "USER_%d", userIndex);
|
||||
returnCode = snprintf(passwordX, PARAMETER_SIZE_LIMIT, "PASSWORD_%d", userIndex);
|
||||
returnCode = snprintf(homeX, PARAMETER_SIZE_LIMIT, "HOME_%d", userIndex);
|
||||
returnCode = snprintf(groupOwnerX, PARAMETER_SIZE_LIMIT, "GROUP_NAME_OWNER_%d", userIndex);
|
||||
returnCode = snprintf(userOwnerX, PARAMETER_SIZE_LIMIT, "USER_NAME_OWNER_%d", userIndex);
|
||||
userIndex++;
|
||||
|
||||
searchUserIndex = searchParameter(userX, parametersVector);
|
||||
@ -568,8 +603,7 @@ static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_Ve
|
||||
printf("\nuserData.gid = %d", userData.ownerShip.gid);
|
||||
printf("\nuserData.uid = %d", userData.ownerShip.uid);
|
||||
printf("\nuserData.ownerShipSet = %d", userData.ownerShip.ownerShipSet);
|
||||
|
||||
|
||||
|
||||
ftpParameters->usersVector.PushBack(&ftpParameters->usersVector, &userData, sizeof(usersParameters_DataType));
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,238 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#include "../ftpData.h"
|
||||
#include "connection.h"
|
||||
|
||||
|
||||
|
||||
int socketPrintf(ftpDataType * ftpData, int clientId, const char *__restrict __fmt, ...)
|
||||
{
|
||||
#define COMMAND_BUFFER 9600
|
||||
#define SOCKET_PRINTF_BUFFER 2048
|
||||
int bytesWritten = 0;
|
||||
char theBuffer[SOCKET_PRINTF_BUFFER];
|
||||
char commandBuffer[COMMAND_BUFFER];
|
||||
int theStringSize = 0, theCommandSize = 0;
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
memset(&commandBuffer, 0, COMMAND_BUFFER);
|
||||
printf("\nWriting to socket id %d, TLS %d: ", clientId, ftpData->clients[clientId].tlsIsEnabled);
|
||||
|
||||
pthread_mutex_lock(&ftpData->clients[clientId].writeMutex);
|
||||
|
||||
va_list args;
|
||||
va_start(args, __fmt);
|
||||
while (*__fmt != '\0')
|
||||
{
|
||||
int i = 0;
|
||||
theStringSize = 0;
|
||||
switch(*__fmt)
|
||||
{
|
||||
case 'd':
|
||||
case 'D':
|
||||
{
|
||||
int theInteger = va_arg(args, int);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%d", theInteger);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
case 'C':
|
||||
{
|
||||
int theCharInteger = va_arg(args, int);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%c", theCharInteger);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'F':
|
||||
{
|
||||
float theDouble = va_arg(args, double);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%f", theDouble);
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
case 'S':
|
||||
{
|
||||
char * theString = va_arg(args, char *);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%s", theString);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'L':
|
||||
{
|
||||
long long int theLongLongInt = va_arg(args, long long int);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%lld", theLongLongInt);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
printf("\n Switch is default (%c)", *__fmt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i <theStringSize; i++)
|
||||
{
|
||||
if (theCommandSize < COMMAND_BUFFER)
|
||||
{
|
||||
commandBuffer[theCommandSize++] = theBuffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
++__fmt;
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
|
||||
if (ftpData->clients[clientId].tlsIsEnabled != 1)
|
||||
{
|
||||
bytesWritten = write(ftpData->clients[clientId].socketDescriptor, commandBuffer, theCommandSize);
|
||||
}
|
||||
else if (ftpData->clients[clientId].tlsIsEnabled == 1)
|
||||
{
|
||||
#ifdef OPENSSL_ENABLED
|
||||
bytesWritten = SSL_write(ftpData->clients[clientId].ssl, commandBuffer, theCommandSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
printf("\n%s", commandBuffer);
|
||||
|
||||
pthread_mutex_unlock(&ftpData->clients[clientId].writeMutex);
|
||||
|
||||
return bytesWritten;
|
||||
}
|
||||
|
||||
int socketWorkerPrintf(ftpDataType * ftpData, int clientId, const char *__restrict __fmt, ...)
|
||||
{
|
||||
#define SOCKET_PRINTF_BUFFER 2048
|
||||
|
||||
int bytesWritten = 0;
|
||||
char theBuffer[SOCKET_PRINTF_BUFFER];
|
||||
int theStringSize = 0;
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
printf("\nWriting to worker socket id %dd, TLS %d: ", clientId, ftpData->clients[clientId].dataChannelIsTls);
|
||||
va_list args;
|
||||
va_start(args, __fmt);
|
||||
while (*__fmt != '\0')
|
||||
{
|
||||
theStringSize = 0;
|
||||
switch(*__fmt)
|
||||
{
|
||||
case 'd':
|
||||
case 'D':
|
||||
{
|
||||
int theInteger = va_arg(args, int);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%d", theInteger);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
case 'C':
|
||||
{
|
||||
int theCharInteger = va_arg(args, int);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%c", theCharInteger);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'F':
|
||||
{
|
||||
float theDouble = va_arg(args, double);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%f", theDouble);
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
case 'S':
|
||||
{
|
||||
char * theString = va_arg(args, char *);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%s", theString);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'L':
|
||||
{
|
||||
long long int theLongLongInt = va_arg(args, long long int);
|
||||
memset(&theBuffer, 0, SOCKET_PRINTF_BUFFER);
|
||||
theStringSize = snprintf(theBuffer, SOCKET_PRINTF_BUFFER, "%lld", theLongLongInt);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
printf("\n Switch is default (%c)", *__fmt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (theStringSize >= SOCKET_PRINTF_BUFFER) {
|
||||
printf("\n String buffer is full!");
|
||||
}
|
||||
else if (theStringSize < SOCKET_PRINTF_BUFFER &&
|
||||
theStringSize > 0)
|
||||
{
|
||||
int theReturnCode = 0;
|
||||
|
||||
if (ftpData->clients[clientId].dataChannelIsTls != 1)
|
||||
{
|
||||
theReturnCode = write(ftpData->clients[clientId].workerData.socketConnection, theBuffer, theStringSize);
|
||||
}
|
||||
else if (ftpData->clients[clientId].dataChannelIsTls == 1)
|
||||
{
|
||||
|
||||
#ifdef OPENSSL_ENABLED
|
||||
if (ftpData->clients[clientId].workerData.passiveModeOn == 1){
|
||||
theReturnCode = SSL_write(ftpData->clients[clientId].workerData.serverSsl, theBuffer, theStringSize);
|
||||
printf("%s", theBuffer);
|
||||
}
|
||||
else if (ftpData->clients[clientId].workerData.activeModeOn == 1){
|
||||
theReturnCode = SSL_write(ftpData->clients[clientId].workerData.clientSsl, theBuffer, theStringSize);
|
||||
printf("%s", theBuffer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (theReturnCode > 0)
|
||||
{
|
||||
bytesWritten += theReturnCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytesWritten = theReturnCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(theStringSize == 0)
|
||||
{
|
||||
printf("\n Nothing to write.. ");
|
||||
}
|
||||
|
||||
++__fmt;
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return bytesWritten;
|
||||
}
|
||||
|
||||
/* Return the higher socket available*/
|
||||
int getMaximumSocketFd(int mainSocket, ftpDataType * ftpData)
|
||||
{
|
||||
@ -132,7 +360,9 @@ int createActiveSocket(int port, char *ipAddress)
|
||||
{
|
||||
int sockfd;
|
||||
struct sockaddr_in serv_addr;
|
||||
|
||||
|
||||
printf("\n Connection socket is going to start ip: %s:%d \n", ipAddress, port);
|
||||
//sleep(100);
|
||||
memset(&serv_addr, 0, sizeof(struct sockaddr_in));
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(port);
|
||||
@ -211,8 +441,8 @@ void closeSocket(ftpDataType * ftpData, int processingSocket)
|
||||
shutdown(ftpData->clients[processingSocket].socketDescriptor, SHUT_RDWR);
|
||||
close(ftpData->clients[processingSocket].socketDescriptor);
|
||||
|
||||
resetClientData(&ftpData->clients[processingSocket], 0);
|
||||
resetWorkerData(&ftpData->clients[processingSocket].workerData, 0);
|
||||
resetClientData(ftpData, processingSocket, 0);
|
||||
resetWorkerData(ftpData, processingSocket, 0);
|
||||
|
||||
//Update client connecteds
|
||||
ftpData->connectedClients--;
|
||||
@ -232,10 +462,10 @@ void closeClient(ftpDataType * ftpData, int processingSocket)
|
||||
|
||||
if (ftpData->clients[processingSocket].workerData.threadIsAlive == 1)
|
||||
{
|
||||
void *pReturn;
|
||||
pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread);
|
||||
pthread_join(ftpData->clients[processingSocket].workerData.workerThread, &pReturn);
|
||||
printf("\nQuit command received the Pasv Thread has been cancelled.");
|
||||
void *pReturn;
|
||||
pthread_cancel(ftpData->clients[processingSocket].workerData.workerThread);
|
||||
//pthread_join(ftpData->clients[processingSocket].workerData.workerThread, &pReturn);
|
||||
printf("\nQuit command received the Pasv Thread has been cancelled.");
|
||||
}
|
||||
|
||||
FD_CLR(ftpData->clients[processingSocket].socketDescriptor, &ftpData->connectionData.rsetAll);
|
||||
@ -381,12 +611,16 @@ int evaluateClientSocketConnection(ftpDataType * ftpData)
|
||||
if (ftpData->ftpParameters.maximumConnectionsPerIp > 0 &&
|
||||
numberOfConnectionFromSameIp >= ftpData->ftpParameters.maximumConnectionsPerIp)
|
||||
{
|
||||
dprintf(ftpData->clients[availableSocketIndex].socketDescriptor, "530 too many connection from your ip address %s \r\n", ftpData->clients[availableSocketIndex].clientIpAddress);
|
||||
int theReturnCode = socketPrintf(ftpData, availableSocketIndex, "sss", "530 too many connection from your ip address ", ftpData->clients[availableSocketIndex].clientIpAddress, " \r\n");
|
||||
ftpData->clients[availableSocketIndex].closeTheClient = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
write(ftpData->clients[availableSocketIndex].socketDescriptor, ftpData->welcomeMessage, strlen(ftpData->welcomeMessage));
|
||||
int returnCode = socketPrintf(ftpData, availableSocketIndex, "s", ftpData->welcomeMessage);
|
||||
if (returnCode <= 0)
|
||||
{
|
||||
ftpData->clients[availableSocketIndex].closeTheClient = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -410,14 +644,9 @@ int evaluateClientSocketConnection(ftpDataType * ftpData)
|
||||
write(socketRefuseFd, messageToWrite, strlen(messageToWrite));
|
||||
shutdown(socketRefuseFd, SHUT_RDWR);
|
||||
close(socketRefuseFd);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpData->clients[availableSocketIndex].closeTheClient = 1;
|
||||
printf("\n3 Errno = %d", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -48,7 +48,8 @@ int selectWait(ftpDataType * ftpData);
|
||||
int isClientConnected(ftpDataType * ftpData, int cliendId);
|
||||
int getAvailableClientSocketIndex(ftpDataType * ftpData);
|
||||
int evaluateClientSocketConnection(ftpDataType * ftpData);
|
||||
|
||||
int socketPrintf(ftpDataType * ftpData, int clientId, const char *__restrict __fmt, ...);
|
||||
int socketWorkerPrintf(ftpDataType * ftpData, int clientId, const char *__restrict __fmt, ...);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -44,7 +44,8 @@ int isProcessAlreadyRunning(void)
|
||||
{
|
||||
int fd;
|
||||
int returnCode;
|
||||
char buf[16];
|
||||
char buf[30];
|
||||
memset(buf, 0,30);
|
||||
fd = open(LOCKFILE, O_RDWR|O_CREAT, LOCKMODE);
|
||||
if (fd < 0)
|
||||
{
|
||||
@ -66,8 +67,8 @@ int isProcessAlreadyRunning(void)
|
||||
|
||||
//printf("\nFILE_LockFile returnCode = %d", returnCode);
|
||||
ftruncate(fd, 0);
|
||||
sprintf(buf, "%ld", (long)getpid());
|
||||
write(fd, buf, strlen(buf)+1);
|
||||
returnCode = snprintf(buf, 100, "%ld", (long)getpid());
|
||||
returnCode = write(fd, buf, strlen(buf)+1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -133,4 +134,4 @@ void daemonize(const char *cmd)
|
||||
fd0 = open("/dev/null", O_RDWR);
|
||||
fd1 = dup(0);
|
||||
fd2 = dup(0);
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,8 @@ long int FILE_GetAvailableSpace(const char* path)
|
||||
/* Get the file size */
|
||||
long long int FILE_GetFileSize(FILE *TheFilePointer)
|
||||
{
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
#ifdef LARGE_FILE_SUPPORT_ENABLED
|
||||
//#warning LARGE FILE SUPPORT IS ENABLED!
|
||||
long long int Prev = 0, TheFileSize = 0;
|
||||
Prev = ftello64(TheFilePointer);
|
||||
fseeko64(TheFilePointer, 0, SEEK_END);
|
||||
@ -100,7 +101,8 @@ long long int FILE_GetFileSize(FILE *TheFilePointer)
|
||||
return TheFileSize;
|
||||
#endif
|
||||
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#ifndef LARGE_FILE_SUPPORT_ENABLED
|
||||
#warning LARGE FILE SUPPORT IS NOT ENABLED!
|
||||
long long int Prev = 0, TheFileSize = 0;
|
||||
Prev = ftell(TheFilePointer);
|
||||
fseek(TheFilePointer, 0, SEEK_END);
|
||||
@ -114,7 +116,8 @@ long long int FILE_GetFileSizeFromPath(char *TheFileName)
|
||||
{
|
||||
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
#ifdef LARGE_FILE_SUPPORT_ENABLED
|
||||
//#warning LARGE FILE SUPPORT IS ENABLED!
|
||||
if (FILE_IsFile(TheFileName) == 1)
|
||||
{
|
||||
FILE *TheFilePointer;
|
||||
@ -133,7 +136,8 @@ long long int FILE_GetFileSizeFromPath(char *TheFileName)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#ifndef LARGE_FILE_SUPPORT_ENABLED
|
||||
#warning LARGE FILE SUPPORT IS NOT ENABLED!
|
||||
if (FILE_IsFile(TheFileName) == 1)
|
||||
{
|
||||
FILE *TheFilePointer;
|
||||
@ -160,11 +164,13 @@ int FILE_IsFile(const char *TheFileName)
|
||||
{
|
||||
FILE *TheFile;
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
#ifdef LARGE_FILE_SUPPORT_ENABLED
|
||||
//#warning LARGE FILE SUPPORT IS ENABLED!
|
||||
TheFile = fopen64(TheFileName, "rb");
|
||||
#endif
|
||||
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#ifndef LARGE_FILE_SUPPORT_ENABLED
|
||||
#warning LARGE FILE SUPPORT IS NOT ENABLED!
|
||||
TheFile = fopen(TheFileName, "rb");
|
||||
#endif
|
||||
|
||||
@ -190,7 +196,7 @@ void FILE_GetDirectoryInodeList(char * DirectoryInodeName, char *** InodeList, i
|
||||
|
||||
if (FILE_IsDirectory(DirectoryInodeName))
|
||||
{
|
||||
printf("\nReading directory: %s", DirectoryInodeName);
|
||||
//printf("\nReading directory: %s", DirectoryInodeName);
|
||||
|
||||
DIR *TheDirectory;
|
||||
struct dirent *dir;
|
||||
@ -293,11 +299,13 @@ int FILE_GetStringFromFile(char * filename, char **file_content)
|
||||
}
|
||||
|
||||
|
||||
#ifdef _LARGEFILE64_SOURCE
|
||||
#ifdef LARGE_FILE_SUPPORT_ENABLED
|
||||
//#warning LARGE FILE SUPPORT IS ENABLED!
|
||||
FILE *file = fopen64(filename, "rb");
|
||||
#endif
|
||||
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#ifndef LARGE_FILE_SUPPORT_ENABLED
|
||||
#warning LARGE FILE SUPPORT IS NOT ENABLED!
|
||||
FILE *file = fopen(filename, "rb");
|
||||
#endif
|
||||
|
||||
|
229
library/openSsl.c
Normal file
229
library/openSsl.c
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2018 Ugo Cirmignani.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifdef OPENSSL_ENABLED
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include "openSsl.h"
|
||||
#include "fileManagement.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#define MUTEX_TYPE pthread_mutex_t
|
||||
#define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
|
||||
#define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
|
||||
#define MUTEX_LOCK(x) pthread_mutex_lock(&(x))
|
||||
#define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
|
||||
#define THREAD_ID pthread_self()
|
||||
|
||||
/* This array will store all of the mutexes available to OpenSSL. */
|
||||
static MUTEX_TYPE *mutex_buf = NULL;
|
||||
|
||||
void initOpenssl()
|
||||
{
|
||||
OpenSSL_add_all_algorithms(); /* Load cryptos, et.al. */
|
||||
SSL_load_error_strings(); /* Bring in and register error messages */
|
||||
ERR_load_BIO_strings();
|
||||
ERR_load_crypto_strings();
|
||||
SSL_library_init();
|
||||
thread_setup();
|
||||
}
|
||||
|
||||
void cleanupOpenssl()
|
||||
{
|
||||
thread_cleanup();
|
||||
EVP_cleanup();
|
||||
}
|
||||
|
||||
SSL_CTX *createServerContext()
|
||||
{
|
||||
const SSL_METHOD *method;
|
||||
SSL_CTX *ctx;
|
||||
|
||||
method = TLS_server_method();
|
||||
|
||||
ctx = SSL_CTX_new(method);
|
||||
if (!ctx)
|
||||
{
|
||||
perror("Unable to create server SSL context");
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
SSL_CTX *createClientContext(void)
|
||||
{
|
||||
const SSL_METHOD *method;
|
||||
SSL_CTX *ctx;
|
||||
method = TLS_client_method(); /* Create new client-method instance */
|
||||
ctx = SSL_CTX_new(method); /* Create new context */
|
||||
//SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1);
|
||||
//SSL_CTX_set_options(ctx, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION | SSL_OP_CIPHER_SERVER_PREFERENCE| SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1);
|
||||
//SSL_CTX_set_ecdh_auto(ctx, 1);
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
perror("Unable to create server SSL context");
|
||||
ERR_print_errors_fp(stderr);
|
||||
abort();
|
||||
exit(0);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
void configureClientContext(SSL_CTX *ctx, char *certificatePath, char* privateCertificatePath)
|
||||
{/*
|
||||
if (FILE_IsFile(certificatePath) != 1)
|
||||
{
|
||||
printf("\ncertificate file: %s not found!", certificatePath);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (FILE_IsFile(privateCertificatePath) != 1)
|
||||
{
|
||||
printf("\ncertificate file: %s not found!", privateCertificatePath);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Set the key and cert
|
||||
if (SSL_CTX_use_certificate_file(ctx, certificatePath, SSL_FILETYPE_PEM) <= 0) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_PrivateKey_file(ctx, privateCertificatePath, SSL_FILETYPE_PEM) <= 0 ) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
} */
|
||||
}
|
||||
|
||||
void configureContext(SSL_CTX *ctx, char *certificatePath, char* privateCertificatePath)
|
||||
{
|
||||
if (FILE_IsFile(certificatePath) != 1)
|
||||
{
|
||||
printf("\ncertificate file: %s not found!", certificatePath);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (FILE_IsFile(privateCertificatePath) != 1)
|
||||
{
|
||||
printf("\ncertificate file: %s not found!", privateCertificatePath);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
SSL_CTX_set_ecdh_auto(ctx, 1);
|
||||
|
||||
/* Set the key and cert */
|
||||
if (SSL_CTX_use_certificate_file(ctx, certificatePath, SSL_FILETYPE_PEM) <= 0) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_PrivateKey_file(ctx, privateCertificatePath, SSL_FILETYPE_PEM) <= 0 ) {
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShowCerts(SSL* ssl)
|
||||
{ X509 *cert;
|
||||
char *line;
|
||||
|
||||
cert = SSL_get_peer_certificate(ssl); /* get the server's certificate */
|
||||
if ( cert != NULL )
|
||||
{
|
||||
printf("Server certificates:\n");
|
||||
line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0);
|
||||
printf("Subject: %s\n", line);
|
||||
free(line); /* free the malloc'ed string */
|
||||
line = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0);
|
||||
printf("Issuer: %s\n", line);
|
||||
free(line); /* free the malloc'ed string */
|
||||
X509_free(cert); /* free the malloc'ed certificate copy */
|
||||
}
|
||||
else
|
||||
printf("No certificates.\n");
|
||||
}
|
||||
|
||||
|
||||
void handle_error(const char *file, int lineno, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "** %s:%d %s\n", file, lineno, msg);
|
||||
ERR_print_errors_fp(stderr);
|
||||
/* exit(-1); */
|
||||
}
|
||||
|
||||
static void locking_function(int mode, int n, const char *file, int line)
|
||||
{
|
||||
if(mode & CRYPTO_LOCK)
|
||||
MUTEX_LOCK(mutex_buf[n]);
|
||||
else
|
||||
MUTEX_UNLOCK(mutex_buf[n]);
|
||||
}
|
||||
|
||||
static unsigned long id_function(void)
|
||||
{
|
||||
return ((unsigned long)THREAD_ID);
|
||||
}
|
||||
|
||||
int thread_setup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
mutex_buf = malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE));
|
||||
if(!mutex_buf)
|
||||
return 0;
|
||||
for(i = 0; i < CRYPTO_num_locks(); i++)
|
||||
MUTEX_SETUP(mutex_buf[i]);
|
||||
CRYPTO_set_id_callback(id_function);
|
||||
CRYPTO_set_locking_callback(locking_function);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int thread_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!mutex_buf)
|
||||
return 0;
|
||||
CRYPTO_set_id_callback(NULL);
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
for(i = 0; i < CRYPTO_num_locks(); i++)
|
||||
MUTEX_CLEANUP(mutex_buf[i]);
|
||||
free(mutex_buf);
|
||||
mutex_buf = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
52
library/openSsl.h
Normal file
52
library/openSsl.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2018 Ugo Cirmignani.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifdef OPENSSL_ENABLED
|
||||
#ifndef OPENSSL_H
|
||||
#define OPENSSL_H
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#define TLS_NEGOTIATING_TIMEOUT 30
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void initOpenssl();
|
||||
void cleanupOpenssl();
|
||||
int thread_cleanup(void);
|
||||
int thread_setup(void);
|
||||
void handle_error(const char *file, int lineno, const char *msg);
|
||||
SSL_CTX *createServerContext();
|
||||
SSL_CTX *createClientContext();
|
||||
void configureContext(SSL_CTX *ctx, char *certificatePath, char* privateCertificatePath);
|
||||
void configureClientContext(SSL_CTX *ctx, char *certificatePath, char* privateCertificatePath);
|
||||
void ShowCerts(SSL* ssl);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OPENSSL_H */
|
||||
#endif
|
@ -56,9 +56,17 @@ static void ignore_sigpipe(void)
|
||||
}
|
||||
}
|
||||
|
||||
void onUftpClose(int sig)
|
||||
{
|
||||
printf("\nuFTP exit()\n");
|
||||
deallocateMemory();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void signalHandlerInstall(void)
|
||||
{
|
||||
//signal(SIGPIPE, signal_callback_handler);
|
||||
signal(SIGINT,onUftpClose);
|
||||
signal(SIGUSR2,SIG_IGN);
|
||||
signal(SIGPIPE,SIG_IGN);
|
||||
signal(SIGALRM,SIG_IGN);
|
||||
|
@ -31,6 +31,7 @@ extern "C" {
|
||||
|
||||
void signalHandlerInstall(void);
|
||||
void signal_callback_handler(int signum);
|
||||
void onUftpClose(int sig);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,143 +0,0 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a -pre and a -post target defined where you can add customized code.
|
||||
#
|
||||
# This makefile implements configuration specific macros and targets.
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
GREP=grep
|
||||
NM=nm
|
||||
CCADMIN=CCadmin
|
||||
RANLIB=ranlib
|
||||
CC=gcc
|
||||
CCC=g++
|
||||
CXX=g++
|
||||
FC=gfortran
|
||||
AS=as
|
||||
|
||||
# Macros
|
||||
CND_PLATFORM=GNU-Linux
|
||||
CND_DLIB_EXT=so
|
||||
CND_CONF=Debug
|
||||
CND_DISTDIR=dist
|
||||
CND_BUILDDIR=build
|
||||
|
||||
# Include project Makefile
|
||||
include Makefile
|
||||
|
||||
# Object Directory
|
||||
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
|
||||
|
||||
# Object Files
|
||||
OBJECTFILES= \
|
||||
${OBJECTDIR}/ftpCommandElaborate.o \
|
||||
${OBJECTDIR}/ftpData.o \
|
||||
${OBJECTDIR}/ftpServer.o \
|
||||
${OBJECTDIR}/library/configRead.o \
|
||||
${OBJECTDIR}/library/connection.o \
|
||||
${OBJECTDIR}/library/daemon.o \
|
||||
${OBJECTDIR}/library/dynamicVectors.o \
|
||||
${OBJECTDIR}/library/fileManagement.o \
|
||||
${OBJECTDIR}/library/logFunctions.o \
|
||||
${OBJECTDIR}/library/signals.o \
|
||||
${OBJECTDIR}/uFTP.o
|
||||
|
||||
|
||||
# C Compiler Flags
|
||||
CFLAGS=-pthread
|
||||
|
||||
# CC Compiler Flags
|
||||
CCFLAGS=
|
||||
CXXFLAGS=
|
||||
|
||||
# Fortran Compiler Flags
|
||||
FFLAGS=
|
||||
|
||||
# Assembler Flags
|
||||
ASFLAGS=
|
||||
|
||||
# Link Libraries and Options
|
||||
LDLIBSOPTIONS=
|
||||
|
||||
# Build Targets
|
||||
.build-conf: ${BUILD_SUBPROJECTS}
|
||||
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp
|
||||
|
||||
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp: ${OBJECTFILES}
|
||||
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
|
||||
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||
|
||||
${OBJECTDIR}/ftpCommandElaborate.o: ftpCommandElaborate.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpCommandElaborate.o ftpCommandElaborate.c
|
||||
|
||||
${OBJECTDIR}/ftpData.o: ftpData.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpData.o ftpData.c
|
||||
|
||||
${OBJECTDIR}/ftpServer.o: ftpServer.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpServer.o ftpServer.c
|
||||
|
||||
${OBJECTDIR}/library/configRead.o: library/configRead.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/configRead.o library/configRead.c
|
||||
|
||||
${OBJECTDIR}/library/connection.o: library/connection.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/connection.o library/connection.c
|
||||
|
||||
${OBJECTDIR}/library/daemon.o: library/daemon.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/daemon.o library/daemon.c
|
||||
|
||||
${OBJECTDIR}/library/dynamicVectors.o: library/dynamicVectors.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/dynamicVectors.o library/dynamicVectors.c
|
||||
|
||||
${OBJECTDIR}/library/fileManagement.o: library/fileManagement.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/fileManagement.o library/fileManagement.c
|
||||
|
||||
${OBJECTDIR}/library/logFunctions.o: library/logFunctions.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
|
||||
|
||||
${OBJECTDIR}/library/signals.o: library/signals.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
|
||||
|
||||
${OBJECTDIR}/uFTP.o: uFTP.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -g -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/uFTP.o uFTP.c
|
||||
|
||||
# Subprojects
|
||||
.build-subprojects:
|
||||
|
||||
# Clean Targets
|
||||
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
|
||||
|
||||
# Subprojects
|
||||
.clean-subprojects:
|
||||
|
||||
# Enable dependency checking
|
||||
.dep.inc: .depcheck-impl
|
||||
|
||||
include .dep.inc
|
@ -1,143 +0,0 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a -pre and a -post target defined where you can add customized code.
|
||||
#
|
||||
# This makefile implements configuration specific macros and targets.
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
GREP=grep
|
||||
NM=nm
|
||||
CCADMIN=CCadmin
|
||||
RANLIB=ranlib
|
||||
CC=gcc
|
||||
CCC=g++
|
||||
CXX=g++
|
||||
FC=gfortran
|
||||
AS=as
|
||||
|
||||
# Macros
|
||||
CND_PLATFORM=GNU-Linux
|
||||
CND_DLIB_EXT=so
|
||||
CND_CONF=Release
|
||||
CND_DISTDIR=dist
|
||||
CND_BUILDDIR=build
|
||||
|
||||
# Include project Makefile
|
||||
include Makefile
|
||||
|
||||
# Object Directory
|
||||
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
|
||||
|
||||
# Object Files
|
||||
OBJECTFILES= \
|
||||
${OBJECTDIR}/ftpCommandElaborate.o \
|
||||
${OBJECTDIR}/ftpData.o \
|
||||
${OBJECTDIR}/ftpServer.o \
|
||||
${OBJECTDIR}/library/configRead.o \
|
||||
${OBJECTDIR}/library/connection.o \
|
||||
${OBJECTDIR}/library/daemon.o \
|
||||
${OBJECTDIR}/library/dynamicVectors.o \
|
||||
${OBJECTDIR}/library/fileManagement.o \
|
||||
${OBJECTDIR}/library/logFunctions.o \
|
||||
${OBJECTDIR}/library/signals.o \
|
||||
${OBJECTDIR}/uFTP.o
|
||||
|
||||
|
||||
# C Compiler Flags
|
||||
CFLAGS=
|
||||
|
||||
# CC Compiler Flags
|
||||
CCFLAGS=
|
||||
CXXFLAGS=
|
||||
|
||||
# Fortran Compiler Flags
|
||||
FFLAGS=
|
||||
|
||||
# Assembler Flags
|
||||
ASFLAGS=
|
||||
|
||||
# Link Libraries and Options
|
||||
LDLIBSOPTIONS=
|
||||
|
||||
# Build Targets
|
||||
.build-conf: ${BUILD_SUBPROJECTS}
|
||||
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp
|
||||
|
||||
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp: ${OBJECTFILES}
|
||||
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
|
||||
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||
|
||||
${OBJECTDIR}/ftpCommandElaborate.o: ftpCommandElaborate.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpCommandElaborate.o ftpCommandElaborate.c
|
||||
|
||||
${OBJECTDIR}/ftpData.o: ftpData.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpData.o ftpData.c
|
||||
|
||||
${OBJECTDIR}/ftpServer.o: ftpServer.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpServer.o ftpServer.c
|
||||
|
||||
${OBJECTDIR}/library/configRead.o: library/configRead.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/configRead.o library/configRead.c
|
||||
|
||||
${OBJECTDIR}/library/connection.o: library/connection.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/connection.o library/connection.c
|
||||
|
||||
${OBJECTDIR}/library/daemon.o: library/daemon.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/daemon.o library/daemon.c
|
||||
|
||||
${OBJECTDIR}/library/dynamicVectors.o: library/dynamicVectors.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/dynamicVectors.o library/dynamicVectors.c
|
||||
|
||||
${OBJECTDIR}/library/fileManagement.o: library/fileManagement.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/fileManagement.o library/fileManagement.c
|
||||
|
||||
${OBJECTDIR}/library/logFunctions.o: library/logFunctions.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
|
||||
|
||||
${OBJECTDIR}/library/signals.o: library/signals.c
|
||||
${MKDIR} -p ${OBJECTDIR}/library
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
|
||||
|
||||
${OBJECTDIR}/uFTP.o: uFTP.c
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} "$@.d"
|
||||
$(COMPILE.c) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/uFTP.o uFTP.c
|
||||
|
||||
# Subprojects
|
||||
.build-subprojects:
|
||||
|
||||
# Clean Targets
|
||||
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
|
||||
|
||||
# Subprojects
|
||||
.clean-subprojects:
|
||||
|
||||
# Enable dependency checking
|
||||
.dep.inc: .depcheck-impl
|
||||
|
||||
include .dep.inc
|
@ -1,133 +0,0 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a pre- and a post- target defined where you can add customization code.
|
||||
#
|
||||
# This makefile implements macros and targets common to all configurations.
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
|
||||
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
|
||||
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
|
||||
# and .clean-reqprojects-conf unless SUB has the value 'no'
|
||||
SUB_no=NO
|
||||
SUBPROJECTS=${SUB_${SUB}}
|
||||
BUILD_SUBPROJECTS_=.build-subprojects
|
||||
BUILD_SUBPROJECTS_NO=
|
||||
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
|
||||
CLEAN_SUBPROJECTS_=.clean-subprojects
|
||||
CLEAN_SUBPROJECTS_NO=
|
||||
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
|
||||
|
||||
|
||||
# Project Name
|
||||
PROJECTNAME=uFTP
|
||||
|
||||
# Active Configuration
|
||||
DEFAULTCONF=Debug
|
||||
CONF=${DEFAULTCONF}
|
||||
|
||||
# All Configurations
|
||||
ALLCONFS=Debug Release
|
||||
|
||||
|
||||
# build
|
||||
.build-impl: .build-pre .validate-impl .depcheck-impl
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
|
||||
|
||||
|
||||
# clean
|
||||
.clean-impl: .clean-pre .validate-impl .depcheck-impl
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
|
||||
|
||||
|
||||
# clobber
|
||||
.clobber-impl: .clobber-pre .depcheck-impl
|
||||
@#echo "=> Running $@..."
|
||||
for CONF in ${ALLCONFS}; \
|
||||
do \
|
||||
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
|
||||
done
|
||||
|
||||
# all
|
||||
.all-impl: .all-pre .depcheck-impl
|
||||
@#echo "=> Running $@..."
|
||||
for CONF in ${ALLCONFS}; \
|
||||
do \
|
||||
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
|
||||
done
|
||||
|
||||
# build tests
|
||||
.build-tests-impl: .build-impl .build-tests-pre
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
|
||||
|
||||
# run tests
|
||||
.test-impl: .build-tests-impl .test-pre
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
|
||||
|
||||
# dependency checking support
|
||||
.depcheck-impl:
|
||||
@echo "# This code depends on make tool being used" >.dep.inc
|
||||
@if [ -n "${MAKE_VERSION}" ]; then \
|
||||
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
|
||||
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
|
||||
echo "include \$${DEPFILES}" >>.dep.inc; \
|
||||
echo "endif" >>.dep.inc; \
|
||||
else \
|
||||
echo ".KEEP_STATE:" >>.dep.inc; \
|
||||
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
|
||||
fi
|
||||
|
||||
# configuration validation
|
||||
.validate-impl:
|
||||
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
|
||||
then \
|
||||
echo ""; \
|
||||
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
|
||||
echo "See 'make help' for details."; \
|
||||
echo "Current directory: " `pwd`; \
|
||||
echo ""; \
|
||||
fi
|
||||
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
|
||||
then \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
# help
|
||||
.help-impl: .help-pre
|
||||
@echo "This makefile supports the following configurations:"
|
||||
@echo " ${ALLCONFS}"
|
||||
@echo ""
|
||||
@echo "and the following targets:"
|
||||
@echo " build (default target)"
|
||||
@echo " clean"
|
||||
@echo " clobber"
|
||||
@echo " all"
|
||||
@echo " help"
|
||||
@echo ""
|
||||
@echo "Makefile Usage:"
|
||||
@echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
|
||||
@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
|
||||
@echo " make [SUB=no] clobber"
|
||||
@echo " make [SUB=no] all"
|
||||
@echo " make help"
|
||||
@echo ""
|
||||
@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
|
||||
@echo " also build subprojects."
|
||||
@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
|
||||
@echo " also clean subprojects."
|
||||
@echo "Target 'clobber' will remove all built files from all configurations and,"
|
||||
@echo " unless 'SUB=no', also from subprojects."
|
||||
@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
|
||||
@echo " also build subprojects."
|
||||
@echo "Target 'help' prints this message."
|
||||
@echo ""
|
||||
|
@ -1,35 +0,0 @@
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
# NOCDDL
|
||||
#
|
||||
CND_BASEDIR=`pwd`
|
||||
CND_BUILDDIR=build
|
||||
CND_DISTDIR=dist
|
||||
# Debug configuration
|
||||
CND_PLATFORM_Debug=GNU-Linux
|
||||
CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux
|
||||
CND_ARTIFACT_NAME_Debug=uftp
|
||||
CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/uftp
|
||||
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
|
||||
CND_PACKAGE_NAME_Debug=uftp.tar
|
||||
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/uftp.tar
|
||||
# Release configuration
|
||||
CND_PLATFORM_Release=GNU-Linux
|
||||
CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux
|
||||
CND_ARTIFACT_NAME_Release=uftp
|
||||
CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/uftp
|
||||
CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package
|
||||
CND_PACKAGE_NAME_Release=uftp.tar
|
||||
CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/uftp.tar
|
||||
#
|
||||
# include compiler specific variables
|
||||
#
|
||||
# dmake command
|
||||
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
|
||||
(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
|
||||
#
|
||||
# gmake command
|
||||
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
|
||||
#
|
||||
include nbproject/private/Makefile-variables.mk
|
@ -1,76 +0,0 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
|
||||
# Macros
|
||||
TOP=`pwd`
|
||||
CND_PLATFORM=GNU-Linux
|
||||
CND_CONF=Debug
|
||||
CND_DISTDIR=dist
|
||||
CND_BUILDDIR=build
|
||||
CND_DLIB_EXT=so
|
||||
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
|
||||
TMPDIRNAME=tmp-packaging
|
||||
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp
|
||||
OUTPUT_BASENAME=uftp
|
||||
PACKAGE_TOP_DIR=uftp/
|
||||
|
||||
# Functions
|
||||
function checkReturnCode
|
||||
{
|
||||
rc=$?
|
||||
if [ $rc != 0 ]
|
||||
then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
function makeDirectory
|
||||
# $1 directory path
|
||||
# $2 permission (optional)
|
||||
{
|
||||
mkdir -p "$1"
|
||||
checkReturnCode
|
||||
if [ "$2" != "" ]
|
||||
then
|
||||
chmod $2 "$1"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
function copyFileToTmpDir
|
||||
# $1 from-file path
|
||||
# $2 to-file path
|
||||
# $3 permission
|
||||
{
|
||||
cp "$1" "$2"
|
||||
checkReturnCode
|
||||
if [ "$3" != "" ]
|
||||
then
|
||||
chmod $3 "$2"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "${TOP}"
|
||||
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
|
||||
rm -rf ${NBTMPDIR}
|
||||
mkdir -p ${NBTMPDIR}
|
||||
|
||||
# Copy files and create directories and links
|
||||
cd "${TOP}"
|
||||
makeDirectory "${NBTMPDIR}/uftp/bin"
|
||||
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
|
||||
|
||||
|
||||
# Generate tar file
|
||||
cd "${TOP}"
|
||||
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/uftp.tar
|
||||
cd ${NBTMPDIR}
|
||||
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/uftp.tar *
|
||||
checkReturnCode
|
||||
|
||||
# Cleanup
|
||||
cd "${TOP}"
|
||||
rm -rf ${NBTMPDIR}
|
@ -1,76 +0,0 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
|
||||
# Macros
|
||||
TOP=`pwd`
|
||||
CND_PLATFORM=GNU-Linux
|
||||
CND_CONF=Release
|
||||
CND_DISTDIR=dist
|
||||
CND_BUILDDIR=build
|
||||
CND_DLIB_EXT=so
|
||||
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
|
||||
TMPDIRNAME=tmp-packaging
|
||||
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp
|
||||
OUTPUT_BASENAME=uftp
|
||||
PACKAGE_TOP_DIR=uftp/
|
||||
|
||||
# Functions
|
||||
function checkReturnCode
|
||||
{
|
||||
rc=$?
|
||||
if [ $rc != 0 ]
|
||||
then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
function makeDirectory
|
||||
# $1 directory path
|
||||
# $2 permission (optional)
|
||||
{
|
||||
mkdir -p "$1"
|
||||
checkReturnCode
|
||||
if [ "$2" != "" ]
|
||||
then
|
||||
chmod $2 "$1"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
function copyFileToTmpDir
|
||||
# $1 from-file path
|
||||
# $2 to-file path
|
||||
# $3 permission
|
||||
{
|
||||
cp "$1" "$2"
|
||||
checkReturnCode
|
||||
if [ "$3" != "" ]
|
||||
then
|
||||
chmod $3 "$2"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "${TOP}"
|
||||
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
|
||||
rm -rf ${NBTMPDIR}
|
||||
mkdir -p ${NBTMPDIR}
|
||||
|
||||
# Copy files and create directories and links
|
||||
cd "${TOP}"
|
||||
makeDirectory "${NBTMPDIR}/uftp/bin"
|
||||
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
|
||||
|
||||
|
||||
# Generate tar file
|
||||
cd "${TOP}"
|
||||
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/uftp.tar
|
||||
cd ${NBTMPDIR}
|
||||
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/uftp.tar *
|
||||
checkReturnCode
|
||||
|
||||
# Cleanup
|
||||
cd "${TOP}"
|
||||
rm -rf ${NBTMPDIR}
|
@ -1,212 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="100">
|
||||
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true">
|
||||
<logicalFolder name="library" displayName="library" projectFiles="true">
|
||||
<itemPath>library/configRead.h</itemPath>
|
||||
<itemPath>library/connection.h</itemPath>
|
||||
<itemPath>library/dynamicVectors.h</itemPath>
|
||||
<itemPath>library/fileManagement.h</itemPath>
|
||||
<itemPath>library/logFunctions.h</itemPath>
|
||||
<itemPath>library/signals.h</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>library/daemon.h</itemPath>
|
||||
<itemPath>ftpCommandsElaborate.h</itemPath>
|
||||
<itemPath>ftpData.h</itemPath>
|
||||
<itemPath>ftpServer.h</itemPath>
|
||||
<itemPath>ftpSpecs.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ResourceFiles"
|
||||
displayName="Resource Files"
|
||||
projectFiles="true">
|
||||
<itemPath>README.md</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="SourceFiles"
|
||||
displayName="Source Files"
|
||||
projectFiles="true">
|
||||
<logicalFolder name="library" displayName="library" projectFiles="true">
|
||||
<itemPath>library/configRead.c</itemPath>
|
||||
<itemPath>library/connection.c</itemPath>
|
||||
<itemPath>library/daemon.c</itemPath>
|
||||
<itemPath>library/dynamicVectors.c</itemPath>
|
||||
<itemPath>library/fileManagement.c</itemPath>
|
||||
<itemPath>library/logFunctions.c</itemPath>
|
||||
<itemPath>library/signals.c</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>MakeFileGeneric</itemPath>
|
||||
<itemPath>ftpCommandElaborate.c</itemPath>
|
||||
<itemPath>ftpData.c</itemPath>
|
||||
<itemPath>ftpServer.c</itemPath>
|
||||
<itemPath>todo.txt</itemPath>
|
||||
<itemPath>uFTP.c</itemPath>
|
||||
<itemPath>uftpd.cfg</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="TestFiles"
|
||||
displayName="Test Files"
|
||||
projectFiles="false"
|
||||
kind="TEST_LOGICAL_FOLDER">
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
projectFiles="false"
|
||||
kind="IMPORTANT_FILES_FOLDER">
|
||||
<itemPath>Makefile</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<sourceRootList>
|
||||
<Elem>library</Elem>
|
||||
</sourceRootList>
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<confs>
|
||||
<conf name="Debug" type="1">
|
||||
<toolsSet>
|
||||
<compilerSet>default</compilerSet>
|
||||
<dependencyChecking>true</dependencyChecking>
|
||||
<rebuildPropChanged>false</rebuildPropChanged>
|
||||
</toolsSet>
|
||||
<compileType>
|
||||
<cTool>
|
||||
<commandlineTool>gcc </commandlineTool>
|
||||
<incDir>
|
||||
<pElem>library</pElem>
|
||||
</incDir>
|
||||
<incFile>
|
||||
<pElem>library/dynamicVectors.h</pElem>
|
||||
<pElem>library/fileManagement.h</pElem>
|
||||
</incFile>
|
||||
<commandLine>-pthread</commandLine>
|
||||
<preprocessorList>
|
||||
<Elem>_LARGEFILE64_SOURCE</Elem>
|
||||
</preprocessorList>
|
||||
</cTool>
|
||||
</compileType>
|
||||
<item path="MakeFileGeneric" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="README.md" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandElaborate.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandsElaborate.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpData.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpData.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpServer.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpServer.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpSpecs.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/configRead.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/configRead.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/connection.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/connection.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/daemon.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/daemon.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/dynamicVectors.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/dynamicVectors.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/fileManagement.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/fileManagement.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/logFunctions.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/logFunctions.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="todo.txt" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="uFTP.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="uftpd.cfg" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
</conf>
|
||||
<conf name="Release" type="1">
|
||||
<toolsSet>
|
||||
<compilerSet>default</compilerSet>
|
||||
<dependencyChecking>true</dependencyChecking>
|
||||
<rebuildPropChanged>false</rebuildPropChanged>
|
||||
</toolsSet>
|
||||
<compileType>
|
||||
<cTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</cTool>
|
||||
<ccTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</ccTool>
|
||||
<fortranCompilerTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</fortranCompilerTool>
|
||||
<asmTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</asmTool>
|
||||
</compileType>
|
||||
<item path="MakeFileGeneric" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="README.md" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandElaborate.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpCommandsElaborate.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpData.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpData.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpServer.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpServer.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="ftpSpecs.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/configRead.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/configRead.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/connection.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/connection.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/daemon.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/daemon.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/dynamicVectors.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/dynamicVectors.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/fileManagement.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/fileManagement.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/logFunctions.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/logFunctions.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="library/signals.h" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="todo.txt" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
<item path="uFTP.c" ex="false" tool="0" flavor2="0">
|
||||
</item>
|
||||
<item path="uftpd.cfg" ex="false" tool="3" flavor2="0">
|
||||
</item>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
@ -1,7 +0,0 @@
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
# NOCDDL
|
||||
#
|
||||
# Debug configuration
|
||||
# Release configuration
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
||||
*
|
||||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
|
||||
* Other names may be trademarks of their respective owners.
|
||||
*
|
||||
* The contents of this file are subject to the terms of either the GNU
|
||||
* General Public License Version 2 only ("GPL") or the Common
|
||||
* Development and Distribution License("CDDL") (collectively, the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. You can obtain a copy of the License at
|
||||
* http://www.netbeans.org/cddl-gplv2.html
|
||||
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
||||
* specific language governing permissions and limitations under the
|
||||
* License. When distributing the software, include this License Header
|
||||
* Notice in each file and include the License file at
|
||||
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the GPL Version 2 section of the License file that
|
||||
* accompanied this code. If applicable, add the following below the
|
||||
* License Header, with the fields enclosed by brackets [] replaced by
|
||||
* your own identifying information:
|
||||
* "Portions Copyrighted [year] [name of copyright owner]"
|
||||
*
|
||||
* If you wish your version of this file to be governed by only the CDDL
|
||||
* or only the GPL Version 2, indicate your decision by adding
|
||||
* "[Contributor] elects to include this software in this distribution
|
||||
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
||||
* single choice of license, a recipient has the option to distribute
|
||||
* your version of this file under either the CDDL, the GPL Version 2 or
|
||||
* to extend the choice of license to its licensees as provided above.
|
||||
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
||||
* Version 2 license, then the option applies only if the new code is
|
||||
* made subject to such option by the copyright holder.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// List of standard headers was taken in http://en.cppreference.com/w/c/header
|
||||
|
||||
#include <assert.h> // Conditionally compiled macro that compares its argument to zero
|
||||
#include <ctype.h> // Functions to determine the type contained in character data
|
||||
#include <errno.h> // Macros reporting error conditions
|
||||
#include <float.h> // Limits of float types
|
||||
#include <limits.h> // Sizes of basic types
|
||||
#include <locale.h> // Localization utilities
|
||||
#include <math.h> // Common mathematics functions
|
||||
#include <setjmp.h> // Nonlocal jumps
|
||||
#include <signal.h> // Signal handling
|
||||
#include <stdarg.h> // Variable arguments
|
||||
#include <stddef.h> // Common macro definitions
|
||||
#include <stdio.h> // Input/output
|
||||
#include <string.h> // String handling
|
||||
#include <stdlib.h> // General utilities: memory management, program utilities, string conversions, random numbers
|
||||
#include <time.h> // Time/date utilities
|
||||
#include <iso646.h> // (since C95) Alternative operator spellings
|
||||
#include <wchar.h> // (since C95) Extended multibyte and wide character utilities
|
||||
#include <wctype.h> // (since C95) Wide character classification and mapping utilities
|
||||
#ifdef _STDC_C99
|
||||
#include <complex.h> // (since C99) Complex number arithmetic
|
||||
#include <fenv.h> // (since C99) Floating-point environment
|
||||
#include <inttypes.h> // (since C99) Format conversion of integer types
|
||||
#include <stdbool.h> // (since C99) Boolean type
|
||||
#include <stdint.h> // (since C99) Fixed-width integer types
|
||||
#include <tgmath.h> // (since C99) Type-generic math (macros wrapping math.h and complex.h)
|
||||
#endif
|
||||
#ifdef _STDC_C11
|
||||
#include <stdalign.h> // (since C11) alignas and alignof convenience macros
|
||||
#include <stdatomic.h> // (since C11) Atomic types
|
||||
#include <stdnoreturn.h> // (since C11) noreturn convenience macros
|
||||
#include <threads.h> // (since C11) Thread library
|
||||
#include <uchar.h> // (since C11) UTF-16 and UTF-32 character utilities
|
||||
#endif
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="100">
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<confs>
|
||||
<conf name="Debug" type="1">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<platform>2</platform>
|
||||
</toolsSet>
|
||||
<dbx_gdbdebugger version="1">
|
||||
<gdb_pathmaps>
|
||||
</gdb_pathmaps>
|
||||
<gdb_interceptlist>
|
||||
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
|
||||
</gdb_interceptlist>
|
||||
<gdb_signals>
|
||||
</gdb_signals>
|
||||
<gdb_options>
|
||||
<DebugOptions>
|
||||
</DebugOptions>
|
||||
</gdb_options>
|
||||
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
|
||||
</dbx_gdbdebugger>
|
||||
<nativedebugger version="1">
|
||||
<engine>gdb</engine>
|
||||
</nativedebugger>
|
||||
<runprofile version="9">
|
||||
<runcommandpicklist>
|
||||
<runcommandpicklistitem>sudo "${OUTPUT_PATH}" </runcommandpicklistitem>
|
||||
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
|
||||
<runcommandpicklistitem>sudo "${OUTPUT_PATH}"</runcommandpicklistitem>
|
||||
</runcommandpicklist>
|
||||
<runcommand>sudo "${OUTPUT_PATH}"</runcommand>
|
||||
<rundir></rundir>
|
||||
<buildfirst>true</buildfirst>
|
||||
<console-type>1</console-type>
|
||||
<terminal-type>0</terminal-type>
|
||||
<remove-instrumentation>0</remove-instrumentation>
|
||||
<environment>
|
||||
</environment>
|
||||
</runprofile>
|
||||
</conf>
|
||||
<conf name="Release" type="1">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<platform>2</platform>
|
||||
</toolsSet>
|
||||
<dbx_gdbdebugger version="1">
|
||||
<gdb_pathmaps>
|
||||
</gdb_pathmaps>
|
||||
<gdb_interceptlist>
|
||||
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
|
||||
</gdb_interceptlist>
|
||||
<gdb_options>
|
||||
<DebugOptions>
|
||||
</DebugOptions>
|
||||
</gdb_options>
|
||||
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
|
||||
</dbx_gdbdebugger>
|
||||
<nativedebugger version="1">
|
||||
<engine>gdb</engine>
|
||||
</nativedebugger>
|
||||
<runprofile version="9">
|
||||
<runcommandpicklist>
|
||||
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
|
||||
</runcommandpicklist>
|
||||
<runcommand>"${OUTPUT_PATH}"</runcommand>
|
||||
<rundir></rundir>
|
||||
<buildfirst>true</buildfirst>
|
||||
<terminal-type>0</terminal-type>
|
||||
<remove-instrumentation>0</remove-instrumentation>
|
||||
<environment>
|
||||
</environment>
|
||||
</runprofile>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
||||
*
|
||||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
|
||||
* Other names may be trademarks of their respective owners.
|
||||
*
|
||||
* The contents of this file are subject to the terms of either the GNU
|
||||
* General Public License Version 2 only ("GPL") or the Common
|
||||
* Development and Distribution License("CDDL") (collectively, the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. You can obtain a copy of the License at
|
||||
* http://www.netbeans.org/cddl-gplv2.html
|
||||
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
||||
* specific language governing permissions and limitations under the
|
||||
* License. When distributing the software, include this License Header
|
||||
* Notice in each file and include the License file at
|
||||
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the GPL Version 2 section of the License file that
|
||||
* accompanied this code. If applicable, add the following below the
|
||||
* License Header, with the fields enclosed by brackets [] replaced by
|
||||
* your own identifying information:
|
||||
* "Portions Copyrighted [year] [name of copyright owner]"
|
||||
*
|
||||
* If you wish your version of this file to be governed by only the CDDL
|
||||
* or only the GPL Version 2, indicate your decision by adding
|
||||
* "[Contributor] elects to include this software in this distribution
|
||||
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
||||
* single choice of license, a recipient has the option to distribute
|
||||
* your version of this file under either the CDDL, the GPL Version 2 or
|
||||
* to extend the choice of license to its licensees as provided above.
|
||||
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
||||
* Version 2 license, then the option applies only if the new code is
|
||||
* made subject to such option by the copyright holder.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// List of standard headers was taken in http://en.cppreference.com/w/cpp/header
|
||||
|
||||
#include <cstdlib> // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search
|
||||
#include <csignal> // Functions and macro constants for signal management
|
||||
#include <csetjmp> // Macro (and function) that saves (and jumps) to an execution context
|
||||
#include <cstdarg> // Handling of variable length argument lists
|
||||
#include <typeinfo> // Runtime type information utilities
|
||||
#include <bitset> // std::bitset class template
|
||||
#include <functional> // Function objects, designed for use with the standard algorithms
|
||||
#include <utility> // Various utility components
|
||||
#include <ctime> // C-style time/date utilites
|
||||
#include <cstddef> // typedefs for types such as size_t, NULL and others
|
||||
#include <new> // Low-level memory management utilities
|
||||
#include <memory> // Higher level memory management utilities
|
||||
#include <climits> // limits of integral types
|
||||
#include <cfloat> // limits of float types
|
||||
#include <limits> // standardized way to query properties of arithmetic types
|
||||
#include <exception> // Exception handling utilities
|
||||
#include <stdexcept> // Standard exception objects
|
||||
#include <cassert> // Conditionally compiled macro that compares its argument to zero
|
||||
#include <cerrno> // Macro containing the last error number
|
||||
#include <cctype> // functions to determine the type contained in character data
|
||||
#include <cwctype> // functions for determining the type of wide character data
|
||||
#include <cstring> // various narrow character string handling functions
|
||||
#include <cwchar> // various wide and multibyte string handling functions
|
||||
#include <string> // std::basic_string class template
|
||||
#include <vector> // std::vector container
|
||||
#include <deque> // std::deque container
|
||||
#include <list> // std::list container
|
||||
#include <set> // std::set and std::multiset associative containers
|
||||
#include <map> // std::map and std::multimap associative containers
|
||||
#include <stack> // std::stack container adaptor
|
||||
#include <queue> // std::queue and std::priority_queue container adaptors
|
||||
#include <algorithm> // Algorithms that operate on containers
|
||||
#include <iterator> // Container iterators
|
||||
#include <cmath> // Common mathematics functions
|
||||
#include <complex> // Complex number type
|
||||
#include <valarray> // Class for representing and manipulating arrays of values
|
||||
#include <numeric> // Numeric operations on values in containers
|
||||
#include <iosfwd> // forward declarations of all classes in the input/output library
|
||||
#include <ios> // std::ios_base class, std::basic_ios class template and several typedefs
|
||||
#include <istream> // std::basic_istream class template and several typedefs
|
||||
#include <ostream> // std::basic_ostream, std::basic_iostream class templates and several typedefs
|
||||
#include <iostream> // several standard stream objects
|
||||
#include <fstream> // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs
|
||||
#include <sstream> // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs
|
||||
#include <strstream> // std::strstream, std::istrstream, std::ostrstream(deprecated)
|
||||
#include <iomanip> // Helper functions to control the format or input and output
|
||||
#include <streambuf> // std::basic_streambuf class template
|
||||
#include <cstdio> // C-style input-output functions
|
||||
#include <locale> // Localization utilities
|
||||
#include <clocale> // C localization utilities
|
||||
#include <ciso646> // empty header. The macros that appear in iso646.h in C are keywords in C++
|
||||
#if __cplusplus >= 201103L
|
||||
#include <typeindex> // (since C++11) std::type_index
|
||||
#include <type_traits> // (since C++11) Compile-time type information
|
||||
#include <chrono> // (since C++11) C++ time utilites
|
||||
#include <initializer_list> // (since C++11) std::initializer_list class template
|
||||
#include <tuple> // (since C++11) std::tuple class template
|
||||
#include <scoped_allocator> // (since C++11) Nested allocator class
|
||||
#include <cstdint> // (since C++11) fixed-size types and limits of other types
|
||||
#include <cinttypes> // (since C++11) formatting macros , intmax_t and uintmax_t math and conversions
|
||||
#include <system_error> // (since C++11) defines std::error_code, a platform-dependent error code
|
||||
#include <cuchar> // (since C++11) C-style Unicode character conversion functions
|
||||
#include <array> // (since C++11) std::array container
|
||||
#include <forward_list> // (since C++11) std::forward_list container
|
||||
#include <unordered_set> // (since C++11) std::unordered_set and std::unordered_multiset unordered associative containers
|
||||
#include <unordered_map> // (since C++11) std::unordered_map and std::unordered_multimap unordered associative containers
|
||||
#include <random> // (since C++11) Random number generators and distributions
|
||||
#include <ratio> // (since C++11) Compile-time rational arithmetic
|
||||
#include <cfenv> // (since C++11) Floating-point environment access functions
|
||||
#include <codecvt> // (since C++11) Unicode conversion facilities
|
||||
#include <regex> // (since C++11) Classes, algorithms and iterators to support regular expression processing
|
||||
#include <atomic> // (since C++11) Atomic operations library
|
||||
#include <ccomplex> // (since C++11)(deprecated in C++17) simply includes the header <complex>
|
||||
#include <ctgmath> // (since C++11)(deprecated in C++17) simply includes the headers <ccomplex> (until C++17)<complex> (since C++17) and <cmath>: the overloads equivalent to the contents of the C header tgmath.h are already provided by those headers
|
||||
#include <cstdalign> // (since C++11)(deprecated in C++17) defines one compatibility macro constant
|
||||
#include <cstdbool> // (since C++11)(deprecated in C++17) defines one compatibility macro constant
|
||||
#include <thread> // (since C++11) std::thread class and supporting functions
|
||||
#include <mutex> // (since C++11) mutual exclusion primitives
|
||||
#include <future> // (since C++11) primitives for asynchronous computations
|
||||
#include <condition_variable> // (since C++11) thread waiting conditions
|
||||
#endif
|
||||
#if __cplusplus >= 201300L
|
||||
#include <shared_mutex> // (since C++14) shared mutual exclusion primitives
|
||||
#endif
|
||||
#if __cplusplus >= 201500L
|
||||
#include <any> // (since C++17) std::any class template
|
||||
#include <optional> // (since C++17) std::optional class template
|
||||
#include <variant> // (since C++17) std::variant class template
|
||||
#include <memory_resource> // (since C++17) Polymorphic allocators and memory resources
|
||||
#include <string_view> // (since C++17) std::basic_string_view class template
|
||||
#include <execution> // (since C++17) Predefined execution policies for parallel versions of the algorithms
|
||||
#include <filesystem> // (since C++17) std::path class and supporting functions
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
# Launchers File syntax:
|
||||
#
|
||||
# [Must-have property line]
|
||||
# launcher1.runCommand=<Run Command>
|
||||
# [Optional extra properties]
|
||||
# launcher1.displayName=<Display Name, runCommand by default>
|
||||
# launcher1.hide=<true if lancher is not visible in menu, false by default>
|
||||
# launcher1.buildCommand=<Build Command, Build Command specified in project properties by default>
|
||||
# launcher1.runDir=<Run Directory, ${PROJECT_DIR} by default>
|
||||
# launcher1.runInOwnTab=<false if launcher reuse common "Run" output tab, true by default>
|
||||
# launcher1.symbolFiles=<Symbol Files loaded by debugger, ${OUTPUT_PATH} by default>
|
||||
# launcher1.env.<Environment variable KEY>=<Environment variable VALUE>
|
||||
# (If this value is quoted with ` it is handled as a native command which execution result will become the value)
|
||||
# [Common launcher properties]
|
||||
# common.runDir=<Run Directory>
|
||||
# (This value is overwritten by a launcher specific runDir value if the latter exists)
|
||||
# common.env.<Environment variable KEY>=<Environment variable VALUE>
|
||||
# (Environment variables from common launcher are merged with launcher specific variables)
|
||||
# common.symbolFiles=<Symbol Files loaded by debugger>
|
||||
# (This value is overwritten by a launcher specific symbolFiles value if the latter exists)
|
||||
#
|
||||
# In runDir, symbolFiles and env fields you can use these macroses:
|
||||
# ${PROJECT_DIR} - project directory absolute path
|
||||
# ${OUTPUT_PATH} - linker output path (relative to project directory path)
|
||||
# ${OUTPUT_BASENAME}- linker output filename
|
||||
# ${TESTDIR} - test files directory (relative to project directory path)
|
||||
# ${OBJECTDIR} - object files directory (relative to project directory path)
|
||||
# ${CND_DISTDIR} - distribution directory (relative to project directory path)
|
||||
# ${CND_BUILDDIR} - build directory (relative to project directory path)
|
||||
# ${CND_PLATFORM} - platform name
|
||||
# ${CND_CONF} - configuration name
|
||||
# ${CND_DLIB_EXT} - dynamic library extension
|
||||
#
|
||||
# All the project launchers must be listed in the file!
|
||||
#
|
||||
# launcher1.runCommand=...
|
||||
# launcher2.runCommand=...
|
||||
# ...
|
||||
# common.runDir=...
|
||||
# common.env.KEY=VALUE
|
||||
|
||||
# launcher1.runCommand=<type your run command here>
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<data xmlns="http://www.netbeans.org/ns/make-project-private/1">
|
||||
<activeConfTypeElem>1</activeConfTypeElem>
|
||||
<activeConfIndexElem>0</activeConfIndexElem>
|
||||
</data>
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
@ -1,2 +0,0 @@
|
||||
#Sat Oct 21 15:56:01 CEST 2017
|
||||
project.license=mit
|
@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.cnd.makeproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/make-project/1">
|
||||
<name>uFTP</name>
|
||||
<c-extensions>c</c-extensions>
|
||||
<cpp-extensions/>
|
||||
<header-extensions>h</header-extensions>
|
||||
<sourceEncoding>UTF-8</sourceEncoding>
|
||||
<make-dep-projects/>
|
||||
<sourceRootList>
|
||||
<sourceRootElem>library</sourceRootElem>
|
||||
</sourceRootList>
|
||||
<confList>
|
||||
<confElem>
|
||||
<name>Debug</name>
|
||||
<type>1</type>
|
||||
</confElem>
|
||||
<confElem>
|
||||
<name>Release</name>
|
||||
<type>1</type>
|
||||
</confElem>
|
||||
</confList>
|
||||
<formatting>
|
||||
<project-formatting-style>false</project-formatting-style>
|
||||
</formatting>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
22
testNotes.txt
Normal file
22
testNotes.txt
Normal file
@ -0,0 +1,22 @@
|
||||
#NOTES ONLY FOR DEVELOPERS
|
||||
#OPENSSL TEST COMMANDS
|
||||
|
||||
#Required packages to compile
|
||||
sudo apt-get install libssl-dev
|
||||
|
||||
|
||||
#Remove password from a certificate
|
||||
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
|
||||
openssl rsa -in key.pem -out newkey.pem
|
||||
handle SIGPIPE nostop noprint pass
|
||||
|
||||
|
||||
#Testing ssl
|
||||
openssl s_client -starttls ftp -connect 192.168.1.237:21
|
||||
sudo openssl s_server -key key.pem -cert cert.pem -accept 123
|
||||
openssl s_client -connect 127.0.0.1:49473
|
||||
USER username
|
||||
PASS password
|
||||
PROT P
|
||||
PORT 192,168,1,237,0,123
|
||||
LIST
|
@ -10,10 +10,10 @@ MAXIMUM_ALLOWED_FTP_CONNECTION = 30
|
||||
FTP_PORT = 21
|
||||
#TCP/IP PORT SETTINGS (DEFAULT 21)
|
||||
|
||||
SINGLE_INSTANCE = true
|
||||
SINGLE_INSTANCE = false
|
||||
#Allow only one server instance (true or false)
|
||||
|
||||
DAEMON_MODE = true
|
||||
DAEMON_MODE = false
|
||||
#Run in background, daemon mode ok
|
||||
|
||||
IDLE_MAX_TIMEOUT = 3600
|
||||
@ -32,6 +32,10 @@ MAX_CONNECTION_TRY_PER_IP = 10
|
||||
#THE IP ADDRESS WILL BE BLOCKED FOR 5 MINUTES AFTER WRONG LOGIN USERNAME AND PASSWORD
|
||||
#0 TO DISABLE
|
||||
|
||||
#TLS CERTIFICATE FILE PATH
|
||||
CERTIFICATE_PATH=/home/ugo/NetBeansProjects/uFTP/cert.pem
|
||||
PRIVATE_CERTIFICATE_PATH=/home/ugo/NetBeansProjects/uFTP/key.pem
|
||||
|
||||
#USERS
|
||||
#START FROM USER 0 TO XXX
|
||||
USER_0 = username
|
||||
|
Reference in New Issue
Block a user