This commit is contained in:
root
2024-04-07 14:24:07 +02:00
parent 345828b576
commit 3781eb0b50
4 changed files with 39 additions and 18 deletions

View File

@ -46,31 +46,33 @@
#include "ftpCommandsElaborate.h"
/* Elaborate the User login command */
int parseCommandUser(ftpDataType *data, int socketId)
int parseCommandUser(ftpDataType * data, int socketId)
{
int returnCode;
char *theUserName;
theUserName = getFtpCommandArg("USER", data->clients[socketId].theCommandReceived, 0);
if (strlen(theUserName) >= 1)
{
setDynamicStringDataType(&data->clients[socketId].login.name, theUserName, strlen(theUserName), &data->clients[socketId].memoryTable);
returnCode = socketPrintf(data, socketId, "s", "331 User ok, Waiting for the password.\r\n");
if (data->ftpParameters.forceTLS == 1 && data->clients[socketId].tlsIsEnabled == 0)
{
returnCode = socketPrintf(data, socketId, "s", "534 Policy Requires SSL.\r\n");
}
else
{
if (strlen(theUserName) >= 1)
{
setDynamicStringDataType(&data->clients[socketId].login.name, theUserName, strlen(theUserName), &data->clients[socketId].memoryTable);
returnCode = socketPrintf(data, socketId, "s", "331 User ok, Waiting for the password.\r\n");
}
else
{
returnCode = socketPrintf(data, socketId, "s", "430 Invalid username.\r\n");
}
}
if (returnCode <= 0)
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
if (returnCode <= 0)
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
return FTP_COMMAND_PROCESSED;
}
else
{
returnCode = socketPrintf(data, socketId, "s", "430 Invalid username.\r\n");
if (returnCode <= 0)
return FTP_COMMAND_PROCESSED_WRITE_ERROR;
return FTP_COMMAND_PROCESSED;
}
return FTP_COMMAND_PROCESSED;
}
/* Elaborate the User login command */

View File

@ -92,6 +92,7 @@ struct ftpParameters
char certificatePath[MAXIMUM_INODE_NAME];
char privateCertificatePath[MAXIMUM_INODE_NAME];
int pamAuthEnabled;
int forceTLS;
/* If specified, use a port range for pasv connections */
int connectionPortMin;

View File

@ -493,6 +493,20 @@ static int parseConfigurationFile(ftpParameters_DataType *ftpParameters, DYNV_Ve
// printf("\nENABLE_PAM_AUTH parameter not found in the configuration file, using the default value: %d", ftpParameters->pamAuthEnabled);
}
ftpParameters->forceTLS = 0;
searchIndex = searchParameter("FORCE_TLS", parametersVector);
if (searchIndex != -1)
{
if(compareStringCaseInsensitive(((parameter_DataType *) parametersVector->Data[searchIndex])->value, "true", strlen("true")) == 1)
ftpParameters->forceTLS = 1;
}
else
{
// printf("\FORCE_TLS parameter not found in the configuration file, using the default value: %d", ftpParameters->forceTLS);
}
ftpParameters->maximumIdleInactivity = 3600;
searchIndex = searchParameter("IDLE_MAX_TIMEOUT", parametersVector);
if (searchIndex != -1)

View File

@ -38,6 +38,10 @@ PRIVATE_CERTIFICATE_PATH=/etc/uFTP/key.pem
#and /etc/shadow
ENABLE_PAM_AUTH = false
# Force usage of the TLS
# If enabled, only TLS connections will be allowed
FORCE_TLS = false
#
# Random port for passive FTP connections range
#