diff --git a/MakeFileGeneric b/MakeFileGeneric index 9a48e36..af4391f 100644 --- a/MakeFileGeneric +++ b/MakeFileGeneric @@ -22,7 +22,8 @@ OPTIMIZATION=-O3 HEADERS=-I LIBPATH=./build/modules/ BUILDFILES=start uFTP end -DEFINITIONS=-D_LARGEFILE64_SOURCE +#DEFINITIONS=-D_LARGEFILE64_SOURCE +DEFINITIONS= all: $(BUILDFILES) diff --git a/build/Debug/GNU-Linux/ftpCommandElaborate.o b/build/Debug/GNU-Linux/ftpCommandElaborate.o index 83cef74..727ccd9 100644 Binary files a/build/Debug/GNU-Linux/ftpCommandElaborate.o and b/build/Debug/GNU-Linux/ftpCommandElaborate.o differ diff --git a/build/Debug/GNU-Linux/ftpData.o b/build/Debug/GNU-Linux/ftpData.o index 4e64b40..3ca4e6f 100644 Binary files a/build/Debug/GNU-Linux/ftpData.o and b/build/Debug/GNU-Linux/ftpData.o differ diff --git a/build/Debug/GNU-Linux/ftpServer.o b/build/Debug/GNU-Linux/ftpServer.o index 74e41f6..14f6853 100644 Binary files a/build/Debug/GNU-Linux/ftpServer.o and b/build/Debug/GNU-Linux/ftpServer.o differ diff --git a/build/Debug/GNU-Linux/library/configRead.o b/build/Debug/GNU-Linux/library/configRead.o index 8a95c11..576f936 100644 Binary files a/build/Debug/GNU-Linux/library/configRead.o and b/build/Debug/GNU-Linux/library/configRead.o differ diff --git a/build/Debug/GNU-Linux/library/connection.o b/build/Debug/GNU-Linux/library/connection.o index 0c3bfa6..d921fa3 100644 Binary files a/build/Debug/GNU-Linux/library/connection.o and b/build/Debug/GNU-Linux/library/connection.o differ diff --git a/build/Debug/GNU-Linux/library/daemon.o b/build/Debug/GNU-Linux/library/daemon.o index cb3b55e..189e05e 100644 Binary files a/build/Debug/GNU-Linux/library/daemon.o and b/build/Debug/GNU-Linux/library/daemon.o differ diff --git a/build/Debug/GNU-Linux/library/dynamicVectors.o b/build/Debug/GNU-Linux/library/dynamicVectors.o index 48bfca3..04fd60e 100644 Binary files a/build/Debug/GNU-Linux/library/dynamicVectors.o and b/build/Debug/GNU-Linux/library/dynamicVectors.o differ diff --git a/build/Debug/GNU-Linux/library/fileManagement.o b/build/Debug/GNU-Linux/library/fileManagement.o index 910a535..9066ae9 100644 Binary files a/build/Debug/GNU-Linux/library/fileManagement.o and b/build/Debug/GNU-Linux/library/fileManagement.o differ diff --git a/build/Debug/GNU-Linux/library/logFunctions.o b/build/Debug/GNU-Linux/library/logFunctions.o index 3236b58..5021827 100644 Binary files a/build/Debug/GNU-Linux/library/logFunctions.o and b/build/Debug/GNU-Linux/library/logFunctions.o differ diff --git a/build/Debug/GNU-Linux/library/signals.o b/build/Debug/GNU-Linux/library/signals.o index 948405a..053691b 100644 Binary files a/build/Debug/GNU-Linux/library/signals.o and b/build/Debug/GNU-Linux/library/signals.o differ diff --git a/build/Debug/GNU-Linux/uFTP.o b/build/Debug/GNU-Linux/uFTP.o index c4ebf3b..65e5484 100644 Binary files a/build/Debug/GNU-Linux/uFTP.o and b/build/Debug/GNU-Linux/uFTP.o differ diff --git a/build/Release/GNU-Linux/ftpCommandElaborate.o b/build/Release/GNU-Linux/ftpCommandElaborate.o new file mode 100644 index 0000000..4f26c9a Binary files /dev/null and b/build/Release/GNU-Linux/ftpCommandElaborate.o differ diff --git a/build/Release/GNU-Linux/ftpCommandElaborate.o.d b/build/Release/GNU-Linux/ftpCommandElaborate.o.d new file mode 100644 index 0000000..89264c2 --- /dev/null +++ b/build/Release/GNU-Linux/ftpCommandElaborate.o.d @@ -0,0 +1,22 @@ +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: diff --git a/build/Release/GNU-Linux/ftpData.o b/build/Release/GNU-Linux/ftpData.o new file mode 100644 index 0000000..7490fa0 Binary files /dev/null and b/build/Release/GNU-Linux/ftpData.o differ diff --git a/build/Release/GNU-Linux/ftpData.o.d b/build/Release/GNU-Linux/ftpData.o.d new file mode 100644 index 0000000..5bd6d3f --- /dev/null +++ b/build/Release/GNU-Linux/ftpData.o.d @@ -0,0 +1,20 @@ +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: diff --git a/build/Release/GNU-Linux/ftpServer.o b/build/Release/GNU-Linux/ftpServer.o new file mode 100644 index 0000000..3c85790 Binary files /dev/null and b/build/Release/GNU-Linux/ftpServer.o differ diff --git a/build/Release/GNU-Linux/ftpServer.o.d b/build/Release/GNU-Linux/ftpServer.o.d new file mode 100644 index 0000000..024a6fa --- /dev/null +++ b/build/Release/GNU-Linux/ftpServer.o.d @@ -0,0 +1,26 @@ +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: diff --git a/build/Release/GNU-Linux/library/configRead.o b/build/Release/GNU-Linux/library/configRead.o new file mode 100644 index 0000000..2d2c42e Binary files /dev/null and b/build/Release/GNU-Linux/library/configRead.o differ diff --git a/build/Release/GNU-Linux/library/configRead.o.d b/build/Release/GNU-Linux/library/configRead.o.d new file mode 100644 index 0000000..256b794 --- /dev/null +++ b/build/Release/GNU-Linux/library/configRead.o.d @@ -0,0 +1,16 @@ +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: diff --git a/build/Release/GNU-Linux/library/connection.o b/build/Release/GNU-Linux/library/connection.o new file mode 100644 index 0000000..5d47fb7 Binary files /dev/null and b/build/Release/GNU-Linux/library/connection.o differ diff --git a/build/Release/GNU-Linux/library/connection.o.d b/build/Release/GNU-Linux/library/connection.o.d new file mode 100644 index 0000000..bf0bff0 --- /dev/null +++ b/build/Release/GNU-Linux/library/connection.o.d @@ -0,0 +1,9 @@ +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: diff --git a/build/Release/GNU-Linux/library/daemon.o b/build/Release/GNU-Linux/library/daemon.o new file mode 100644 index 0000000..0312512 Binary files /dev/null and b/build/Release/GNU-Linux/library/daemon.o differ diff --git a/build/Release/GNU-Linux/library/daemon.o.d b/build/Release/GNU-Linux/library/daemon.o.d new file mode 100644 index 0000000..3b7f89b --- /dev/null +++ b/build/Release/GNU-Linux/library/daemon.o.d @@ -0,0 +1,6 @@ +build/Release/GNU-Linux/library/daemon.o: library/daemon.c \ + library/fileManagement.h library/dynamicVectors.h + +library/fileManagement.h: + +library/dynamicVectors.h: diff --git a/build/Release/GNU-Linux/library/dynamicVectors.o b/build/Release/GNU-Linux/library/dynamicVectors.o new file mode 100644 index 0000000..147b9cb Binary files /dev/null and b/build/Release/GNU-Linux/library/dynamicVectors.o differ diff --git a/build/Release/GNU-Linux/library/dynamicVectors.o.d b/build/Release/GNU-Linux/library/dynamicVectors.o.d new file mode 100644 index 0000000..aad49ae --- /dev/null +++ b/build/Release/GNU-Linux/library/dynamicVectors.o.d @@ -0,0 +1,4 @@ +build/Release/GNU-Linux/library/dynamicVectors.o: \ + library/dynamicVectors.c library/dynamicVectors.h + +library/dynamicVectors.h: diff --git a/build/Release/GNU-Linux/library/fileManagement.o b/build/Release/GNU-Linux/library/fileManagement.o new file mode 100644 index 0000000..2ef7796 Binary files /dev/null and b/build/Release/GNU-Linux/library/fileManagement.o differ diff --git a/build/Release/GNU-Linux/library/fileManagement.o.d b/build/Release/GNU-Linux/library/fileManagement.o.d new file mode 100644 index 0000000..e65ea70 --- /dev/null +++ b/build/Release/GNU-Linux/library/fileManagement.o.d @@ -0,0 +1,7 @@ +build/Release/GNU-Linux/library/fileManagement.o: \ + library/fileManagement.c library/fileManagement.h \ + library/dynamicVectors.h + +library/fileManagement.h: + +library/dynamicVectors.h: diff --git a/build/Release/GNU-Linux/library/logFunctions.o b/build/Release/GNU-Linux/library/logFunctions.o new file mode 100644 index 0000000..0ea1537 Binary files /dev/null and b/build/Release/GNU-Linux/library/logFunctions.o differ diff --git a/build/Release/GNU-Linux/library/logFunctions.o.d b/build/Release/GNU-Linux/library/logFunctions.o.d new file mode 100644 index 0000000..c78775e --- /dev/null +++ b/build/Release/GNU-Linux/library/logFunctions.o.d @@ -0,0 +1,4 @@ +build/Release/GNU-Linux/library/logFunctions.o: library/logFunctions.c \ + library/logFunctions.h + +library/logFunctions.h: diff --git a/build/Release/GNU-Linux/library/signals.o b/build/Release/GNU-Linux/library/signals.o new file mode 100644 index 0000000..0c967e0 Binary files /dev/null and b/build/Release/GNU-Linux/library/signals.o differ diff --git a/build/Release/GNU-Linux/library/signals.o.d b/build/Release/GNU-Linux/library/signals.o.d new file mode 100644 index 0000000..3ad557a --- /dev/null +++ b/build/Release/GNU-Linux/library/signals.o.d @@ -0,0 +1,4 @@ +build/Release/GNU-Linux/library/signals.o: library/signals.c \ + library/../ftpServer.h + +library/../ftpServer.h: diff --git a/build/Release/GNU-Linux/uFTP.o b/build/Release/GNU-Linux/uFTP.o new file mode 100644 index 0000000..2b23bbc Binary files /dev/null and b/build/Release/GNU-Linux/uFTP.o differ diff --git a/build/Release/GNU-Linux/uFTP.o.d b/build/Release/GNU-Linux/uFTP.o.d new file mode 100644 index 0000000..6eef1ae --- /dev/null +++ b/build/Release/GNU-Linux/uFTP.o.d @@ -0,0 +1,3 @@ +build/Release/GNU-Linux/uFTP.o: uFTP.c ftpServer.h + +ftpServer.h: diff --git a/build/modules/configRead.o b/build/modules/configRead.o index 6f9e048..b05b4a2 100644 Binary files a/build/modules/configRead.o and b/build/modules/configRead.o differ diff --git a/build/modules/connection.o b/build/modules/connection.o index aa4d3df..6b62d0f 100644 Binary files a/build/modules/connection.o and b/build/modules/connection.o differ diff --git a/build/modules/daemon.o b/build/modules/daemon.o index 8c2a1f4..cab69d2 100644 Binary files a/build/modules/daemon.o and b/build/modules/daemon.o differ diff --git a/build/modules/dynamicVectors.o b/build/modules/dynamicVectors.o index cf2cc12..7de222b 100644 Binary files a/build/modules/dynamicVectors.o and b/build/modules/dynamicVectors.o differ diff --git a/build/modules/fileManagement.o b/build/modules/fileManagement.o index b7abbb3..dc56ce6 100644 Binary files a/build/modules/fileManagement.o and b/build/modules/fileManagement.o differ diff --git a/build/modules/ftpCommandElaborate.o b/build/modules/ftpCommandElaborate.o index a2759bf..7d9a524 100644 Binary files a/build/modules/ftpCommandElaborate.o and b/build/modules/ftpCommandElaborate.o differ diff --git a/build/modules/ftpData.o b/build/modules/ftpData.o index f7b623f..2f4c961 100644 Binary files a/build/modules/ftpData.o and b/build/modules/ftpData.o differ diff --git a/build/modules/ftpServer.o b/build/modules/ftpServer.o index 3f2c331..e49875c 100644 Binary files a/build/modules/ftpServer.o and b/build/modules/ftpServer.o differ diff --git a/build/modules/logFunctions.o b/build/modules/logFunctions.o index e90f8fa..f9b5602 100644 Binary files a/build/modules/logFunctions.o and b/build/modules/logFunctions.o differ diff --git a/build/modules/signals.o b/build/modules/signals.o index ce2ca71..06e949b 100644 Binary files a/build/modules/signals.o and b/build/modules/signals.o differ diff --git a/build/uFTP b/build/uFTP new file mode 100755 index 0000000..a97643c Binary files /dev/null and b/build/uFTP differ diff --git a/build/uftpd.cfg b/build/uftpd.cfg new file mode 100644 index 0000000..bbd168b --- /dev/null +++ b/build/uftpd.cfg @@ -0,0 +1,39 @@ +#FTP CONFIGURATION SAMPLE + +####################################################### +# UFTP SERVER SETTINGS # +####################################################### + +MAXIMUM_ALLOWED_FTP_CONNECTION = 30 +#MAXIMUM ALLOWED CONNECTIONS ON THE SERVER + +FTP_PORT = 900 +#TCP/IP PORT SETTINGS (DEFAULT 21) + +SINGLE_INSTANCE = false +#Allow only one server instance (true or false) + +DAEMON_MODE = false +#Run in background, daemon mode ok + +IDLE_MAX_TIMEOUT = 3600 +# Idle timeout in seconds, client are disconnected for inactivity after the +# specified amount of time in seconds, set to 0 to disable + +MAX_CONNECTION_NUMBER_PER_IP = 2 +#MAX CONNECTIONS PER IP +#LIMIT THE MAXIMUM NUMBER OF CONNECTION FOR EACH IP ADDRESS +# 0 TO DISABLE + +MAX_CONNECTION_TRY_PER_IP = 3 +#MAX LOGIN TRY PER IP +#THE IP ADDRESS WILL BE BLOCKED FOR 5 MINUTES AFTER WRONG LOGIN USERNAME AND PASSWORD +#0 TO DISABLE + +#USERS +#START FROM USER 0 TO XXX +USER_0 = root +PASSWORD_0 = arm +HOME_0 = / +GROUP_NAME_OWNER_0 = root +USER_NAME_OWNER_0 = root diff --git a/dist/Debug/GNU-Linux/uftp b/dist/Debug/GNU-Linux/uftp index 1f82536..c28093e 100755 Binary files a/dist/Debug/GNU-Linux/uftp and b/dist/Debug/GNU-Linux/uftp differ diff --git a/ftpCommandElaborate.c b/ftpCommandElaborate.c index 39ee6c0..8810b97 100644 --- a/ftpCommandElaborate.c +++ b/ftpCommandElaborate.c @@ -903,7 +903,16 @@ long long int writeRetrFile(char * theFilename, int thePasvSocketConnection, lon long long int theFileSize; char buffer[FTP_COMMAND_ELABORATE_CHAR_BUFFER]; - retrFP = fopen64(theFilename, "rb"); + + #ifdef _LARGEFILE64_SOURCE + retrFP = fopen64(theFilename, "rb"); + #endif + + #ifndef _LARGEFILE64_SOURCE + retrFP = fopen(theFilename, "rb"); + #endif + + if (retrFP == NULL) { return -1; @@ -914,7 +923,15 @@ long long int writeRetrFile(char * theFilename, int thePasvSocketConnection, lon if (startFrom > 0) { //printf("\nSeek startFrom: %d", startFrom); - currentPosition = (long long int) lseek64(fileno(retrFP), startFrom, SEEK_SET); + + #ifdef _LARGEFILE64_SOURCE + currentPosition = (long long int) lseek64(fileno(retrFP), startFrom, SEEK_SET); + #endif + + #ifndef _LARGEFILE64_SOURCE + currentPosition = (long long int) lseek(fileno(retrFP), startFrom, SEEK_SET); + #endif + // printf("\nSeek result: %ld", currentPosition); if (currentPosition == -1) { @@ -939,9 +956,6 @@ long long int writeRetrFile(char * theFilename, int thePasvSocketConnection, lon toReturn = toReturn + writtenSize; } } - - //printf("\n Bytes written: %ld", toReturn); - fclose(retrFP); retrFP = NULL; return toReturn; @@ -1141,4 +1155,4 @@ int setPermissions(char * permissionsCommand, char * basePath, ownerShip_DataTyp } return 1; -} \ No newline at end of file +} diff --git a/ftpServer.c b/ftpServer.c index a084066..0d88d04 100644 --- a/ftpServer.c +++ b/ftpServer.c @@ -164,7 +164,16 @@ void *connectionWorkerHandle(void * socketId) compareStringCaseInsensitive(ftpData.clients[theSocketId].workerData.theCommandReceived, "STOR", strlen("STOR")) == 1 && ftpData.clients[theSocketId].fileToStor.textLen > 0) { - ftpData.clients[theSocketId].workerData.theStorFile = fopen64(ftpData.clients[theSocketId].fileToStor.text, "wb"); + + #ifdef _LARGEFILE64_SOURCE + ftpData.clients[theSocketId].workerData.theStorFile = fopen64(ftpData.clients[theSocketId].fileToStor.text, "wb"); + #endif + + #ifndef _LARGEFILE64_SOURCE + ftpData.clients[theSocketId].workerData.theStorFile = fopen(ftpData.clients[theSocketId].fileToStor.text, "wb"); + #endif + + if (ftpData.clients[theSocketId].workerData.theStorFile == NULL) { diff --git a/library/configRead.c b/library/configRead.c index 2e72216..1722d98 100644 --- a/library/configRead.c +++ b/library/configRead.c @@ -65,13 +65,21 @@ void configurationRead(ftpParameters_DataType *ftpParameters) if (FILE_IsFile(LOCAL_CONFIGURATION_FILENAME) == 1) { - printf("\nReading configuration from \n -> %s", LOCAL_CONFIGURATION_FILENAME); + 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", DEFAULT_CONFIGURATION_FILENAME); + printf("\nReading configuration from \n -> %s\n", DEFAULT_CONFIGURATION_FILENAME); + returnCode = readConfigurationFile(DEFAULT_CONFIGURATION_FILENAME, &configParameters); + + printf("\nDONE\n"); + } if (returnCode == 1) @@ -149,7 +157,13 @@ static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *paramet int theFileSize = 0; int i, state, nameIndex, valueIndex, allowSpacesInValue; char * theFileContent; + + + printf("\n FILE_GetStringFromFile"); + theFileSize = FILE_GetStringFromFile(path, &theFileContent); + printf("\n FILE_GetStringFromFile Done"); + char name[PARAMETER_SIZE_LIMIT]; char value[PARAMETER_SIZE_LIMIT]; @@ -296,7 +310,8 @@ static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *paramet nameIndex = 0; valueIndex = 0; state = STATE_START; - //printf("\nParameter read: %s = %s", parameter.name, parameter.value); + printf("\nParameter read: %s = %s", parameter.name, parameter.value); + parametersVector->PushBack(parametersVector, ¶meter, sizeof(parameter_DataType)); } break; @@ -318,7 +333,8 @@ static int readConfigurationFile(char *path, DYNV_VectorGenericDataType *paramet memset(value, 0, PARAMETER_SIZE_LIMIT); nameIndex = 0; valueIndex = 0; - //printf("\nParameter read: %s = %s", parameter.name, parameter.value); + printf("\nParameter read: %s = %s", parameter.name, parameter.value); + parametersVector->PushBack(parametersVector, ¶meter, sizeof(parameter_DataType)); } diff --git a/library/fileManagement.c b/library/fileManagement.c index 80ed79c..dbde774 100644 --- a/library/fileManagement.c +++ b/library/fileManagement.c @@ -91,39 +91,85 @@ long int FILE_GetAvailableSpace(const char* path) /* Get the file size */ long long int FILE_GetFileSize(FILE *TheFilePointer) { +#ifdef _LARGEFILE64_SOURCE long long int Prev = 0, TheFileSize = 0; Prev = ftello64(TheFilePointer); fseeko64(TheFilePointer, 0, SEEK_END); TheFileSize = ftello64(TheFilePointer); fseeko64(TheFilePointer, Prev, SEEK_SET); return TheFileSize; +#endif + +#ifndef _LARGEFILE64_SOURCE + long long int Prev = 0, TheFileSize = 0; + Prev = ftell(TheFilePointer); + fseek(TheFilePointer, 0, SEEK_END); + TheFileSize = ftell(TheFilePointer); + fseek(TheFilePointer, Prev, SEEK_SET); + return TheFileSize; +#endif } long long int FILE_GetFileSizeFromPath(char *TheFileName) { - if (FILE_IsFile(TheFileName) == 1) - { - FILE *TheFilePointer; - TheFilePointer = fopen64(TheFileName, "rb"); - long long int Prev = 0, TheFileSize = 0; - Prev = ftello64(TheFilePointer); - fseeko64(TheFilePointer, 0L, SEEK_END); - TheFileSize = ftello64(TheFilePointer); - fseeko64(TheFilePointer, Prev, SEEK_SET); - fclose(TheFilePointer); - return TheFileSize; - } - else - { - return 0; - } + + +#ifdef _LARGEFILE64_SOURCE + if (FILE_IsFile(TheFileName) == 1) + { + FILE *TheFilePointer; + TheFilePointer = fopen64(TheFileName, "rb"); + long long int Prev = 0, TheFileSize = 0; + Prev = ftello64(TheFilePointer); + fseeko64(TheFilePointer, 0L, SEEK_END); + TheFileSize = ftello64(TheFilePointer); + fseeko64(TheFilePointer, Prev, SEEK_SET); + fclose(TheFilePointer); + return TheFileSize; + } + else + { + return 0; + } +#endif + +#ifndef _LARGEFILE64_SOURCE + if (FILE_IsFile(TheFileName) == 1) + { + FILE *TheFilePointer; + TheFilePointer = fopen(TheFileName, "rb"); + long long int Prev = 0, TheFileSize = 0; + Prev = ftell(TheFilePointer); + fseek(TheFilePointer, 0L, SEEK_END); + TheFileSize = ftell(TheFilePointer); + fseek(TheFilePointer, Prev, SEEK_SET); + fclose(TheFilePointer); + return TheFileSize; + } + else + { + return 0; + } +#endif + + } /* Check if a file is valid */ int FILE_IsFile(const char *TheFileName) { FILE *TheFile; - TheFile = fopen64(TheFileName, "rb"); + +#ifdef _LARGEFILE64_SOURCE +TheFile = fopen64(TheFileName, "rb"); +#endif + +#ifndef _LARGEFILE64_SOURCE +TheFile = fopen(TheFileName, "rb"); +#endif + + + if (TheFile != NULL) { @@ -222,7 +268,14 @@ int FILE_GetStringFromFile(char * filename, char **file_content) return 0; } - FILE *file = fopen(filename, "rb"); + + #ifdef _LARGEFILE64_SOURCE + FILE *file = fopen64(filename, "rb"); + #endif + + #ifndef _LARGEFILE64_SOURCE + FILE *file = fopen(filename, "rb"); + #endif if (file == NULL) { @@ -232,6 +285,8 @@ int FILE_GetStringFromFile(char * filename, char **file_content) file_size = FILE_GetFileSize(file); + + count = 0; *file_content = (char *) malloc(file_size * sizeof(char) + 100); @@ -240,8 +295,14 @@ int FILE_GetStringFromFile(char * filename, char **file_content) (*file_content)[count++] = (char) c; } (*file_content)[count] = '\0'; + + + fclose(file); - return (count); + + + + return count; } void FILE_ReadStringParameters(char * filename, DYNV_VectorGenericDataType *ParametersVector) @@ -505,7 +566,6 @@ char * FILE_GetGroupOwner(char *fileName) return toReturn; } - time_t FILE_GetLastModifiedData(char *path) { struct stat statbuf; @@ -553,7 +613,6 @@ void FILE_DirectoryToParent(char ** sourceString) } } - int FILE_LockFile(int fd) { struct flock fl; @@ -564,7 +623,6 @@ int FILE_LockFile(int fd) return(fcntl(fd, F_SETLK, &fl)); } - int FILE_doChownFromUidGid(const char *file_path, uid_t uid, gid_t gid) { if (chown(file_path, uid, gid) == -1) @@ -606,7 +664,6 @@ int FILE_doChownFromUidGidString ( const char *file_path, return 1; } - uid_t FILE_getUID(const char *user_name) { struct passwd *pwd; @@ -630,4 +687,4 @@ gid_t FILE_getGID(const char *group_name) } return grp->gr_gid; -} \ No newline at end of file +} diff --git a/uftpd.cfg b/uftpd.cfg new file mode 100644 index 0000000..9b80319 --- /dev/null +++ b/uftpd.cfg @@ -0,0 +1,51 @@ +#FTP CONFIGURATION SAMPLE + +####################################################### +# UFTP SERVER SETTINGS # +####################################################### + +MAXIMUM_ALLOWED_FTP_CONNECTION = 30 +#MAXIMUM ALLOWED CONNECTIONS ON THE SERVER + +FTP_PORT = 21 +#TCP/IP PORT SETTINGS (DEFAULT 21) + +SINGLE_INSTANCE = true +#Allow only one server instance (true or false) + +DAEMON_MODE = true +#Run in background, daemon mode ok + +IDLE_MAX_TIMEOUT = 3600 +# Idle timeout in seconds, client are disconnected for inactivity after the +# specified amount of time in seconds, set to 0 to disable + + +MAX_CONNECTION_NUMBER_PER_IP = 2 +#MAX CONNECTIONS PER IP +#LIMIT THE MAXIMUM NUMBER OF CONNECTION FOR EACH IP ADDRESS +# 0 TO DISABLE + + +MAX_CONNECTION_TRY_PER_IP = 3 +#MAX LOGIN TRY PER IP +#THE IP ADDRESS WILL BE BLOCKED FOR 5 MINUTES AFTER WRONG LOGIN USERNAME AND PASSWORD +#0 TO DISABLE + +#USERS +#START FROM USER 0 TO XXX +USER_0 = username +PASSWORD_0 = password +HOME_0 = / +GROUP_NAME_OWNER_0 = usergroup +USER_NAME_OWNER_0 = user + +USER_1 = apache +PASSWORD_1 = apachePassword +HOME_1 = /var/www/html/ +GROUP_NAME_OWNER_1 = www-data +USER_NAME_OWNER_1 = www-data + +USER_2 = anotherUsername +PASSWORD_2 = anotherPassowrd +HOME_2 = /