mirror of
https://github.com/kingk85/uFTP.git
synced 2025-07-25 13:16:12 +03:00
working on SSL and memory deallocation
This commit is contained in:
BIN
build/Debug/GNU-Linux/ftpCommandElaborate.o
Normal file
BIN
build/Debug/GNU-Linux/ftpCommandElaborate.o
Normal file
Binary file not shown.
32
build/Debug/GNU-Linux/ftpCommandElaborate.o.d
Normal file
32
build/Debug/GNU-Linux/ftpCommandElaborate.o.d
Normal file
@ -0,0 +1,32 @@
|
||||
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 library/openSsl.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:
|
||||
|
||||
library/openSsl.h:
|
||||
|
||||
ftpCommandsElaborate.h:
|
BIN
build/Debug/GNU-Linux/ftpData.o
Normal file
BIN
build/Debug/GNU-Linux/ftpData.o
Normal file
Binary file not shown.
27
build/Debug/GNU-Linux/ftpData.o.d
Normal file
27
build/Debug/GNU-Linux/ftpData.o.d
Normal file
@ -0,0 +1,27 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/ftpServer.o
Normal file
BIN
build/Debug/GNU-Linux/ftpServer.o
Normal file
Binary file not shown.
36
build/Debug/GNU-Linux/ftpServer.o.d
Normal file
36
build/Debug/GNU-Linux/ftpServer.o.d
Normal file
@ -0,0 +1,36 @@
|
||||
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/openSsl.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/openSsl.h:
|
||||
|
||||
library/connection.h:
|
BIN
build/Debug/GNU-Linux/library/configRead.o
Normal file
BIN
build/Debug/GNU-Linux/library/configRead.o
Normal file
Binary file not shown.
23
build/Debug/GNU-Linux/library/configRead.o.d
Normal file
23
build/Debug/GNU-Linux/library/configRead.o.d
Normal file
@ -0,0 +1,23 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/library/connection.o
Normal file
BIN
build/Debug/GNU-Linux/library/connection.o
Normal file
Binary file not shown.
16
build/Debug/GNU-Linux/library/connection.o.d
Normal file
16
build/Debug/GNU-Linux/library/connection.o.d
Normal file
@ -0,0 +1,16 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/library/daemon.o
Normal file
BIN
build/Debug/GNU-Linux/library/daemon.o
Normal file
Binary file not shown.
11
build/Debug/GNU-Linux/library/daemon.o.d
Normal file
11
build/Debug/GNU-Linux/library/daemon.o.d
Normal file
@ -0,0 +1,11 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/library/dynamicVectors.o
Normal file
BIN
build/Debug/GNU-Linux/library/dynamicVectors.o
Normal file
Binary file not shown.
11
build/Debug/GNU-Linux/library/dynamicVectors.o.d
Normal file
11
build/Debug/GNU-Linux/library/dynamicVectors.o.d
Normal file
@ -0,0 +1,11 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/library/fileManagement.o
Normal file
BIN
build/Debug/GNU-Linux/library/fileManagement.o
Normal file
Binary file not shown.
14
build/Debug/GNU-Linux/library/fileManagement.o.d
Normal file
14
build/Debug/GNU-Linux/library/fileManagement.o.d
Normal file
@ -0,0 +1,14 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/library/logFunctions.o
Normal file
BIN
build/Debug/GNU-Linux/library/logFunctions.o
Normal file
Binary file not shown.
11
build/Debug/GNU-Linux/library/logFunctions.o.d
Normal file
11
build/Debug/GNU-Linux/library/logFunctions.o.d
Normal file
@ -0,0 +1,11 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/library/openSsl.o
Normal file
BIN
build/Debug/GNU-Linux/library/openSsl.o
Normal file
Binary file not shown.
11
build/Debug/GNU-Linux/library/openSsl.o.d
Normal file
11
build/Debug/GNU-Linux/library/openSsl.o.d
Normal file
@ -0,0 +1,11 @@
|
||||
build/Debug/GNU-Linux/library/openSsl.o: library/openSsl.c \
|
||||
library/dynamicVectors.h library/fileManagement.h \
|
||||
library/dynamicVectors.h library/openSsl.h
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/fileManagement.h:
|
||||
|
||||
library/dynamicVectors.h:
|
||||
|
||||
library/openSsl.h:
|
BIN
build/Debug/GNU-Linux/library/signals.o
Normal file
BIN
build/Debug/GNU-Linux/library/signals.o
Normal file
Binary file not shown.
11
build/Debug/GNU-Linux/library/signals.o.d
Normal file
11
build/Debug/GNU-Linux/library/signals.o.d
Normal file
@ -0,0 +1,11 @@
|
||||
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:
|
BIN
build/Debug/GNU-Linux/uFTP.o
Normal file
BIN
build/Debug/GNU-Linux/uFTP.o
Normal file
Binary file not shown.
10
build/Debug/GNU-Linux/uFTP.o.d
Normal file
10
build/Debug/GNU-Linux/uFTP.o.d
Normal file
@ -0,0 +1,10 @@
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/uFTP
BIN
build/uFTP
Binary file not shown.
BIN
dist/Debug/GNU-Linux/uftp
vendored
BIN
dist/Debug/GNU-Linux/uftp
vendored
Binary file not shown.
44
ftpServer.c
44
ftpServer.c
@ -356,9 +356,9 @@ void runFtpServer(void)
|
||||
/* the maximum socket fd is now the main socket descriptor */
|
||||
ftpData.connectionData.maxSocketFD = ftpData.connectionData.theMainSocket+1;
|
||||
|
||||
init_openssl();
|
||||
ctx = create_context();
|
||||
configure_context(ctx);
|
||||
initOpenssl();
|
||||
ctx = createContext();
|
||||
configureContext(ctx);
|
||||
|
||||
//Endless loop ftp process
|
||||
while (1)
|
||||
@ -529,20 +529,30 @@ static int processCommand(int processingElement)
|
||||
returnCode = dprintf(ftpData.clients[processingElement].socketDescriptor, "234 AUTH TLS OK..\r\n");
|
||||
|
||||
|
||||
ftpData.clients[processingElement].tlsIsEnabled = 1;
|
||||
SSL *ssl;
|
||||
ssl = SSL_new(ctx);
|
||||
ftpData.clients[processingElement].tlsIsEnabled = 1;
|
||||
SSL *ssl;
|
||||
ssl = SSL_new(ctx);
|
||||
SSL_set_fd(ssl, ftpData.clients[processingElement].socketDescriptor);
|
||||
|
||||
if (SSL_accept(ssl) <= 0) {
|
||||
printf("\nSSL ERRORS");
|
||||
ERR_print_errors_fp(stderr);
|
||||
int sslAcceptTimeout = 0;
|
||||
do {
|
||||
returnCode = SSL_accept(ssl);
|
||||
printf("\nSSL waiting handshake %d.. return code = %d", sslAcceptTimeout, returnCode);
|
||||
if (returnCode <= 0) {
|
||||
printf("\nSSL ERRORS");
|
||||
ERR_print_errors_fp(stderr);
|
||||
}
|
||||
else {
|
||||
printf("\nSSL ACCEPTED");
|
||||
fflush(0);
|
||||
SSL_write(ssl, "ciao prova\r\n", strlen("ciao prova\r\n"));
|
||||
}
|
||||
sslAcceptTimeout++;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
else {
|
||||
printf("\nSSL ACCEPTED");
|
||||
SSL_write(ssl, "ciao prova\r\n", strlen("ciao prova\r\n"));
|
||||
}
|
||||
|
||||
while(returnCode <=0 && sslAcceptTimeout < 3);
|
||||
printf("\nReading ssl");
|
||||
char buffer[100];
|
||||
int readenb = 0;
|
||||
while(1)
|
||||
@ -711,3 +721,9 @@ 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.. ");
|
||||
}
|
@ -33,6 +33,7 @@ void runFtpServer(void);
|
||||
void *connectionWorkerHandle(void * socketId);
|
||||
void workerCleanup(void *socketId);
|
||||
void signal_callback_handler(int signum);
|
||||
void deallocateMemory(void);
|
||||
|
||||
#endif /* FTPSERVER_H */
|
||||
|
||||
|
@ -32,18 +32,18 @@
|
||||
|
||||
#include "openSsl.h"
|
||||
|
||||
void init_openssl()
|
||||
void initOpenssl()
|
||||
{
|
||||
SSL_load_error_strings();
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
}
|
||||
|
||||
void cleanup_openssl()
|
||||
void cleanupOpenssl()
|
||||
{
|
||||
EVP_cleanup();
|
||||
}
|
||||
|
||||
SSL_CTX *create_context()
|
||||
SSL_CTX *createContext()
|
||||
{
|
||||
const SSL_METHOD *method;
|
||||
SSL_CTX *ctx;
|
||||
@ -60,7 +60,7 @@ SSL_CTX *create_context()
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void configure_context(SSL_CTX *ctx)
|
||||
void configureContext(SSL_CTX *ctx)
|
||||
{
|
||||
SSL_CTX_set_ecdh_auto(ctx, 1);
|
||||
|
||||
|
@ -33,11 +33,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void init_openssl();
|
||||
void cleanup_openssl();
|
||||
SSL_CTX *create_context();
|
||||
void configure_context(SSL_CTX *ctx);
|
||||
|
||||
void initOpenssl();
|
||||
void cleanupOpenssl();
|
||||
SSL_CTX *createContext();
|
||||
void configureContext(SSL_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -56,9 +56,17 @@ static void ignore_sigpipe(void)
|
||||
}
|
||||
}
|
||||
|
||||
void onUftpClose(void)
|
||||
{
|
||||
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(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -7,15 +7,19 @@
|
||||
<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>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpCommandElaborate.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/signals.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/signals.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpServer.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/uFTP.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/MakeFileGeneric</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpServer.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/configRead.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpCommandsElaborate.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpData.c</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.h</file>
|
||||
<file>file:/home/ugo/NetBeansProjects/uFTP/ftpCommandElaborate.c</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
Reference in New Issue
Block a user