TLS preliminary test ok!

This commit is contained in:
Ugo Cirmignani
2018-12-02 19:28:14 +01:00
parent 2e4ccaf32d
commit 3b7f6ea4ad
22 changed files with 240 additions and 121 deletions

View File

@ -5,18 +5,24 @@ OUTPATH=./build/
SOURCE_MODULES_PATH=./library/
#FOR DEBUG PURPOSE
CFLAGS=-c -Wall -I. -g -O0
#CFLAGS=-c -Wall -I.
CFLAGSTEMP=-c -Wall -I. -g -O0
#CFLAGSTEMP=-c -Wall -I.
OPTIMIZATION=-O3
HEADERS=-I
LIBPATH=./build/modules/
BUILDFILES=start uFTP end
LIBS=-lpthread -lssl -lcrypto
#DEFINITIONS=
#ENABLE_LARGE_FILE_SUPPORT=
#TO ENABLE THE LARGE FILE SUPPORT UNCOMMENT THE NEXT LINE
DEFINITIONS=-D_LARGEFILE64_SOURCE
ENABLE_LARGE_FILE_SUPPORT=-D LARGE_FILE_SUPPORT_ENABLED -D _LARGEFILE64_SOURCE
#ENABLE_OPENSSL_SUPPORT=
#TO ENABLE OPENSSL SUPPORT UNCOMMENT THE NEXT LINE
ENABLE_OPENSSL_SUPPORT=-D OPENSSL_ENABLED
CFLAGS=$(CFLAGSTEMP) $(ENABLE_LARGE_FILE_SUPPORT) $(ENABLE_OPENSSL_SUPPORT)
all: $(BUILDFILES)
@ -31,7 +37,7 @@ 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 openSsl.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 $(LIBPATH)openSsl.o -o $(OUTPATH)uFTP $(LIBS)
@$(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)
daemon.o:
@$(CC) $(CFLAGS) $(SOURCE_MODULES_PATH)daemon.c -o $(LIBPATH)daemon.o

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.

Binary file not shown.

View File

@ -218,30 +218,61 @@ int parseCommandPass(ftpDataType * data, int socketId)
}
}
int parseCommandAuth(clientDataType *theClientData, SSL_CTX *ctx)
int parseCommandAuth(ftpDataType * data, int socketId)
{
int returnCode;
//returnCode = socketPrintf(data, socketId, "s", "234 AUTH TLS OK..\r\n");
if (returnCode <= 0)
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
theClientData->tlsIsEnabled = 1;
SSL *ssl;
ssl = SSL_new(ctx);
SSL_set_fd(ssl, theClientData->socketDescriptor);
#ifndef OPENSSL_ENABLED
returnCode = socketPrintf(data, socketId, "s", "502 Security extensions not implemented.\r\n");
if (returnCode <= 0)
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
if (SSL_accept(ssl) <= 0) {
printf("\nSSL ERRORS");
ERR_print_errors_fp(stderr);
return FTP_COMMAND_PROCESSED;
#endif
#ifdef OPENSSL_ENABLED
returnCode = socketPrintf(data, socketId, "s", "234 AUTH TLS OK..\r\n");
if (returnCode <= 0)
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
data->clients[socketId].tlsIsEnabled = 1;
printf("\n SSL_set_fd");
fflush(0);
SSL_set_fd(data->clients[socketId].ssl, data->clients[socketId].socketDescriptor);
printf("\n SSL_set_fd OK");
fflush(0);
int sslAcceptTimeout = 0;
do {
returnCode = SSL_accept(data->clients[socketId].ssl);
printf("\n SSL_accept");
fflush(0);
printf("\nSSL waiting handshake %d.. return code = %d", sslAcceptTimeout, returnCode);
fflush(0);
if (returnCode <= 0) {
printf("\nSSL ERRORS");
fflush(0);
ERR_print_errors_fp(stderr);
}
else {
printf("\nSSL ACCEPTED");
fflush(0);
}
sslAcceptTimeout++;
sleep(1);
}
else {
printf("\nSSL ACCEPTED");
SSL_write(ssl, "ciao prova\r\n", strlen("ciao prova\r\n"));
}
//client -> AUTH TLS
//server -> 234 AUTH TLS OK.
while(returnCode <=0 &&
sslAcceptTimeout < 3);
return FTP_COMMAND_PROCESSED;
#endif
return FTP_COMMAND_PROCESSED;
}
@ -346,22 +377,31 @@ int parseCommandPasv(ftpDataType * data, int socketId)
{
/* Create worker thread */
void *pReturn;
int returnCode;
printf("\n data->clients[%d].workerData.workerThread = %d",socketId, (int)data->clients[socketId].workerData.workerThread);
if (data->clients[socketId].workerData.threadIsAlive == 1)
{
pthread_cancel(data->clients[socketId].workerData.workerThread);
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
}
pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
data->clients[socketId].workerData.passiveModeOn = 1;
data->clients[socketId].workerData.activeModeOn = 0;
pthread_create(&data->clients[socketId].workerData.workerThread, NULL, connectionWorkerHandle, (void *) &data->clients[socketId].clientProgressiveNumber);
returnCode = pthread_create(&data->clients[socketId].workerData.workerThread, NULL, connectionWorkerHandle, (void *) &data->clients[socketId].clientProgressiveNumber);
if (returnCode != 0)
{
printf("\nError in pthread_create %d", returnCode);
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
}
return FTP_COMMAND_PROCESSED;
}
int parseCommandPort(ftpDataType * data, int socketId)
{
int returnCode;
char *theIpAndPort;
int ipAddressBytes[4];
int portBytes[2];
@ -373,12 +413,20 @@ int parseCommandPort(ftpDataType * data, int socketId)
void *pReturn;
if (data->clients[socketId].workerData.threadIsAlive == 1)
{
pthread_cancel(data->clients[socketId].workerData.workerThread);
returnCode = pthread_cancel(data->clients[socketId].workerData.workerThread);
}
pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
returnCode = pthread_join(data->clients[socketId].workerData.workerThread, &pReturn);
data->clients[socketId].workerData.passiveModeOn = 0;
data->clients[socketId].workerData.activeModeOn = 1;
pthread_create(&data->clients[socketId].workerData.workerThread, NULL, connectionWorkerHandle, (void *) &data->clients[socketId].clientProgressiveNumber);
returnCode = pthread_create(&data->clients[socketId].workerData.workerThread, NULL, connectionWorkerHandle, (void *) &data->clients[socketId].clientProgressiveNumber);
if (returnCode != 0)
{
printf("\nError in pthread_create %d", returnCode);
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
}
return FTP_COMMAND_PROCESSED;
}
@ -1058,11 +1106,13 @@ long long int writeRetrFile(char * theFilename, int thePasvSocketConnection, lon
long long int theFileSize;
char buffer[FTP_COMMAND_ELABORATE_CHAR_BUFFER];
#ifdef _LARGEFILE64_SOURCE
#ifdef LARGE_FILE_SUPPORT_ENABLED
//#warning LARGE FILE SUPPORT IS ENABLED!
retrFP = fopen64(theFilename, "rb");
#endif
#ifndef _LARGEFILE64_SOURCE
#ifndef LARGE_FILE_SUPPORT_ENABLED
#warning LARGE FILE SUPPORT IS NOT ENABLED!
retrFP = fopen(theFilename, "rb");
#endif
@ -1076,11 +1126,13 @@ long long int writeRetrFile(char * theFilename, int thePasvSocketConnection, lon
if (startFrom > 0)
{
#ifdef _LARGEFILE64_SOURCE
#ifdef LARGE_FILE_SUPPORT_ENABLED
//#warning LARGE FILE SUPPORT IS ENABLED!
currentPosition = (long long int) lseek64(fileno(retrFP), startFrom, SEEK_SET);
#endif
#ifndef _LARGEFILE64_SOURCE
#ifndef LARGE_FILE_SUPPORT_ENABLED
#warning LARGE FILE SUPPORT IS NOT ENABLED!
currentPosition = (long long int) lseek(fileno(retrFP), startFrom, SEEK_SET);
#endif

View File

@ -50,9 +50,7 @@ extern "C" {
int parseCommandUser(ftpDataType * data, int socketId);
int parseCommandSite(ftpDataType * data, int socketId);
int parseCommandPass(ftpDataType * data, int socketId);
int parseCommandAuth(clientDataType *theClientData, SSL_CTX *);
int parseCommandAuth(ftpDataType * data, int socketId);
int parseCommandPwd(ftpDataType * data, int socketId);
int parseCommandSyst(ftpDataType * data, int socketId);
int parseCommandFeat(ftpDataType * data, int socketId);

View File

@ -603,66 +603,76 @@ void resetWorkerData(workerDataType *workerData, int isInitialization)
}
}
void resetClientData(clientDataType *clientData, int isInitialization)
void resetClientData(ftpDataType *data, int clientId, int isInitialization)
{
if (isInitialization != 1)
{
if (clientData->workerData.threadIsAlive == 1)
if (data->clients[clientId].workerData.threadIsAlive == 1)
{
void *pReturn;
pthread_cancel(clientData->workerData.workerThread);
pthread_join(clientData->workerData.workerThread, &pReturn);
pthread_cancel(data->clients[clientId].workerData.workerThread);
pthread_join(data->clients[clientId].workerData.workerThread, &pReturn);
}
else
{
void *pReturn = NULL;
pthread_join(clientData->workerData.workerThread, &pReturn);
pthread_join(data->clients[clientId].workerData.workerThread, &pReturn);
}
pthread_mutex_destroy(&clientData->writeMutex);
pthread_mutex_destroy(&data->clients[clientId].writeMutex);
#ifdef OPENSSL_ENABLED
SSL_free(data->clients[clientId].ssl);
#endif
}
if (pthread_mutex_init(&clientData->writeMutex, NULL) != 0)
if (pthread_mutex_init(&data->clients[clientId].writeMutex, NULL) != 0)
{
printf("\nclientData->writeMutex init failed\n");
exit(0);
}
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);
data->clients[clientId].tlsIsEnabled = 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].lastActivityTimeStamp = 0;
#ifdef OPENSSL_ENABLED
data->clients[clientId].ssl = SSL_new(data->ctx);
#endif
}
int compareStringCaseInsensitive(char * stringIn, char * stringRef, int stringLenght)

View File

@ -148,7 +148,10 @@ struct workerData
struct clientData
{
#ifdef OPENSSL_ENABLED
SSL *ssl;
#endif
int tlsIsEnabled;
pthread_mutex_t writeMutex;
@ -207,7 +210,10 @@ struct ConnectionParameters
struct ftpData
{
#ifdef OPENSSL_ENABLED
SSL_CTX *ctx;
#endif
int connectedClients;
char welcomeMessage[1024];
ConnectionData_DataType connectionData;
@ -247,8 +253,10 @@ int writeListDataInfoToSocket(char * thePath, int theSocket, int *filesNumber, i
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 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);

View File

@ -48,7 +48,6 @@
#include "ftpCommandsElaborate.h"
ftpDataType ftpData;
SSL_CTX *ctx;
static int processCommand(int processingElement);
@ -160,11 +159,13 @@ void *connectionWorkerHandle(void * socketId)
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
@ -325,9 +326,9 @@ 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();
@ -351,9 +352,6 @@ void runFtpServer(void)
/* the maximum socket fd is now the main socket descriptor */
ftpData.connectionData.maxSocketFD = ftpData.connectionData.theMainSocket+1;
initOpenssl();
ctx = createContext();
configureContext(ctx);
//Endless loop ftp process
while (1)
@ -391,8 +389,20 @@ void runFtpServer(void)
if (FD_ISSET(ftpData.clients[processingSock].socketDescriptor, &ftpData.connectionData.rset) ||
FD_ISSET(ftpData.clients[processingSock].socketDescriptor, &ftpData.connectionData.eset))
{
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);
@ -519,12 +529,12 @@ static int processCommand(int processingElement)
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "AUTH", strlen("AUTH")) == 1)
{
printf("\nAUTH COMMAND RECEIVED");
toReturn = parseCommandAuth(&ftpData, processingElement);
int returnCode;
//returnCode = dprintf(theClientData->socketDescriptor, "502 Security extensions not implemented.\r\n");
returnCode = dprintf(ftpData.clients[processingElement].socketDescriptor, "234 AUTH TLS OK..\r\n");
//returnCode = dprintf(theClientData->socketDescriptor, "502 Security extensions not implemented.\r\n");
//returnCode = dprintf(ftpData.clients[processingElement].socketDescriptor, "234 AUTH TLS OK..\r\n");
/*
ftpData.clients[processingElement].tlsIsEnabled = 1;
SSL *ssl;
ssl = SSL_new(ctx);
@ -559,8 +569,8 @@ static int processCommand(int processingElement)
sleep(1);
}
*/
// toReturn = parseCommandAuth(&ftpData.clients[processingElement], ctx);
}
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PWD", strlen("PWD")) == 1)
{
@ -721,4 +731,8 @@ static int processCommand(int processingElement)
void deallocateMemory(void)
{
printf("\n Deallocating the memory.. ");
#ifndef OPENSSL_ENABLED
SSL_CTX_free(ftpData.ctx);
cleanup_openssl();
#endif
}

View File

@ -27,7 +27,9 @@
#define FTPSERVER_H
#define MAX_FTP_CLIENTS 10
#define UFTP_SERVER_VERSION "1.0.1 beta"
#define UFTP_SERVER_VERSION "2.0.0 beta"
#warning remove in final release, must be specified by makefile
#define OPENSSL_ENABLED
void runFtpServer(void);
void *connectionWorkerHandle(void * socketId);

View File

@ -30,6 +30,7 @@
#include "configRead.h"
#include "../ftpData.h"
#include "dynamicVectors.h"
#include "openSsl.h"
#include "fileManagement.h"
#include "daemon.h"
@ -122,10 +123,17 @@ void applyConfiguration(ftpParameters_DataType *ftpParameters)
void initFtpData(ftpDataType *ftpData)
{
int i;
int i;
/* Intializes random number generator */
srand(time(NULL));
#ifdef OPENSSL_ENABLED
#warning OPENSSL ENABLED!
initOpenssl();
ftpData->ctx = createContext();
configureContext(ftpData->ctx);
#endif
ftpData->connectedClients = 0;
ftpData->clients = (clientDataType *) malloc( sizeof(clientDataType) * ftpData->ftpParameters.maxClients);
@ -143,7 +151,7 @@ void initFtpData(ftpDataType *ftpData)
for (i = 0; i < ftpData->ftpParameters.maxClients; i++)
{
resetWorkerData(&ftpData->clients[i].workerData, 1);
resetClientData(&ftpData->clients[i], 1);
resetClientData(ftpData, i, 1);
ftpData->clients[i].clientProgressiveNumber = i;
}
@ -573,8 +581,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));
}

View File

@ -120,7 +120,18 @@ int socketPrintf(ftpDataType * ftpData, int clientId, const char *__restrict __f
theStringSize > 0)
{
int theReturnCode = 0;
theReturnCode = write(ftpData->clients[clientId].socketDescriptor, theBuffer, theStringSize);
if (ftpData->clients[clientId].tlsIsEnabled != 1)
{
theReturnCode = write(ftpData->clients[clientId].socketDescriptor, theBuffer, theStringSize);
}
else if (ftpData->clients[clientId].tlsIsEnabled == 1)
{
#ifdef OPENSSL_ENABLED
theReturnCode = SSL_write(ftpData->clients[clientId].ssl, theBuffer, theStringSize);
#endif
}
printf("%s", theBuffer);
if (theReturnCode > 0)
@ -320,7 +331,7 @@ void closeSocket(ftpDataType * ftpData, int processingSocket)
shutdown(ftpData->clients[processingSocket].socketDescriptor, SHUT_RDWR);
close(ftpData->clients[processingSocket].socketDescriptor);
resetClientData(&ftpData->clients[processingSocket], 0);
resetClientData(ftpData, processingSocket, 0);
resetWorkerData(&ftpData->clients[processingSocket].workerData, 0);
//Update client connecteds
@ -495,7 +506,7 @@ int evaluateClientSocketConnection(ftpDataType * ftpData)
}
else
{
int returnCode = socketPrintf(&ftpData, availableSocketIndex, "s", ftpData->welcomeMessage);
int returnCode = socketPrintf(ftpData, availableSocketIndex, "s", ftpData->welcomeMessage);
if (returnCode <= 0)
{
ftpData->clients[availableSocketIndex].closeTheClient = 1;

View File

@ -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
@ -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

View File

@ -21,7 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifdef OPENSSL_ENABLED
#warning SSL ENABLED
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
@ -74,4 +75,5 @@ void configureContext(SSL_CTX *ctx)
ERR_print_errors_fp(stderr);
exit(EXIT_FAILURE);
}
}
}
#endif

View File

@ -21,7 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifdef OPENSSL_ENABLED
#warning SSL ENABLED
#ifndef OPENSSL_H
#define OPENSSL_H
@ -43,4 +44,4 @@ void configureContext(SSL_CTX *ctx);
#endif
#endif /* OPENSSL_H */
#endif

View File

@ -76,62 +76,62 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/uftp: ${OBJECTFILES}
${OBJECTDIR}/ftpCommandElaborate.o: ftpCommandElaborate.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpCommandElaborate.o ftpCommandElaborate.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpCommandElaborate.o ftpCommandElaborate.c
${OBJECTDIR}/ftpData.o: ftpData.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpData.o ftpData.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpData.o ftpData.c
${OBJECTDIR}/ftpServer.o: ftpServer.c
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/ftpServer.o ftpServer.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/configRead.o library/configRead.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/connection.o library/connection.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/daemon.o library/daemon.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/dynamicVectors.o library/dynamicVectors.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/fileManagement.o library/fileManagement.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/logFunctions.o library/logFunctions.c
${OBJECTDIR}/library/openSsl.o: library/openSsl.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/openSsl.o library/openSsl.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/openSsl.o library/openSsl.c
${OBJECTDIR}/library/signals.o: library/signals.c
${MKDIR} -p ${OBJECTDIR}/library
${RM} "$@.d"
$(COMPILE.c) -g -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/library/signals.o library/signals.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -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 -Wall -D_LARGEFILE64_SOURCE -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/uFTP.o uFTP.c
$(COMPILE.c) -g -Wall -D_LARGE_FILE_SUPPORT_ENABLED -Ilibrary -include library/dynamicVectors.h -include library/fileManagement.h `pkg-config --cflags libcrypto` `pkg-config --cflags libssl` `pkg-config --cflags openssl` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/uFTP.o uFTP.c
# Subprojects
.build-subprojects:

View File

@ -80,7 +80,7 @@
<pElem>library/fileManagement.h</pElem>
</incFile>
<preprocessorList>
<Elem>_LARGEFILE64_SOURCE</Elem>
<Elem>_LARGE_FILE_SUPPORT_ENABLED</Elem>
</preprocessorList>
<warningLevel>2</warningLevel>
</cTool>