mirror of
https://github.com/kingk85/uFTP.git
synced 2025-04-12 10:48:40 +03:00
Manually merged pull request https://github.com/kingk85/uFTP/pull/12
This commit is contained in:
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user