FTP server anonymous does't work on MQX4.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FTP server anonymous does't work on MQX4.1

Jump to solution
759 Views
Curro
Contributor III

Hello to everyone,

I'm working with a Kinetis K60 on a custom board and I'm using FTP server with MQX 4.1.

I try to set anonymous connection with no results.

I compiled MQX with

/*

** MGCT: <option type="bool"/>

*/

#ifndef FTPSRVCFG_IS_ANONYMOUS

  #define FTPSRVCFG_IS_ANONYMOUS             (1)

#endif

in rtcscfg.h file and FTP so defined in my code:

uint32_t initFTP()

{

FTPSRV_PARAM_STRUCT params={0};

uint32_t handle;

  #if RTCSCFG_ENABLE_IP4

  params.af |= AF_INET;

  #endif

  #if RTCSCFG_ENABLE_IP6

  params.af |= AF_INET6;

  #endif

  params.auth_table = NULL;

  params.root_dir = "a:";

  handle = FTPSRV_init(&params);

  return handle;

}

I also tried to comment params.auth_table line or to create a FTPSRV_AUTH_STRUCT with 0, NULL or "" fields but ftp server never works.


Everything is ok i create a user+passw connection (not anonymous).

Any idea?

Many thanks and best regards,

Corrado

0 Kudos
1 Solution
608 Views
RadekS
NXP Employee
NXP Employee

After more detail analysis, we discovered that I was wrong.

It is rather misunderstanding instead of bug.

Anonymous authentication works correctly according RFC959.

I would like to split it into two points according two option how to understand to anonymous connection:

1. If you set macro FTPSRVCFG_IS_ANONYMOUS as 1, FTP server will accepts all FTP commands without any successful authentication process – you don’t need authentication process for FTP commands.

2. If your client forces you to execute authentication with user name “anonymous” for anonymous connection, you can set ftpsrv_users[] to {"anonymous", "", NULL}.  In that case any password will be accepted however password string must contain at least one character (could be any).

This behavior fits to RFC959. Note: In that case, rules for macro FTPSRVCFG_IS_ANONYMOUS is not applied because authentication process was executed as successful.

Problem is only in case when we want use “anonymous” as user name and empty string as password (just click on enter when client asks for password).

This combination is not accepted by FTP server by default.

If you would like apply also this option, please edit ftpsrv_cmd.c file and made modification from:

if (input->pass != NULL)

    {

        /* Validate username and password */

        if (ftpsrv_check_authtbl(session))

        {

session->auth_state = FTPSRV_LOGGED_IN;

session->message = (char*) ftpsrvmsg_pass;

        }

        else

        {

session->auth_state = FTPSRV_LOGGED_OUT;

session->message = (char*) ftpsrvmsg_authfail;

        }

        retval = FTPSRV_OK;

    }

    else

    {

session->message = (char*) ftpsrvmsg_badsyntax;

        retval = FTPSRV_ERROR;

    }

to:

/* Validate username and password */

    if (ftpsrv_check_authtbl(session))

    {

session->auth_state = FTPSRV_LOGGED_IN;

session->message = (char*) ftpsrvmsg_pass;

    }

    else

    {

session->auth_state = FTPSRV_LOGGED_OUT;

session->message = (char*) ftpsrvmsg_authfail;

    }

      retval = FTPSRV_OK;

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
608 Views
RadekS
NXP Employee
NXP Employee

Thank you for your bug report.

I tested it and you are right it is a bug – anonymous authentication don’t work.

Unfortunately I didn’t found any fast fix for that till now.

Anyway, I reported it into our internal bug database and it will be fixed in one of next MQX releases.

I just discover funny thing.

If ftpsrv_users[] contains {"anonymous", "", NULL},

ftp works with username “anonymous” and password “NULL”

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
609 Views
RadekS
NXP Employee
NXP Employee

After more detail analysis, we discovered that I was wrong.

It is rather misunderstanding instead of bug.

Anonymous authentication works correctly according RFC959.

I would like to split it into two points according two option how to understand to anonymous connection:

1. If you set macro FTPSRVCFG_IS_ANONYMOUS as 1, FTP server will accepts all FTP commands without any successful authentication process – you don’t need authentication process for FTP commands.

2. If your client forces you to execute authentication with user name “anonymous” for anonymous connection, you can set ftpsrv_users[] to {"anonymous", "", NULL}.  In that case any password will be accepted however password string must contain at least one character (could be any).

This behavior fits to RFC959. Note: In that case, rules for macro FTPSRVCFG_IS_ANONYMOUS is not applied because authentication process was executed as successful.

Problem is only in case when we want use “anonymous” as user name and empty string as password (just click on enter when client asks for password).

This combination is not accepted by FTP server by default.

If you would like apply also this option, please edit ftpsrv_cmd.c file and made modification from:

if (input->pass != NULL)

    {

        /* Validate username and password */

        if (ftpsrv_check_authtbl(session))

        {

session->auth_state = FTPSRV_LOGGED_IN;

session->message = (char*) ftpsrvmsg_pass;

        }

        else

        {

session->auth_state = FTPSRV_LOGGED_OUT;

session->message = (char*) ftpsrvmsg_authfail;

        }

        retval = FTPSRV_OK;

    }

    else

    {

session->message = (char*) ftpsrvmsg_badsyntax;

        retval = FTPSRV_ERROR;

    }

to:

/* Validate username and password */

    if (ftpsrv_check_authtbl(session))

    {

session->auth_state = FTPSRV_LOGGED_IN;

session->message = (char*) ftpsrvmsg_pass;

    }

    else

    {

session->auth_state = FTPSRV_LOGGED_OUT;

session->message = (char*) ftpsrvmsg_authfail;

    }

      retval = FTPSRV_OK;

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
608 Views
Curro
Contributor III

My firmware on MQX4.1 is not fully compatible with MQX3.8 one, but now everythink is clear and OK.

Many thanks and best regards,

Corrado

0 Kudos