XPWD, XCUP, XMKD, XRMD implementation

This commit is contained in:
root
2024-04-16 21:20:33 +02:00
parent 7b3682b109
commit 8d70cbcf09
3 changed files with 19 additions and 6 deletions

View File

@ -1023,7 +1023,10 @@ int parseCommandMkd(ftpDataType *data, int socketId)
char *theDirectoryFilename;
dynamicStringDataType mkdFileName;
theDirectoryFilename = getFtpCommandArg("MKD", data->clients[socketId].theCommandReceived, 0);
if (compareStringCaseInsensitive(data->clients[socketId].theCommandReceived, "MKD", strlen("MKD")) == 1)
theDirectoryFilename = getFtpCommandArg("MKD", data->clients[socketId].theCommandReceived, 0);
else if (compareStringCaseInsensitive(data->clients[socketId].theCommandReceived, "XMKD", strlen("XMKD")) == 1)
theDirectoryFilename = getFtpCommandArg("XMKD", data->clients[socketId].theCommandReceived, 0);
cleanDynamicStringDataType(&mkdFileName, 1, &data->clients[socketId].memoryTable);
isSafePath = getSafePath(&mkdFileName, theDirectoryFilename, &data->clients[socketId].login, &data->clients[socketId].memoryTable);
@ -1270,7 +1273,12 @@ int parseCommandRmd(ftpDataType *data, int socketId)
char *theDirectoryFilename;
dynamicStringDataType rmdFileName;
theDirectoryFilename = getFtpCommandArg("RMD", data->clients[socketId].theCommandReceived, 0);
if(compareStringCaseInsensitive(data->clients[socketId].theCommandReceived, "RMD", strlen("RMD")) == 1)
theDirectoryFilename = getFtpCommandArg("RMD", data->clients[socketId].theCommandReceived, 0);
else if(compareStringCaseInsensitive(data->clients[socketId].theCommandReceived, "XRMD", strlen("XRMD")) == 1)
theDirectoryFilename = getFtpCommandArg("XRMD", data->clients[socketId].theCommandReceived, 0);
cleanDynamicStringDataType(&rmdFileName, 1, &data->clients[socketId].memoryTable);
isSafePath = getSafePath(&rmdFileName, theDirectoryFilename, &data->clients[socketId].login, &data->clients[socketId].memoryTable);

View File

@ -82,7 +82,6 @@ int parseCommandStor(ftpDataType * data, int socketId);
int parseCommandCwd(ftpDataType * data, int socketId);
int parseCommandRest(ftpDataType * data, int socketId);
int parseCommandAppe(ftpDataType * data, int socketId);
int parseCommandCdup(ftpDataType * data, int socketId);
int parseCommandDele(ftpDataType * data, int socketId);
int parseCommandMdtm(ftpDataType * data, int socketId);

View File

@ -822,8 +822,10 @@ static int processCommand(int processingElement)
//my_printf("\nCCC COMMAND RECEIVED");
toReturn = parseCommandCcc(&ftpData, processingElement);
}
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PWD", strlen("PWD")) == 1)
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "PWD", strlen("PWD")) == 1 ||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "XPWD", strlen("XPWD")) == 1)
{
// XPWD
//my_printf("\nPWD COMMAND RECEIVED");
toReturn = parseCommandPwd(&ftpData, processingElement);
}
@ -878,6 +880,7 @@ static int processCommand(int processingElement)
toReturn = parseCommandList(&ftpData, processingElement);
}
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "CDUP", strlen("CDUP")) == 1 ||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "XCUP", strlen("XCUP")) == 1 ||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "CWD ..", strlen("CWD ..")) == 1)
{
//my_printf("\nCDUP COMMAND RECEIVED");
@ -903,7 +906,8 @@ static int processCommand(int processingElement)
//my_printf("\nSTOR COMMAND RECEIVED");
toReturn = parseCommandStor(&ftpData, processingElement);
}
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "MKD", strlen("MKD")) == 1)
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "MKD", strlen("MKD")) == 1 ||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "XMKD", strlen("XMKD")) == 1)
{
//my_printf("\nMKD command received");
toReturn = parseCommandMkd(&ftpData, processingElement);
@ -938,8 +942,10 @@ static int processCommand(int processingElement)
//my_printf("\nQUIT command received");
toReturn = parseCommandQuit(&ftpData, processingElement);
}
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "RMD", strlen("RMD")) == 1)
else if(compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "RMD", strlen("RMD")) == 1 ||
compareStringCaseInsensitive(ftpData.clients[processingElement].theCommandReceived, "XRMD", strlen("XRMD")) == 1)
{
// XRMD
// my_printf("\nRMD command received");
toReturn = parseCommandRmd(&ftpData, processingElement);
}