FTP - UserName/Password

Discussion to talk about software related topics only.
Post Reply
clemieux
Posts: 9
Joined: Sun Jun 29, 2008 7:35 pm

FTP - UserName/Password

Post by clemieux »

I've seen a handful of examples where there are comments stating "validate your username and password here", which is all fine - but how do I invoke a username/password entry dialog box whenever somebody attempts to access my ftp server?

Thanks much!

p.s. - maybe I should add that this deals with development on the PK-70...

-Chris L
mrchadwickusa
Posts: 11
Joined: Tue Jul 01, 2008 7:31 am

Re: FTP - UserName/Password

Post by mrchadwickusa »

Hi Chris,

I realize this is a late answer, but I've only recently started working with the FTP stuff on the Netburner myself.

I'm also using the PK70 and your implimentation of

void * FTPDSessionStart( const char *user, const char *passwd, const IPADDR hi_ip )

determines the user names and passwords you will accept, by returning either a NULL pointer if you don't want to allow the FTP session, or a pointer to something that results in a non zero pointer, like an allocated string or static int, as in the examples, or some other persistant object you create to track the session.

Other than that it's up to whatever FTP client is accessing your server to actually prompt the user for a user name and password. Those will be the values passed in to FTPDSessionStart.

When that function gets called you must examine the user and passwd strings and determine if they are OK then return an appropriate non zero pointer, or a NULL pointer if they are not OK.

My experience has been that if you return a 0 in response to that function, the browser (I'm using Firefox) will put up a prompt for the user and password.

If you haven't done so I highly recommend stealing the code from the Nburn\examples\FTP\FTPD_AppUpdate\main.cpp and playing with that, but instrument all of the FTP functions to see what gets passed in as your server is accessed:

Code: Select all

void * FTPDSessionStart( const char *user, const char *passwd, const IPADDR hi_ip )
{
    iprintf("\r\nFTPD_SessionStart: ");
    ShowIP(hi_ip);
    iprintf("  User: %s Password: %s\r\n", user, passwd);
    char * rtnthing = (char*)malloc(80);
    if(strncmp(user, "MRC", 3) || !*user)
        return 0;
    strncpy(rtnthing, "The return thing", 80);
    iprintf("\r\n%s", rtnthing);
    return rtnthing; /* Return a non zero value */
}

and:

int FTPD_DirectoryExists( const char *full_directory, void *pSession )
{
   iprintf("\r\nFTPD_DirectoryExists %s", full_directory);
   if(pSession)
       iprintf("\n\r%s", pSession); //Should print "The return thing"
   return FTPD_OK;
}

etc.

Hope that helps, good luck with your project!

Mike Chadwick
Post Reply